babylon.module.d.ts 5.3 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705
  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. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/observable" {
  50. import { Nullable } from "babylonjs/types";
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * 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.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * 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).
  162. * 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.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. readonly observers: Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @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.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module "babylonjs/Misc/domManagement" {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Extracts text content from a DOM element hierarchy
  284. * @param element defines the root element
  285. * @returns a string
  286. */
  287. static GetDOMTextContent(element: HTMLElement): string;
  288. }
  289. }
  290. declare module "babylonjs/Misc/logger" {
  291. /**
  292. * Logger used througouht the application to allow configuration of
  293. * the log level required for the messages.
  294. */
  295. export class Logger {
  296. /**
  297. * No log
  298. */
  299. static readonly NoneLogLevel: number;
  300. /**
  301. * Only message logs
  302. */
  303. static readonly MessageLogLevel: number;
  304. /**
  305. * Only warning logs
  306. */
  307. static readonly WarningLogLevel: number;
  308. /**
  309. * Only error logs
  310. */
  311. static readonly ErrorLogLevel: number;
  312. /**
  313. * All logs
  314. */
  315. static readonly AllLogLevel: number;
  316. private static _LogCache;
  317. /**
  318. * Gets a value indicating the number of loading errors
  319. * @ignorenaming
  320. */
  321. static errorsCount: number;
  322. /**
  323. * Callback called when a new log is added
  324. */
  325. static OnNewCacheEntry: (entry: string) => void;
  326. private static _AddLogEntry;
  327. private static _FormatMessage;
  328. private static _LogDisabled;
  329. private static _LogEnabled;
  330. private static _WarnDisabled;
  331. private static _WarnEnabled;
  332. private static _ErrorDisabled;
  333. private static _ErrorEnabled;
  334. /**
  335. * Log a message to the console
  336. */
  337. static Log: (message: string) => void;
  338. /**
  339. * Write a warning message to the console
  340. */
  341. static Warn: (message: string) => void;
  342. /**
  343. * Write an error message to the console
  344. */
  345. static Error: (message: string) => void;
  346. /**
  347. * Gets current log cache (list of logs)
  348. */
  349. static readonly LogCache: string;
  350. /**
  351. * Clears the log cache
  352. */
  353. static ClearLogCache(): void;
  354. /**
  355. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  356. */
  357. static LogLevels: number;
  358. }
  359. }
  360. declare module "babylonjs/Misc/typeStore" {
  361. /** @hidden */
  362. export class _TypeStore {
  363. /** @hidden */
  364. static RegisteredTypes: {
  365. [key: string]: Object;
  366. };
  367. /** @hidden */
  368. static GetClass(fqdn: string): any;
  369. }
  370. }
  371. declare module "babylonjs/Misc/deepCopier" {
  372. /**
  373. * Class containing a set of static utilities functions for deep copy.
  374. */
  375. export class DeepCopier {
  376. /**
  377. * Tries to copy an object by duplicating every property
  378. * @param source defines the source object
  379. * @param destination defines the target object
  380. * @param doNotCopyList defines a list of properties to avoid
  381. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  382. */
  383. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  384. }
  385. }
  386. declare module "babylonjs/Misc/precisionDate" {
  387. /**
  388. * Class containing a set of static utilities functions for precision date
  389. */
  390. export class PrecisionDate {
  391. /**
  392. * Gets either window.performance.now() if supported or Date.now() else
  393. */
  394. static readonly Now: number;
  395. }
  396. }
  397. declare module "babylonjs/Misc/devTools" {
  398. /** @hidden */
  399. export class _DevTools {
  400. static WarnImport(name: string): string;
  401. }
  402. }
  403. declare module "babylonjs/Misc/webRequest" {
  404. /**
  405. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  406. */
  407. export class WebRequest {
  408. private _xhr;
  409. /**
  410. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  411. * i.e. when loading files, where the server/service expects an Authorization header
  412. */
  413. static CustomRequestHeaders: {
  414. [key: string]: string;
  415. };
  416. /**
  417. * Add callback functions in this array to update all the requests before they get sent to the network
  418. */
  419. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  420. private _injectCustomRequestHeaders;
  421. /**
  422. * Gets or sets a function to be called when loading progress changes
  423. */
  424. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  425. /**
  426. * Returns client's state
  427. */
  428. readonly readyState: number;
  429. /**
  430. * Returns client's status
  431. */
  432. readonly status: number;
  433. /**
  434. * Returns client's status as a text
  435. */
  436. readonly statusText: string;
  437. /**
  438. * Returns client's response
  439. */
  440. readonly response: any;
  441. /**
  442. * Returns client's response url
  443. */
  444. readonly responseURL: string;
  445. /**
  446. * Returns client's response as text
  447. */
  448. readonly responseText: string;
  449. /**
  450. * Gets or sets the expected response type
  451. */
  452. responseType: XMLHttpRequestResponseType;
  453. /** @hidden */
  454. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  455. /** @hidden */
  456. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  457. /**
  458. * Cancels any network activity
  459. */
  460. abort(): void;
  461. /**
  462. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  463. * @param body defines an optional request body
  464. */
  465. send(body?: Document | BodyInit | null): void;
  466. /**
  467. * Sets the request method, request URL
  468. * @param method defines the method to use (GET, POST, etc..)
  469. * @param url defines the url to connect with
  470. */
  471. open(method: string, url: string): void;
  472. }
  473. }
  474. declare module "babylonjs/Misc/fileRequest" {
  475. import { Observable } from "babylonjs/Misc/observable";
  476. /**
  477. * File request interface
  478. */
  479. export interface IFileRequest {
  480. /**
  481. * Raised when the request is complete (success or error).
  482. */
  483. onCompleteObservable: Observable<IFileRequest>;
  484. /**
  485. * Aborts the request for a file.
  486. */
  487. abort: () => void;
  488. }
  489. }
  490. declare module "babylonjs/Misc/performanceMonitor" {
  491. /**
  492. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  493. */
  494. export class PerformanceMonitor {
  495. private _enabled;
  496. private _rollingFrameTime;
  497. private _lastFrameTimeMs;
  498. /**
  499. * constructor
  500. * @param frameSampleSize The number of samples required to saturate the sliding window
  501. */
  502. constructor(frameSampleSize?: number);
  503. /**
  504. * Samples current frame
  505. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  506. */
  507. sampleFrame(timeMs?: number): void;
  508. /**
  509. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  510. */
  511. readonly averageFrameTime: number;
  512. /**
  513. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  514. */
  515. readonly averageFrameTimeVariance: number;
  516. /**
  517. * Returns the frame time of the most recent frame
  518. */
  519. readonly instantaneousFrameTime: number;
  520. /**
  521. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  522. */
  523. readonly averageFPS: number;
  524. /**
  525. * Returns the average framerate in frames per second using the most recent frame time
  526. */
  527. readonly instantaneousFPS: number;
  528. /**
  529. * Returns true if enough samples have been taken to completely fill the sliding window
  530. */
  531. readonly isSaturated: boolean;
  532. /**
  533. * Enables contributions to the sliding window sample set
  534. */
  535. enable(): void;
  536. /**
  537. * Disables contributions to the sliding window sample set
  538. * Samples will not be interpolated over the disabled period
  539. */
  540. disable(): void;
  541. /**
  542. * Returns true if sampling is enabled
  543. */
  544. readonly isEnabled: boolean;
  545. /**
  546. * Resets performance monitor
  547. */
  548. reset(): void;
  549. }
  550. /**
  551. * RollingAverage
  552. *
  553. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  554. */
  555. export class RollingAverage {
  556. /**
  557. * Current average
  558. */
  559. average: number;
  560. /**
  561. * Current variance
  562. */
  563. variance: number;
  564. protected _samples: Array<number>;
  565. protected _sampleCount: number;
  566. protected _pos: number;
  567. protected _m2: number;
  568. /**
  569. * constructor
  570. * @param length The number of samples required to saturate the sliding window
  571. */
  572. constructor(length: number);
  573. /**
  574. * Adds a sample to the sample set
  575. * @param v The sample value
  576. */
  577. add(v: number): void;
  578. /**
  579. * Returns previously added values or null if outside of history or outside the sliding window domain
  580. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  581. * @return Value previously recorded with add() or null if outside of range
  582. */
  583. history(i: number): number;
  584. /**
  585. * Returns true if enough samples have been taken to completely fill the sliding window
  586. * @return true if sample-set saturated
  587. */
  588. isSaturated(): boolean;
  589. /**
  590. * Resets the rolling average (equivalent to 0 samples taken so far)
  591. */
  592. reset(): void;
  593. /**
  594. * Wraps a value around the sample range boundaries
  595. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  596. * @return Wrapped position in sample range
  597. */
  598. protected _wrapPosition(i: number): number;
  599. }
  600. }
  601. declare module "babylonjs/Misc/stringDictionary" {
  602. import { Nullable } from "babylonjs/types";
  603. /**
  604. * This class implement a typical dictionary using a string as key and the generic type T as value.
  605. * The underlying implementation relies on an associative array to ensure the best performances.
  606. * The value can be anything including 'null' but except 'undefined'
  607. */
  608. export class StringDictionary<T> {
  609. /**
  610. * This will clear this dictionary and copy the content from the 'source' one.
  611. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  612. * @param source the dictionary to take the content from and copy to this dictionary
  613. */
  614. copyFrom(source: StringDictionary<T>): void;
  615. /**
  616. * Get a value based from its key
  617. * @param key the given key to get the matching value from
  618. * @return the value if found, otherwise undefined is returned
  619. */
  620. get(key: string): T | undefined;
  621. /**
  622. * Get a value from its key or add it if it doesn't exist.
  623. * This method will ensure you that a given key/data will be present in the dictionary.
  624. * @param key the given key to get the matching value from
  625. * @param factory the factory that will create the value if the key is not present in the dictionary.
  626. * The factory will only be invoked if there's no data for the given key.
  627. * @return the value corresponding to the key.
  628. */
  629. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  630. /**
  631. * Get a value from its key if present in the dictionary otherwise add it
  632. * @param key the key to get the value from
  633. * @param val if there's no such key/value pair in the dictionary add it with this value
  634. * @return the value corresponding to the key
  635. */
  636. getOrAdd(key: string, val: T): T;
  637. /**
  638. * Check if there's a given key in the dictionary
  639. * @param key the key to check for
  640. * @return true if the key is present, false otherwise
  641. */
  642. contains(key: string): boolean;
  643. /**
  644. * Add a new key and its corresponding value
  645. * @param key the key to add
  646. * @param value the value corresponding to the key
  647. * @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
  648. */
  649. add(key: string, value: T): boolean;
  650. /**
  651. * Update a specific value associated to a key
  652. * @param key defines the key to use
  653. * @param value defines the value to store
  654. * @returns true if the value was updated (or false if the key was not found)
  655. */
  656. set(key: string, value: T): boolean;
  657. /**
  658. * Get the element of the given key and remove it from the dictionary
  659. * @param key defines the key to search
  660. * @returns the value associated with the key or null if not found
  661. */
  662. getAndRemove(key: string): Nullable<T>;
  663. /**
  664. * Remove a key/value from the dictionary.
  665. * @param key the key to remove
  666. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  667. */
  668. remove(key: string): boolean;
  669. /**
  670. * Clear the whole content of the dictionary
  671. */
  672. clear(): void;
  673. /**
  674. * Gets the current count
  675. */
  676. readonly count: number;
  677. /**
  678. * Execute a callback on each key/val of the dictionary.
  679. * Note that you can remove any element in this dictionary in the callback implementation
  680. * @param callback the callback to execute on a given key/value pair
  681. */
  682. forEach(callback: (key: string, val: T) => void): void;
  683. /**
  684. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  685. * If the callback returns null or undefined the method will iterate to the next key/value pair
  686. * Note that you can remove any element in this dictionary in the callback implementation
  687. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  688. * @returns the first item
  689. */
  690. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  691. private _count;
  692. private _data;
  693. }
  694. }
  695. declare module "babylonjs/Meshes/dataBuffer" {
  696. /**
  697. * Class used to store gfx data (like WebGLBuffer)
  698. */
  699. export class DataBuffer {
  700. /**
  701. * Gets or sets the number of objects referencing this buffer
  702. */
  703. references: number;
  704. /** Gets or sets the size of the underlying buffer */
  705. capacity: number;
  706. /**
  707. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  708. */
  709. is32Bits: boolean;
  710. /**
  711. * Gets the underlying buffer
  712. */
  713. readonly underlyingResource: any;
  714. }
  715. }
  716. declare module "babylonjs/Meshes/buffer" {
  717. import { Nullable, DataArray } from "babylonjs/types";
  718. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  719. /**
  720. * Class used to store data that will be store in GPU memory
  721. */
  722. export class Buffer {
  723. private _engine;
  724. private _buffer;
  725. /** @hidden */
  726. _data: Nullable<DataArray>;
  727. private _updatable;
  728. private _instanced;
  729. /**
  730. * Gets the byte stride.
  731. */
  732. readonly byteStride: number;
  733. /**
  734. * Constructor
  735. * @param engine the engine
  736. * @param data the data to use for this buffer
  737. * @param updatable whether the data is updatable
  738. * @param stride the stride (optional)
  739. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  740. * @param instanced whether the buffer is instanced (optional)
  741. * @param useBytes set to true if the stride in in bytes (optional)
  742. */
  743. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  744. /**
  745. * Create a new VertexBuffer based on the current buffer
  746. * @param kind defines the vertex buffer kind (position, normal, etc.)
  747. * @param offset defines offset in the buffer (0 by default)
  748. * @param size defines the size in floats of attributes (position is 3 for instance)
  749. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  750. * @param instanced defines if the vertex buffer contains indexed data
  751. * @param useBytes defines if the offset and stride are in bytes
  752. * @returns the new vertex buffer
  753. */
  754. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  755. /**
  756. * Gets a boolean indicating if the Buffer is updatable?
  757. * @returns true if the buffer is updatable
  758. */
  759. isUpdatable(): boolean;
  760. /**
  761. * Gets current buffer's data
  762. * @returns a DataArray or null
  763. */
  764. getData(): Nullable<DataArray>;
  765. /**
  766. * Gets underlying native buffer
  767. * @returns underlying native buffer
  768. */
  769. getBuffer(): Nullable<DataBuffer>;
  770. /**
  771. * Gets the stride in float32 units (i.e. byte stride / 4).
  772. * May not be an integer if the byte stride is not divisible by 4.
  773. * DEPRECATED. Use byteStride instead.
  774. * @returns the stride in float32 units
  775. */
  776. getStrideSize(): number;
  777. /**
  778. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  779. * @param data defines the data to store
  780. */
  781. create(data?: Nullable<DataArray>): void;
  782. /** @hidden */
  783. _rebuild(): void;
  784. /**
  785. * Update current buffer data
  786. * @param data defines the data to store
  787. */
  788. update(data: DataArray): void;
  789. /**
  790. * Updates the data directly.
  791. * @param data the new data
  792. * @param offset the new offset
  793. * @param vertexCount the vertex count (optional)
  794. * @param useBytes set to true if the offset is in bytes
  795. */
  796. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  797. /**
  798. * Release all resources
  799. */
  800. dispose(): void;
  801. }
  802. /**
  803. * Specialized buffer used to store vertex data
  804. */
  805. export class VertexBuffer {
  806. /** @hidden */
  807. _buffer: Buffer;
  808. private _kind;
  809. private _size;
  810. private _ownsBuffer;
  811. private _instanced;
  812. private _instanceDivisor;
  813. /**
  814. * The byte type.
  815. */
  816. static readonly BYTE: number;
  817. /**
  818. * The unsigned byte type.
  819. */
  820. static readonly UNSIGNED_BYTE: number;
  821. /**
  822. * The short type.
  823. */
  824. static readonly SHORT: number;
  825. /**
  826. * The unsigned short type.
  827. */
  828. static readonly UNSIGNED_SHORT: number;
  829. /**
  830. * The integer type.
  831. */
  832. static readonly INT: number;
  833. /**
  834. * The unsigned integer type.
  835. */
  836. static readonly UNSIGNED_INT: number;
  837. /**
  838. * The float type.
  839. */
  840. static readonly FLOAT: number;
  841. /**
  842. * Gets or sets the instance divisor when in instanced mode
  843. */
  844. instanceDivisor: number;
  845. /**
  846. * Gets the byte stride.
  847. */
  848. readonly byteStride: number;
  849. /**
  850. * Gets the byte offset.
  851. */
  852. readonly byteOffset: number;
  853. /**
  854. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  855. */
  856. readonly normalized: boolean;
  857. /**
  858. * Gets the data type of each component in the array.
  859. */
  860. readonly type: number;
  861. /**
  862. * Constructor
  863. * @param engine the engine
  864. * @param data the data to use for this vertex buffer
  865. * @param kind the vertex buffer kind
  866. * @param updatable whether the data is updatable
  867. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  868. * @param stride the stride (optional)
  869. * @param instanced whether the buffer is instanced (optional)
  870. * @param offset the offset of the data (optional)
  871. * @param size the number of components (optional)
  872. * @param type the type of the component (optional)
  873. * @param normalized whether the data contains normalized data (optional)
  874. * @param useBytes set to true if stride and offset are in bytes (optional)
  875. */
  876. 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);
  877. /** @hidden */
  878. _rebuild(): void;
  879. /**
  880. * Returns the kind of the VertexBuffer (string)
  881. * @returns a string
  882. */
  883. getKind(): string;
  884. /**
  885. * Gets a boolean indicating if the VertexBuffer is updatable?
  886. * @returns true if the buffer is updatable
  887. */
  888. isUpdatable(): boolean;
  889. /**
  890. * Gets current buffer's data
  891. * @returns a DataArray or null
  892. */
  893. getData(): Nullable<DataArray>;
  894. /**
  895. * Gets underlying native buffer
  896. * @returns underlying native buffer
  897. */
  898. getBuffer(): Nullable<DataBuffer>;
  899. /**
  900. * Gets the stride in float32 units (i.e. byte stride / 4).
  901. * May not be an integer if the byte stride is not divisible by 4.
  902. * DEPRECATED. Use byteStride instead.
  903. * @returns the stride in float32 units
  904. */
  905. getStrideSize(): number;
  906. /**
  907. * Returns the offset as a multiple of the type byte length.
  908. * DEPRECATED. Use byteOffset instead.
  909. * @returns the offset in bytes
  910. */
  911. getOffset(): number;
  912. /**
  913. * Returns the number of components per vertex attribute (integer)
  914. * @returns the size in float
  915. */
  916. getSize(): number;
  917. /**
  918. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  919. * @returns true if this buffer is instanced
  920. */
  921. getIsInstanced(): boolean;
  922. /**
  923. * Returns the instancing divisor, zero for non-instanced (integer).
  924. * @returns a number
  925. */
  926. getInstanceDivisor(): number;
  927. /**
  928. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  929. * @param data defines the data to store
  930. */
  931. create(data?: DataArray): void;
  932. /**
  933. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  934. * This function will create a new buffer if the current one is not updatable
  935. * @param data defines the data to store
  936. */
  937. update(data: DataArray): void;
  938. /**
  939. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  940. * Returns the directly updated WebGLBuffer.
  941. * @param data the new data
  942. * @param offset the new offset
  943. * @param useBytes set to true if the offset is in bytes
  944. */
  945. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  946. /**
  947. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  948. */
  949. dispose(): void;
  950. /**
  951. * Enumerates each value of this vertex buffer as numbers.
  952. * @param count the number of values to enumerate
  953. * @param callback the callback function called for each value
  954. */
  955. forEach(count: number, callback: (value: number, index: number) => void): void;
  956. /**
  957. * Positions
  958. */
  959. static readonly PositionKind: string;
  960. /**
  961. * Normals
  962. */
  963. static readonly NormalKind: string;
  964. /**
  965. * Tangents
  966. */
  967. static readonly TangentKind: string;
  968. /**
  969. * Texture coordinates
  970. */
  971. static readonly UVKind: string;
  972. /**
  973. * Texture coordinates 2
  974. */
  975. static readonly UV2Kind: string;
  976. /**
  977. * Texture coordinates 3
  978. */
  979. static readonly UV3Kind: string;
  980. /**
  981. * Texture coordinates 4
  982. */
  983. static readonly UV4Kind: string;
  984. /**
  985. * Texture coordinates 5
  986. */
  987. static readonly UV5Kind: string;
  988. /**
  989. * Texture coordinates 6
  990. */
  991. static readonly UV6Kind: string;
  992. /**
  993. * Colors
  994. */
  995. static readonly ColorKind: string;
  996. /**
  997. * Matrix indices (for bones)
  998. */
  999. static readonly MatricesIndicesKind: string;
  1000. /**
  1001. * Matrix weights (for bones)
  1002. */
  1003. static readonly MatricesWeightsKind: string;
  1004. /**
  1005. * Additional matrix indices (for bones)
  1006. */
  1007. static readonly MatricesIndicesExtraKind: string;
  1008. /**
  1009. * Additional matrix weights (for bones)
  1010. */
  1011. static readonly MatricesWeightsExtraKind: string;
  1012. /**
  1013. * Deduces the stride given a kind.
  1014. * @param kind The kind string to deduce
  1015. * @returns The deduced stride
  1016. */
  1017. static DeduceStride(kind: string): number;
  1018. /**
  1019. * Gets the byte length of the given type.
  1020. * @param type the type
  1021. * @returns the number of bytes
  1022. */
  1023. static GetTypeByteLength(type: number): number;
  1024. /**
  1025. * Enumerates each value of the given parameters as numbers.
  1026. * @param data the data to enumerate
  1027. * @param byteOffset the byte offset of the data
  1028. * @param byteStride the byte stride of the data
  1029. * @param componentCount the number of components per element
  1030. * @param componentType the type of the component
  1031. * @param count the number of values to enumerate
  1032. * @param normalized whether the data is normalized
  1033. * @param callback the callback function called for each value
  1034. */
  1035. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1036. private static _GetFloatValue;
  1037. }
  1038. }
  1039. declare module "babylonjs/Maths/math.scalar" {
  1040. /**
  1041. * Scalar computation library
  1042. */
  1043. export class Scalar {
  1044. /**
  1045. * Two pi constants convenient for computation.
  1046. */
  1047. static TwoPi: number;
  1048. /**
  1049. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1050. * @param a number
  1051. * @param b number
  1052. * @param epsilon (default = 1.401298E-45)
  1053. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1054. */
  1055. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1056. /**
  1057. * Returns a string : the upper case translation of the number i to hexadecimal.
  1058. * @param i number
  1059. * @returns the upper case translation of the number i to hexadecimal.
  1060. */
  1061. static ToHex(i: number): string;
  1062. /**
  1063. * Returns -1 if value is negative and +1 is value is positive.
  1064. * @param value the value
  1065. * @returns the value itself if it's equal to zero.
  1066. */
  1067. static Sign(value: number): number;
  1068. /**
  1069. * Returns the value itself if it's between min and max.
  1070. * Returns min if the value is lower than min.
  1071. * Returns max if the value is greater than max.
  1072. * @param value the value to clmap
  1073. * @param min the min value to clamp to (default: 0)
  1074. * @param max the max value to clamp to (default: 1)
  1075. * @returns the clamped value
  1076. */
  1077. static Clamp(value: number, min?: number, max?: number): number;
  1078. /**
  1079. * the log2 of value.
  1080. * @param value the value to compute log2 of
  1081. * @returns the log2 of value.
  1082. */
  1083. static Log2(value: number): number;
  1084. /**
  1085. * Loops the value, so that it is never larger than length and never smaller than 0.
  1086. *
  1087. * This is similar to the modulo operator but it works with floating point numbers.
  1088. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1089. * With t = 5 and length = 2.5, the result would be 0.0.
  1090. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1091. * @param value the value
  1092. * @param length the length
  1093. * @returns the looped value
  1094. */
  1095. static Repeat(value: number, length: number): number;
  1096. /**
  1097. * Normalize the value between 0.0 and 1.0 using min and max values
  1098. * @param value value to normalize
  1099. * @param min max to normalize between
  1100. * @param max min to normalize between
  1101. * @returns the normalized value
  1102. */
  1103. static Normalize(value: number, min: number, max: number): number;
  1104. /**
  1105. * Denormalize the value from 0.0 and 1.0 using min and max values
  1106. * @param normalized value to denormalize
  1107. * @param min max to denormalize between
  1108. * @param max min to denormalize between
  1109. * @returns the denormalized value
  1110. */
  1111. static Denormalize(normalized: number, min: number, max: number): number;
  1112. /**
  1113. * Calculates the shortest difference between two given angles given in degrees.
  1114. * @param current current angle in degrees
  1115. * @param target target angle in degrees
  1116. * @returns the delta
  1117. */
  1118. static DeltaAngle(current: number, target: number): number;
  1119. /**
  1120. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1121. * @param tx value
  1122. * @param length length
  1123. * @returns The returned value will move back and forth between 0 and length
  1124. */
  1125. static PingPong(tx: number, length: number): number;
  1126. /**
  1127. * Interpolates between min and max with smoothing at the limits.
  1128. *
  1129. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1130. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1131. * @param from from
  1132. * @param to to
  1133. * @param tx value
  1134. * @returns the smooth stepped value
  1135. */
  1136. static SmoothStep(from: number, to: number, tx: number): number;
  1137. /**
  1138. * Moves a value current towards target.
  1139. *
  1140. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1141. * Negative values of maxDelta pushes the value away from target.
  1142. * @param current current value
  1143. * @param target target value
  1144. * @param maxDelta max distance to move
  1145. * @returns resulting value
  1146. */
  1147. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1148. /**
  1149. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1150. *
  1151. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1152. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1153. * @param current current value
  1154. * @param target target value
  1155. * @param maxDelta max distance to move
  1156. * @returns resulting angle
  1157. */
  1158. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1159. /**
  1160. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1161. * @param start start value
  1162. * @param end target value
  1163. * @param amount amount to lerp between
  1164. * @returns the lerped value
  1165. */
  1166. static Lerp(start: number, end: number, amount: number): number;
  1167. /**
  1168. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1169. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1170. * @param start start value
  1171. * @param end target value
  1172. * @param amount amount to lerp between
  1173. * @returns the lerped value
  1174. */
  1175. static LerpAngle(start: number, end: number, amount: number): number;
  1176. /**
  1177. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1178. * @param a start value
  1179. * @param b target value
  1180. * @param value value between a and b
  1181. * @returns the inverseLerp value
  1182. */
  1183. static InverseLerp(a: number, b: number, value: number): number;
  1184. /**
  1185. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1186. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1187. * @param value1 spline value
  1188. * @param tangent1 spline value
  1189. * @param value2 spline value
  1190. * @param tangent2 spline value
  1191. * @param amount input value
  1192. * @returns hermite result
  1193. */
  1194. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1195. /**
  1196. * Returns a random float number between and min and max values
  1197. * @param min min value of random
  1198. * @param max max value of random
  1199. * @returns random value
  1200. */
  1201. static RandomRange(min: number, max: number): number;
  1202. /**
  1203. * This function returns percentage of a number in a given range.
  1204. *
  1205. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1206. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1207. * @param number to convert to percentage
  1208. * @param min min range
  1209. * @param max max range
  1210. * @returns the percentage
  1211. */
  1212. static RangeToPercent(number: number, min: number, max: number): number;
  1213. /**
  1214. * This function returns number that corresponds to the percentage in a given range.
  1215. *
  1216. * PercentToRange(0.34,0,100) will return 34.
  1217. * @param percent to convert to number
  1218. * @param min min range
  1219. * @param max max range
  1220. * @returns the number
  1221. */
  1222. static PercentToRange(percent: number, min: number, max: number): number;
  1223. /**
  1224. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1225. * @param angle The angle to normalize in radian.
  1226. * @return The converted angle.
  1227. */
  1228. static NormalizeRadians(angle: number): number;
  1229. }
  1230. }
  1231. declare module "babylonjs/Maths/math.constants" {
  1232. /**
  1233. * Constant used to convert a value to gamma space
  1234. * @ignorenaming
  1235. */
  1236. export const ToGammaSpace: number;
  1237. /**
  1238. * Constant used to convert a value to linear space
  1239. * @ignorenaming
  1240. */
  1241. export const ToLinearSpace = 2.2;
  1242. /**
  1243. * Constant used to define the minimal number value in Babylon.js
  1244. * @ignorenaming
  1245. */
  1246. let Epsilon: number;
  1247. export { Epsilon };
  1248. }
  1249. declare module "babylonjs/Maths/math.viewport" {
  1250. /**
  1251. * Class used to represent a viewport on screen
  1252. */
  1253. export class Viewport {
  1254. /** viewport left coordinate */
  1255. x: number;
  1256. /** viewport top coordinate */
  1257. y: number;
  1258. /**viewport width */
  1259. width: number;
  1260. /** viewport height */
  1261. height: number;
  1262. /**
  1263. * Creates a Viewport object located at (x, y) and sized (width, height)
  1264. * @param x defines viewport left coordinate
  1265. * @param y defines viewport top coordinate
  1266. * @param width defines the viewport width
  1267. * @param height defines the viewport height
  1268. */
  1269. constructor(
  1270. /** viewport left coordinate */
  1271. x: number,
  1272. /** viewport top coordinate */
  1273. y: number,
  1274. /**viewport width */
  1275. width: number,
  1276. /** viewport height */
  1277. height: number);
  1278. /**
  1279. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1280. * @param renderWidth defines the rendering width
  1281. * @param renderHeight defines the rendering height
  1282. * @returns a new Viewport
  1283. */
  1284. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1285. /**
  1286. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1287. * @param renderWidth defines the rendering width
  1288. * @param renderHeight defines the rendering height
  1289. * @param ref defines the target viewport
  1290. * @returns the current viewport
  1291. */
  1292. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1293. /**
  1294. * Returns a new Viewport copied from the current one
  1295. * @returns a new Viewport
  1296. */
  1297. clone(): Viewport;
  1298. }
  1299. }
  1300. declare module "babylonjs/Misc/arrayTools" {
  1301. /**
  1302. * Class containing a set of static utilities functions for arrays.
  1303. */
  1304. export class ArrayTools {
  1305. /**
  1306. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1307. * @param size the number of element to construct and put in the array
  1308. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1309. * @returns a new array filled with new objects
  1310. */
  1311. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1312. }
  1313. }
  1314. declare module "babylonjs/Maths/math.like" {
  1315. import { float, int, DeepImmutable } from "babylonjs/types";
  1316. /**
  1317. * @hidden
  1318. */
  1319. export interface IColor4Like {
  1320. r: float;
  1321. g: float;
  1322. b: float;
  1323. a: float;
  1324. }
  1325. /**
  1326. * @hidden
  1327. */
  1328. export interface IColor3Like {
  1329. r: float;
  1330. g: float;
  1331. b: float;
  1332. }
  1333. /**
  1334. * @hidden
  1335. */
  1336. export interface IVector4Like {
  1337. x: float;
  1338. y: float;
  1339. z: float;
  1340. w: float;
  1341. }
  1342. /**
  1343. * @hidden
  1344. */
  1345. export interface IVector3Like {
  1346. x: float;
  1347. y: float;
  1348. z: float;
  1349. }
  1350. /**
  1351. * @hidden
  1352. */
  1353. export interface IVector2Like {
  1354. x: float;
  1355. y: float;
  1356. }
  1357. /**
  1358. * @hidden
  1359. */
  1360. export interface IMatrixLike {
  1361. toArray(): DeepImmutable<Float32Array>;
  1362. updateFlag: int;
  1363. }
  1364. /**
  1365. * @hidden
  1366. */
  1367. export interface IViewportLike {
  1368. x: float;
  1369. y: float;
  1370. width: float;
  1371. height: float;
  1372. }
  1373. /**
  1374. * @hidden
  1375. */
  1376. export interface IPlaneLike {
  1377. normal: IVector3Like;
  1378. d: float;
  1379. normalize(): void;
  1380. }
  1381. }
  1382. declare module "babylonjs/Maths/math.vector" {
  1383. import { Viewport } from "babylonjs/Maths/math.viewport";
  1384. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1385. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1386. /**
  1387. * Class representing a vector containing 2 coordinates
  1388. */
  1389. export class Vector2 {
  1390. /** defines the first coordinate */
  1391. x: number;
  1392. /** defines the second coordinate */
  1393. y: number;
  1394. /**
  1395. * Creates a new Vector2 from the given x and y coordinates
  1396. * @param x defines the first coordinate
  1397. * @param y defines the second coordinate
  1398. */
  1399. constructor(
  1400. /** defines the first coordinate */
  1401. x?: number,
  1402. /** defines the second coordinate */
  1403. y?: number);
  1404. /**
  1405. * Gets a string with the Vector2 coordinates
  1406. * @returns a string with the Vector2 coordinates
  1407. */
  1408. toString(): string;
  1409. /**
  1410. * Gets class name
  1411. * @returns the string "Vector2"
  1412. */
  1413. getClassName(): string;
  1414. /**
  1415. * Gets current vector hash code
  1416. * @returns the Vector2 hash code as a number
  1417. */
  1418. getHashCode(): number;
  1419. /**
  1420. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1421. * @param array defines the source array
  1422. * @param index defines the offset in source array
  1423. * @returns the current Vector2
  1424. */
  1425. toArray(array: FloatArray, index?: number): Vector2;
  1426. /**
  1427. * Copy the current vector to an array
  1428. * @returns a new array with 2 elements: the Vector2 coordinates.
  1429. */
  1430. asArray(): number[];
  1431. /**
  1432. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1433. * @param source defines the source Vector2
  1434. * @returns the current updated Vector2
  1435. */
  1436. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1437. /**
  1438. * Sets the Vector2 coordinates with the given floats
  1439. * @param x defines the first coordinate
  1440. * @param y defines the second coordinate
  1441. * @returns the current updated Vector2
  1442. */
  1443. copyFromFloats(x: number, y: number): Vector2;
  1444. /**
  1445. * Sets the Vector2 coordinates with the given floats
  1446. * @param x defines the first coordinate
  1447. * @param y defines the second coordinate
  1448. * @returns the current updated Vector2
  1449. */
  1450. set(x: number, y: number): Vector2;
  1451. /**
  1452. * Add another vector with the current one
  1453. * @param otherVector defines the other vector
  1454. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1455. */
  1456. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1457. /**
  1458. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1459. * @param otherVector defines the other vector
  1460. * @param result defines the target vector
  1461. * @returns the unmodified current Vector2
  1462. */
  1463. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1464. /**
  1465. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1466. * @param otherVector defines the other vector
  1467. * @returns the current updated Vector2
  1468. */
  1469. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1470. /**
  1471. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1472. * @param otherVector defines the other vector
  1473. * @returns a new Vector2
  1474. */
  1475. addVector3(otherVector: Vector3): Vector2;
  1476. /**
  1477. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1478. * @param otherVector defines the other vector
  1479. * @returns a new Vector2
  1480. */
  1481. subtract(otherVector: Vector2): Vector2;
  1482. /**
  1483. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1484. * @param otherVector defines the other vector
  1485. * @param result defines the target vector
  1486. * @returns the unmodified current Vector2
  1487. */
  1488. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1489. /**
  1490. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1491. * @param otherVector defines the other vector
  1492. * @returns the current updated Vector2
  1493. */
  1494. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1495. /**
  1496. * Multiplies in place the current Vector2 coordinates by the given ones
  1497. * @param otherVector defines the other vector
  1498. * @returns the current updated Vector2
  1499. */
  1500. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1501. /**
  1502. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1503. * @param otherVector defines the other vector
  1504. * @returns a new Vector2
  1505. */
  1506. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1507. /**
  1508. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1509. * @param otherVector defines the other vector
  1510. * @param result defines the target vector
  1511. * @returns the unmodified current Vector2
  1512. */
  1513. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1514. /**
  1515. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1516. * @param x defines the first coordinate
  1517. * @param y defines the second coordinate
  1518. * @returns a new Vector2
  1519. */
  1520. multiplyByFloats(x: number, y: number): Vector2;
  1521. /**
  1522. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1523. * @param otherVector defines the other vector
  1524. * @returns a new Vector2
  1525. */
  1526. divide(otherVector: Vector2): Vector2;
  1527. /**
  1528. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1529. * @param otherVector defines the other vector
  1530. * @param result defines the target vector
  1531. * @returns the unmodified current Vector2
  1532. */
  1533. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1534. /**
  1535. * Divides the current Vector2 coordinates by the given ones
  1536. * @param otherVector defines the other vector
  1537. * @returns the current updated Vector2
  1538. */
  1539. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1540. /**
  1541. * Gets a new Vector2 with current Vector2 negated coordinates
  1542. * @returns a new Vector2
  1543. */
  1544. negate(): Vector2;
  1545. /**
  1546. * Multiply the Vector2 coordinates by scale
  1547. * @param scale defines the scaling factor
  1548. * @returns the current updated Vector2
  1549. */
  1550. scaleInPlace(scale: number): Vector2;
  1551. /**
  1552. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1553. * @param scale defines the scaling factor
  1554. * @returns a new Vector2
  1555. */
  1556. scale(scale: number): Vector2;
  1557. /**
  1558. * Scale the current Vector2 values by a factor to a given Vector2
  1559. * @param scale defines the scale factor
  1560. * @param result defines the Vector2 object where to store the result
  1561. * @returns the unmodified current Vector2
  1562. */
  1563. scaleToRef(scale: number, result: Vector2): Vector2;
  1564. /**
  1565. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1566. * @param scale defines the scale factor
  1567. * @param result defines the Vector2 object where to store the result
  1568. * @returns the unmodified current Vector2
  1569. */
  1570. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1571. /**
  1572. * Gets a boolean if two vectors are equals
  1573. * @param otherVector defines the other vector
  1574. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1575. */
  1576. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1577. /**
  1578. * Gets a boolean if two vectors are equals (using an epsilon value)
  1579. * @param otherVector defines the other vector
  1580. * @param epsilon defines the minimal distance to consider equality
  1581. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1582. */
  1583. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1584. /**
  1585. * Gets a new Vector2 from current Vector2 floored values
  1586. * @returns a new Vector2
  1587. */
  1588. floor(): Vector2;
  1589. /**
  1590. * Gets a new Vector2 from current Vector2 floored values
  1591. * @returns a new Vector2
  1592. */
  1593. fract(): Vector2;
  1594. /**
  1595. * Gets the length of the vector
  1596. * @returns the vector length (float)
  1597. */
  1598. length(): number;
  1599. /**
  1600. * Gets the vector squared length
  1601. * @returns the vector squared length (float)
  1602. */
  1603. lengthSquared(): number;
  1604. /**
  1605. * Normalize the vector
  1606. * @returns the current updated Vector2
  1607. */
  1608. normalize(): Vector2;
  1609. /**
  1610. * Gets a new Vector2 copied from the Vector2
  1611. * @returns a new Vector2
  1612. */
  1613. clone(): Vector2;
  1614. /**
  1615. * Gets a new Vector2(0, 0)
  1616. * @returns a new Vector2
  1617. */
  1618. static Zero(): Vector2;
  1619. /**
  1620. * Gets a new Vector2(1, 1)
  1621. * @returns a new Vector2
  1622. */
  1623. static One(): Vector2;
  1624. /**
  1625. * Gets a new Vector2 set from the given index element of the given array
  1626. * @param array defines the data source
  1627. * @param offset defines the offset in the data source
  1628. * @returns a new Vector2
  1629. */
  1630. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1631. /**
  1632. * Sets "result" from the given index element of the given array
  1633. * @param array defines the data source
  1634. * @param offset defines the offset in the data source
  1635. * @param result defines the target vector
  1636. */
  1637. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1638. /**
  1639. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1640. * @param value1 defines 1st point of control
  1641. * @param value2 defines 2nd point of control
  1642. * @param value3 defines 3rd point of control
  1643. * @param value4 defines 4th point of control
  1644. * @param amount defines the interpolation factor
  1645. * @returns a new Vector2
  1646. */
  1647. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1648. /**
  1649. * 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".
  1650. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1651. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1652. * @param value defines the value to clamp
  1653. * @param min defines the lower limit
  1654. * @param max defines the upper limit
  1655. * @returns a new Vector2
  1656. */
  1657. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1658. /**
  1659. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1660. * @param value1 defines the 1st control point
  1661. * @param tangent1 defines the outgoing tangent
  1662. * @param value2 defines the 2nd control point
  1663. * @param tangent2 defines the incoming tangent
  1664. * @param amount defines the interpolation factor
  1665. * @returns a new Vector2
  1666. */
  1667. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1668. /**
  1669. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1670. * @param start defines the start vector
  1671. * @param end defines the end vector
  1672. * @param amount defines the interpolation factor
  1673. * @returns a new Vector2
  1674. */
  1675. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1676. /**
  1677. * Gets the dot product of the vector "left" and the vector "right"
  1678. * @param left defines first vector
  1679. * @param right defines second vector
  1680. * @returns the dot product (float)
  1681. */
  1682. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1683. /**
  1684. * Returns a new Vector2 equal to the normalized given vector
  1685. * @param vector defines the vector to normalize
  1686. * @returns a new Vector2
  1687. */
  1688. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1689. /**
  1690. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1691. * @param left defines 1st vector
  1692. * @param right defines 2nd vector
  1693. * @returns a new Vector2
  1694. */
  1695. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1696. /**
  1697. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1698. * @param left defines 1st vector
  1699. * @param right defines 2nd vector
  1700. * @returns a new Vector2
  1701. */
  1702. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1703. /**
  1704. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1705. * @param vector defines the vector to transform
  1706. * @param transformation defines the matrix to apply
  1707. * @returns a new Vector2
  1708. */
  1709. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1710. /**
  1711. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1712. * @param vector defines the vector to transform
  1713. * @param transformation defines the matrix to apply
  1714. * @param result defines the target vector
  1715. */
  1716. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1717. /**
  1718. * Determines if a given vector is included in a triangle
  1719. * @param p defines the vector to test
  1720. * @param p0 defines 1st triangle point
  1721. * @param p1 defines 2nd triangle point
  1722. * @param p2 defines 3rd triangle point
  1723. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1724. */
  1725. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1726. /**
  1727. * Gets the distance between the vectors "value1" and "value2"
  1728. * @param value1 defines first vector
  1729. * @param value2 defines second vector
  1730. * @returns the distance between vectors
  1731. */
  1732. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1733. /**
  1734. * Returns the squared distance between the vectors "value1" and "value2"
  1735. * @param value1 defines first vector
  1736. * @param value2 defines second vector
  1737. * @returns the squared distance between vectors
  1738. */
  1739. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1740. /**
  1741. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1742. * @param value1 defines first vector
  1743. * @param value2 defines second vector
  1744. * @returns a new Vector2
  1745. */
  1746. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1747. /**
  1748. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1749. * @param p defines the middle point
  1750. * @param segA defines one point of the segment
  1751. * @param segB defines the other point of the segment
  1752. * @returns the shortest distance
  1753. */
  1754. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1755. }
  1756. /**
  1757. * Classed used to store (x,y,z) vector representation
  1758. * A Vector3 is the main object used in 3D geometry
  1759. * It can represent etiher the coordinates of a point the space, either a direction
  1760. * Reminder: js uses a left handed forward facing system
  1761. */
  1762. export class Vector3 {
  1763. /**
  1764. * Defines the first coordinates (on X axis)
  1765. */
  1766. x: number;
  1767. /**
  1768. * Defines the second coordinates (on Y axis)
  1769. */
  1770. y: number;
  1771. /**
  1772. * Defines the third coordinates (on Z axis)
  1773. */
  1774. z: number;
  1775. private static _UpReadOnly;
  1776. private static _ZeroReadOnly;
  1777. /**
  1778. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1779. * @param x defines the first coordinates (on X axis)
  1780. * @param y defines the second coordinates (on Y axis)
  1781. * @param z defines the third coordinates (on Z axis)
  1782. */
  1783. constructor(
  1784. /**
  1785. * Defines the first coordinates (on X axis)
  1786. */
  1787. x?: number,
  1788. /**
  1789. * Defines the second coordinates (on Y axis)
  1790. */
  1791. y?: number,
  1792. /**
  1793. * Defines the third coordinates (on Z axis)
  1794. */
  1795. z?: number);
  1796. /**
  1797. * Creates a string representation of the Vector3
  1798. * @returns a string with the Vector3 coordinates.
  1799. */
  1800. toString(): string;
  1801. /**
  1802. * Gets the class name
  1803. * @returns the string "Vector3"
  1804. */
  1805. getClassName(): string;
  1806. /**
  1807. * Creates the Vector3 hash code
  1808. * @returns a number which tends to be unique between Vector3 instances
  1809. */
  1810. getHashCode(): number;
  1811. /**
  1812. * Creates an array containing three elements : the coordinates of the Vector3
  1813. * @returns a new array of numbers
  1814. */
  1815. asArray(): number[];
  1816. /**
  1817. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1818. * @param array defines the destination array
  1819. * @param index defines the offset in the destination array
  1820. * @returns the current Vector3
  1821. */
  1822. toArray(array: FloatArray, index?: number): Vector3;
  1823. /**
  1824. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1825. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1826. */
  1827. toQuaternion(): Quaternion;
  1828. /**
  1829. * Adds the given vector to the current Vector3
  1830. * @param otherVector defines the second operand
  1831. * @returns the current updated Vector3
  1832. */
  1833. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1834. /**
  1835. * Adds the given coordinates to the current Vector3
  1836. * @param x defines the x coordinate of the operand
  1837. * @param y defines the y coordinate of the operand
  1838. * @param z defines the z coordinate of the operand
  1839. * @returns the current updated Vector3
  1840. */
  1841. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1842. /**
  1843. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1844. * @param otherVector defines the second operand
  1845. * @returns the resulting Vector3
  1846. */
  1847. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1848. /**
  1849. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1850. * @param otherVector defines the second operand
  1851. * @param result defines the Vector3 object where to store the result
  1852. * @returns the current Vector3
  1853. */
  1854. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1855. /**
  1856. * Subtract the given vector from the current Vector3
  1857. * @param otherVector defines the second operand
  1858. * @returns the current updated Vector3
  1859. */
  1860. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1861. /**
  1862. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1863. * @param otherVector defines the second operand
  1864. * @returns the resulting Vector3
  1865. */
  1866. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1867. /**
  1868. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1869. * @param otherVector defines the second operand
  1870. * @param result defines the Vector3 object where to store the result
  1871. * @returns the current Vector3
  1872. */
  1873. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1874. /**
  1875. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1876. * @param x defines the x coordinate of the operand
  1877. * @param y defines the y coordinate of the operand
  1878. * @param z defines the z coordinate of the operand
  1879. * @returns the resulting Vector3
  1880. */
  1881. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1882. /**
  1883. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1884. * @param x defines the x coordinate of the operand
  1885. * @param y defines the y coordinate of the operand
  1886. * @param z defines the z coordinate of the operand
  1887. * @param result defines the Vector3 object where to store the result
  1888. * @returns the current Vector3
  1889. */
  1890. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1891. /**
  1892. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1893. * @returns a new Vector3
  1894. */
  1895. negate(): Vector3;
  1896. /**
  1897. * Multiplies the Vector3 coordinates by the float "scale"
  1898. * @param scale defines the multiplier factor
  1899. * @returns the current updated Vector3
  1900. */
  1901. scaleInPlace(scale: number): Vector3;
  1902. /**
  1903. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1904. * @param scale defines the multiplier factor
  1905. * @returns a new Vector3
  1906. */
  1907. scale(scale: number): Vector3;
  1908. /**
  1909. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1910. * @param scale defines the multiplier factor
  1911. * @param result defines the Vector3 object where to store the result
  1912. * @returns the current Vector3
  1913. */
  1914. scaleToRef(scale: number, result: Vector3): Vector3;
  1915. /**
  1916. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1917. * @param scale defines the scale factor
  1918. * @param result defines the Vector3 object where to store the result
  1919. * @returns the unmodified current Vector3
  1920. */
  1921. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1922. /**
  1923. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1924. * @param otherVector defines the second operand
  1925. * @returns true if both vectors are equals
  1926. */
  1927. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1928. /**
  1929. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1930. * @param otherVector defines the second operand
  1931. * @param epsilon defines the minimal distance to define values as equals
  1932. * @returns true if both vectors are distant less than epsilon
  1933. */
  1934. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1935. /**
  1936. * Returns true if the current Vector3 coordinates equals the given floats
  1937. * @param x defines the x coordinate of the operand
  1938. * @param y defines the y coordinate of the operand
  1939. * @param z defines the z coordinate of the operand
  1940. * @returns true if both vectors are equals
  1941. */
  1942. equalsToFloats(x: number, y: number, z: number): boolean;
  1943. /**
  1944. * Multiplies the current Vector3 coordinates by the given ones
  1945. * @param otherVector defines the second operand
  1946. * @returns the current updated Vector3
  1947. */
  1948. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1949. /**
  1950. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1951. * @param otherVector defines the second operand
  1952. * @returns the new Vector3
  1953. */
  1954. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1955. /**
  1956. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1957. * @param otherVector defines the second operand
  1958. * @param result defines the Vector3 object where to store the result
  1959. * @returns the current Vector3
  1960. */
  1961. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1962. /**
  1963. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1964. * @param x defines the x coordinate of the operand
  1965. * @param y defines the y coordinate of the operand
  1966. * @param z defines the z coordinate of the operand
  1967. * @returns the new Vector3
  1968. */
  1969. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1970. /**
  1971. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1972. * @param otherVector defines the second operand
  1973. * @returns the new Vector3
  1974. */
  1975. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1976. /**
  1977. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1978. * @param otherVector defines the second operand
  1979. * @param result defines the Vector3 object where to store the result
  1980. * @returns the current Vector3
  1981. */
  1982. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1983. /**
  1984. * Divides the current Vector3 coordinates by the given ones.
  1985. * @param otherVector defines the second operand
  1986. * @returns the current updated Vector3
  1987. */
  1988. divideInPlace(otherVector: Vector3): Vector3;
  1989. /**
  1990. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1991. * @param other defines the second operand
  1992. * @returns the current updated Vector3
  1993. */
  1994. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1995. /**
  1996. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1997. * @param other defines the second operand
  1998. * @returns the current updated Vector3
  1999. */
  2000. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2001. /**
  2002. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2003. * @param x defines the x coordinate of the operand
  2004. * @param y defines the y coordinate of the operand
  2005. * @param z defines the z coordinate of the operand
  2006. * @returns the current updated Vector3
  2007. */
  2008. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2009. /**
  2010. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2011. * @param x defines the x coordinate of the operand
  2012. * @param y defines the y coordinate of the operand
  2013. * @param z defines the z coordinate of the operand
  2014. * @returns the current updated Vector3
  2015. */
  2016. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2017. /**
  2018. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2019. * Check if is non uniform within a certain amount of decimal places to account for this
  2020. * @param epsilon the amount the values can differ
  2021. * @returns if the the vector is non uniform to a certain number of decimal places
  2022. */
  2023. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2024. /**
  2025. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2026. */
  2027. readonly isNonUniform: boolean;
  2028. /**
  2029. * Gets a new Vector3 from current Vector3 floored values
  2030. * @returns a new Vector3
  2031. */
  2032. floor(): Vector3;
  2033. /**
  2034. * Gets a new Vector3 from current Vector3 floored values
  2035. * @returns a new Vector3
  2036. */
  2037. fract(): Vector3;
  2038. /**
  2039. * Gets the length of the Vector3
  2040. * @returns the length of the Vector3
  2041. */
  2042. length(): number;
  2043. /**
  2044. * Gets the squared length of the Vector3
  2045. * @returns squared length of the Vector3
  2046. */
  2047. lengthSquared(): number;
  2048. /**
  2049. * Normalize the current Vector3.
  2050. * Please note that this is an in place operation.
  2051. * @returns the current updated Vector3
  2052. */
  2053. normalize(): Vector3;
  2054. /**
  2055. * Reorders the x y z properties of the vector in place
  2056. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2057. * @returns the current updated vector
  2058. */
  2059. reorderInPlace(order: string): this;
  2060. /**
  2061. * Rotates the vector around 0,0,0 by a quaternion
  2062. * @param quaternion the rotation quaternion
  2063. * @param result vector to store the result
  2064. * @returns the resulting vector
  2065. */
  2066. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2067. /**
  2068. * Rotates a vector around a given point
  2069. * @param quaternion the rotation quaternion
  2070. * @param point the point to rotate around
  2071. * @param result vector to store the result
  2072. * @returns the resulting vector
  2073. */
  2074. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2075. /**
  2076. * Normalize the current Vector3 with the given input length.
  2077. * Please note that this is an in place operation.
  2078. * @param len the length of the vector
  2079. * @returns the current updated Vector3
  2080. */
  2081. normalizeFromLength(len: number): Vector3;
  2082. /**
  2083. * Normalize the current Vector3 to a new vector
  2084. * @returns the new Vector3
  2085. */
  2086. normalizeToNew(): Vector3;
  2087. /**
  2088. * Normalize the current Vector3 to the reference
  2089. * @param reference define the Vector3 to update
  2090. * @returns the updated Vector3
  2091. */
  2092. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2093. /**
  2094. * Creates a new Vector3 copied from the current Vector3
  2095. * @returns the new Vector3
  2096. */
  2097. clone(): Vector3;
  2098. /**
  2099. * Copies the given vector coordinates to the current Vector3 ones
  2100. * @param source defines the source Vector3
  2101. * @returns the current updated Vector3
  2102. */
  2103. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2104. /**
  2105. * Copies the given floats to the current Vector3 coordinates
  2106. * @param x defines the x coordinate of the operand
  2107. * @param y defines the y coordinate of the operand
  2108. * @param z defines the z coordinate of the operand
  2109. * @returns the current updated Vector3
  2110. */
  2111. copyFromFloats(x: number, y: number, z: number): Vector3;
  2112. /**
  2113. * Copies the given floats to the current Vector3 coordinates
  2114. * @param x defines the x coordinate of the operand
  2115. * @param y defines the y coordinate of the operand
  2116. * @param z defines the z coordinate of the operand
  2117. * @returns the current updated Vector3
  2118. */
  2119. set(x: number, y: number, z: number): Vector3;
  2120. /**
  2121. * Copies the given float to the current Vector3 coordinates
  2122. * @param v defines the x, y and z coordinates of the operand
  2123. * @returns the current updated Vector3
  2124. */
  2125. setAll(v: number): Vector3;
  2126. /**
  2127. * Get the clip factor between two vectors
  2128. * @param vector0 defines the first operand
  2129. * @param vector1 defines the second operand
  2130. * @param axis defines the axis to use
  2131. * @param size defines the size along the axis
  2132. * @returns the clip factor
  2133. */
  2134. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2135. /**
  2136. * Get angle between two vectors
  2137. * @param vector0 angle between vector0 and vector1
  2138. * @param vector1 angle between vector0 and vector1
  2139. * @param normal direction of the normal
  2140. * @return the angle between vector0 and vector1
  2141. */
  2142. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2143. /**
  2144. * Returns a new Vector3 set from the index "offset" of the given array
  2145. * @param array defines the source array
  2146. * @param offset defines the offset in the source array
  2147. * @returns the new Vector3
  2148. */
  2149. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2150. /**
  2151. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2152. * This function is deprecated. Use FromArray instead
  2153. * @param array defines the source array
  2154. * @param offset defines the offset in the source array
  2155. * @returns the new Vector3
  2156. */
  2157. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2158. /**
  2159. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2160. * @param array defines the source array
  2161. * @param offset defines the offset in the source array
  2162. * @param result defines the Vector3 where to store the result
  2163. */
  2164. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2165. /**
  2166. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2167. * This function is deprecated. Use FromArrayToRef instead.
  2168. * @param array defines the source array
  2169. * @param offset defines the offset in the source array
  2170. * @param result defines the Vector3 where to store the result
  2171. */
  2172. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2173. /**
  2174. * Sets the given vector "result" with the given floats.
  2175. * @param x defines the x coordinate of the source
  2176. * @param y defines the y coordinate of the source
  2177. * @param z defines the z coordinate of the source
  2178. * @param result defines the Vector3 where to store the result
  2179. */
  2180. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2181. /**
  2182. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2183. * @returns a new empty Vector3
  2184. */
  2185. static Zero(): Vector3;
  2186. /**
  2187. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2188. * @returns a new unit Vector3
  2189. */
  2190. static One(): Vector3;
  2191. /**
  2192. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2193. * @returns a new up Vector3
  2194. */
  2195. static Up(): Vector3;
  2196. /**
  2197. * Gets a up Vector3 that must not be updated
  2198. */
  2199. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2200. /**
  2201. * Gets a zero Vector3 that must not be updated
  2202. */
  2203. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2204. /**
  2205. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2206. * @returns a new down Vector3
  2207. */
  2208. static Down(): Vector3;
  2209. /**
  2210. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2211. * @returns a new forward Vector3
  2212. */
  2213. static Forward(): Vector3;
  2214. /**
  2215. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2216. * @returns a new forward Vector3
  2217. */
  2218. static Backward(): Vector3;
  2219. /**
  2220. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2221. * @returns a new right Vector3
  2222. */
  2223. static Right(): Vector3;
  2224. /**
  2225. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2226. * @returns a new left Vector3
  2227. */
  2228. static Left(): Vector3;
  2229. /**
  2230. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2231. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2232. * @param vector defines the Vector3 to transform
  2233. * @param transformation defines the transformation matrix
  2234. * @returns the transformed Vector3
  2235. */
  2236. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2237. /**
  2238. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2239. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2240. * @param vector defines the Vector3 to transform
  2241. * @param transformation defines the transformation matrix
  2242. * @param result defines the Vector3 where to store the result
  2243. */
  2244. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2245. /**
  2246. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2247. * This method computes tranformed coordinates only, not transformed direction vectors
  2248. * @param x define the x coordinate of the source vector
  2249. * @param y define the y coordinate of the source vector
  2250. * @param z define the z coordinate of the source vector
  2251. * @param transformation defines the transformation matrix
  2252. * @param result defines the Vector3 where to store the result
  2253. */
  2254. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2255. /**
  2256. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2257. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2258. * @param vector defines the Vector3 to transform
  2259. * @param transformation defines the transformation matrix
  2260. * @returns the new Vector3
  2261. */
  2262. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2263. /**
  2264. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2265. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2266. * @param vector defines the Vector3 to transform
  2267. * @param transformation defines the transformation matrix
  2268. * @param result defines the Vector3 where to store the result
  2269. */
  2270. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2271. /**
  2272. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2273. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2274. * @param x define the x coordinate of the source vector
  2275. * @param y define the y coordinate of the source vector
  2276. * @param z define the z coordinate of the source vector
  2277. * @param transformation defines the transformation matrix
  2278. * @param result defines the Vector3 where to store the result
  2279. */
  2280. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2281. /**
  2282. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2283. * @param value1 defines the first control point
  2284. * @param value2 defines the second control point
  2285. * @param value3 defines the third control point
  2286. * @param value4 defines the fourth control point
  2287. * @param amount defines the amount on the spline to use
  2288. * @returns the new Vector3
  2289. */
  2290. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2291. /**
  2292. * 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"
  2293. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2294. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2295. * @param value defines the current value
  2296. * @param min defines the lower range value
  2297. * @param max defines the upper range value
  2298. * @returns the new Vector3
  2299. */
  2300. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2301. /**
  2302. * 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"
  2303. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2304. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2305. * @param value defines the current value
  2306. * @param min defines the lower range value
  2307. * @param max defines the upper range value
  2308. * @param result defines the Vector3 where to store the result
  2309. */
  2310. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2311. /**
  2312. * Checks if a given vector is inside a specific range
  2313. * @param v defines the vector to test
  2314. * @param min defines the minimum range
  2315. * @param max defines the maximum range
  2316. */
  2317. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2318. /**
  2319. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2320. * @param value1 defines the first control point
  2321. * @param tangent1 defines the first tangent vector
  2322. * @param value2 defines the second control point
  2323. * @param tangent2 defines the second tangent vector
  2324. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2325. * @returns the new Vector3
  2326. */
  2327. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2328. /**
  2329. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2330. * @param start defines the start value
  2331. * @param end defines the end value
  2332. * @param amount max defines amount between both (between 0 and 1)
  2333. * @returns the new Vector3
  2334. */
  2335. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2336. /**
  2337. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2338. * @param start defines the start value
  2339. * @param end defines the end value
  2340. * @param amount max defines amount between both (between 0 and 1)
  2341. * @param result defines the Vector3 where to store the result
  2342. */
  2343. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2344. /**
  2345. * Returns the dot product (float) between the vectors "left" and "right"
  2346. * @param left defines the left operand
  2347. * @param right defines the right operand
  2348. * @returns the dot product
  2349. */
  2350. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2351. /**
  2352. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2353. * The cross product is then orthogonal to both "left" and "right"
  2354. * @param left defines the left operand
  2355. * @param right defines the right operand
  2356. * @returns the cross product
  2357. */
  2358. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2359. /**
  2360. * Sets the given vector "result" with the cross product of "left" and "right"
  2361. * The cross product is then orthogonal to both "left" and "right"
  2362. * @param left defines the left operand
  2363. * @param right defines the right operand
  2364. * @param result defines the Vector3 where to store the result
  2365. */
  2366. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2367. /**
  2368. * Returns a new Vector3 as the normalization of the given vector
  2369. * @param vector defines the Vector3 to normalize
  2370. * @returns the new Vector3
  2371. */
  2372. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2373. /**
  2374. * Sets the given vector "result" with the normalization of the given first vector
  2375. * @param vector defines the Vector3 to normalize
  2376. * @param result defines the Vector3 where to store the result
  2377. */
  2378. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2379. /**
  2380. * Project a Vector3 onto screen space
  2381. * @param vector defines the Vector3 to project
  2382. * @param world defines the world matrix to use
  2383. * @param transform defines the transform (view x projection) matrix to use
  2384. * @param viewport defines the screen viewport to use
  2385. * @returns the new Vector3
  2386. */
  2387. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2388. /** @hidden */
  2389. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2390. /**
  2391. * Unproject from screen space to object space
  2392. * @param source defines the screen space Vector3 to use
  2393. * @param viewportWidth defines the current width of the viewport
  2394. * @param viewportHeight defines the current height of the viewport
  2395. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2396. * @param transform defines the transform (view x projection) matrix to use
  2397. * @returns the new Vector3
  2398. */
  2399. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2400. /**
  2401. * Unproject from screen space to object space
  2402. * @param source defines the screen space Vector3 to use
  2403. * @param viewportWidth defines the current width of the viewport
  2404. * @param viewportHeight defines the current height of the viewport
  2405. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2406. * @param view defines the view matrix to use
  2407. * @param projection defines the projection matrix to use
  2408. * @returns the new Vector3
  2409. */
  2410. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2411. /**
  2412. * Unproject from screen space to object space
  2413. * @param source defines the screen space Vector3 to use
  2414. * @param viewportWidth defines the current width of the viewport
  2415. * @param viewportHeight defines the current height of the viewport
  2416. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2417. * @param view defines the view matrix to use
  2418. * @param projection defines the projection matrix to use
  2419. * @param result defines the Vector3 where to store the result
  2420. */
  2421. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2422. /**
  2423. * Unproject from screen space to object space
  2424. * @param sourceX defines the screen space x coordinate to use
  2425. * @param sourceY defines the screen space y coordinate to use
  2426. * @param sourceZ defines the screen space z coordinate to use
  2427. * @param viewportWidth defines the current width of the viewport
  2428. * @param viewportHeight defines the current height of the viewport
  2429. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2430. * @param view defines the view matrix to use
  2431. * @param projection defines the projection matrix to use
  2432. * @param result defines the Vector3 where to store the result
  2433. */
  2434. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2435. /**
  2436. * Gets the minimal coordinate values between two Vector3
  2437. * @param left defines the first operand
  2438. * @param right defines the second operand
  2439. * @returns the new Vector3
  2440. */
  2441. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2442. /**
  2443. * Gets the maximal coordinate values between two Vector3
  2444. * @param left defines the first operand
  2445. * @param right defines the second operand
  2446. * @returns the new Vector3
  2447. */
  2448. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2449. /**
  2450. * Returns the distance between the vectors "value1" and "value2"
  2451. * @param value1 defines the first operand
  2452. * @param value2 defines the second operand
  2453. * @returns the distance
  2454. */
  2455. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2456. /**
  2457. * Returns the squared distance between the vectors "value1" and "value2"
  2458. * @param value1 defines the first operand
  2459. * @param value2 defines the second operand
  2460. * @returns the squared distance
  2461. */
  2462. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2463. /**
  2464. * Returns a new Vector3 located at the center between "value1" and "value2"
  2465. * @param value1 defines the first operand
  2466. * @param value2 defines the second operand
  2467. * @returns the new Vector3
  2468. */
  2469. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2470. /**
  2471. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2472. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2473. * to something in order to rotate it from its local system to the given target system
  2474. * Note: axis1, axis2 and axis3 are normalized during this operation
  2475. * @param axis1 defines the first axis
  2476. * @param axis2 defines the second axis
  2477. * @param axis3 defines the third axis
  2478. * @returns a new Vector3
  2479. */
  2480. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2481. /**
  2482. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2483. * @param axis1 defines the first axis
  2484. * @param axis2 defines the second axis
  2485. * @param axis3 defines the third axis
  2486. * @param ref defines the Vector3 where to store the result
  2487. */
  2488. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2489. }
  2490. /**
  2491. * Vector4 class created for EulerAngle class conversion to Quaternion
  2492. */
  2493. export class Vector4 {
  2494. /** x value of the vector */
  2495. x: number;
  2496. /** y value of the vector */
  2497. y: number;
  2498. /** z value of the vector */
  2499. z: number;
  2500. /** w value of the vector */
  2501. w: number;
  2502. /**
  2503. * Creates a Vector4 object from the given floats.
  2504. * @param x x value of the vector
  2505. * @param y y value of the vector
  2506. * @param z z value of the vector
  2507. * @param w w value of the vector
  2508. */
  2509. constructor(
  2510. /** x value of the vector */
  2511. x: number,
  2512. /** y value of the vector */
  2513. y: number,
  2514. /** z value of the vector */
  2515. z: number,
  2516. /** w value of the vector */
  2517. w: number);
  2518. /**
  2519. * Returns the string with the Vector4 coordinates.
  2520. * @returns a string containing all the vector values
  2521. */
  2522. toString(): string;
  2523. /**
  2524. * Returns the string "Vector4".
  2525. * @returns "Vector4"
  2526. */
  2527. getClassName(): string;
  2528. /**
  2529. * Returns the Vector4 hash code.
  2530. * @returns a unique hash code
  2531. */
  2532. getHashCode(): number;
  2533. /**
  2534. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2535. * @returns the resulting array
  2536. */
  2537. asArray(): number[];
  2538. /**
  2539. * Populates the given array from the given index with the Vector4 coordinates.
  2540. * @param array array to populate
  2541. * @param index index of the array to start at (default: 0)
  2542. * @returns the Vector4.
  2543. */
  2544. toArray(array: FloatArray, index?: number): Vector4;
  2545. /**
  2546. * Adds the given vector to the current Vector4.
  2547. * @param otherVector the vector to add
  2548. * @returns the updated Vector4.
  2549. */
  2550. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2551. /**
  2552. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2553. * @param otherVector the vector to add
  2554. * @returns the resulting vector
  2555. */
  2556. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2557. /**
  2558. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2559. * @param otherVector the vector to add
  2560. * @param result the vector to store the result
  2561. * @returns the current Vector4.
  2562. */
  2563. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2564. /**
  2565. * Subtract in place the given vector from the current Vector4.
  2566. * @param otherVector the vector to subtract
  2567. * @returns the updated Vector4.
  2568. */
  2569. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2570. /**
  2571. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2572. * @param otherVector the vector to add
  2573. * @returns the new vector with the result
  2574. */
  2575. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2576. /**
  2577. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2578. * @param otherVector the vector to subtract
  2579. * @param result the vector to store the result
  2580. * @returns the current Vector4.
  2581. */
  2582. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2583. /**
  2584. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2585. */
  2586. /**
  2587. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2588. * @param x value to subtract
  2589. * @param y value to subtract
  2590. * @param z value to subtract
  2591. * @param w value to subtract
  2592. * @returns new vector containing the result
  2593. */
  2594. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2595. /**
  2596. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2597. * @param x value to subtract
  2598. * @param y value to subtract
  2599. * @param z value to subtract
  2600. * @param w value to subtract
  2601. * @param result the vector to store the result in
  2602. * @returns the current Vector4.
  2603. */
  2604. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2605. /**
  2606. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2607. * @returns a new vector with the negated values
  2608. */
  2609. negate(): Vector4;
  2610. /**
  2611. * Multiplies the current Vector4 coordinates by scale (float).
  2612. * @param scale the number to scale with
  2613. * @returns the updated Vector4.
  2614. */
  2615. scaleInPlace(scale: number): Vector4;
  2616. /**
  2617. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2618. * @param scale the number to scale with
  2619. * @returns a new vector with the result
  2620. */
  2621. scale(scale: number): Vector4;
  2622. /**
  2623. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2624. * @param scale the number to scale with
  2625. * @param result a vector to store the result in
  2626. * @returns the current Vector4.
  2627. */
  2628. scaleToRef(scale: number, result: Vector4): Vector4;
  2629. /**
  2630. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2631. * @param scale defines the scale factor
  2632. * @param result defines the Vector4 object where to store the result
  2633. * @returns the unmodified current Vector4
  2634. */
  2635. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2636. /**
  2637. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2638. * @param otherVector the vector to compare against
  2639. * @returns true if they are equal
  2640. */
  2641. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2642. /**
  2643. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2644. * @param otherVector vector to compare against
  2645. * @param epsilon (Default: very small number)
  2646. * @returns true if they are equal
  2647. */
  2648. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2649. /**
  2650. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2651. * @param x x value to compare against
  2652. * @param y y value to compare against
  2653. * @param z z value to compare against
  2654. * @param w w value to compare against
  2655. * @returns true if equal
  2656. */
  2657. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2658. /**
  2659. * Multiplies in place the current Vector4 by the given one.
  2660. * @param otherVector vector to multiple with
  2661. * @returns the updated Vector4.
  2662. */
  2663. multiplyInPlace(otherVector: Vector4): Vector4;
  2664. /**
  2665. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2666. * @param otherVector vector to multiple with
  2667. * @returns resulting new vector
  2668. */
  2669. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2670. /**
  2671. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2672. * @param otherVector vector to multiple with
  2673. * @param result vector to store the result
  2674. * @returns the current Vector4.
  2675. */
  2676. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2677. /**
  2678. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2679. * @param x x value multiply with
  2680. * @param y y value multiply with
  2681. * @param z z value multiply with
  2682. * @param w w value multiply with
  2683. * @returns resulting new vector
  2684. */
  2685. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2686. /**
  2687. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2688. * @param otherVector vector to devide with
  2689. * @returns resulting new vector
  2690. */
  2691. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2692. /**
  2693. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2694. * @param otherVector vector to devide with
  2695. * @param result vector to store the result
  2696. * @returns the current Vector4.
  2697. */
  2698. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2699. /**
  2700. * Divides the current Vector3 coordinates by the given ones.
  2701. * @param otherVector vector to devide with
  2702. * @returns the updated Vector3.
  2703. */
  2704. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2705. /**
  2706. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2707. * @param other defines the second operand
  2708. * @returns the current updated Vector4
  2709. */
  2710. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2711. /**
  2712. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2713. * @param other defines the second operand
  2714. * @returns the current updated Vector4
  2715. */
  2716. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2717. /**
  2718. * Gets a new Vector4 from current Vector4 floored values
  2719. * @returns a new Vector4
  2720. */
  2721. floor(): Vector4;
  2722. /**
  2723. * Gets a new Vector4 from current Vector3 floored values
  2724. * @returns a new Vector4
  2725. */
  2726. fract(): Vector4;
  2727. /**
  2728. * Returns the Vector4 length (float).
  2729. * @returns the length
  2730. */
  2731. length(): number;
  2732. /**
  2733. * Returns the Vector4 squared length (float).
  2734. * @returns the length squared
  2735. */
  2736. lengthSquared(): number;
  2737. /**
  2738. * Normalizes in place the Vector4.
  2739. * @returns the updated Vector4.
  2740. */
  2741. normalize(): Vector4;
  2742. /**
  2743. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2744. * @returns this converted to a new vector3
  2745. */
  2746. toVector3(): Vector3;
  2747. /**
  2748. * Returns a new Vector4 copied from the current one.
  2749. * @returns the new cloned vector
  2750. */
  2751. clone(): Vector4;
  2752. /**
  2753. * Updates the current Vector4 with the given one coordinates.
  2754. * @param source the source vector to copy from
  2755. * @returns the updated Vector4.
  2756. */
  2757. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2758. /**
  2759. * Updates the current Vector4 coordinates with the given floats.
  2760. * @param x float to copy from
  2761. * @param y float to copy from
  2762. * @param z float to copy from
  2763. * @param w float to copy from
  2764. * @returns the updated Vector4.
  2765. */
  2766. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2767. /**
  2768. * Updates the current Vector4 coordinates with the given floats.
  2769. * @param x float to set from
  2770. * @param y float to set from
  2771. * @param z float to set from
  2772. * @param w float to set from
  2773. * @returns the updated Vector4.
  2774. */
  2775. set(x: number, y: number, z: number, w: number): Vector4;
  2776. /**
  2777. * Copies the given float to the current Vector3 coordinates
  2778. * @param v defines the x, y, z and w coordinates of the operand
  2779. * @returns the current updated Vector3
  2780. */
  2781. setAll(v: number): Vector4;
  2782. /**
  2783. * Returns a new Vector4 set from the starting index of the given array.
  2784. * @param array the array to pull values from
  2785. * @param offset the offset into the array to start at
  2786. * @returns the new vector
  2787. */
  2788. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2789. /**
  2790. * Updates the given vector "result" from the starting index of the given array.
  2791. * @param array the array to pull values from
  2792. * @param offset the offset into the array to start at
  2793. * @param result the vector to store the result in
  2794. */
  2795. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2796. /**
  2797. * Updates the given vector "result" from the starting index of the given Float32Array.
  2798. * @param array the array to pull values from
  2799. * @param offset the offset into the array to start at
  2800. * @param result the vector to store the result in
  2801. */
  2802. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2803. /**
  2804. * Updates the given vector "result" coordinates from the given floats.
  2805. * @param x float to set from
  2806. * @param y float to set from
  2807. * @param z float to set from
  2808. * @param w float to set from
  2809. * @param result the vector to the floats in
  2810. */
  2811. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2812. /**
  2813. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2814. * @returns the new vector
  2815. */
  2816. static Zero(): Vector4;
  2817. /**
  2818. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2819. * @returns the new vector
  2820. */
  2821. static One(): Vector4;
  2822. /**
  2823. * Returns a new normalized Vector4 from the given one.
  2824. * @param vector the vector to normalize
  2825. * @returns the vector
  2826. */
  2827. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2828. /**
  2829. * Updates the given vector "result" from the normalization of the given one.
  2830. * @param vector the vector to normalize
  2831. * @param result the vector to store the result in
  2832. */
  2833. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2834. /**
  2835. * Returns a vector with the minimum values from the left and right vectors
  2836. * @param left left vector to minimize
  2837. * @param right right vector to minimize
  2838. * @returns a new vector with the minimum of the left and right vector values
  2839. */
  2840. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2841. /**
  2842. * Returns a vector with the maximum values from the left and right vectors
  2843. * @param left left vector to maximize
  2844. * @param right right vector to maximize
  2845. * @returns a new vector with the maximum of the left and right vector values
  2846. */
  2847. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2848. /**
  2849. * Returns the distance (float) between the vectors "value1" and "value2".
  2850. * @param value1 value to calulate the distance between
  2851. * @param value2 value to calulate the distance between
  2852. * @return the distance between the two vectors
  2853. */
  2854. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2855. /**
  2856. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2857. * @param value1 value to calulate the distance between
  2858. * @param value2 value to calulate the distance between
  2859. * @return the distance between the two vectors squared
  2860. */
  2861. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2862. /**
  2863. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2864. * @param value1 value to calulate the center between
  2865. * @param value2 value to calulate the center between
  2866. * @return the center between the two vectors
  2867. */
  2868. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2869. /**
  2870. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2871. * This methods computes transformed normalized direction vectors only.
  2872. * @param vector the vector to transform
  2873. * @param transformation the transformation matrix to apply
  2874. * @returns the new vector
  2875. */
  2876. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2877. /**
  2878. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2879. * This methods computes transformed normalized direction vectors only.
  2880. * @param vector the vector to transform
  2881. * @param transformation the transformation matrix to apply
  2882. * @param result the vector to store the result in
  2883. */
  2884. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2885. /**
  2886. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2887. * This methods computes transformed normalized direction vectors only.
  2888. * @param x value to transform
  2889. * @param y value to transform
  2890. * @param z value to transform
  2891. * @param w value to transform
  2892. * @param transformation the transformation matrix to apply
  2893. * @param result the vector to store the results in
  2894. */
  2895. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2896. /**
  2897. * Creates a new Vector4 from a Vector3
  2898. * @param source defines the source data
  2899. * @param w defines the 4th component (default is 0)
  2900. * @returns a new Vector4
  2901. */
  2902. static FromVector3(source: Vector3, w?: number): Vector4;
  2903. }
  2904. /**
  2905. * Class used to store quaternion data
  2906. * @see https://en.wikipedia.org/wiki/Quaternion
  2907. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2908. */
  2909. export class Quaternion {
  2910. /** defines the first component (0 by default) */
  2911. x: number;
  2912. /** defines the second component (0 by default) */
  2913. y: number;
  2914. /** defines the third component (0 by default) */
  2915. z: number;
  2916. /** defines the fourth component (1.0 by default) */
  2917. w: number;
  2918. /**
  2919. * Creates a new Quaternion from the given floats
  2920. * @param x defines the first component (0 by default)
  2921. * @param y defines the second component (0 by default)
  2922. * @param z defines the third component (0 by default)
  2923. * @param w defines the fourth component (1.0 by default)
  2924. */
  2925. constructor(
  2926. /** defines the first component (0 by default) */
  2927. x?: number,
  2928. /** defines the second component (0 by default) */
  2929. y?: number,
  2930. /** defines the third component (0 by default) */
  2931. z?: number,
  2932. /** defines the fourth component (1.0 by default) */
  2933. w?: number);
  2934. /**
  2935. * Gets a string representation for the current quaternion
  2936. * @returns a string with the Quaternion coordinates
  2937. */
  2938. toString(): string;
  2939. /**
  2940. * Gets the class name of the quaternion
  2941. * @returns the string "Quaternion"
  2942. */
  2943. getClassName(): string;
  2944. /**
  2945. * Gets a hash code for this quaternion
  2946. * @returns the quaternion hash code
  2947. */
  2948. getHashCode(): number;
  2949. /**
  2950. * Copy the quaternion to an array
  2951. * @returns a new array populated with 4 elements from the quaternion coordinates
  2952. */
  2953. asArray(): number[];
  2954. /**
  2955. * Check if two quaternions are equals
  2956. * @param otherQuaternion defines the second operand
  2957. * @return true if the current quaternion and the given one coordinates are strictly equals
  2958. */
  2959. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2960. /**
  2961. * Clone the current quaternion
  2962. * @returns a new quaternion copied from the current one
  2963. */
  2964. clone(): Quaternion;
  2965. /**
  2966. * Copy a quaternion to the current one
  2967. * @param other defines the other quaternion
  2968. * @returns the updated current quaternion
  2969. */
  2970. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2971. /**
  2972. * Updates the current quaternion with the given float coordinates
  2973. * @param x defines the x coordinate
  2974. * @param y defines the y coordinate
  2975. * @param z defines the z coordinate
  2976. * @param w defines the w coordinate
  2977. * @returns the updated current quaternion
  2978. */
  2979. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2980. /**
  2981. * Updates the current quaternion from the given float coordinates
  2982. * @param x defines the x coordinate
  2983. * @param y defines the y coordinate
  2984. * @param z defines the z coordinate
  2985. * @param w defines the w coordinate
  2986. * @returns the updated current quaternion
  2987. */
  2988. set(x: number, y: number, z: number, w: number): Quaternion;
  2989. /**
  2990. * Adds two quaternions
  2991. * @param other defines the second operand
  2992. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2993. */
  2994. add(other: DeepImmutable<Quaternion>): Quaternion;
  2995. /**
  2996. * Add a quaternion to the current one
  2997. * @param other defines the quaternion to add
  2998. * @returns the current quaternion
  2999. */
  3000. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3001. /**
  3002. * Subtract two quaternions
  3003. * @param other defines the second operand
  3004. * @returns a new quaternion as the subtraction result of the given one from the current one
  3005. */
  3006. subtract(other: Quaternion): Quaternion;
  3007. /**
  3008. * Multiplies the current quaternion by a scale factor
  3009. * @param value defines the scale factor
  3010. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3011. */
  3012. scale(value: number): Quaternion;
  3013. /**
  3014. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3015. * @param scale defines the scale factor
  3016. * @param result defines the Quaternion object where to store the result
  3017. * @returns the unmodified current quaternion
  3018. */
  3019. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3020. /**
  3021. * Multiplies in place the current quaternion by a scale factor
  3022. * @param value defines the scale factor
  3023. * @returns the current modified quaternion
  3024. */
  3025. scaleInPlace(value: number): Quaternion;
  3026. /**
  3027. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3028. * @param scale defines the scale factor
  3029. * @param result defines the Quaternion object where to store the result
  3030. * @returns the unmodified current quaternion
  3031. */
  3032. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3033. /**
  3034. * Multiplies two quaternions
  3035. * @param q1 defines the second operand
  3036. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3037. */
  3038. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3039. /**
  3040. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3041. * @param q1 defines the second operand
  3042. * @param result defines the target quaternion
  3043. * @returns the current quaternion
  3044. */
  3045. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3046. /**
  3047. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3048. * @param q1 defines the second operand
  3049. * @returns the currentupdated quaternion
  3050. */
  3051. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3052. /**
  3053. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3054. * @param ref defines the target quaternion
  3055. * @returns the current quaternion
  3056. */
  3057. conjugateToRef(ref: Quaternion): Quaternion;
  3058. /**
  3059. * Conjugates in place (1-q) the current quaternion
  3060. * @returns the current updated quaternion
  3061. */
  3062. conjugateInPlace(): Quaternion;
  3063. /**
  3064. * Conjugates in place (1-q) the current quaternion
  3065. * @returns a new quaternion
  3066. */
  3067. conjugate(): Quaternion;
  3068. /**
  3069. * Gets length of current quaternion
  3070. * @returns the quaternion length (float)
  3071. */
  3072. length(): number;
  3073. /**
  3074. * Normalize in place the current quaternion
  3075. * @returns the current updated quaternion
  3076. */
  3077. normalize(): Quaternion;
  3078. /**
  3079. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3080. * @param order is a reserved parameter and is ignore for now
  3081. * @returns a new Vector3 containing the Euler angles
  3082. */
  3083. toEulerAngles(order?: string): Vector3;
  3084. /**
  3085. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3086. * @param result defines the vector which will be filled with the Euler angles
  3087. * @param order is a reserved parameter and is ignore for now
  3088. * @returns the current unchanged quaternion
  3089. */
  3090. toEulerAnglesToRef(result: Vector3): Quaternion;
  3091. /**
  3092. * Updates the given rotation matrix with the current quaternion values
  3093. * @param result defines the target matrix
  3094. * @returns the current unchanged quaternion
  3095. */
  3096. toRotationMatrix(result: Matrix): Quaternion;
  3097. /**
  3098. * Updates the current quaternion from the given rotation matrix values
  3099. * @param matrix defines the source matrix
  3100. * @returns the current updated quaternion
  3101. */
  3102. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3103. /**
  3104. * Creates a new quaternion from a rotation matrix
  3105. * @param matrix defines the source matrix
  3106. * @returns a new quaternion created from the given rotation matrix values
  3107. */
  3108. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3109. /**
  3110. * Updates the given quaternion with the given rotation matrix values
  3111. * @param matrix defines the source matrix
  3112. * @param result defines the target quaternion
  3113. */
  3114. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3115. /**
  3116. * Returns the dot product (float) between the quaternions "left" and "right"
  3117. * @param left defines the left operand
  3118. * @param right defines the right operand
  3119. * @returns the dot product
  3120. */
  3121. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3122. /**
  3123. * Checks if the two quaternions are close to each other
  3124. * @param quat0 defines the first quaternion to check
  3125. * @param quat1 defines the second quaternion to check
  3126. * @returns true if the two quaternions are close to each other
  3127. */
  3128. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3129. /**
  3130. * Creates an empty quaternion
  3131. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3132. */
  3133. static Zero(): Quaternion;
  3134. /**
  3135. * Inverse a given quaternion
  3136. * @param q defines the source quaternion
  3137. * @returns a new quaternion as the inverted current quaternion
  3138. */
  3139. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3140. /**
  3141. * Inverse a given quaternion
  3142. * @param q defines the source quaternion
  3143. * @param result the quaternion the result will be stored in
  3144. * @returns the result quaternion
  3145. */
  3146. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3147. /**
  3148. * Creates an identity quaternion
  3149. * @returns the identity quaternion
  3150. */
  3151. static Identity(): Quaternion;
  3152. /**
  3153. * Gets a boolean indicating if the given quaternion is identity
  3154. * @param quaternion defines the quaternion to check
  3155. * @returns true if the quaternion is identity
  3156. */
  3157. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3158. /**
  3159. * Creates a quaternion from a rotation around an axis
  3160. * @param axis defines the axis to use
  3161. * @param angle defines the angle to use
  3162. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3163. */
  3164. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3165. /**
  3166. * Creates a rotation around an axis and stores it into the given quaternion
  3167. * @param axis defines the axis to use
  3168. * @param angle defines the angle to use
  3169. * @param result defines the target quaternion
  3170. * @returns the target quaternion
  3171. */
  3172. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3173. /**
  3174. * Creates a new quaternion from data stored into an array
  3175. * @param array defines the data source
  3176. * @param offset defines the offset in the source array where the data starts
  3177. * @returns a new quaternion
  3178. */
  3179. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3180. /**
  3181. * Create a quaternion from Euler rotation angles
  3182. * @param x Pitch
  3183. * @param y Yaw
  3184. * @param z Roll
  3185. * @returns the new Quaternion
  3186. */
  3187. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3188. /**
  3189. * Updates a quaternion from Euler rotation angles
  3190. * @param x Pitch
  3191. * @param y Yaw
  3192. * @param z Roll
  3193. * @param result the quaternion to store the result
  3194. * @returns the updated quaternion
  3195. */
  3196. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3197. /**
  3198. * Create a quaternion from Euler rotation vector
  3199. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3200. * @returns the new Quaternion
  3201. */
  3202. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3203. /**
  3204. * Updates a quaternion from Euler rotation vector
  3205. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3206. * @param result the quaternion to store the result
  3207. * @returns the updated quaternion
  3208. */
  3209. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3210. /**
  3211. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3212. * @param yaw defines the rotation around Y axis
  3213. * @param pitch defines the rotation around X axis
  3214. * @param roll defines the rotation around Z axis
  3215. * @returns the new quaternion
  3216. */
  3217. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3218. /**
  3219. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3220. * @param yaw defines the rotation around Y axis
  3221. * @param pitch defines the rotation around X axis
  3222. * @param roll defines the rotation around Z axis
  3223. * @param result defines the target quaternion
  3224. */
  3225. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3226. /**
  3227. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3228. * @param alpha defines the rotation around first axis
  3229. * @param beta defines the rotation around second axis
  3230. * @param gamma defines the rotation around third axis
  3231. * @returns the new quaternion
  3232. */
  3233. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3234. /**
  3235. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3236. * @param alpha defines the rotation around first axis
  3237. * @param beta defines the rotation around second axis
  3238. * @param gamma defines the rotation around third axis
  3239. * @param result defines the target quaternion
  3240. */
  3241. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3242. /**
  3243. * 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)
  3244. * @param axis1 defines the first axis
  3245. * @param axis2 defines the second axis
  3246. * @param axis3 defines the third axis
  3247. * @returns the new quaternion
  3248. */
  3249. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3250. /**
  3251. * 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
  3252. * @param axis1 defines the first axis
  3253. * @param axis2 defines the second axis
  3254. * @param axis3 defines the third axis
  3255. * @param ref defines the target quaternion
  3256. */
  3257. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3258. /**
  3259. * Interpolates between two quaternions
  3260. * @param left defines first quaternion
  3261. * @param right defines second quaternion
  3262. * @param amount defines the gradient to use
  3263. * @returns the new interpolated quaternion
  3264. */
  3265. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3266. /**
  3267. * Interpolates between two quaternions and stores it into a target quaternion
  3268. * @param left defines first quaternion
  3269. * @param right defines second quaternion
  3270. * @param amount defines the gradient to use
  3271. * @param result defines the target quaternion
  3272. */
  3273. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3274. /**
  3275. * Interpolate between two quaternions using Hermite interpolation
  3276. * @param value1 defines first quaternion
  3277. * @param tangent1 defines the incoming tangent
  3278. * @param value2 defines second quaternion
  3279. * @param tangent2 defines the outgoing tangent
  3280. * @param amount defines the target quaternion
  3281. * @returns the new interpolated quaternion
  3282. */
  3283. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3284. }
  3285. /**
  3286. * Class used to store matrix data (4x4)
  3287. */
  3288. export class Matrix {
  3289. private static _updateFlagSeed;
  3290. private static _identityReadOnly;
  3291. private _isIdentity;
  3292. private _isIdentityDirty;
  3293. private _isIdentity3x2;
  3294. private _isIdentity3x2Dirty;
  3295. /**
  3296. * Gets the update flag of the matrix which is an unique number for the matrix.
  3297. * It will be incremented every time the matrix data change.
  3298. * You can use it to speed the comparison between two versions of the same matrix.
  3299. */
  3300. updateFlag: number;
  3301. private readonly _m;
  3302. /**
  3303. * Gets the internal data of the matrix
  3304. */
  3305. readonly m: DeepImmutable<Float32Array>;
  3306. /** @hidden */
  3307. _markAsUpdated(): void;
  3308. /** @hidden */
  3309. private _updateIdentityStatus;
  3310. /**
  3311. * Creates an empty matrix (filled with zeros)
  3312. */
  3313. constructor();
  3314. /**
  3315. * Check if the current matrix is identity
  3316. * @returns true is the matrix is the identity matrix
  3317. */
  3318. isIdentity(): boolean;
  3319. /**
  3320. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3321. * @returns true is the matrix is the identity matrix
  3322. */
  3323. isIdentityAs3x2(): boolean;
  3324. /**
  3325. * Gets the determinant of the matrix
  3326. * @returns the matrix determinant
  3327. */
  3328. determinant(): number;
  3329. /**
  3330. * Returns the matrix as a Float32Array
  3331. * @returns the matrix underlying array
  3332. */
  3333. toArray(): DeepImmutable<Float32Array>;
  3334. /**
  3335. * Returns the matrix as a Float32Array
  3336. * @returns the matrix underlying array.
  3337. */
  3338. asArray(): DeepImmutable<Float32Array>;
  3339. /**
  3340. * Inverts the current matrix in place
  3341. * @returns the current inverted matrix
  3342. */
  3343. invert(): Matrix;
  3344. /**
  3345. * Sets all the matrix elements to zero
  3346. * @returns the current matrix
  3347. */
  3348. reset(): Matrix;
  3349. /**
  3350. * Adds the current matrix with a second one
  3351. * @param other defines the matrix to add
  3352. * @returns a new matrix as the addition of the current matrix and the given one
  3353. */
  3354. add(other: DeepImmutable<Matrix>): Matrix;
  3355. /**
  3356. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3357. * @param other defines the matrix to add
  3358. * @param result defines the target matrix
  3359. * @returns the current matrix
  3360. */
  3361. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3362. /**
  3363. * Adds in place the given matrix to the current matrix
  3364. * @param other defines the second operand
  3365. * @returns the current updated matrix
  3366. */
  3367. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3368. /**
  3369. * Sets the given matrix to the current inverted Matrix
  3370. * @param other defines the target matrix
  3371. * @returns the unmodified current matrix
  3372. */
  3373. invertToRef(other: Matrix): Matrix;
  3374. /**
  3375. * add a value at the specified position in the current Matrix
  3376. * @param index the index of the value within the matrix. between 0 and 15.
  3377. * @param value the value to be added
  3378. * @returns the current updated matrix
  3379. */
  3380. addAtIndex(index: number, value: number): Matrix;
  3381. /**
  3382. * mutiply the specified position in the current Matrix by a value
  3383. * @param index the index of the value within the matrix. between 0 and 15.
  3384. * @param value the value to be added
  3385. * @returns the current updated matrix
  3386. */
  3387. multiplyAtIndex(index: number, value: number): Matrix;
  3388. /**
  3389. * Inserts the translation vector (using 3 floats) in the current matrix
  3390. * @param x defines the 1st component of the translation
  3391. * @param y defines the 2nd component of the translation
  3392. * @param z defines the 3rd component of the translation
  3393. * @returns the current updated matrix
  3394. */
  3395. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3396. /**
  3397. * Adds the translation vector (using 3 floats) in the current matrix
  3398. * @param x defines the 1st component of the translation
  3399. * @param y defines the 2nd component of the translation
  3400. * @param z defines the 3rd component of the translation
  3401. * @returns the current updated matrix
  3402. */
  3403. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3404. /**
  3405. * Inserts the translation vector in the current matrix
  3406. * @param vector3 defines the translation to insert
  3407. * @returns the current updated matrix
  3408. */
  3409. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3410. /**
  3411. * Gets the translation value of the current matrix
  3412. * @returns a new Vector3 as the extracted translation from the matrix
  3413. */
  3414. getTranslation(): Vector3;
  3415. /**
  3416. * Fill a Vector3 with the extracted translation from the matrix
  3417. * @param result defines the Vector3 where to store the translation
  3418. * @returns the current matrix
  3419. */
  3420. getTranslationToRef(result: Vector3): Matrix;
  3421. /**
  3422. * Remove rotation and scaling part from the matrix
  3423. * @returns the updated matrix
  3424. */
  3425. removeRotationAndScaling(): Matrix;
  3426. /**
  3427. * Multiply two matrices
  3428. * @param other defines the second operand
  3429. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3430. */
  3431. multiply(other: DeepImmutable<Matrix>): Matrix;
  3432. /**
  3433. * Copy the current matrix from the given one
  3434. * @param other defines the source matrix
  3435. * @returns the current updated matrix
  3436. */
  3437. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3438. /**
  3439. * Populates the given array from the starting index with the current matrix values
  3440. * @param array defines the target array
  3441. * @param offset defines the offset in the target array where to start storing values
  3442. * @returns the current matrix
  3443. */
  3444. copyToArray(array: Float32Array, offset?: number): Matrix;
  3445. /**
  3446. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3447. * @param other defines the second operand
  3448. * @param result defines the matrix where to store the multiplication
  3449. * @returns the current matrix
  3450. */
  3451. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3452. /**
  3453. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3454. * @param other defines the second operand
  3455. * @param result defines the array where to store the multiplication
  3456. * @param offset defines the offset in the target array where to start storing values
  3457. * @returns the current matrix
  3458. */
  3459. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3460. /**
  3461. * Check equality between this matrix and a second one
  3462. * @param value defines the second matrix to compare
  3463. * @returns true is the current matrix and the given one values are strictly equal
  3464. */
  3465. equals(value: DeepImmutable<Matrix>): boolean;
  3466. /**
  3467. * Clone the current matrix
  3468. * @returns a new matrix from the current matrix
  3469. */
  3470. clone(): Matrix;
  3471. /**
  3472. * Returns the name of the current matrix class
  3473. * @returns the string "Matrix"
  3474. */
  3475. getClassName(): string;
  3476. /**
  3477. * Gets the hash code of the current matrix
  3478. * @returns the hash code
  3479. */
  3480. getHashCode(): number;
  3481. /**
  3482. * Decomposes the current Matrix into a translation, rotation and scaling components
  3483. * @param scale defines the scale vector3 given as a reference to update
  3484. * @param rotation defines the rotation quaternion given as a reference to update
  3485. * @param translation defines the translation vector3 given as a reference to update
  3486. * @returns true if operation was successful
  3487. */
  3488. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3489. /**
  3490. * Gets specific row of the matrix
  3491. * @param index defines the number of the row to get
  3492. * @returns the index-th row of the current matrix as a new Vector4
  3493. */
  3494. getRow(index: number): Nullable<Vector4>;
  3495. /**
  3496. * Sets the index-th row of the current matrix to the vector4 values
  3497. * @param index defines the number of the row to set
  3498. * @param row defines the target vector4
  3499. * @returns the updated current matrix
  3500. */
  3501. setRow(index: number, row: Vector4): Matrix;
  3502. /**
  3503. * Compute the transpose of the matrix
  3504. * @returns the new transposed matrix
  3505. */
  3506. transpose(): Matrix;
  3507. /**
  3508. * Compute the transpose of the matrix and store it in a given matrix
  3509. * @param result defines the target matrix
  3510. * @returns the current matrix
  3511. */
  3512. transposeToRef(result: Matrix): Matrix;
  3513. /**
  3514. * Sets the index-th row of the current matrix with the given 4 x float values
  3515. * @param index defines the row index
  3516. * @param x defines the x component to set
  3517. * @param y defines the y component to set
  3518. * @param z defines the z component to set
  3519. * @param w defines the w component to set
  3520. * @returns the updated current matrix
  3521. */
  3522. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3523. /**
  3524. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3525. * @param scale defines the scale factor
  3526. * @returns a new matrix
  3527. */
  3528. scale(scale: number): Matrix;
  3529. /**
  3530. * Scale the current matrix values by a factor to a given result matrix
  3531. * @param scale defines the scale factor
  3532. * @param result defines the matrix to store the result
  3533. * @returns the current matrix
  3534. */
  3535. scaleToRef(scale: number, result: Matrix): Matrix;
  3536. /**
  3537. * Scale the current matrix values by a factor and add the result to a given matrix
  3538. * @param scale defines the scale factor
  3539. * @param result defines the Matrix to store the result
  3540. * @returns the current matrix
  3541. */
  3542. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3543. /**
  3544. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3545. * @param ref matrix to store the result
  3546. */
  3547. toNormalMatrix(ref: Matrix): void;
  3548. /**
  3549. * Gets only rotation part of the current matrix
  3550. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3551. */
  3552. getRotationMatrix(): Matrix;
  3553. /**
  3554. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3555. * @param result defines the target matrix to store data to
  3556. * @returns the current matrix
  3557. */
  3558. getRotationMatrixToRef(result: Matrix): Matrix;
  3559. /**
  3560. * Toggles model matrix from being right handed to left handed in place and vice versa
  3561. */
  3562. toggleModelMatrixHandInPlace(): void;
  3563. /**
  3564. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3565. */
  3566. toggleProjectionMatrixHandInPlace(): void;
  3567. /**
  3568. * Creates a matrix from an array
  3569. * @param array defines the source array
  3570. * @param offset defines an offset in the source array
  3571. * @returns a new Matrix set from the starting index of the given array
  3572. */
  3573. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3574. /**
  3575. * Copy the content of an array into a given matrix
  3576. * @param array defines the source array
  3577. * @param offset defines an offset in the source array
  3578. * @param result defines the target matrix
  3579. */
  3580. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3581. /**
  3582. * Stores an array into a matrix after having multiplied each component by a given factor
  3583. * @param array defines the source array
  3584. * @param offset defines the offset in the source array
  3585. * @param scale defines the scaling factor
  3586. * @param result defines the target matrix
  3587. */
  3588. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3589. /**
  3590. * Gets an identity matrix that must not be updated
  3591. */
  3592. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3593. /**
  3594. * Stores a list of values (16) inside a given matrix
  3595. * @param initialM11 defines 1st value of 1st row
  3596. * @param initialM12 defines 2nd value of 1st row
  3597. * @param initialM13 defines 3rd value of 1st row
  3598. * @param initialM14 defines 4th value of 1st row
  3599. * @param initialM21 defines 1st value of 2nd row
  3600. * @param initialM22 defines 2nd value of 2nd row
  3601. * @param initialM23 defines 3rd value of 2nd row
  3602. * @param initialM24 defines 4th value of 2nd row
  3603. * @param initialM31 defines 1st value of 3rd row
  3604. * @param initialM32 defines 2nd value of 3rd row
  3605. * @param initialM33 defines 3rd value of 3rd row
  3606. * @param initialM34 defines 4th value of 3rd row
  3607. * @param initialM41 defines 1st value of 4th row
  3608. * @param initialM42 defines 2nd value of 4th row
  3609. * @param initialM43 defines 3rd value of 4th row
  3610. * @param initialM44 defines 4th value of 4th row
  3611. * @param result defines the target matrix
  3612. */
  3613. 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;
  3614. /**
  3615. * Creates new matrix from a list of values (16)
  3616. * @param initialM11 defines 1st value of 1st row
  3617. * @param initialM12 defines 2nd value of 1st row
  3618. * @param initialM13 defines 3rd value of 1st row
  3619. * @param initialM14 defines 4th value of 1st row
  3620. * @param initialM21 defines 1st value of 2nd row
  3621. * @param initialM22 defines 2nd value of 2nd row
  3622. * @param initialM23 defines 3rd value of 2nd row
  3623. * @param initialM24 defines 4th value of 2nd row
  3624. * @param initialM31 defines 1st value of 3rd row
  3625. * @param initialM32 defines 2nd value of 3rd row
  3626. * @param initialM33 defines 3rd value of 3rd row
  3627. * @param initialM34 defines 4th value of 3rd row
  3628. * @param initialM41 defines 1st value of 4th row
  3629. * @param initialM42 defines 2nd value of 4th row
  3630. * @param initialM43 defines 3rd value of 4th row
  3631. * @param initialM44 defines 4th value of 4th row
  3632. * @returns the new matrix
  3633. */
  3634. 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;
  3635. /**
  3636. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3637. * @param scale defines the scale vector3
  3638. * @param rotation defines the rotation quaternion
  3639. * @param translation defines the translation vector3
  3640. * @returns a new matrix
  3641. */
  3642. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3643. /**
  3644. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3645. * @param scale defines the scale vector3
  3646. * @param rotation defines the rotation quaternion
  3647. * @param translation defines the translation vector3
  3648. * @param result defines the target matrix
  3649. */
  3650. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3651. /**
  3652. * Creates a new identity matrix
  3653. * @returns a new identity matrix
  3654. */
  3655. static Identity(): Matrix;
  3656. /**
  3657. * Creates a new identity matrix and stores the result in a given matrix
  3658. * @param result defines the target matrix
  3659. */
  3660. static IdentityToRef(result: Matrix): void;
  3661. /**
  3662. * Creates a new zero matrix
  3663. * @returns a new zero matrix
  3664. */
  3665. static Zero(): Matrix;
  3666. /**
  3667. * Creates a new rotation matrix for "angle" radians around the X axis
  3668. * @param angle defines the angle (in radians) to use
  3669. * @return the new matrix
  3670. */
  3671. static RotationX(angle: number): Matrix;
  3672. /**
  3673. * Creates a new matrix as the invert of a given matrix
  3674. * @param source defines the source matrix
  3675. * @returns the new matrix
  3676. */
  3677. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3678. /**
  3679. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3680. * @param angle defines the angle (in radians) to use
  3681. * @param result defines the target matrix
  3682. */
  3683. static RotationXToRef(angle: number, result: Matrix): void;
  3684. /**
  3685. * Creates a new rotation matrix for "angle" radians around the Y axis
  3686. * @param angle defines the angle (in radians) to use
  3687. * @return the new matrix
  3688. */
  3689. static RotationY(angle: number): Matrix;
  3690. /**
  3691. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3692. * @param angle defines the angle (in radians) to use
  3693. * @param result defines the target matrix
  3694. */
  3695. static RotationYToRef(angle: number, result: Matrix): void;
  3696. /**
  3697. * Creates a new rotation matrix for "angle" radians around the Z axis
  3698. * @param angle defines the angle (in radians) to use
  3699. * @return the new matrix
  3700. */
  3701. static RotationZ(angle: number): Matrix;
  3702. /**
  3703. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3704. * @param angle defines the angle (in radians) to use
  3705. * @param result defines the target matrix
  3706. */
  3707. static RotationZToRef(angle: number, result: Matrix): void;
  3708. /**
  3709. * Creates a new rotation matrix for "angle" radians around the given axis
  3710. * @param axis defines the axis to use
  3711. * @param angle defines the angle (in radians) to use
  3712. * @return the new matrix
  3713. */
  3714. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3715. /**
  3716. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3717. * @param axis defines the axis to use
  3718. * @param angle defines the angle (in radians) to use
  3719. * @param result defines the target matrix
  3720. */
  3721. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3722. /**
  3723. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3724. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3725. * @param from defines the vector to align
  3726. * @param to defines the vector to align to
  3727. * @param result defines the target matrix
  3728. */
  3729. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3730. /**
  3731. * Creates a rotation matrix
  3732. * @param yaw defines the yaw angle in radians (Y axis)
  3733. * @param pitch defines the pitch angle in radians (X axis)
  3734. * @param roll defines the roll angle in radians (X axis)
  3735. * @returns the new rotation matrix
  3736. */
  3737. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3738. /**
  3739. * Creates a rotation matrix and stores it in a given matrix
  3740. * @param yaw defines the yaw angle in radians (Y axis)
  3741. * @param pitch defines the pitch angle in radians (X axis)
  3742. * @param roll defines the roll angle in radians (X axis)
  3743. * @param result defines the target matrix
  3744. */
  3745. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3746. /**
  3747. * Creates a scaling matrix
  3748. * @param x defines the scale factor on X axis
  3749. * @param y defines the scale factor on Y axis
  3750. * @param z defines the scale factor on Z axis
  3751. * @returns the new matrix
  3752. */
  3753. static Scaling(x: number, y: number, z: number): Matrix;
  3754. /**
  3755. * Creates a scaling matrix and stores it in a given matrix
  3756. * @param x defines the scale factor on X axis
  3757. * @param y defines the scale factor on Y axis
  3758. * @param z defines the scale factor on Z axis
  3759. * @param result defines the target matrix
  3760. */
  3761. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3762. /**
  3763. * Creates a translation matrix
  3764. * @param x defines the translation on X axis
  3765. * @param y defines the translation on Y axis
  3766. * @param z defines the translationon Z axis
  3767. * @returns the new matrix
  3768. */
  3769. static Translation(x: number, y: number, z: number): Matrix;
  3770. /**
  3771. * Creates a translation matrix and stores it in a given matrix
  3772. * @param x defines the translation on X axis
  3773. * @param y defines the translation on Y axis
  3774. * @param z defines the translationon Z axis
  3775. * @param result defines the target matrix
  3776. */
  3777. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3778. /**
  3779. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3780. * @param startValue defines the start value
  3781. * @param endValue defines the end value
  3782. * @param gradient defines the gradient factor
  3783. * @returns the new matrix
  3784. */
  3785. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3786. /**
  3787. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3788. * @param startValue defines the start value
  3789. * @param endValue defines the end value
  3790. * @param gradient defines the gradient factor
  3791. * @param result defines the Matrix object where to store data
  3792. */
  3793. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3794. /**
  3795. * Builds a new matrix whose values are computed by:
  3796. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3797. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3798. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3799. * @param startValue defines the first matrix
  3800. * @param endValue defines the second matrix
  3801. * @param gradient defines the gradient between the two matrices
  3802. * @returns the new matrix
  3803. */
  3804. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3805. /**
  3806. * Update a matrix to values which are computed by:
  3807. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3808. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3809. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3810. * @param startValue defines the first matrix
  3811. * @param endValue defines the second matrix
  3812. * @param gradient defines the gradient between the two matrices
  3813. * @param result defines the target matrix
  3814. */
  3815. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3816. /**
  3817. * 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"
  3818. * This function works in left handed mode
  3819. * @param eye defines the final position of the entity
  3820. * @param target defines where the entity should look at
  3821. * @param up defines the up vector for the entity
  3822. * @returns the new matrix
  3823. */
  3824. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3825. /**
  3826. * 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".
  3827. * This function works in left handed mode
  3828. * @param eye defines the final position of the entity
  3829. * @param target defines where the entity should look at
  3830. * @param up defines the up vector for the entity
  3831. * @param result defines the target matrix
  3832. */
  3833. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3834. /**
  3835. * 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"
  3836. * This function works in right handed mode
  3837. * @param eye defines the final position of the entity
  3838. * @param target defines where the entity should look at
  3839. * @param up defines the up vector for the entity
  3840. * @returns the new matrix
  3841. */
  3842. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3843. /**
  3844. * 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".
  3845. * This function works in right handed mode
  3846. * @param eye defines the final position of the entity
  3847. * @param target defines where the entity should look at
  3848. * @param up defines the up vector for the entity
  3849. * @param result defines the target matrix
  3850. */
  3851. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3852. /**
  3853. * Create a left-handed orthographic projection matrix
  3854. * @param width defines the viewport width
  3855. * @param height defines the viewport height
  3856. * @param znear defines the near clip plane
  3857. * @param zfar defines the far clip plane
  3858. * @returns a new matrix as a left-handed orthographic projection matrix
  3859. */
  3860. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3861. /**
  3862. * Store a left-handed orthographic projection to a given matrix
  3863. * @param width defines the viewport width
  3864. * @param height defines the viewport height
  3865. * @param znear defines the near clip plane
  3866. * @param zfar defines the far clip plane
  3867. * @param result defines the target matrix
  3868. */
  3869. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3870. /**
  3871. * Create a left-handed orthographic projection matrix
  3872. * @param left defines the viewport left coordinate
  3873. * @param right defines the viewport right coordinate
  3874. * @param bottom defines the viewport bottom coordinate
  3875. * @param top defines the viewport top coordinate
  3876. * @param znear defines the near clip plane
  3877. * @param zfar defines the far clip plane
  3878. * @returns a new matrix as a left-handed orthographic projection matrix
  3879. */
  3880. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3881. /**
  3882. * Stores a left-handed orthographic projection into a given matrix
  3883. * @param left defines the viewport left coordinate
  3884. * @param right defines the viewport right coordinate
  3885. * @param bottom defines the viewport bottom coordinate
  3886. * @param top defines the viewport top coordinate
  3887. * @param znear defines the near clip plane
  3888. * @param zfar defines the far clip plane
  3889. * @param result defines the target matrix
  3890. */
  3891. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3892. /**
  3893. * Creates a right-handed orthographic projection matrix
  3894. * @param left defines the viewport left coordinate
  3895. * @param right defines the viewport right coordinate
  3896. * @param bottom defines the viewport bottom coordinate
  3897. * @param top defines the viewport top coordinate
  3898. * @param znear defines the near clip plane
  3899. * @param zfar defines the far clip plane
  3900. * @returns a new matrix as a right-handed orthographic projection matrix
  3901. */
  3902. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3903. /**
  3904. * Stores a right-handed orthographic projection into a given matrix
  3905. * @param left defines the viewport left coordinate
  3906. * @param right defines the viewport right coordinate
  3907. * @param bottom defines the viewport bottom coordinate
  3908. * @param top defines the viewport top coordinate
  3909. * @param znear defines the near clip plane
  3910. * @param zfar defines the far clip plane
  3911. * @param result defines the target matrix
  3912. */
  3913. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3914. /**
  3915. * Creates a left-handed perspective projection matrix
  3916. * @param width defines the viewport width
  3917. * @param height defines the viewport height
  3918. * @param znear defines the near clip plane
  3919. * @param zfar defines the far clip plane
  3920. * @returns a new matrix as a left-handed perspective projection matrix
  3921. */
  3922. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3923. /**
  3924. * Creates a left-handed perspective projection matrix
  3925. * @param fov defines the horizontal field of view
  3926. * @param aspect defines the aspect ratio
  3927. * @param znear defines the near clip plane
  3928. * @param zfar defines the far clip plane
  3929. * @returns a new matrix as a left-handed perspective projection matrix
  3930. */
  3931. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3932. /**
  3933. * Stores a left-handed perspective projection into a given matrix
  3934. * @param fov defines the horizontal field of view
  3935. * @param aspect defines the aspect ratio
  3936. * @param znear defines the near clip plane
  3937. * @param zfar defines the far clip plane
  3938. * @param result defines the target matrix
  3939. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3940. */
  3941. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3942. /**
  3943. * Creates a right-handed perspective projection matrix
  3944. * @param fov defines the horizontal field of view
  3945. * @param aspect defines the aspect ratio
  3946. * @param znear defines the near clip plane
  3947. * @param zfar defines the far clip plane
  3948. * @returns a new matrix as a right-handed perspective projection matrix
  3949. */
  3950. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3951. /**
  3952. * Stores a right-handed perspective projection into a given matrix
  3953. * @param fov defines the horizontal field of view
  3954. * @param aspect defines the aspect ratio
  3955. * @param znear defines the near clip plane
  3956. * @param zfar defines the far clip plane
  3957. * @param result defines the target matrix
  3958. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3959. */
  3960. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3961. /**
  3962. * Stores a perspective projection for WebVR info a given matrix
  3963. * @param fov defines the field of view
  3964. * @param znear defines the near clip plane
  3965. * @param zfar defines the far clip plane
  3966. * @param result defines the target matrix
  3967. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3968. */
  3969. static PerspectiveFovWebVRToRef(fov: {
  3970. upDegrees: number;
  3971. downDegrees: number;
  3972. leftDegrees: number;
  3973. rightDegrees: number;
  3974. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3975. /**
  3976. * Computes a complete transformation matrix
  3977. * @param viewport defines the viewport to use
  3978. * @param world defines the world matrix
  3979. * @param view defines the view matrix
  3980. * @param projection defines the projection matrix
  3981. * @param zmin defines the near clip plane
  3982. * @param zmax defines the far clip plane
  3983. * @returns the transformation matrix
  3984. */
  3985. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3986. /**
  3987. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3988. * @param matrix defines the matrix to use
  3989. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3990. */
  3991. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3992. /**
  3993. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3994. * @param matrix defines the matrix to use
  3995. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3996. */
  3997. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3998. /**
  3999. * Compute the transpose of a given matrix
  4000. * @param matrix defines the matrix to transpose
  4001. * @returns the new matrix
  4002. */
  4003. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4004. /**
  4005. * Compute the transpose of a matrix and store it in a target matrix
  4006. * @param matrix defines the matrix to transpose
  4007. * @param result defines the target matrix
  4008. */
  4009. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4010. /**
  4011. * Computes a reflection matrix from a plane
  4012. * @param plane defines the reflection plane
  4013. * @returns a new matrix
  4014. */
  4015. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4016. /**
  4017. * Computes a reflection matrix from a plane
  4018. * @param plane defines the reflection plane
  4019. * @param result defines the target matrix
  4020. */
  4021. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4022. /**
  4023. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4024. * @param xaxis defines the value of the 1st axis
  4025. * @param yaxis defines the value of the 2nd axis
  4026. * @param zaxis defines the value of the 3rd axis
  4027. * @param result defines the target matrix
  4028. */
  4029. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4030. /**
  4031. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4032. * @param quat defines the quaternion to use
  4033. * @param result defines the target matrix
  4034. */
  4035. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4036. }
  4037. /**
  4038. * @hidden
  4039. */
  4040. export class TmpVectors {
  4041. static Vector2: Vector2[];
  4042. static Vector3: Vector3[];
  4043. static Vector4: Vector4[];
  4044. static Quaternion: Quaternion[];
  4045. static Matrix: Matrix[];
  4046. }
  4047. }
  4048. declare module "babylonjs/Engines/constants" {
  4049. /** Defines the cross module used constants to avoid circular dependncies */
  4050. export class Constants {
  4051. /** Defines that alpha blending is disabled */
  4052. static readonly ALPHA_DISABLE: number;
  4053. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4054. static readonly ALPHA_ADD: number;
  4055. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4056. static readonly ALPHA_COMBINE: number;
  4057. /** Defines that alpha blending to DEST - SRC * DEST */
  4058. static readonly ALPHA_SUBTRACT: number;
  4059. /** Defines that alpha blending to SRC * DEST */
  4060. static readonly ALPHA_MULTIPLY: number;
  4061. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4062. static readonly ALPHA_MAXIMIZED: number;
  4063. /** Defines that alpha blending to SRC + DEST */
  4064. static readonly ALPHA_ONEONE: number;
  4065. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4066. static readonly ALPHA_PREMULTIPLIED: number;
  4067. /**
  4068. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4069. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4070. */
  4071. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4072. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4073. static readonly ALPHA_INTERPOLATE: number;
  4074. /**
  4075. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4076. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4077. */
  4078. static readonly ALPHA_SCREENMODE: number;
  4079. /** Defines that the ressource is not delayed*/
  4080. static readonly DELAYLOADSTATE_NONE: number;
  4081. /** Defines that the ressource was successfully delay loaded */
  4082. static readonly DELAYLOADSTATE_LOADED: number;
  4083. /** Defines that the ressource is currently delay loading */
  4084. static readonly DELAYLOADSTATE_LOADING: number;
  4085. /** Defines that the ressource is delayed and has not started loading */
  4086. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4087. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4088. static readonly NEVER: number;
  4089. /** 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 */
  4090. static readonly ALWAYS: number;
  4091. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4092. static readonly LESS: number;
  4093. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4094. static readonly EQUAL: number;
  4095. /** 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 */
  4096. static readonly LEQUAL: number;
  4097. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4098. static readonly GREATER: number;
  4099. /** 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 */
  4100. static readonly GEQUAL: number;
  4101. /** 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 */
  4102. static readonly NOTEQUAL: number;
  4103. /** Passed to stencilOperation to specify that stencil value must be kept */
  4104. static readonly KEEP: number;
  4105. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4106. static readonly REPLACE: number;
  4107. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4108. static readonly INCR: number;
  4109. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4110. static readonly DECR: number;
  4111. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4112. static readonly INVERT: number;
  4113. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4114. static readonly INCR_WRAP: number;
  4115. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4116. static readonly DECR_WRAP: number;
  4117. /** Texture is not repeating outside of 0..1 UVs */
  4118. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4119. /** Texture is repeating outside of 0..1 UVs */
  4120. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4121. /** Texture is repeating and mirrored */
  4122. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4123. /** ALPHA */
  4124. static readonly TEXTUREFORMAT_ALPHA: number;
  4125. /** LUMINANCE */
  4126. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4127. /** LUMINANCE_ALPHA */
  4128. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4129. /** RGB */
  4130. static readonly TEXTUREFORMAT_RGB: number;
  4131. /** RGBA */
  4132. static readonly TEXTUREFORMAT_RGBA: number;
  4133. /** RED */
  4134. static readonly TEXTUREFORMAT_RED: number;
  4135. /** RED (2nd reference) */
  4136. static readonly TEXTUREFORMAT_R: number;
  4137. /** RG */
  4138. static readonly TEXTUREFORMAT_RG: number;
  4139. /** RED_INTEGER */
  4140. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4141. /** RED_INTEGER (2nd reference) */
  4142. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4143. /** RG_INTEGER */
  4144. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4145. /** RGB_INTEGER */
  4146. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4147. /** RGBA_INTEGER */
  4148. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4149. /** UNSIGNED_BYTE */
  4150. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4151. /** UNSIGNED_BYTE (2nd reference) */
  4152. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4153. /** FLOAT */
  4154. static readonly TEXTURETYPE_FLOAT: number;
  4155. /** HALF_FLOAT */
  4156. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4157. /** BYTE */
  4158. static readonly TEXTURETYPE_BYTE: number;
  4159. /** SHORT */
  4160. static readonly TEXTURETYPE_SHORT: number;
  4161. /** UNSIGNED_SHORT */
  4162. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4163. /** INT */
  4164. static readonly TEXTURETYPE_INT: number;
  4165. /** UNSIGNED_INT */
  4166. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4167. /** UNSIGNED_SHORT_4_4_4_4 */
  4168. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4169. /** UNSIGNED_SHORT_5_5_5_1 */
  4170. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4171. /** UNSIGNED_SHORT_5_6_5 */
  4172. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4173. /** UNSIGNED_INT_2_10_10_10_REV */
  4174. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4175. /** UNSIGNED_INT_24_8 */
  4176. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4177. /** UNSIGNED_INT_10F_11F_11F_REV */
  4178. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4179. /** UNSIGNED_INT_5_9_9_9_REV */
  4180. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4181. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4182. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4183. /** nearest is mag = nearest and min = nearest and mip = linear */
  4184. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4185. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4186. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4187. /** Trilinear is mag = linear and min = linear and mip = linear */
  4188. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4189. /** nearest is mag = nearest and min = nearest and mip = linear */
  4190. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4191. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4192. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4193. /** Trilinear is mag = linear and min = linear and mip = linear */
  4194. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4195. /** mag = nearest and min = nearest and mip = nearest */
  4196. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4197. /** mag = nearest and min = linear and mip = nearest */
  4198. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4199. /** mag = nearest and min = linear and mip = linear */
  4200. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4201. /** mag = nearest and min = linear and mip = none */
  4202. static readonly TEXTURE_NEAREST_LINEAR: number;
  4203. /** mag = nearest and min = nearest and mip = none */
  4204. static readonly TEXTURE_NEAREST_NEAREST: number;
  4205. /** mag = linear and min = nearest and mip = nearest */
  4206. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4207. /** mag = linear and min = nearest and mip = linear */
  4208. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4209. /** mag = linear and min = linear and mip = none */
  4210. static readonly TEXTURE_LINEAR_LINEAR: number;
  4211. /** mag = linear and min = nearest and mip = none */
  4212. static readonly TEXTURE_LINEAR_NEAREST: number;
  4213. /** Explicit coordinates mode */
  4214. static readonly TEXTURE_EXPLICIT_MODE: number;
  4215. /** Spherical coordinates mode */
  4216. static readonly TEXTURE_SPHERICAL_MODE: number;
  4217. /** Planar coordinates mode */
  4218. static readonly TEXTURE_PLANAR_MODE: number;
  4219. /** Cubic coordinates mode */
  4220. static readonly TEXTURE_CUBIC_MODE: number;
  4221. /** Projection coordinates mode */
  4222. static readonly TEXTURE_PROJECTION_MODE: number;
  4223. /** Skybox coordinates mode */
  4224. static readonly TEXTURE_SKYBOX_MODE: number;
  4225. /** Inverse Cubic coordinates mode */
  4226. static readonly TEXTURE_INVCUBIC_MODE: number;
  4227. /** Equirectangular coordinates mode */
  4228. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4229. /** Equirectangular Fixed coordinates mode */
  4230. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4231. /** Equirectangular Fixed Mirrored coordinates mode */
  4232. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4233. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4234. static readonly SCALEMODE_FLOOR: number;
  4235. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4236. static readonly SCALEMODE_NEAREST: number;
  4237. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4238. static readonly SCALEMODE_CEILING: number;
  4239. /**
  4240. * The dirty texture flag value
  4241. */
  4242. static readonly MATERIAL_TextureDirtyFlag: number;
  4243. /**
  4244. * The dirty light flag value
  4245. */
  4246. static readonly MATERIAL_LightDirtyFlag: number;
  4247. /**
  4248. * The dirty fresnel flag value
  4249. */
  4250. static readonly MATERIAL_FresnelDirtyFlag: number;
  4251. /**
  4252. * The dirty attribute flag value
  4253. */
  4254. static readonly MATERIAL_AttributesDirtyFlag: number;
  4255. /**
  4256. * The dirty misc flag value
  4257. */
  4258. static readonly MATERIAL_MiscDirtyFlag: number;
  4259. /**
  4260. * The all dirty flag value
  4261. */
  4262. static readonly MATERIAL_AllDirtyFlag: number;
  4263. /**
  4264. * Returns the triangle fill mode
  4265. */
  4266. static readonly MATERIAL_TriangleFillMode: number;
  4267. /**
  4268. * Returns the wireframe mode
  4269. */
  4270. static readonly MATERIAL_WireFrameFillMode: number;
  4271. /**
  4272. * Returns the point fill mode
  4273. */
  4274. static readonly MATERIAL_PointFillMode: number;
  4275. /**
  4276. * Returns the point list draw mode
  4277. */
  4278. static readonly MATERIAL_PointListDrawMode: number;
  4279. /**
  4280. * Returns the line list draw mode
  4281. */
  4282. static readonly MATERIAL_LineListDrawMode: number;
  4283. /**
  4284. * Returns the line loop draw mode
  4285. */
  4286. static readonly MATERIAL_LineLoopDrawMode: number;
  4287. /**
  4288. * Returns the line strip draw mode
  4289. */
  4290. static readonly MATERIAL_LineStripDrawMode: number;
  4291. /**
  4292. * Returns the triangle strip draw mode
  4293. */
  4294. static readonly MATERIAL_TriangleStripDrawMode: number;
  4295. /**
  4296. * Returns the triangle fan draw mode
  4297. */
  4298. static readonly MATERIAL_TriangleFanDrawMode: number;
  4299. /**
  4300. * Stores the clock-wise side orientation
  4301. */
  4302. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4303. /**
  4304. * Stores the counter clock-wise side orientation
  4305. */
  4306. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4307. /**
  4308. * Nothing
  4309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4310. */
  4311. static readonly ACTION_NothingTrigger: number;
  4312. /**
  4313. * On pick
  4314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4315. */
  4316. static readonly ACTION_OnPickTrigger: number;
  4317. /**
  4318. * On left pick
  4319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4320. */
  4321. static readonly ACTION_OnLeftPickTrigger: number;
  4322. /**
  4323. * On right pick
  4324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4325. */
  4326. static readonly ACTION_OnRightPickTrigger: number;
  4327. /**
  4328. * On center pick
  4329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4330. */
  4331. static readonly ACTION_OnCenterPickTrigger: number;
  4332. /**
  4333. * On pick down
  4334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4335. */
  4336. static readonly ACTION_OnPickDownTrigger: number;
  4337. /**
  4338. * On double pick
  4339. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4340. */
  4341. static readonly ACTION_OnDoublePickTrigger: number;
  4342. /**
  4343. * On pick up
  4344. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4345. */
  4346. static readonly ACTION_OnPickUpTrigger: number;
  4347. /**
  4348. * On pick out.
  4349. * This trigger will only be raised if you also declared a OnPickDown
  4350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4351. */
  4352. static readonly ACTION_OnPickOutTrigger: number;
  4353. /**
  4354. * On long press
  4355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4356. */
  4357. static readonly ACTION_OnLongPressTrigger: number;
  4358. /**
  4359. * On pointer over
  4360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4361. */
  4362. static readonly ACTION_OnPointerOverTrigger: number;
  4363. /**
  4364. * On pointer out
  4365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4366. */
  4367. static readonly ACTION_OnPointerOutTrigger: number;
  4368. /**
  4369. * On every frame
  4370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4371. */
  4372. static readonly ACTION_OnEveryFrameTrigger: number;
  4373. /**
  4374. * On intersection enter
  4375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4376. */
  4377. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4378. /**
  4379. * On intersection exit
  4380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4381. */
  4382. static readonly ACTION_OnIntersectionExitTrigger: number;
  4383. /**
  4384. * On key down
  4385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4386. */
  4387. static readonly ACTION_OnKeyDownTrigger: number;
  4388. /**
  4389. * On key up
  4390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4391. */
  4392. static readonly ACTION_OnKeyUpTrigger: number;
  4393. /**
  4394. * Billboard mode will only apply to Y axis
  4395. */
  4396. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4397. /**
  4398. * Billboard mode will apply to all axes
  4399. */
  4400. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4401. /**
  4402. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4403. */
  4404. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4405. /**
  4406. * Gets or sets base Assets URL
  4407. */
  4408. static PARTICLES_BaseAssetsUrl: string;
  4409. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4410. * Test order :
  4411. * Is the bounding sphere outside the frustum ?
  4412. * If not, are the bounding box vertices outside the frustum ?
  4413. * It not, then the cullable object is in the frustum.
  4414. */
  4415. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4416. /** Culling strategy : Bounding Sphere Only.
  4417. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4418. * It's also less accurate than the standard because some not visible objects can still be selected.
  4419. * Test : is the bounding sphere outside the frustum ?
  4420. * If not, then the cullable object is in the frustum.
  4421. */
  4422. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4423. /** Culling strategy : Optimistic Inclusion.
  4424. * This in an inclusion test first, then the standard exclusion test.
  4425. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4426. * 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.
  4427. * Anyway, it's as accurate as the standard strategy.
  4428. * Test :
  4429. * Is the cullable object bounding sphere center in the frustum ?
  4430. * If not, apply the default culling strategy.
  4431. */
  4432. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4433. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4434. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4435. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4436. * 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.
  4437. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4438. * Test :
  4439. * Is the cullable object bounding sphere center in the frustum ?
  4440. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4441. */
  4442. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4443. /**
  4444. * No logging while loading
  4445. */
  4446. static readonly SCENELOADER_NO_LOGGING: number;
  4447. /**
  4448. * Minimal logging while loading
  4449. */
  4450. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4451. /**
  4452. * Summary logging while loading
  4453. */
  4454. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4455. /**
  4456. * Detailled logging while loading
  4457. */
  4458. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4459. }
  4460. }
  4461. declare module "babylonjs/Engines/IPipelineContext" {
  4462. /**
  4463. * Class used to store and describe the pipeline context associated with an effect
  4464. */
  4465. export interface IPipelineContext {
  4466. /**
  4467. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4468. */
  4469. isAsync: boolean;
  4470. /**
  4471. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4472. */
  4473. isReady: boolean;
  4474. /** @hidden */
  4475. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4476. }
  4477. }
  4478. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  4479. /** @hidden */
  4480. export interface IShaderProcessor {
  4481. attributeProcessor?: (attribute: string) => string;
  4482. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4483. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4484. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4485. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4486. lineProcessor?: (line: string, isFragment: boolean) => string;
  4487. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4488. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4489. }
  4490. }
  4491. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  4492. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  4493. /** @hidden */
  4494. export interface ProcessingOptions {
  4495. defines: string[];
  4496. indexParameters: any;
  4497. isFragment: boolean;
  4498. shouldUseHighPrecisionShader: boolean;
  4499. supportsUniformBuffers: boolean;
  4500. shadersRepository: string;
  4501. includesShadersStore: {
  4502. [key: string]: string;
  4503. };
  4504. processor?: IShaderProcessor;
  4505. version: string;
  4506. platformName: string;
  4507. lookForClosingBracketForUniformBuffer?: boolean;
  4508. }
  4509. }
  4510. declare module "babylonjs/Misc/stringTools" {
  4511. /**
  4512. * Helper to manipulate strings
  4513. */
  4514. export class StringTools {
  4515. /**
  4516. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4517. * @param str Source string
  4518. * @param suffix Suffix to search for in the source string
  4519. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4520. */
  4521. static EndsWith(str: string, suffix: string): boolean;
  4522. /**
  4523. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4524. * @param str Source string
  4525. * @param suffix Suffix to search for in the source string
  4526. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4527. */
  4528. static StartsWith(str: string, suffix: string): boolean;
  4529. }
  4530. }
  4531. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  4532. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4533. /** @hidden */
  4534. export class ShaderCodeNode {
  4535. line: string;
  4536. children: ShaderCodeNode[];
  4537. additionalDefineKey?: string;
  4538. additionalDefineValue?: string;
  4539. isValid(preprocessors: {
  4540. [key: string]: string;
  4541. }): boolean;
  4542. process(preprocessors: {
  4543. [key: string]: string;
  4544. }, options: ProcessingOptions): string;
  4545. }
  4546. }
  4547. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  4548. /** @hidden */
  4549. export class ShaderCodeCursor {
  4550. private _lines;
  4551. lineIndex: number;
  4552. readonly currentLine: string;
  4553. readonly canRead: boolean;
  4554. lines: string[];
  4555. }
  4556. }
  4557. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  4558. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4559. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4560. /** @hidden */
  4561. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4562. process(preprocessors: {
  4563. [key: string]: string;
  4564. }, options: ProcessingOptions): string;
  4565. }
  4566. }
  4567. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  4568. /** @hidden */
  4569. export class ShaderDefineExpression {
  4570. isTrue(preprocessors: {
  4571. [key: string]: string;
  4572. }): boolean;
  4573. }
  4574. }
  4575. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  4576. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4577. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4578. /** @hidden */
  4579. export class ShaderCodeTestNode extends ShaderCodeNode {
  4580. testExpression: ShaderDefineExpression;
  4581. isValid(preprocessors: {
  4582. [key: string]: string;
  4583. }): boolean;
  4584. }
  4585. }
  4586. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  4587. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4588. /** @hidden */
  4589. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4590. define: string;
  4591. not: boolean;
  4592. constructor(define: string, not?: boolean);
  4593. isTrue(preprocessors: {
  4594. [key: string]: string;
  4595. }): boolean;
  4596. }
  4597. }
  4598. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  4599. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4600. /** @hidden */
  4601. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4602. leftOperand: ShaderDefineExpression;
  4603. rightOperand: ShaderDefineExpression;
  4604. isTrue(preprocessors: {
  4605. [key: string]: string;
  4606. }): boolean;
  4607. }
  4608. }
  4609. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  4610. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4611. /** @hidden */
  4612. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4613. leftOperand: ShaderDefineExpression;
  4614. rightOperand: ShaderDefineExpression;
  4615. isTrue(preprocessors: {
  4616. [key: string]: string;
  4617. }): boolean;
  4618. }
  4619. }
  4620. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  4621. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4622. /** @hidden */
  4623. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4624. define: string;
  4625. operand: string;
  4626. testValue: string;
  4627. constructor(define: string, operand: string, testValue: string);
  4628. isTrue(preprocessors: {
  4629. [key: string]: string;
  4630. }): boolean;
  4631. }
  4632. }
  4633. declare module "babylonjs/Misc/loadFileError" {
  4634. import { WebRequest } from "babylonjs/Misc/webRequest";
  4635. /**
  4636. * @ignore
  4637. * Application error to support additional information when loading a file
  4638. */
  4639. export class LoadFileError extends Error {
  4640. /** defines the optional web request */
  4641. request?: WebRequest | undefined;
  4642. private static _setPrototypeOf;
  4643. /**
  4644. * Creates a new LoadFileError
  4645. * @param message defines the message of the error
  4646. * @param request defines the optional web request
  4647. */
  4648. constructor(message: string,
  4649. /** defines the optional web request */
  4650. request?: WebRequest | undefined);
  4651. }
  4652. }
  4653. declare module "babylonjs/Offline/IOfflineProvider" {
  4654. /**
  4655. * Class used to enable access to offline support
  4656. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4657. */
  4658. export interface IOfflineProvider {
  4659. /**
  4660. * Gets a boolean indicating if scene must be saved in the database
  4661. */
  4662. enableSceneOffline: boolean;
  4663. /**
  4664. * Gets a boolean indicating if textures must be saved in the database
  4665. */
  4666. enableTexturesOffline: boolean;
  4667. /**
  4668. * Open the offline support and make it available
  4669. * @param successCallback defines the callback to call on success
  4670. * @param errorCallback defines the callback to call on error
  4671. */
  4672. open(successCallback: () => void, errorCallback: () => void): void;
  4673. /**
  4674. * Loads an image from the offline support
  4675. * @param url defines the url to load from
  4676. * @param image defines the target DOM image
  4677. */
  4678. loadImage(url: string, image: HTMLImageElement): void;
  4679. /**
  4680. * Loads a file from offline support
  4681. * @param url defines the URL to load from
  4682. * @param sceneLoaded defines a callback to call on success
  4683. * @param progressCallBack defines a callback to call when progress changed
  4684. * @param errorCallback defines a callback to call on error
  4685. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4686. */
  4687. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4688. }
  4689. }
  4690. declare module "babylonjs/Misc/filesInputStore" {
  4691. /**
  4692. * Class used to help managing file picking and drag'n'drop
  4693. * File Storage
  4694. */
  4695. export class FilesInputStore {
  4696. /**
  4697. * List of files ready to be loaded
  4698. */
  4699. static FilesToLoad: {
  4700. [key: string]: File;
  4701. };
  4702. }
  4703. }
  4704. declare module "babylonjs/Misc/retryStrategy" {
  4705. import { WebRequest } from "babylonjs/Misc/webRequest";
  4706. /**
  4707. * Class used to define a retry strategy when error happens while loading assets
  4708. */
  4709. export class RetryStrategy {
  4710. /**
  4711. * Function used to defines an exponential back off strategy
  4712. * @param maxRetries defines the maximum number of retries (3 by default)
  4713. * @param baseInterval defines the interval between retries
  4714. * @returns the strategy function to use
  4715. */
  4716. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4717. }
  4718. }
  4719. declare module "babylonjs/Misc/fileTools" {
  4720. import { WebRequest } from "babylonjs/Misc/webRequest";
  4721. import { Nullable } from "babylonjs/types";
  4722. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  4723. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  4724. /**
  4725. * @hidden
  4726. */
  4727. export class FileTools {
  4728. /**
  4729. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4730. */
  4731. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4732. /**
  4733. * Gets or sets the base URL to use to load assets
  4734. */
  4735. static BaseUrl: string;
  4736. /**
  4737. * Default behaviour for cors in the application.
  4738. * It can be a string if the expected behavior is identical in the entire app.
  4739. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4740. */
  4741. static CorsBehavior: string | ((url: string | string[]) => string);
  4742. /**
  4743. * Gets or sets a function used to pre-process url before using them to load assets
  4744. */
  4745. static PreprocessUrl: (url: string) => string;
  4746. /**
  4747. * Removes unwanted characters from an url
  4748. * @param url defines the url to clean
  4749. * @returns the cleaned url
  4750. */
  4751. private static _CleanUrl;
  4752. /**
  4753. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4754. * @param url define the url we are trying
  4755. * @param element define the dom element where to configure the cors policy
  4756. */
  4757. static SetCorsBehavior(url: string | string[], element: {
  4758. crossOrigin: string | null;
  4759. }): void;
  4760. /**
  4761. * Loads an image as an HTMLImageElement.
  4762. * @param input url string, ArrayBuffer, or Blob to load
  4763. * @param onLoad callback called when the image successfully loads
  4764. * @param onError callback called when the image fails to load
  4765. * @param offlineProvider offline provider for caching
  4766. * @returns the HTMLImageElement of the loaded image
  4767. */
  4768. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4769. /**
  4770. * Loads a file
  4771. * @param fileToLoad defines the file to load
  4772. * @param callback defines the callback to call when data is loaded
  4773. * @param progressCallBack defines the callback to call during loading process
  4774. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4775. * @returns a file request object
  4776. */
  4777. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4778. /**
  4779. * Loads a file
  4780. * @param url url string, ArrayBuffer, or Blob to load
  4781. * @param onSuccess callback called when the file successfully loads
  4782. * @param onProgress callback called while file is loading (if the server supports this mode)
  4783. * @param offlineProvider defines the offline provider for caching
  4784. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4785. * @param onError callback called when the file fails to load
  4786. * @returns a file request object
  4787. */
  4788. 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;
  4789. /**
  4790. * Checks if the loaded document was accessed via `file:`-Protocol.
  4791. * @returns boolean
  4792. */
  4793. static IsFileURL(): boolean;
  4794. }
  4795. }
  4796. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  4797. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4798. /** @hidden */
  4799. export class ShaderProcessor {
  4800. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4801. private static _ProcessPrecision;
  4802. private static _ExtractOperation;
  4803. private static _BuildSubExpression;
  4804. private static _BuildExpression;
  4805. private static _MoveCursorWithinIf;
  4806. private static _MoveCursor;
  4807. private static _EvaluatePreProcessors;
  4808. private static _PreparePreProcessors;
  4809. private static _ProcessShaderConversion;
  4810. private static _ProcessIncludes;
  4811. }
  4812. }
  4813. declare module "babylonjs/Maths/math.color" {
  4814. import { DeepImmutable, FloatArray } from "babylonjs/types";
  4815. /**
  4816. * Class used to hold a RBG color
  4817. */
  4818. export class Color3 {
  4819. /**
  4820. * Defines the red component (between 0 and 1, default is 0)
  4821. */
  4822. r: number;
  4823. /**
  4824. * Defines the green component (between 0 and 1, default is 0)
  4825. */
  4826. g: number;
  4827. /**
  4828. * Defines the blue component (between 0 and 1, default is 0)
  4829. */
  4830. b: number;
  4831. /**
  4832. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4833. * @param r defines the red component (between 0 and 1, default is 0)
  4834. * @param g defines the green component (between 0 and 1, default is 0)
  4835. * @param b defines the blue component (between 0 and 1, default is 0)
  4836. */
  4837. constructor(
  4838. /**
  4839. * Defines the red component (between 0 and 1, default is 0)
  4840. */
  4841. r?: number,
  4842. /**
  4843. * Defines the green component (between 0 and 1, default is 0)
  4844. */
  4845. g?: number,
  4846. /**
  4847. * Defines the blue component (between 0 and 1, default is 0)
  4848. */
  4849. b?: number);
  4850. /**
  4851. * Creates a string with the Color3 current values
  4852. * @returns the string representation of the Color3 object
  4853. */
  4854. toString(): string;
  4855. /**
  4856. * Returns the string "Color3"
  4857. * @returns "Color3"
  4858. */
  4859. getClassName(): string;
  4860. /**
  4861. * Compute the Color3 hash code
  4862. * @returns an unique number that can be used to hash Color3 objects
  4863. */
  4864. getHashCode(): number;
  4865. /**
  4866. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4867. * @param array defines the array where to store the r,g,b components
  4868. * @param index defines an optional index in the target array to define where to start storing values
  4869. * @returns the current Color3 object
  4870. */
  4871. toArray(array: FloatArray, index?: number): Color3;
  4872. /**
  4873. * Returns a new Color4 object from the current Color3 and the given alpha
  4874. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4875. * @returns a new Color4 object
  4876. */
  4877. toColor4(alpha?: number): Color4;
  4878. /**
  4879. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4880. * @returns the new array
  4881. */
  4882. asArray(): number[];
  4883. /**
  4884. * Returns the luminance value
  4885. * @returns a float value
  4886. */
  4887. toLuminance(): number;
  4888. /**
  4889. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4890. * @param otherColor defines the second operand
  4891. * @returns the new Color3 object
  4892. */
  4893. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4894. /**
  4895. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4896. * @param otherColor defines the second operand
  4897. * @param result defines the Color3 object where to store the result
  4898. * @returns the current Color3
  4899. */
  4900. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4901. /**
  4902. * Determines equality between Color3 objects
  4903. * @param otherColor defines the second operand
  4904. * @returns true if the rgb values are equal to the given ones
  4905. */
  4906. equals(otherColor: DeepImmutable<Color3>): boolean;
  4907. /**
  4908. * Determines equality between the current Color3 object and a set of r,b,g values
  4909. * @param r defines the red component to check
  4910. * @param g defines the green component to check
  4911. * @param b defines the blue component to check
  4912. * @returns true if the rgb values are equal to the given ones
  4913. */
  4914. equalsFloats(r: number, g: number, b: number): boolean;
  4915. /**
  4916. * Multiplies in place each rgb value by scale
  4917. * @param scale defines the scaling factor
  4918. * @returns the updated Color3
  4919. */
  4920. scale(scale: number): Color3;
  4921. /**
  4922. * Multiplies the rgb values by scale and stores the result into "result"
  4923. * @param scale defines the scaling factor
  4924. * @param result defines the Color3 object where to store the result
  4925. * @returns the unmodified current Color3
  4926. */
  4927. scaleToRef(scale: number, result: Color3): Color3;
  4928. /**
  4929. * Scale the current Color3 values by a factor and add the result to a given Color3
  4930. * @param scale defines the scale factor
  4931. * @param result defines color to store the result into
  4932. * @returns the unmodified current Color3
  4933. */
  4934. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4935. /**
  4936. * Clamps the rgb values by the min and max values and stores the result into "result"
  4937. * @param min defines minimum clamping value (default is 0)
  4938. * @param max defines maximum clamping value (default is 1)
  4939. * @param result defines color to store the result into
  4940. * @returns the original Color3
  4941. */
  4942. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4943. /**
  4944. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4945. * @param otherColor defines the second operand
  4946. * @returns the new Color3
  4947. */
  4948. add(otherColor: DeepImmutable<Color3>): Color3;
  4949. /**
  4950. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4951. * @param otherColor defines the second operand
  4952. * @param result defines Color3 object to store the result into
  4953. * @returns the unmodified current Color3
  4954. */
  4955. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4956. /**
  4957. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4958. * @param otherColor defines the second operand
  4959. * @returns the new Color3
  4960. */
  4961. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4962. /**
  4963. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4964. * @param otherColor defines the second operand
  4965. * @param result defines Color3 object to store the result into
  4966. * @returns the unmodified current Color3
  4967. */
  4968. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4969. /**
  4970. * Copy the current object
  4971. * @returns a new Color3 copied the current one
  4972. */
  4973. clone(): Color3;
  4974. /**
  4975. * Copies the rgb values from the source in the current Color3
  4976. * @param source defines the source Color3 object
  4977. * @returns the updated Color3 object
  4978. */
  4979. copyFrom(source: DeepImmutable<Color3>): Color3;
  4980. /**
  4981. * Updates the Color3 rgb values from the given floats
  4982. * @param r defines the red component to read from
  4983. * @param g defines the green component to read from
  4984. * @param b defines the blue component to read from
  4985. * @returns the current Color3 object
  4986. */
  4987. copyFromFloats(r: number, g: number, b: number): Color3;
  4988. /**
  4989. * Updates the Color3 rgb values from the given floats
  4990. * @param r defines the red component to read from
  4991. * @param g defines the green component to read from
  4992. * @param b defines the blue component to read from
  4993. * @returns the current Color3 object
  4994. */
  4995. set(r: number, g: number, b: number): Color3;
  4996. /**
  4997. * Compute the Color3 hexadecimal code as a string
  4998. * @returns a string containing the hexadecimal representation of the Color3 object
  4999. */
  5000. toHexString(): string;
  5001. /**
  5002. * Computes a new Color3 converted from the current one to linear space
  5003. * @returns a new Color3 object
  5004. */
  5005. toLinearSpace(): Color3;
  5006. /**
  5007. * Converts current color in rgb space to HSV values
  5008. * @returns a new color3 representing the HSV values
  5009. */
  5010. toHSV(): Color3;
  5011. /**
  5012. * Converts current color in rgb space to HSV values
  5013. * @param result defines the Color3 where to store the HSV values
  5014. */
  5015. toHSVToRef(result: Color3): void;
  5016. /**
  5017. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5018. * @param convertedColor defines the Color3 object where to store the linear space version
  5019. * @returns the unmodified Color3
  5020. */
  5021. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5022. /**
  5023. * Computes a new Color3 converted from the current one to gamma space
  5024. * @returns a new Color3 object
  5025. */
  5026. toGammaSpace(): Color3;
  5027. /**
  5028. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5029. * @param convertedColor defines the Color3 object where to store the gamma space version
  5030. * @returns the unmodified Color3
  5031. */
  5032. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5033. private static _BlackReadOnly;
  5034. /**
  5035. * Convert Hue, saturation and value to a Color3 (RGB)
  5036. * @param hue defines the hue
  5037. * @param saturation defines the saturation
  5038. * @param value defines the value
  5039. * @param result defines the Color3 where to store the RGB values
  5040. */
  5041. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5042. /**
  5043. * Creates a new Color3 from the string containing valid hexadecimal values
  5044. * @param hex defines a string containing valid hexadecimal values
  5045. * @returns a new Color3 object
  5046. */
  5047. static FromHexString(hex: string): Color3;
  5048. /**
  5049. * Creates a new Color3 from the starting index of the given array
  5050. * @param array defines the source array
  5051. * @param offset defines an offset in the source array
  5052. * @returns a new Color3 object
  5053. */
  5054. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5055. /**
  5056. * Creates a new Color3 from integer values (< 256)
  5057. * @param r defines the red component to read from (value between 0 and 255)
  5058. * @param g defines the green component to read from (value between 0 and 255)
  5059. * @param b defines the blue component to read from (value between 0 and 255)
  5060. * @returns a new Color3 object
  5061. */
  5062. static FromInts(r: number, g: number, b: number): Color3;
  5063. /**
  5064. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5065. * @param start defines the start Color3 value
  5066. * @param end defines the end Color3 value
  5067. * @param amount defines the gradient value between start and end
  5068. * @returns a new Color3 object
  5069. */
  5070. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5071. /**
  5072. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5073. * @param left defines the start value
  5074. * @param right defines the end value
  5075. * @param amount defines the gradient factor
  5076. * @param result defines the Color3 object where to store the result
  5077. */
  5078. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5079. /**
  5080. * Returns a Color3 value containing a red color
  5081. * @returns a new Color3 object
  5082. */
  5083. static Red(): Color3;
  5084. /**
  5085. * Returns a Color3 value containing a green color
  5086. * @returns a new Color3 object
  5087. */
  5088. static Green(): Color3;
  5089. /**
  5090. * Returns a Color3 value containing a blue color
  5091. * @returns a new Color3 object
  5092. */
  5093. static Blue(): Color3;
  5094. /**
  5095. * Returns a Color3 value containing a black color
  5096. * @returns a new Color3 object
  5097. */
  5098. static Black(): Color3;
  5099. /**
  5100. * Gets a Color3 value containing a black color that must not be updated
  5101. */
  5102. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5103. /**
  5104. * Returns a Color3 value containing a white color
  5105. * @returns a new Color3 object
  5106. */
  5107. static White(): Color3;
  5108. /**
  5109. * Returns a Color3 value containing a purple color
  5110. * @returns a new Color3 object
  5111. */
  5112. static Purple(): Color3;
  5113. /**
  5114. * Returns a Color3 value containing a magenta color
  5115. * @returns a new Color3 object
  5116. */
  5117. static Magenta(): Color3;
  5118. /**
  5119. * Returns a Color3 value containing a yellow color
  5120. * @returns a new Color3 object
  5121. */
  5122. static Yellow(): Color3;
  5123. /**
  5124. * Returns a Color3 value containing a gray color
  5125. * @returns a new Color3 object
  5126. */
  5127. static Gray(): Color3;
  5128. /**
  5129. * Returns a Color3 value containing a teal color
  5130. * @returns a new Color3 object
  5131. */
  5132. static Teal(): Color3;
  5133. /**
  5134. * Returns a Color3 value containing a random color
  5135. * @returns a new Color3 object
  5136. */
  5137. static Random(): Color3;
  5138. }
  5139. /**
  5140. * Class used to hold a RBGA color
  5141. */
  5142. export class Color4 {
  5143. /**
  5144. * Defines the red component (between 0 and 1, default is 0)
  5145. */
  5146. r: number;
  5147. /**
  5148. * Defines the green component (between 0 and 1, default is 0)
  5149. */
  5150. g: number;
  5151. /**
  5152. * Defines the blue component (between 0 and 1, default is 0)
  5153. */
  5154. b: number;
  5155. /**
  5156. * Defines the alpha component (between 0 and 1, default is 1)
  5157. */
  5158. a: number;
  5159. /**
  5160. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5161. * @param r defines the red component (between 0 and 1, default is 0)
  5162. * @param g defines the green component (between 0 and 1, default is 0)
  5163. * @param b defines the blue component (between 0 and 1, default is 0)
  5164. * @param a defines the alpha component (between 0 and 1, default is 1)
  5165. */
  5166. constructor(
  5167. /**
  5168. * Defines the red component (between 0 and 1, default is 0)
  5169. */
  5170. r?: number,
  5171. /**
  5172. * Defines the green component (between 0 and 1, default is 0)
  5173. */
  5174. g?: number,
  5175. /**
  5176. * Defines the blue component (between 0 and 1, default is 0)
  5177. */
  5178. b?: number,
  5179. /**
  5180. * Defines the alpha component (between 0 and 1, default is 1)
  5181. */
  5182. a?: number);
  5183. /**
  5184. * Adds in place the given Color4 values to the current Color4 object
  5185. * @param right defines the second operand
  5186. * @returns the current updated Color4 object
  5187. */
  5188. addInPlace(right: DeepImmutable<Color4>): Color4;
  5189. /**
  5190. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5191. * @returns the new array
  5192. */
  5193. asArray(): number[];
  5194. /**
  5195. * Stores from the starting index in the given array the Color4 successive values
  5196. * @param array defines the array where to store the r,g,b components
  5197. * @param index defines an optional index in the target array to define where to start storing values
  5198. * @returns the current Color4 object
  5199. */
  5200. toArray(array: number[], index?: number): Color4;
  5201. /**
  5202. * Determines equality between Color4 objects
  5203. * @param otherColor defines the second operand
  5204. * @returns true if the rgba values are equal to the given ones
  5205. */
  5206. equals(otherColor: DeepImmutable<Color4>): boolean;
  5207. /**
  5208. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5209. * @param right defines the second operand
  5210. * @returns a new Color4 object
  5211. */
  5212. add(right: DeepImmutable<Color4>): Color4;
  5213. /**
  5214. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5215. * @param right defines the second operand
  5216. * @returns a new Color4 object
  5217. */
  5218. subtract(right: DeepImmutable<Color4>): Color4;
  5219. /**
  5220. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5221. * @param right defines the second operand
  5222. * @param result defines the Color4 object where to store the result
  5223. * @returns the current Color4 object
  5224. */
  5225. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5226. /**
  5227. * Creates a new Color4 with the current Color4 values multiplied by scale
  5228. * @param scale defines the scaling factor to apply
  5229. * @returns a new Color4 object
  5230. */
  5231. scale(scale: number): Color4;
  5232. /**
  5233. * Multiplies the current Color4 values by scale and stores the result in "result"
  5234. * @param scale defines the scaling factor to apply
  5235. * @param result defines the Color4 object where to store the result
  5236. * @returns the current unmodified Color4
  5237. */
  5238. scaleToRef(scale: number, result: Color4): Color4;
  5239. /**
  5240. * Scale the current Color4 values by a factor and add the result to a given Color4
  5241. * @param scale defines the scale factor
  5242. * @param result defines the Color4 object where to store the result
  5243. * @returns the unmodified current Color4
  5244. */
  5245. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5246. /**
  5247. * Clamps the rgb values by the min and max values and stores the result into "result"
  5248. * @param min defines minimum clamping value (default is 0)
  5249. * @param max defines maximum clamping value (default is 1)
  5250. * @param result defines color to store the result into.
  5251. * @returns the cuurent Color4
  5252. */
  5253. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5254. /**
  5255. * Multipy an Color4 value by another and return a new Color4 object
  5256. * @param color defines the Color4 value to multiply by
  5257. * @returns a new Color4 object
  5258. */
  5259. multiply(color: Color4): Color4;
  5260. /**
  5261. * Multipy a Color4 value by another and push the result in a reference value
  5262. * @param color defines the Color4 value to multiply by
  5263. * @param result defines the Color4 to fill the result in
  5264. * @returns the result Color4
  5265. */
  5266. multiplyToRef(color: Color4, result: Color4): Color4;
  5267. /**
  5268. * Creates a string with the Color4 current values
  5269. * @returns the string representation of the Color4 object
  5270. */
  5271. toString(): string;
  5272. /**
  5273. * Returns the string "Color4"
  5274. * @returns "Color4"
  5275. */
  5276. getClassName(): string;
  5277. /**
  5278. * Compute the Color4 hash code
  5279. * @returns an unique number that can be used to hash Color4 objects
  5280. */
  5281. getHashCode(): number;
  5282. /**
  5283. * Creates a new Color4 copied from the current one
  5284. * @returns a new Color4 object
  5285. */
  5286. clone(): Color4;
  5287. /**
  5288. * Copies the given Color4 values into the current one
  5289. * @param source defines the source Color4 object
  5290. * @returns the current updated Color4 object
  5291. */
  5292. copyFrom(source: Color4): Color4;
  5293. /**
  5294. * Copies the given float values into the current one
  5295. * @param r defines the red component to read from
  5296. * @param g defines the green component to read from
  5297. * @param b defines the blue component to read from
  5298. * @param a defines the alpha component to read from
  5299. * @returns the current updated Color4 object
  5300. */
  5301. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5302. /**
  5303. * Copies the given float values into the current one
  5304. * @param r defines the red component to read from
  5305. * @param g defines the green component to read from
  5306. * @param b defines the blue component to read from
  5307. * @param a defines the alpha component to read from
  5308. * @returns the current updated Color4 object
  5309. */
  5310. set(r: number, g: number, b: number, a: number): Color4;
  5311. /**
  5312. * Compute the Color4 hexadecimal code as a string
  5313. * @returns a string containing the hexadecimal representation of the Color4 object
  5314. */
  5315. toHexString(): string;
  5316. /**
  5317. * Computes a new Color4 converted from the current one to linear space
  5318. * @returns a new Color4 object
  5319. */
  5320. toLinearSpace(): Color4;
  5321. /**
  5322. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5323. * @param convertedColor defines the Color4 object where to store the linear space version
  5324. * @returns the unmodified Color4
  5325. */
  5326. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5327. /**
  5328. * Computes a new Color4 converted from the current one to gamma space
  5329. * @returns a new Color4 object
  5330. */
  5331. toGammaSpace(): Color4;
  5332. /**
  5333. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5334. * @param convertedColor defines the Color4 object where to store the gamma space version
  5335. * @returns the unmodified Color4
  5336. */
  5337. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5338. /**
  5339. * Creates a new Color4 from the string containing valid hexadecimal values
  5340. * @param hex defines a string containing valid hexadecimal values
  5341. * @returns a new Color4 object
  5342. */
  5343. static FromHexString(hex: string): Color4;
  5344. /**
  5345. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5346. * @param left defines the start value
  5347. * @param right defines the end value
  5348. * @param amount defines the gradient factor
  5349. * @returns a new Color4 object
  5350. */
  5351. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5352. /**
  5353. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5354. * @param left defines the start value
  5355. * @param right defines the end value
  5356. * @param amount defines the gradient factor
  5357. * @param result defines the Color4 object where to store data
  5358. */
  5359. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5360. /**
  5361. * Creates a new Color4 from a Color3 and an alpha value
  5362. * @param color3 defines the source Color3 to read from
  5363. * @param alpha defines the alpha component (1.0 by default)
  5364. * @returns a new Color4 object
  5365. */
  5366. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5367. /**
  5368. * Creates a new Color4 from the starting index element of the given array
  5369. * @param array defines the source array to read from
  5370. * @param offset defines the offset in the source array
  5371. * @returns a new Color4 object
  5372. */
  5373. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5374. /**
  5375. * Creates a new Color3 from integer values (< 256)
  5376. * @param r defines the red component to read from (value between 0 and 255)
  5377. * @param g defines the green component to read from (value between 0 and 255)
  5378. * @param b defines the blue component to read from (value between 0 and 255)
  5379. * @param a defines the alpha component to read from (value between 0 and 255)
  5380. * @returns a new Color3 object
  5381. */
  5382. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5383. /**
  5384. * Check the content of a given array and convert it to an array containing RGBA data
  5385. * If the original array was already containing count * 4 values then it is returned directly
  5386. * @param colors defines the array to check
  5387. * @param count defines the number of RGBA data to expect
  5388. * @returns an array containing count * 4 values (RGBA)
  5389. */
  5390. static CheckColors4(colors: number[], count: number): number[];
  5391. }
  5392. /**
  5393. * @hidden
  5394. */
  5395. export class TmpColors {
  5396. static Color3: Color3[];
  5397. static Color4: Color4[];
  5398. }
  5399. }
  5400. declare module "babylonjs/Maths/sphericalPolynomial" {
  5401. import { Vector3 } from "babylonjs/Maths/math.vector";
  5402. import { Color3 } from "babylonjs/Maths/math.color";
  5403. /**
  5404. * Class representing spherical harmonics coefficients to the 3rd degree
  5405. */
  5406. export class SphericalHarmonics {
  5407. /**
  5408. * Defines whether or not the harmonics have been prescaled for rendering.
  5409. */
  5410. preScaled: boolean;
  5411. /**
  5412. * The l0,0 coefficients of the spherical harmonics
  5413. */
  5414. l00: Vector3;
  5415. /**
  5416. * The l1,-1 coefficients of the spherical harmonics
  5417. */
  5418. l1_1: Vector3;
  5419. /**
  5420. * The l1,0 coefficients of the spherical harmonics
  5421. */
  5422. l10: Vector3;
  5423. /**
  5424. * The l1,1 coefficients of the spherical harmonics
  5425. */
  5426. l11: Vector3;
  5427. /**
  5428. * The l2,-2 coefficients of the spherical harmonics
  5429. */
  5430. l2_2: Vector3;
  5431. /**
  5432. * The l2,-1 coefficients of the spherical harmonics
  5433. */
  5434. l2_1: Vector3;
  5435. /**
  5436. * The l2,0 coefficients of the spherical harmonics
  5437. */
  5438. l20: Vector3;
  5439. /**
  5440. * The l2,1 coefficients of the spherical harmonics
  5441. */
  5442. l21: Vector3;
  5443. /**
  5444. * The l2,2 coefficients of the spherical harmonics
  5445. */
  5446. l22: Vector3;
  5447. /**
  5448. * Adds a light to the spherical harmonics
  5449. * @param direction the direction of the light
  5450. * @param color the color of the light
  5451. * @param deltaSolidAngle the delta solid angle of the light
  5452. */
  5453. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5454. /**
  5455. * Scales the spherical harmonics by the given amount
  5456. * @param scale the amount to scale
  5457. */
  5458. scaleInPlace(scale: number): void;
  5459. /**
  5460. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5461. *
  5462. * ```
  5463. * E_lm = A_l * L_lm
  5464. * ```
  5465. *
  5466. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5467. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5468. * the scaling factors are given in equation 9.
  5469. */
  5470. convertIncidentRadianceToIrradiance(): void;
  5471. /**
  5472. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5473. *
  5474. * ```
  5475. * L = (1/pi) * E * rho
  5476. * ```
  5477. *
  5478. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5479. */
  5480. convertIrradianceToLambertianRadiance(): void;
  5481. /**
  5482. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5483. * required operations at run time.
  5484. *
  5485. * This is simply done by scaling back the SH with Ylm constants parameter.
  5486. * The trigonometric part being applied by the shader at run time.
  5487. */
  5488. preScaleForRendering(): void;
  5489. /**
  5490. * Constructs a spherical harmonics from an array.
  5491. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5492. * @returns the spherical harmonics
  5493. */
  5494. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5495. /**
  5496. * Gets the spherical harmonics from polynomial
  5497. * @param polynomial the spherical polynomial
  5498. * @returns the spherical harmonics
  5499. */
  5500. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5501. }
  5502. /**
  5503. * Class representing spherical polynomial coefficients to the 3rd degree
  5504. */
  5505. export class SphericalPolynomial {
  5506. private _harmonics;
  5507. /**
  5508. * The spherical harmonics used to create the polynomials.
  5509. */
  5510. readonly preScaledHarmonics: SphericalHarmonics;
  5511. /**
  5512. * The x coefficients of the spherical polynomial
  5513. */
  5514. x: Vector3;
  5515. /**
  5516. * The y coefficients of the spherical polynomial
  5517. */
  5518. y: Vector3;
  5519. /**
  5520. * The z coefficients of the spherical polynomial
  5521. */
  5522. z: Vector3;
  5523. /**
  5524. * The xx coefficients of the spherical polynomial
  5525. */
  5526. xx: Vector3;
  5527. /**
  5528. * The yy coefficients of the spherical polynomial
  5529. */
  5530. yy: Vector3;
  5531. /**
  5532. * The zz coefficients of the spherical polynomial
  5533. */
  5534. zz: Vector3;
  5535. /**
  5536. * The xy coefficients of the spherical polynomial
  5537. */
  5538. xy: Vector3;
  5539. /**
  5540. * The yz coefficients of the spherical polynomial
  5541. */
  5542. yz: Vector3;
  5543. /**
  5544. * The zx coefficients of the spherical polynomial
  5545. */
  5546. zx: Vector3;
  5547. /**
  5548. * Adds an ambient color to the spherical polynomial
  5549. * @param color the color to add
  5550. */
  5551. addAmbient(color: Color3): void;
  5552. /**
  5553. * Scales the spherical polynomial by the given amount
  5554. * @param scale the amount to scale
  5555. */
  5556. scaleInPlace(scale: number): void;
  5557. /**
  5558. * Gets the spherical polynomial from harmonics
  5559. * @param harmonics the spherical harmonics
  5560. * @returns the spherical polynomial
  5561. */
  5562. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5563. /**
  5564. * Constructs a spherical polynomial from an array.
  5565. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5566. * @returns the spherical polynomial
  5567. */
  5568. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5569. }
  5570. }
  5571. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5572. /**
  5573. * Define options used to create a render target texture
  5574. */
  5575. export class RenderTargetCreationOptions {
  5576. /**
  5577. * Specifies is mipmaps must be generated
  5578. */
  5579. generateMipMaps?: boolean;
  5580. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5581. generateDepthBuffer?: boolean;
  5582. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5583. generateStencilBuffer?: boolean;
  5584. /** Defines texture type (int by default) */
  5585. type?: number;
  5586. /** Defines sampling mode (trilinear by default) */
  5587. samplingMode?: number;
  5588. /** Defines format (RGBA by default) */
  5589. format?: number;
  5590. }
  5591. }
  5592. declare module "babylonjs/States/alphaCullingState" {
  5593. /**
  5594. * @hidden
  5595. **/
  5596. export class _AlphaState {
  5597. private _isAlphaBlendDirty;
  5598. private _isBlendFunctionParametersDirty;
  5599. private _isBlendEquationParametersDirty;
  5600. private _isBlendConstantsDirty;
  5601. private _alphaBlend;
  5602. private _blendFunctionParameters;
  5603. private _blendEquationParameters;
  5604. private _blendConstants;
  5605. /**
  5606. * Initializes the state.
  5607. */
  5608. constructor();
  5609. readonly isDirty: boolean;
  5610. alphaBlend: boolean;
  5611. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5612. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5613. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5614. reset(): void;
  5615. apply(gl: WebGLRenderingContext): void;
  5616. }
  5617. }
  5618. declare module "babylonjs/States/depthCullingState" {
  5619. import { Nullable } from "babylonjs/types";
  5620. /**
  5621. * @hidden
  5622. **/
  5623. export class _DepthCullingState {
  5624. private _isDepthTestDirty;
  5625. private _isDepthMaskDirty;
  5626. private _isDepthFuncDirty;
  5627. private _isCullFaceDirty;
  5628. private _isCullDirty;
  5629. private _isZOffsetDirty;
  5630. private _isFrontFaceDirty;
  5631. private _depthTest;
  5632. private _depthMask;
  5633. private _depthFunc;
  5634. private _cull;
  5635. private _cullFace;
  5636. private _zOffset;
  5637. private _frontFace;
  5638. /**
  5639. * Initializes the state.
  5640. */
  5641. constructor();
  5642. readonly isDirty: boolean;
  5643. zOffset: number;
  5644. cullFace: Nullable<number>;
  5645. cull: Nullable<boolean>;
  5646. depthFunc: Nullable<number>;
  5647. depthMask: boolean;
  5648. depthTest: boolean;
  5649. frontFace: Nullable<number>;
  5650. reset(): void;
  5651. apply(gl: WebGLRenderingContext): void;
  5652. }
  5653. }
  5654. declare module "babylonjs/States/stencilState" {
  5655. /**
  5656. * @hidden
  5657. **/
  5658. export class _StencilState {
  5659. /** 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 */
  5660. static readonly ALWAYS: number;
  5661. /** Passed to stencilOperation to specify that stencil value must be kept */
  5662. static readonly KEEP: number;
  5663. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5664. static readonly REPLACE: number;
  5665. private _isStencilTestDirty;
  5666. private _isStencilMaskDirty;
  5667. private _isStencilFuncDirty;
  5668. private _isStencilOpDirty;
  5669. private _stencilTest;
  5670. private _stencilMask;
  5671. private _stencilFunc;
  5672. private _stencilFuncRef;
  5673. private _stencilFuncMask;
  5674. private _stencilOpStencilFail;
  5675. private _stencilOpDepthFail;
  5676. private _stencilOpStencilDepthPass;
  5677. readonly isDirty: boolean;
  5678. stencilFunc: number;
  5679. stencilFuncRef: number;
  5680. stencilFuncMask: number;
  5681. stencilOpStencilFail: number;
  5682. stencilOpDepthFail: number;
  5683. stencilOpStencilDepthPass: number;
  5684. stencilMask: number;
  5685. stencilTest: boolean;
  5686. constructor();
  5687. reset(): void;
  5688. apply(gl: WebGLRenderingContext): void;
  5689. }
  5690. }
  5691. declare module "babylonjs/States/index" {
  5692. export * from "babylonjs/States/alphaCullingState";
  5693. export * from "babylonjs/States/depthCullingState";
  5694. export * from "babylonjs/States/stencilState";
  5695. }
  5696. declare module "babylonjs/Instrumentation/timeToken" {
  5697. import { Nullable } from "babylonjs/types";
  5698. /**
  5699. * @hidden
  5700. **/
  5701. export class _TimeToken {
  5702. _startTimeQuery: Nullable<WebGLQuery>;
  5703. _endTimeQuery: Nullable<WebGLQuery>;
  5704. _timeElapsedQuery: Nullable<WebGLQuery>;
  5705. _timeElapsedQueryEnded: boolean;
  5706. }
  5707. }
  5708. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5709. /**
  5710. * Class used to evalaute queries containing `and` and `or` operators
  5711. */
  5712. export class AndOrNotEvaluator {
  5713. /**
  5714. * Evaluate a query
  5715. * @param query defines the query to evaluate
  5716. * @param evaluateCallback defines the callback used to filter result
  5717. * @returns true if the query matches
  5718. */
  5719. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5720. private static _HandleParenthesisContent;
  5721. private static _SimplifyNegation;
  5722. }
  5723. }
  5724. declare module "babylonjs/Misc/tags" {
  5725. /**
  5726. * Class used to store custom tags
  5727. */
  5728. export class Tags {
  5729. /**
  5730. * Adds support for tags on the given object
  5731. * @param obj defines the object to use
  5732. */
  5733. static EnableFor(obj: any): void;
  5734. /**
  5735. * Removes tags support
  5736. * @param obj defines the object to use
  5737. */
  5738. static DisableFor(obj: any): void;
  5739. /**
  5740. * Gets a boolean indicating if the given object has tags
  5741. * @param obj defines the object to use
  5742. * @returns a boolean
  5743. */
  5744. static HasTags(obj: any): boolean;
  5745. /**
  5746. * Gets the tags available on a given object
  5747. * @param obj defines the object to use
  5748. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5749. * @returns the tags
  5750. */
  5751. static GetTags(obj: any, asString?: boolean): any;
  5752. /**
  5753. * Adds tags to an object
  5754. * @param obj defines the object to use
  5755. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5756. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5757. */
  5758. static AddTagsTo(obj: any, tagsString: string): void;
  5759. /**
  5760. * @hidden
  5761. */
  5762. static _AddTagTo(obj: any, tag: string): void;
  5763. /**
  5764. * Removes specific tags from a specific object
  5765. * @param obj defines the object to use
  5766. * @param tagsString defines the tags to remove
  5767. */
  5768. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5769. /**
  5770. * @hidden
  5771. */
  5772. static _RemoveTagFrom(obj: any, tag: string): void;
  5773. /**
  5774. * Defines if tags hosted on an object match a given query
  5775. * @param obj defines the object to use
  5776. * @param tagsQuery defines the tag query
  5777. * @returns a boolean
  5778. */
  5779. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5780. }
  5781. }
  5782. declare module "babylonjs/Maths/math.path" {
  5783. import { DeepImmutable, Nullable } from "babylonjs/types";
  5784. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5785. /**
  5786. * Defines potential orientation for back face culling
  5787. */
  5788. export enum Orientation {
  5789. /**
  5790. * Clockwise
  5791. */
  5792. CW = 0,
  5793. /** Counter clockwise */
  5794. CCW = 1
  5795. }
  5796. /** Class used to represent a Bezier curve */
  5797. export class BezierCurve {
  5798. /**
  5799. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5800. * @param t defines the time
  5801. * @param x1 defines the left coordinate on X axis
  5802. * @param y1 defines the left coordinate on Y axis
  5803. * @param x2 defines the right coordinate on X axis
  5804. * @param y2 defines the right coordinate on Y axis
  5805. * @returns the interpolated value
  5806. */
  5807. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5808. }
  5809. /**
  5810. * Defines angle representation
  5811. */
  5812. export class Angle {
  5813. private _radians;
  5814. /**
  5815. * Creates an Angle object of "radians" radians (float).
  5816. * @param radians the angle in radians
  5817. */
  5818. constructor(radians: number);
  5819. /**
  5820. * Get value in degrees
  5821. * @returns the Angle value in degrees (float)
  5822. */
  5823. degrees(): number;
  5824. /**
  5825. * Get value in radians
  5826. * @returns the Angle value in radians (float)
  5827. */
  5828. radians(): number;
  5829. /**
  5830. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5831. * @param a defines first vector
  5832. * @param b defines second vector
  5833. * @returns a new Angle
  5834. */
  5835. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5836. /**
  5837. * Gets a new Angle object from the given float in radians
  5838. * @param radians defines the angle value in radians
  5839. * @returns a new Angle
  5840. */
  5841. static FromRadians(radians: number): Angle;
  5842. /**
  5843. * Gets a new Angle object from the given float in degrees
  5844. * @param degrees defines the angle value in degrees
  5845. * @returns a new Angle
  5846. */
  5847. static FromDegrees(degrees: number): Angle;
  5848. }
  5849. /**
  5850. * This represents an arc in a 2d space.
  5851. */
  5852. export class Arc2 {
  5853. /** Defines the start point of the arc */
  5854. startPoint: Vector2;
  5855. /** Defines the mid point of the arc */
  5856. midPoint: Vector2;
  5857. /** Defines the end point of the arc */
  5858. endPoint: Vector2;
  5859. /**
  5860. * Defines the center point of the arc.
  5861. */
  5862. centerPoint: Vector2;
  5863. /**
  5864. * Defines the radius of the arc.
  5865. */
  5866. radius: number;
  5867. /**
  5868. * Defines the angle of the arc (from mid point to end point).
  5869. */
  5870. angle: Angle;
  5871. /**
  5872. * Defines the start angle of the arc (from start point to middle point).
  5873. */
  5874. startAngle: Angle;
  5875. /**
  5876. * Defines the orientation of the arc (clock wise/counter clock wise).
  5877. */
  5878. orientation: Orientation;
  5879. /**
  5880. * Creates an Arc object from the three given points : start, middle and end.
  5881. * @param startPoint Defines the start point of the arc
  5882. * @param midPoint Defines the midlle point of the arc
  5883. * @param endPoint Defines the end point of the arc
  5884. */
  5885. constructor(
  5886. /** Defines the start point of the arc */
  5887. startPoint: Vector2,
  5888. /** Defines the mid point of the arc */
  5889. midPoint: Vector2,
  5890. /** Defines the end point of the arc */
  5891. endPoint: Vector2);
  5892. }
  5893. /**
  5894. * Represents a 2D path made up of multiple 2D points
  5895. */
  5896. export class Path2 {
  5897. private _points;
  5898. private _length;
  5899. /**
  5900. * If the path start and end point are the same
  5901. */
  5902. closed: boolean;
  5903. /**
  5904. * Creates a Path2 object from the starting 2D coordinates x and y.
  5905. * @param x the starting points x value
  5906. * @param y the starting points y value
  5907. */
  5908. constructor(x: number, y: number);
  5909. /**
  5910. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5911. * @param x the added points x value
  5912. * @param y the added points y value
  5913. * @returns the updated Path2.
  5914. */
  5915. addLineTo(x: number, y: number): Path2;
  5916. /**
  5917. * 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.
  5918. * @param midX middle point x value
  5919. * @param midY middle point y value
  5920. * @param endX end point x value
  5921. * @param endY end point y value
  5922. * @param numberOfSegments (default: 36)
  5923. * @returns the updated Path2.
  5924. */
  5925. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5926. /**
  5927. * Closes the Path2.
  5928. * @returns the Path2.
  5929. */
  5930. close(): Path2;
  5931. /**
  5932. * Gets the sum of the distance between each sequential point in the path
  5933. * @returns the Path2 total length (float).
  5934. */
  5935. length(): number;
  5936. /**
  5937. * Gets the points which construct the path
  5938. * @returns the Path2 internal array of points.
  5939. */
  5940. getPoints(): Vector2[];
  5941. /**
  5942. * Retreives the point at the distance aways from the starting point
  5943. * @param normalizedLengthPosition the length along the path to retreive the point from
  5944. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5945. */
  5946. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5947. /**
  5948. * Creates a new path starting from an x and y position
  5949. * @param x starting x value
  5950. * @param y starting y value
  5951. * @returns a new Path2 starting at the coordinates (x, y).
  5952. */
  5953. static StartingAt(x: number, y: number): Path2;
  5954. }
  5955. /**
  5956. * Represents a 3D path made up of multiple 3D points
  5957. */
  5958. export class Path3D {
  5959. /**
  5960. * an array of Vector3, the curve axis of the Path3D
  5961. */
  5962. path: Vector3[];
  5963. private _curve;
  5964. private _distances;
  5965. private _tangents;
  5966. private _normals;
  5967. private _binormals;
  5968. private _raw;
  5969. /**
  5970. * new Path3D(path, normal, raw)
  5971. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5972. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5973. * @param path an array of Vector3, the curve axis of the Path3D
  5974. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5975. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5976. */
  5977. constructor(
  5978. /**
  5979. * an array of Vector3, the curve axis of the Path3D
  5980. */
  5981. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5982. /**
  5983. * Returns the Path3D array of successive Vector3 designing its curve.
  5984. * @returns the Path3D array of successive Vector3 designing its curve.
  5985. */
  5986. getCurve(): Vector3[];
  5987. /**
  5988. * Returns an array populated with tangent vectors on each Path3D curve point.
  5989. * @returns an array populated with tangent vectors on each Path3D curve point.
  5990. */
  5991. getTangents(): Vector3[];
  5992. /**
  5993. * Returns an array populated with normal vectors on each Path3D curve point.
  5994. * @returns an array populated with normal vectors on each Path3D curve point.
  5995. */
  5996. getNormals(): Vector3[];
  5997. /**
  5998. * Returns an array populated with binormal vectors on each Path3D curve point.
  5999. * @returns an array populated with binormal vectors on each Path3D curve point.
  6000. */
  6001. getBinormals(): Vector3[];
  6002. /**
  6003. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  6004. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  6005. */
  6006. getDistances(): number[];
  6007. /**
  6008. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  6009. * @param path path which all values are copied into the curves points
  6010. * @param firstNormal which should be projected onto the curve
  6011. * @returns the same object updated.
  6012. */
  6013. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  6014. private _compute;
  6015. private _getFirstNonNullVector;
  6016. private _getLastNonNullVector;
  6017. private _normalVector;
  6018. }
  6019. /**
  6020. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6021. * A Curve3 is designed from a series of successive Vector3.
  6022. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  6023. */
  6024. export class Curve3 {
  6025. private _points;
  6026. private _length;
  6027. /**
  6028. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  6029. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  6030. * @param v1 (Vector3) the control point
  6031. * @param v2 (Vector3) the end point of the Quadratic Bezier
  6032. * @param nbPoints (integer) the wanted number of points in the curve
  6033. * @returns the created Curve3
  6034. */
  6035. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6036. /**
  6037. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  6038. * @param v0 (Vector3) the origin point of the Cubic Bezier
  6039. * @param v1 (Vector3) the first control point
  6040. * @param v2 (Vector3) the second control point
  6041. * @param v3 (Vector3) the end point of the Cubic Bezier
  6042. * @param nbPoints (integer) the wanted number of points in the curve
  6043. * @returns the created Curve3
  6044. */
  6045. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6046. /**
  6047. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6048. * @param p1 (Vector3) the origin point of the Hermite Spline
  6049. * @param t1 (Vector3) the tangent vector at the origin point
  6050. * @param p2 (Vector3) the end point of the Hermite Spline
  6051. * @param t2 (Vector3) the tangent vector at the end point
  6052. * @param nbPoints (integer) the wanted number of points in the curve
  6053. * @returns the created Curve3
  6054. */
  6055. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6056. /**
  6057. * Returns a Curve3 object along a CatmullRom Spline curve :
  6058. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6059. * @param nbPoints (integer) the wanted number of points between each curve control points
  6060. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6061. * @returns the created Curve3
  6062. */
  6063. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6064. /**
  6065. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6066. * A Curve3 is designed from a series of successive Vector3.
  6067. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6068. * @param points points which make up the curve
  6069. */
  6070. constructor(points: Vector3[]);
  6071. /**
  6072. * @returns the Curve3 stored array of successive Vector3
  6073. */
  6074. getPoints(): Vector3[];
  6075. /**
  6076. * @returns the computed length (float) of the curve.
  6077. */
  6078. length(): number;
  6079. /**
  6080. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6081. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6082. * curveA and curveB keep unchanged.
  6083. * @param curve the curve to continue from this curve
  6084. * @returns the newly constructed curve
  6085. */
  6086. continue(curve: DeepImmutable<Curve3>): Curve3;
  6087. private _computeLength;
  6088. }
  6089. }
  6090. declare module "babylonjs/Animations/easing" {
  6091. /**
  6092. * This represents the main contract an easing function should follow.
  6093. * Easing functions are used throughout the animation system.
  6094. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6095. */
  6096. export interface IEasingFunction {
  6097. /**
  6098. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6099. * of the easing function.
  6100. * The link below provides some of the most common examples of easing functions.
  6101. * @see https://easings.net/
  6102. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6103. * @returns the corresponding value on the curve defined by the easing function
  6104. */
  6105. ease(gradient: number): number;
  6106. }
  6107. /**
  6108. * Base class used for every default easing function.
  6109. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6110. */
  6111. export class EasingFunction implements IEasingFunction {
  6112. /**
  6113. * Interpolation follows the mathematical formula associated with the easing function.
  6114. */
  6115. static readonly EASINGMODE_EASEIN: number;
  6116. /**
  6117. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6118. */
  6119. static readonly EASINGMODE_EASEOUT: number;
  6120. /**
  6121. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6122. */
  6123. static readonly EASINGMODE_EASEINOUT: number;
  6124. private _easingMode;
  6125. /**
  6126. * Sets the easing mode of the current function.
  6127. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6128. */
  6129. setEasingMode(easingMode: number): void;
  6130. /**
  6131. * Gets the current easing mode.
  6132. * @returns the easing mode
  6133. */
  6134. getEasingMode(): number;
  6135. /**
  6136. * @hidden
  6137. */
  6138. easeInCore(gradient: number): number;
  6139. /**
  6140. * Given an input gradient between 0 and 1, this returns the corresponding value
  6141. * of the easing function.
  6142. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6143. * @returns the corresponding value on the curve defined by the easing function
  6144. */
  6145. ease(gradient: number): number;
  6146. }
  6147. /**
  6148. * Easing function with a circle shape (see link below).
  6149. * @see https://easings.net/#easeInCirc
  6150. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6151. */
  6152. export class CircleEase extends EasingFunction implements IEasingFunction {
  6153. /** @hidden */
  6154. easeInCore(gradient: number): number;
  6155. }
  6156. /**
  6157. * Easing function with a ease back shape (see link below).
  6158. * @see https://easings.net/#easeInBack
  6159. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6160. */
  6161. export class BackEase extends EasingFunction implements IEasingFunction {
  6162. /** Defines the amplitude of the function */
  6163. amplitude: number;
  6164. /**
  6165. * Instantiates a back ease easing
  6166. * @see https://easings.net/#easeInBack
  6167. * @param amplitude Defines the amplitude of the function
  6168. */
  6169. constructor(
  6170. /** Defines the amplitude of the function */
  6171. amplitude?: number);
  6172. /** @hidden */
  6173. easeInCore(gradient: number): number;
  6174. }
  6175. /**
  6176. * Easing function with a bouncing shape (see link below).
  6177. * @see https://easings.net/#easeInBounce
  6178. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6179. */
  6180. export class BounceEase extends EasingFunction implements IEasingFunction {
  6181. /** Defines the number of bounces */
  6182. bounces: number;
  6183. /** Defines the amplitude of the bounce */
  6184. bounciness: number;
  6185. /**
  6186. * Instantiates a bounce easing
  6187. * @see https://easings.net/#easeInBounce
  6188. * @param bounces Defines the number of bounces
  6189. * @param bounciness Defines the amplitude of the bounce
  6190. */
  6191. constructor(
  6192. /** Defines the number of bounces */
  6193. bounces?: number,
  6194. /** Defines the amplitude of the bounce */
  6195. bounciness?: number);
  6196. /** @hidden */
  6197. easeInCore(gradient: number): number;
  6198. }
  6199. /**
  6200. * Easing function with a power of 3 shape (see link below).
  6201. * @see https://easings.net/#easeInCubic
  6202. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6203. */
  6204. export class CubicEase extends EasingFunction implements IEasingFunction {
  6205. /** @hidden */
  6206. easeInCore(gradient: number): number;
  6207. }
  6208. /**
  6209. * Easing function with an elastic shape (see link below).
  6210. * @see https://easings.net/#easeInElastic
  6211. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6212. */
  6213. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6214. /** Defines the number of oscillations*/
  6215. oscillations: number;
  6216. /** Defines the amplitude of the oscillations*/
  6217. springiness: number;
  6218. /**
  6219. * Instantiates an elastic easing function
  6220. * @see https://easings.net/#easeInElastic
  6221. * @param oscillations Defines the number of oscillations
  6222. * @param springiness Defines the amplitude of the oscillations
  6223. */
  6224. constructor(
  6225. /** Defines the number of oscillations*/
  6226. oscillations?: number,
  6227. /** Defines the amplitude of the oscillations*/
  6228. springiness?: number);
  6229. /** @hidden */
  6230. easeInCore(gradient: number): number;
  6231. }
  6232. /**
  6233. * Easing function with an exponential shape (see link below).
  6234. * @see https://easings.net/#easeInExpo
  6235. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6236. */
  6237. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6238. /** Defines the exponent of the function */
  6239. exponent: number;
  6240. /**
  6241. * Instantiates an exponential easing function
  6242. * @see https://easings.net/#easeInExpo
  6243. * @param exponent Defines the exponent of the function
  6244. */
  6245. constructor(
  6246. /** Defines the exponent of the function */
  6247. exponent?: number);
  6248. /** @hidden */
  6249. easeInCore(gradient: number): number;
  6250. }
  6251. /**
  6252. * Easing function with a power shape (see link below).
  6253. * @see https://easings.net/#easeInQuad
  6254. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6255. */
  6256. export class PowerEase extends EasingFunction implements IEasingFunction {
  6257. /** Defines the power of the function */
  6258. power: number;
  6259. /**
  6260. * Instantiates an power base easing function
  6261. * @see https://easings.net/#easeInQuad
  6262. * @param power Defines the power of the function
  6263. */
  6264. constructor(
  6265. /** Defines the power of the function */
  6266. power?: number);
  6267. /** @hidden */
  6268. easeInCore(gradient: number): number;
  6269. }
  6270. /**
  6271. * Easing function with a power of 2 shape (see link below).
  6272. * @see https://easings.net/#easeInQuad
  6273. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6274. */
  6275. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6276. /** @hidden */
  6277. easeInCore(gradient: number): number;
  6278. }
  6279. /**
  6280. * Easing function with a power of 4 shape (see link below).
  6281. * @see https://easings.net/#easeInQuart
  6282. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6283. */
  6284. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6285. /** @hidden */
  6286. easeInCore(gradient: number): number;
  6287. }
  6288. /**
  6289. * Easing function with a power of 5 shape (see link below).
  6290. * @see https://easings.net/#easeInQuint
  6291. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6292. */
  6293. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6294. /** @hidden */
  6295. easeInCore(gradient: number): number;
  6296. }
  6297. /**
  6298. * Easing function with a sin shape (see link below).
  6299. * @see https://easings.net/#easeInSine
  6300. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6301. */
  6302. export class SineEase extends EasingFunction implements IEasingFunction {
  6303. /** @hidden */
  6304. easeInCore(gradient: number): number;
  6305. }
  6306. /**
  6307. * Easing function with a bezier shape (see link below).
  6308. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6309. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6310. */
  6311. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6312. /** Defines the x component of the start tangent in the bezier curve */
  6313. x1: number;
  6314. /** Defines the y component of the start tangent in the bezier curve */
  6315. y1: number;
  6316. /** Defines the x component of the end tangent in the bezier curve */
  6317. x2: number;
  6318. /** Defines the y component of the end tangent in the bezier curve */
  6319. y2: number;
  6320. /**
  6321. * Instantiates a bezier function
  6322. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6323. * @param x1 Defines the x component of the start tangent in the bezier curve
  6324. * @param y1 Defines the y component of the start tangent in the bezier curve
  6325. * @param x2 Defines the x component of the end tangent in the bezier curve
  6326. * @param y2 Defines the y component of the end tangent in the bezier curve
  6327. */
  6328. constructor(
  6329. /** Defines the x component of the start tangent in the bezier curve */
  6330. x1?: number,
  6331. /** Defines the y component of the start tangent in the bezier curve */
  6332. y1?: number,
  6333. /** Defines the x component of the end tangent in the bezier curve */
  6334. x2?: number,
  6335. /** Defines the y component of the end tangent in the bezier curve */
  6336. y2?: number);
  6337. /** @hidden */
  6338. easeInCore(gradient: number): number;
  6339. }
  6340. }
  6341. declare module "babylonjs/Animations/animationKey" {
  6342. /**
  6343. * Defines an interface which represents an animation key frame
  6344. */
  6345. export interface IAnimationKey {
  6346. /**
  6347. * Frame of the key frame
  6348. */
  6349. frame: number;
  6350. /**
  6351. * Value at the specifies key frame
  6352. */
  6353. value: any;
  6354. /**
  6355. * The input tangent for the cubic hermite spline
  6356. */
  6357. inTangent?: any;
  6358. /**
  6359. * The output tangent for the cubic hermite spline
  6360. */
  6361. outTangent?: any;
  6362. /**
  6363. * The animation interpolation type
  6364. */
  6365. interpolation?: AnimationKeyInterpolation;
  6366. }
  6367. /**
  6368. * Enum for the animation key frame interpolation type
  6369. */
  6370. export enum AnimationKeyInterpolation {
  6371. /**
  6372. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6373. */
  6374. STEP = 1
  6375. }
  6376. }
  6377. declare module "babylonjs/Animations/animationRange" {
  6378. /**
  6379. * Represents the range of an animation
  6380. */
  6381. export class AnimationRange {
  6382. /**The name of the animation range**/
  6383. name: string;
  6384. /**The starting frame of the animation */
  6385. from: number;
  6386. /**The ending frame of the animation*/
  6387. to: number;
  6388. /**
  6389. * Initializes the range of an animation
  6390. * @param name The name of the animation range
  6391. * @param from The starting frame of the animation
  6392. * @param to The ending frame of the animation
  6393. */
  6394. constructor(
  6395. /**The name of the animation range**/
  6396. name: string,
  6397. /**The starting frame of the animation */
  6398. from: number,
  6399. /**The ending frame of the animation*/
  6400. to: number);
  6401. /**
  6402. * Makes a copy of the animation range
  6403. * @returns A copy of the animation range
  6404. */
  6405. clone(): AnimationRange;
  6406. }
  6407. }
  6408. declare module "babylonjs/Animations/animationEvent" {
  6409. /**
  6410. * Composed of a frame, and an action function
  6411. */
  6412. export class AnimationEvent {
  6413. /** The frame for which the event is triggered **/
  6414. frame: number;
  6415. /** The event to perform when triggered **/
  6416. action: (currentFrame: number) => void;
  6417. /** Specifies if the event should be triggered only once**/
  6418. onlyOnce?: boolean | undefined;
  6419. /**
  6420. * Specifies if the animation event is done
  6421. */
  6422. isDone: boolean;
  6423. /**
  6424. * Initializes the animation event
  6425. * @param frame The frame for which the event is triggered
  6426. * @param action The event to perform when triggered
  6427. * @param onlyOnce Specifies if the event should be triggered only once
  6428. */
  6429. constructor(
  6430. /** The frame for which the event is triggered **/
  6431. frame: number,
  6432. /** The event to perform when triggered **/
  6433. action: (currentFrame: number) => void,
  6434. /** Specifies if the event should be triggered only once**/
  6435. onlyOnce?: boolean | undefined);
  6436. /** @hidden */
  6437. _clone(): AnimationEvent;
  6438. }
  6439. }
  6440. declare module "babylonjs/Behaviors/behavior" {
  6441. import { Nullable } from "babylonjs/types";
  6442. /**
  6443. * Interface used to define a behavior
  6444. */
  6445. export interface Behavior<T> {
  6446. /** gets or sets behavior's name */
  6447. name: string;
  6448. /**
  6449. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6450. */
  6451. init(): void;
  6452. /**
  6453. * Called when the behavior is attached to a target
  6454. * @param target defines the target where the behavior is attached to
  6455. */
  6456. attach(target: T): void;
  6457. /**
  6458. * Called when the behavior is detached from its target
  6459. */
  6460. detach(): void;
  6461. }
  6462. /**
  6463. * Interface implemented by classes supporting behaviors
  6464. */
  6465. export interface IBehaviorAware<T> {
  6466. /**
  6467. * Attach a behavior
  6468. * @param behavior defines the behavior to attach
  6469. * @returns the current host
  6470. */
  6471. addBehavior(behavior: Behavior<T>): T;
  6472. /**
  6473. * Remove a behavior from the current object
  6474. * @param behavior defines the behavior to detach
  6475. * @returns the current host
  6476. */
  6477. removeBehavior(behavior: Behavior<T>): T;
  6478. /**
  6479. * Gets a behavior using its name to search
  6480. * @param name defines the name to search
  6481. * @returns the behavior or null if not found
  6482. */
  6483. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6484. }
  6485. }
  6486. declare module "babylonjs/Misc/smartArray" {
  6487. /**
  6488. * Defines an array and its length.
  6489. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6490. */
  6491. export interface ISmartArrayLike<T> {
  6492. /**
  6493. * The data of the array.
  6494. */
  6495. data: Array<T>;
  6496. /**
  6497. * The active length of the array.
  6498. */
  6499. length: number;
  6500. }
  6501. /**
  6502. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6503. */
  6504. export class SmartArray<T> implements ISmartArrayLike<T> {
  6505. /**
  6506. * The full set of data from the array.
  6507. */
  6508. data: Array<T>;
  6509. /**
  6510. * The active length of the array.
  6511. */
  6512. length: number;
  6513. protected _id: number;
  6514. /**
  6515. * Instantiates a Smart Array.
  6516. * @param capacity defines the default capacity of the array.
  6517. */
  6518. constructor(capacity: number);
  6519. /**
  6520. * Pushes a value at the end of the active data.
  6521. * @param value defines the object to push in the array.
  6522. */
  6523. push(value: T): void;
  6524. /**
  6525. * Iterates over the active data and apply the lambda to them.
  6526. * @param func defines the action to apply on each value.
  6527. */
  6528. forEach(func: (content: T) => void): void;
  6529. /**
  6530. * Sorts the full sets of data.
  6531. * @param compareFn defines the comparison function to apply.
  6532. */
  6533. sort(compareFn: (a: T, b: T) => number): void;
  6534. /**
  6535. * Resets the active data to an empty array.
  6536. */
  6537. reset(): void;
  6538. /**
  6539. * Releases all the data from the array as well as the array.
  6540. */
  6541. dispose(): void;
  6542. /**
  6543. * Concats the active data with a given array.
  6544. * @param array defines the data to concatenate with.
  6545. */
  6546. concat(array: any): void;
  6547. /**
  6548. * Returns the position of a value in the active data.
  6549. * @param value defines the value to find the index for
  6550. * @returns the index if found in the active data otherwise -1
  6551. */
  6552. indexOf(value: T): number;
  6553. /**
  6554. * Returns whether an element is part of the active data.
  6555. * @param value defines the value to look for
  6556. * @returns true if found in the active data otherwise false
  6557. */
  6558. contains(value: T): boolean;
  6559. private static _GlobalId;
  6560. }
  6561. /**
  6562. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6563. * The data in this array can only be present once
  6564. */
  6565. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6566. private _duplicateId;
  6567. /**
  6568. * Pushes a value at the end of the active data.
  6569. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6570. * @param value defines the object to push in the array.
  6571. */
  6572. push(value: T): void;
  6573. /**
  6574. * Pushes a value at the end of the active data.
  6575. * If the data is already present, it won t be added again
  6576. * @param value defines the object to push in the array.
  6577. * @returns true if added false if it was already present
  6578. */
  6579. pushNoDuplicate(value: T): boolean;
  6580. /**
  6581. * Resets the active data to an empty array.
  6582. */
  6583. reset(): void;
  6584. /**
  6585. * Concats the active data with a given array.
  6586. * This ensures no dupplicate will be present in the result.
  6587. * @param array defines the data to concatenate with.
  6588. */
  6589. concatWithNoDuplicate(array: any): void;
  6590. }
  6591. }
  6592. declare module "babylonjs/Cameras/cameraInputsManager" {
  6593. import { Nullable } from "babylonjs/types";
  6594. import { Camera } from "babylonjs/Cameras/camera";
  6595. /**
  6596. * @ignore
  6597. * This is a list of all the different input types that are available in the application.
  6598. * Fo instance: ArcRotateCameraGamepadInput...
  6599. */
  6600. export var CameraInputTypes: {};
  6601. /**
  6602. * This is the contract to implement in order to create a new input class.
  6603. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6604. */
  6605. export interface ICameraInput<TCamera extends Camera> {
  6606. /**
  6607. * Defines the camera the input is attached to.
  6608. */
  6609. camera: Nullable<TCamera>;
  6610. /**
  6611. * Gets the class name of the current intput.
  6612. * @returns the class name
  6613. */
  6614. getClassName(): string;
  6615. /**
  6616. * Get the friendly name associated with the input class.
  6617. * @returns the input friendly name
  6618. */
  6619. getSimpleName(): string;
  6620. /**
  6621. * Attach the input controls to a specific dom element to get the input from.
  6622. * @param element Defines the element the controls should be listened from
  6623. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6624. */
  6625. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6626. /**
  6627. * Detach the current controls from the specified dom element.
  6628. * @param element Defines the element to stop listening the inputs from
  6629. */
  6630. detachControl(element: Nullable<HTMLElement>): void;
  6631. /**
  6632. * Update the current camera state depending on the inputs that have been used this frame.
  6633. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6634. */
  6635. checkInputs?: () => void;
  6636. }
  6637. /**
  6638. * Represents a map of input types to input instance or input index to input instance.
  6639. */
  6640. export interface CameraInputsMap<TCamera extends Camera> {
  6641. /**
  6642. * Accessor to the input by input type.
  6643. */
  6644. [name: string]: ICameraInput<TCamera>;
  6645. /**
  6646. * Accessor to the input by input index.
  6647. */
  6648. [idx: number]: ICameraInput<TCamera>;
  6649. }
  6650. /**
  6651. * This represents the input manager used within a camera.
  6652. * It helps dealing with all the different kind of input attached to a camera.
  6653. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6654. */
  6655. export class CameraInputsManager<TCamera extends Camera> {
  6656. /**
  6657. * Defines the list of inputs attahed to the camera.
  6658. */
  6659. attached: CameraInputsMap<TCamera>;
  6660. /**
  6661. * Defines the dom element the camera is collecting inputs from.
  6662. * This is null if the controls have not been attached.
  6663. */
  6664. attachedElement: Nullable<HTMLElement>;
  6665. /**
  6666. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6667. */
  6668. noPreventDefault: boolean;
  6669. /**
  6670. * Defined the camera the input manager belongs to.
  6671. */
  6672. camera: TCamera;
  6673. /**
  6674. * Update the current camera state depending on the inputs that have been used this frame.
  6675. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6676. */
  6677. checkInputs: () => void;
  6678. /**
  6679. * Instantiate a new Camera Input Manager.
  6680. * @param camera Defines the camera the input manager blongs to
  6681. */
  6682. constructor(camera: TCamera);
  6683. /**
  6684. * Add an input method to a camera
  6685. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6686. * @param input camera input method
  6687. */
  6688. add(input: ICameraInput<TCamera>): void;
  6689. /**
  6690. * Remove a specific input method from a camera
  6691. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6692. * @param inputToRemove camera input method
  6693. */
  6694. remove(inputToRemove: ICameraInput<TCamera>): void;
  6695. /**
  6696. * Remove a specific input type from a camera
  6697. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6698. * @param inputType the type of the input to remove
  6699. */
  6700. removeByType(inputType: string): void;
  6701. private _addCheckInputs;
  6702. /**
  6703. * Attach the input controls to the currently attached dom element to listen the events from.
  6704. * @param input Defines the input to attach
  6705. */
  6706. attachInput(input: ICameraInput<TCamera>): void;
  6707. /**
  6708. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6709. * @param element Defines the dom element to collect the events from
  6710. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6711. */
  6712. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6713. /**
  6714. * Detach the current manager inputs controls from a specific dom element.
  6715. * @param element Defines the dom element to collect the events from
  6716. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6717. */
  6718. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6719. /**
  6720. * Rebuild the dynamic inputCheck function from the current list of
  6721. * defined inputs in the manager.
  6722. */
  6723. rebuildInputCheck(): void;
  6724. /**
  6725. * Remove all attached input methods from a camera
  6726. */
  6727. clear(): void;
  6728. /**
  6729. * Serialize the current input manager attached to a camera.
  6730. * This ensures than once parsed,
  6731. * the input associated to the camera will be identical to the current ones
  6732. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6733. */
  6734. serialize(serializedCamera: any): void;
  6735. /**
  6736. * Parses an input manager serialized JSON to restore the previous list of inputs
  6737. * and states associated to a camera.
  6738. * @param parsedCamera Defines the JSON to parse
  6739. */
  6740. parse(parsedCamera: any): void;
  6741. }
  6742. }
  6743. declare module "babylonjs/Collisions/intersectionInfo" {
  6744. import { Nullable } from "babylonjs/types";
  6745. /**
  6746. * @hidden
  6747. */
  6748. export class IntersectionInfo {
  6749. bu: Nullable<number>;
  6750. bv: Nullable<number>;
  6751. distance: number;
  6752. faceId: number;
  6753. subMeshId: number;
  6754. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6755. }
  6756. }
  6757. declare module "babylonjs/Maths/math.plane" {
  6758. import { DeepImmutable } from "babylonjs/types";
  6759. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6760. /**
  6761. * Represens a plane by the equation ax + by + cz + d = 0
  6762. */
  6763. export class Plane {
  6764. private static _TmpMatrix;
  6765. /**
  6766. * Normal of the plane (a,b,c)
  6767. */
  6768. normal: Vector3;
  6769. /**
  6770. * d component of the plane
  6771. */
  6772. d: number;
  6773. /**
  6774. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6775. * @param a a component of the plane
  6776. * @param b b component of the plane
  6777. * @param c c component of the plane
  6778. * @param d d component of the plane
  6779. */
  6780. constructor(a: number, b: number, c: number, d: number);
  6781. /**
  6782. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6783. */
  6784. asArray(): number[];
  6785. /**
  6786. * @returns a new plane copied from the current Plane.
  6787. */
  6788. clone(): Plane;
  6789. /**
  6790. * @returns the string "Plane".
  6791. */
  6792. getClassName(): string;
  6793. /**
  6794. * @returns the Plane hash code.
  6795. */
  6796. getHashCode(): number;
  6797. /**
  6798. * Normalize the current Plane in place.
  6799. * @returns the updated Plane.
  6800. */
  6801. normalize(): Plane;
  6802. /**
  6803. * Applies a transformation the plane and returns the result
  6804. * @param transformation the transformation matrix to be applied to the plane
  6805. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6806. */
  6807. transform(transformation: DeepImmutable<Matrix>): Plane;
  6808. /**
  6809. * Calcualtte the dot product between the point and the plane normal
  6810. * @param point point to calculate the dot product with
  6811. * @returns the dot product (float) of the point coordinates and the plane normal.
  6812. */
  6813. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6814. /**
  6815. * Updates the current Plane from the plane defined by the three given points.
  6816. * @param point1 one of the points used to contruct the plane
  6817. * @param point2 one of the points used to contruct the plane
  6818. * @param point3 one of the points used to contruct the plane
  6819. * @returns the updated Plane.
  6820. */
  6821. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6822. /**
  6823. * Checks if the plane is facing a given direction
  6824. * @param direction the direction to check if the plane is facing
  6825. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6826. * @returns True is the vector "direction" is the same side than the plane normal.
  6827. */
  6828. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6829. /**
  6830. * Calculates the distance to a point
  6831. * @param point point to calculate distance to
  6832. * @returns the signed distance (float) from the given point to the Plane.
  6833. */
  6834. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6835. /**
  6836. * Creates a plane from an array
  6837. * @param array the array to create a plane from
  6838. * @returns a new Plane from the given array.
  6839. */
  6840. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6841. /**
  6842. * Creates a plane from three points
  6843. * @param point1 point used to create the plane
  6844. * @param point2 point used to create the plane
  6845. * @param point3 point used to create the plane
  6846. * @returns a new Plane defined by the three given points.
  6847. */
  6848. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6849. /**
  6850. * Creates a plane from an origin point and a normal
  6851. * @param origin origin of the plane to be constructed
  6852. * @param normal normal of the plane to be constructed
  6853. * @returns a new Plane the normal vector to this plane at the given origin point.
  6854. * Note : the vector "normal" is updated because normalized.
  6855. */
  6856. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6857. /**
  6858. * Calculates the distance from a plane and a point
  6859. * @param origin origin of the plane to be constructed
  6860. * @param normal normal of the plane to be constructed
  6861. * @param point point to calculate distance to
  6862. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6863. */
  6864. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6865. }
  6866. }
  6867. declare module "babylonjs/Culling/boundingSphere" {
  6868. import { DeepImmutable } from "babylonjs/types";
  6869. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6870. import { Plane } from "babylonjs/Maths/math.plane";
  6871. /**
  6872. * Class used to store bounding sphere information
  6873. */
  6874. export class BoundingSphere {
  6875. /**
  6876. * Gets the center of the bounding sphere in local space
  6877. */
  6878. readonly center: Vector3;
  6879. /**
  6880. * Radius of the bounding sphere in local space
  6881. */
  6882. radius: number;
  6883. /**
  6884. * Gets the center of the bounding sphere in world space
  6885. */
  6886. readonly centerWorld: Vector3;
  6887. /**
  6888. * Radius of the bounding sphere in world space
  6889. */
  6890. radiusWorld: number;
  6891. /**
  6892. * Gets the minimum vector in local space
  6893. */
  6894. readonly minimum: Vector3;
  6895. /**
  6896. * Gets the maximum vector in local space
  6897. */
  6898. readonly maximum: Vector3;
  6899. private _worldMatrix;
  6900. private static readonly TmpVector3;
  6901. /**
  6902. * Creates a new bounding sphere
  6903. * @param min defines the minimum vector (in local space)
  6904. * @param max defines the maximum vector (in local space)
  6905. * @param worldMatrix defines the new world matrix
  6906. */
  6907. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6908. /**
  6909. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6910. * @param min defines the new minimum vector (in local space)
  6911. * @param max defines the new maximum vector (in local space)
  6912. * @param worldMatrix defines the new world matrix
  6913. */
  6914. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6915. /**
  6916. * Scale the current bounding sphere by applying a scale factor
  6917. * @param factor defines the scale factor to apply
  6918. * @returns the current bounding box
  6919. */
  6920. scale(factor: number): BoundingSphere;
  6921. /**
  6922. * Gets the world matrix of the bounding box
  6923. * @returns a matrix
  6924. */
  6925. getWorldMatrix(): DeepImmutable<Matrix>;
  6926. /** @hidden */
  6927. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6928. /**
  6929. * Tests if the bounding sphere is intersecting the frustum planes
  6930. * @param frustumPlanes defines the frustum planes to test
  6931. * @returns true if there is an intersection
  6932. */
  6933. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6934. /**
  6935. * Tests if the bounding sphere center is in between the frustum planes.
  6936. * Used for optimistic fast inclusion.
  6937. * @param frustumPlanes defines the frustum planes to test
  6938. * @returns true if the sphere center is in between the frustum planes
  6939. */
  6940. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6941. /**
  6942. * Tests if a point is inside the bounding sphere
  6943. * @param point defines the point to test
  6944. * @returns true if the point is inside the bounding sphere
  6945. */
  6946. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6947. /**
  6948. * Checks if two sphere intersct
  6949. * @param sphere0 sphere 0
  6950. * @param sphere1 sphere 1
  6951. * @returns true if the speres intersect
  6952. */
  6953. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6954. }
  6955. }
  6956. declare module "babylonjs/Culling/boundingBox" {
  6957. import { DeepImmutable } from "babylonjs/types";
  6958. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6959. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6960. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6961. import { Plane } from "babylonjs/Maths/math.plane";
  6962. /**
  6963. * Class used to store bounding box information
  6964. */
  6965. export class BoundingBox implements ICullable {
  6966. /**
  6967. * Gets the 8 vectors representing the bounding box in local space
  6968. */
  6969. readonly vectors: Vector3[];
  6970. /**
  6971. * Gets the center of the bounding box in local space
  6972. */
  6973. readonly center: Vector3;
  6974. /**
  6975. * Gets the center of the bounding box in world space
  6976. */
  6977. readonly centerWorld: Vector3;
  6978. /**
  6979. * Gets the extend size in local space
  6980. */
  6981. readonly extendSize: Vector3;
  6982. /**
  6983. * Gets the extend size in world space
  6984. */
  6985. readonly extendSizeWorld: Vector3;
  6986. /**
  6987. * Gets the OBB (object bounding box) directions
  6988. */
  6989. readonly directions: Vector3[];
  6990. /**
  6991. * Gets the 8 vectors representing the bounding box in world space
  6992. */
  6993. readonly vectorsWorld: Vector3[];
  6994. /**
  6995. * Gets the minimum vector in world space
  6996. */
  6997. readonly minimumWorld: Vector3;
  6998. /**
  6999. * Gets the maximum vector in world space
  7000. */
  7001. readonly maximumWorld: Vector3;
  7002. /**
  7003. * Gets the minimum vector in local space
  7004. */
  7005. readonly minimum: Vector3;
  7006. /**
  7007. * Gets the maximum vector in local space
  7008. */
  7009. readonly maximum: Vector3;
  7010. private _worldMatrix;
  7011. private static readonly TmpVector3;
  7012. /**
  7013. * @hidden
  7014. */
  7015. _tag: number;
  7016. /**
  7017. * Creates a new bounding box
  7018. * @param min defines the minimum vector (in local space)
  7019. * @param max defines the maximum vector (in local space)
  7020. * @param worldMatrix defines the new world matrix
  7021. */
  7022. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7023. /**
  7024. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7025. * @param min defines the new minimum vector (in local space)
  7026. * @param max defines the new maximum vector (in local space)
  7027. * @param worldMatrix defines the new world matrix
  7028. */
  7029. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7030. /**
  7031. * Scale the current bounding box by applying a scale factor
  7032. * @param factor defines the scale factor to apply
  7033. * @returns the current bounding box
  7034. */
  7035. scale(factor: number): BoundingBox;
  7036. /**
  7037. * Gets the world matrix of the bounding box
  7038. * @returns a matrix
  7039. */
  7040. getWorldMatrix(): DeepImmutable<Matrix>;
  7041. /** @hidden */
  7042. _update(world: DeepImmutable<Matrix>): void;
  7043. /**
  7044. * Tests if the bounding box is intersecting the frustum planes
  7045. * @param frustumPlanes defines the frustum planes to test
  7046. * @returns true if there is an intersection
  7047. */
  7048. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7049. /**
  7050. * Tests if the bounding box is entirely inside the frustum planes
  7051. * @param frustumPlanes defines the frustum planes to test
  7052. * @returns true if there is an inclusion
  7053. */
  7054. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7055. /**
  7056. * Tests if a point is inside the bounding box
  7057. * @param point defines the point to test
  7058. * @returns true if the point is inside the bounding box
  7059. */
  7060. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7061. /**
  7062. * Tests if the bounding box intersects with a bounding sphere
  7063. * @param sphere defines the sphere to test
  7064. * @returns true if there is an intersection
  7065. */
  7066. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7067. /**
  7068. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7069. * @param min defines the min vector to use
  7070. * @param max defines the max vector to use
  7071. * @returns true if there is an intersection
  7072. */
  7073. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7074. /**
  7075. * Tests if two bounding boxes are intersections
  7076. * @param box0 defines the first box to test
  7077. * @param box1 defines the second box to test
  7078. * @returns true if there is an intersection
  7079. */
  7080. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7081. /**
  7082. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7083. * @param minPoint defines the minimum vector of the bounding box
  7084. * @param maxPoint defines the maximum vector of the bounding box
  7085. * @param sphereCenter defines the sphere center
  7086. * @param sphereRadius defines the sphere radius
  7087. * @returns true if there is an intersection
  7088. */
  7089. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7090. /**
  7091. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7092. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7093. * @param frustumPlanes defines the frustum planes to test
  7094. * @return true if there is an inclusion
  7095. */
  7096. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7097. /**
  7098. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7099. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7100. * @param frustumPlanes defines the frustum planes to test
  7101. * @return true if there is an intersection
  7102. */
  7103. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7104. }
  7105. }
  7106. declare module "babylonjs/Collisions/collider" {
  7107. import { Nullable, IndicesArray } from "babylonjs/types";
  7108. import { Vector3 } from "babylonjs/Maths/math.vector";
  7109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7110. import { Plane } from "babylonjs/Maths/math.plane";
  7111. /** @hidden */
  7112. export class Collider {
  7113. /** Define if a collision was found */
  7114. collisionFound: boolean;
  7115. /**
  7116. * Define last intersection point in local space
  7117. */
  7118. intersectionPoint: Vector3;
  7119. /**
  7120. * Define last collided mesh
  7121. */
  7122. collidedMesh: Nullable<AbstractMesh>;
  7123. private _collisionPoint;
  7124. private _planeIntersectionPoint;
  7125. private _tempVector;
  7126. private _tempVector2;
  7127. private _tempVector3;
  7128. private _tempVector4;
  7129. private _edge;
  7130. private _baseToVertex;
  7131. private _destinationPoint;
  7132. private _slidePlaneNormal;
  7133. private _displacementVector;
  7134. /** @hidden */
  7135. _radius: Vector3;
  7136. /** @hidden */
  7137. _retry: number;
  7138. private _velocity;
  7139. private _basePoint;
  7140. private _epsilon;
  7141. /** @hidden */
  7142. _velocityWorldLength: number;
  7143. /** @hidden */
  7144. _basePointWorld: Vector3;
  7145. private _velocityWorld;
  7146. private _normalizedVelocity;
  7147. /** @hidden */
  7148. _initialVelocity: Vector3;
  7149. /** @hidden */
  7150. _initialPosition: Vector3;
  7151. private _nearestDistance;
  7152. private _collisionMask;
  7153. collisionMask: number;
  7154. /**
  7155. * Gets the plane normal used to compute the sliding response (in local space)
  7156. */
  7157. readonly slidePlaneNormal: Vector3;
  7158. /** @hidden */
  7159. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7160. /** @hidden */
  7161. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7162. /** @hidden */
  7163. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7164. /** @hidden */
  7165. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7166. /** @hidden */
  7167. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7168. /** @hidden */
  7169. _getResponse(pos: Vector3, vel: Vector3): void;
  7170. }
  7171. }
  7172. declare module "babylonjs/Culling/boundingInfo" {
  7173. import { DeepImmutable } from "babylonjs/types";
  7174. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7175. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7176. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7177. import { Plane } from "babylonjs/Maths/math.plane";
  7178. import { Collider } from "babylonjs/Collisions/collider";
  7179. /**
  7180. * Interface for cullable objects
  7181. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7182. */
  7183. export interface ICullable {
  7184. /**
  7185. * Checks if the object or part of the object is in the frustum
  7186. * @param frustumPlanes Camera near/planes
  7187. * @returns true if the object is in frustum otherwise false
  7188. */
  7189. isInFrustum(frustumPlanes: Plane[]): boolean;
  7190. /**
  7191. * Checks if a cullable object (mesh...) is in the camera frustum
  7192. * Unlike isInFrustum this cheks the full bounding box
  7193. * @param frustumPlanes Camera near/planes
  7194. * @returns true if the object is in frustum otherwise false
  7195. */
  7196. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7197. }
  7198. /**
  7199. * Info for a bounding data of a mesh
  7200. */
  7201. export class BoundingInfo implements ICullable {
  7202. /**
  7203. * Bounding box for the mesh
  7204. */
  7205. readonly boundingBox: BoundingBox;
  7206. /**
  7207. * Bounding sphere for the mesh
  7208. */
  7209. readonly boundingSphere: BoundingSphere;
  7210. private _isLocked;
  7211. private static readonly TmpVector3;
  7212. /**
  7213. * Constructs bounding info
  7214. * @param minimum min vector of the bounding box/sphere
  7215. * @param maximum max vector of the bounding box/sphere
  7216. * @param worldMatrix defines the new world matrix
  7217. */
  7218. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7219. /**
  7220. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7221. * @param min defines the new minimum vector (in local space)
  7222. * @param max defines the new maximum vector (in local space)
  7223. * @param worldMatrix defines the new world matrix
  7224. */
  7225. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7226. /**
  7227. * min vector of the bounding box/sphere
  7228. */
  7229. readonly minimum: Vector3;
  7230. /**
  7231. * max vector of the bounding box/sphere
  7232. */
  7233. readonly maximum: Vector3;
  7234. /**
  7235. * If the info is locked and won't be updated to avoid perf overhead
  7236. */
  7237. isLocked: boolean;
  7238. /**
  7239. * Updates the bounding sphere and box
  7240. * @param world world matrix to be used to update
  7241. */
  7242. update(world: DeepImmutable<Matrix>): void;
  7243. /**
  7244. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7245. * @param center New center of the bounding info
  7246. * @param extend New extend of the bounding info
  7247. * @returns the current bounding info
  7248. */
  7249. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7250. /**
  7251. * Scale the current bounding info by applying a scale factor
  7252. * @param factor defines the scale factor to apply
  7253. * @returns the current bounding info
  7254. */
  7255. scale(factor: number): BoundingInfo;
  7256. /**
  7257. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7258. * @param frustumPlanes defines the frustum to test
  7259. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7260. * @returns true if the bounding info is in the frustum planes
  7261. */
  7262. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7263. /**
  7264. * Gets the world distance between the min and max points of the bounding box
  7265. */
  7266. readonly diagonalLength: number;
  7267. /**
  7268. * Checks if a cullable object (mesh...) is in the camera frustum
  7269. * Unlike isInFrustum this cheks the full bounding box
  7270. * @param frustumPlanes Camera near/planes
  7271. * @returns true if the object is in frustum otherwise false
  7272. */
  7273. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7274. /** @hidden */
  7275. _checkCollision(collider: Collider): boolean;
  7276. /**
  7277. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7278. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7279. * @param point the point to check intersection with
  7280. * @returns if the point intersects
  7281. */
  7282. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7283. /**
  7284. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7285. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7286. * @param boundingInfo the bounding info to check intersection with
  7287. * @param precise if the intersection should be done using OBB
  7288. * @returns if the bounding info intersects
  7289. */
  7290. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7291. }
  7292. }
  7293. declare module "babylonjs/Maths/math.functions" {
  7294. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7295. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7296. /**
  7297. * Extracts minimum and maximum values from a list of indexed positions
  7298. * @param positions defines the positions to use
  7299. * @param indices defines the indices to the positions
  7300. * @param indexStart defines the start index
  7301. * @param indexCount defines the end index
  7302. * @param bias defines bias value to add to the result
  7303. * @return minimum and maximum values
  7304. */
  7305. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7306. minimum: Vector3;
  7307. maximum: Vector3;
  7308. };
  7309. /**
  7310. * Extracts minimum and maximum values from a list of positions
  7311. * @param positions defines the positions to use
  7312. * @param start defines the start index in the positions array
  7313. * @param count defines the number of positions to handle
  7314. * @param bias defines bias value to add to the result
  7315. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7316. * @return minimum and maximum values
  7317. */
  7318. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7319. minimum: Vector3;
  7320. maximum: Vector3;
  7321. };
  7322. }
  7323. declare module "babylonjs/Misc/iInspectable" {
  7324. /**
  7325. * Enum that determines the text-wrapping mode to use.
  7326. */
  7327. export enum InspectableType {
  7328. /**
  7329. * Checkbox for booleans
  7330. */
  7331. Checkbox = 0,
  7332. /**
  7333. * Sliders for numbers
  7334. */
  7335. Slider = 1,
  7336. /**
  7337. * Vector3
  7338. */
  7339. Vector3 = 2,
  7340. /**
  7341. * Quaternions
  7342. */
  7343. Quaternion = 3,
  7344. /**
  7345. * Color3
  7346. */
  7347. Color3 = 4,
  7348. /**
  7349. * String
  7350. */
  7351. String = 5
  7352. }
  7353. /**
  7354. * Interface used to define custom inspectable properties.
  7355. * This interface is used by the inspector to display custom property grids
  7356. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7357. */
  7358. export interface IInspectable {
  7359. /**
  7360. * Gets the label to display
  7361. */
  7362. label: string;
  7363. /**
  7364. * Gets the name of the property to edit
  7365. */
  7366. propertyName: string;
  7367. /**
  7368. * Gets the type of the editor to use
  7369. */
  7370. type: InspectableType;
  7371. /**
  7372. * Gets the minimum value of the property when using in "slider" mode
  7373. */
  7374. min?: number;
  7375. /**
  7376. * Gets the maximum value of the property when using in "slider" mode
  7377. */
  7378. max?: number;
  7379. /**
  7380. * Gets the setp to use when using in "slider" mode
  7381. */
  7382. step?: number;
  7383. }
  7384. }
  7385. declare module "babylonjs/Misc/timingTools" {
  7386. /**
  7387. * Class used to provide helper for timing
  7388. */
  7389. export class TimingTools {
  7390. /**
  7391. * Polyfill for setImmediate
  7392. * @param action defines the action to execute after the current execution block
  7393. */
  7394. static SetImmediate(action: () => void): void;
  7395. }
  7396. }
  7397. declare module "babylonjs/Misc/instantiationTools" {
  7398. /**
  7399. * Class used to enable instatition of objects by class name
  7400. */
  7401. export class InstantiationTools {
  7402. /**
  7403. * Use this object to register external classes like custom textures or material
  7404. * to allow the laoders to instantiate them
  7405. */
  7406. static RegisteredExternalClasses: {
  7407. [key: string]: Object;
  7408. };
  7409. /**
  7410. * Tries to instantiate a new object from a given class name
  7411. * @param className defines the class name to instantiate
  7412. * @returns the new object or null if the system was not able to do the instantiation
  7413. */
  7414. static Instantiate(className: string): any;
  7415. }
  7416. }
  7417. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  7418. import { Nullable } from "babylonjs/types";
  7419. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7420. /**
  7421. * This represents the required contract to create a new type of texture loader.
  7422. */
  7423. export interface IInternalTextureLoader {
  7424. /**
  7425. * Defines wether the loader supports cascade loading the different faces.
  7426. */
  7427. supportCascades: boolean;
  7428. /**
  7429. * This returns if the loader support the current file information.
  7430. * @param extension defines the file extension of the file being loaded
  7431. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7432. * @param fallback defines the fallback internal texture if any
  7433. * @param isBase64 defines whether the texture is encoded as a base64
  7434. * @param isBuffer defines whether the texture data are stored as a buffer
  7435. * @returns true if the loader can load the specified file
  7436. */
  7437. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7438. /**
  7439. * Transform the url before loading if required.
  7440. * @param rootUrl the url of the texture
  7441. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7442. * @returns the transformed texture
  7443. */
  7444. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7445. /**
  7446. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7447. * @param rootUrl the url of the texture
  7448. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7449. * @returns the fallback texture
  7450. */
  7451. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7452. /**
  7453. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7454. * @param data contains the texture data
  7455. * @param texture defines the BabylonJS internal texture
  7456. * @param createPolynomials will be true if polynomials have been requested
  7457. * @param onLoad defines the callback to trigger once the texture is ready
  7458. * @param onError defines the callback to trigger in case of error
  7459. */
  7460. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7461. /**
  7462. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7463. * @param data contains the texture data
  7464. * @param texture defines the BabylonJS internal texture
  7465. * @param callback defines the method to call once ready to upload
  7466. */
  7467. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7468. }
  7469. }
  7470. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7471. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7472. import { Nullable } from "babylonjs/types";
  7473. import { Scene } from "babylonjs/scene";
  7474. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7475. module "babylonjs/Engines/engine" {
  7476. interface Engine {
  7477. /**
  7478. * Creates a depth stencil cube texture.
  7479. * This is only available in WebGL 2.
  7480. * @param size The size of face edge in the cube texture.
  7481. * @param options The options defining the cube texture.
  7482. * @returns The cube texture
  7483. */
  7484. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7485. /**
  7486. * Creates a cube texture
  7487. * @param rootUrl defines the url where the files to load is located
  7488. * @param scene defines the current scene
  7489. * @param files defines the list of files to load (1 per face)
  7490. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7491. * @param onLoad defines an optional callback raised when the texture is loaded
  7492. * @param onError defines an optional callback raised if there is an issue to load the texture
  7493. * @param format defines the format of the data
  7494. * @param forcedExtension defines the extension to use to pick the right loader
  7495. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7496. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7497. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7498. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7499. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7500. * @returns the cube texture as an InternalTexture
  7501. */
  7502. 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;
  7503. /**
  7504. * Creates a cube texture
  7505. * @param rootUrl defines the url where the files to load is located
  7506. * @param scene defines the current scene
  7507. * @param files defines the list of files to load (1 per face)
  7508. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7509. * @param onLoad defines an optional callback raised when the texture is loaded
  7510. * @param onError defines an optional callback raised if there is an issue to load the texture
  7511. * @param format defines the format of the data
  7512. * @param forcedExtension defines the extension to use to pick the right loader
  7513. * @returns the cube texture as an InternalTexture
  7514. */
  7515. 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;
  7516. /**
  7517. * Creates a cube texture
  7518. * @param rootUrl defines the url where the files to load is located
  7519. * @param scene defines the current scene
  7520. * @param files defines the list of files to load (1 per face)
  7521. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7522. * @param onLoad defines an optional callback raised when the texture is loaded
  7523. * @param onError defines an optional callback raised if there is an issue to load the texture
  7524. * @param format defines the format of the data
  7525. * @param forcedExtension defines the extension to use to pick the right loader
  7526. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7527. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7528. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7529. * @returns the cube texture as an InternalTexture
  7530. */
  7531. 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;
  7532. /** @hidden */
  7533. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7534. /** @hidden */
  7535. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7536. /** @hidden */
  7537. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7538. /** @hidden */
  7539. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7540. }
  7541. }
  7542. }
  7543. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7544. import { Nullable } from "babylonjs/types";
  7545. import { Scene } from "babylonjs/scene";
  7546. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7547. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7548. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7549. /**
  7550. * Class for creating a cube texture
  7551. */
  7552. export class CubeTexture extends BaseTexture {
  7553. private _delayedOnLoad;
  7554. /**
  7555. * The url of the texture
  7556. */
  7557. url: string;
  7558. /**
  7559. * Gets or sets the center of the bounding box associated with the cube texture.
  7560. * It must define where the camera used to render the texture was set
  7561. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7562. */
  7563. boundingBoxPosition: Vector3;
  7564. private _boundingBoxSize;
  7565. /**
  7566. * Gets or sets the size of the bounding box associated with the cube texture
  7567. * When defined, the cubemap will switch to local mode
  7568. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7569. * @example https://www.babylonjs-playground.com/#RNASML
  7570. */
  7571. /**
  7572. * Returns the bounding box size
  7573. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7574. */
  7575. boundingBoxSize: Vector3;
  7576. protected _rotationY: number;
  7577. /**
  7578. * Sets texture matrix rotation angle around Y axis in radians.
  7579. */
  7580. /**
  7581. * Gets texture matrix rotation angle around Y axis radians.
  7582. */
  7583. rotationY: number;
  7584. /**
  7585. * Are mip maps generated for this texture or not.
  7586. */
  7587. readonly noMipmap: boolean;
  7588. private _noMipmap;
  7589. private _files;
  7590. private _extensions;
  7591. private _textureMatrix;
  7592. private _format;
  7593. private _createPolynomials;
  7594. /** @hidden */
  7595. _prefiltered: boolean;
  7596. /**
  7597. * Creates a cube texture from an array of image urls
  7598. * @param files defines an array of image urls
  7599. * @param scene defines the hosting scene
  7600. * @param noMipmap specifies if mip maps are not used
  7601. * @returns a cube texture
  7602. */
  7603. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7604. /**
  7605. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7606. * @param url defines the url of the prefiltered texture
  7607. * @param scene defines the scene the texture is attached to
  7608. * @param forcedExtension defines the extension of the file if different from the url
  7609. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7610. * @return the prefiltered texture
  7611. */
  7612. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7613. /**
  7614. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7615. * as prefiltered data.
  7616. * @param rootUrl defines the url of the texture or the root name of the six images
  7617. * @param scene defines the scene the texture is attached to
  7618. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7619. * @param noMipmap defines if mipmaps should be created or not
  7620. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7621. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7622. * @param onError defines a callback triggered in case of error during load
  7623. * @param format defines the internal format to use for the texture once loaded
  7624. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7625. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7626. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7627. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7628. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7629. * @return the cube texture
  7630. */
  7631. 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);
  7632. /**
  7633. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7634. */
  7635. readonly isPrefiltered: boolean;
  7636. /**
  7637. * Get the current class name of the texture useful for serialization or dynamic coding.
  7638. * @returns "CubeTexture"
  7639. */
  7640. getClassName(): string;
  7641. /**
  7642. * Update the url (and optional buffer) of this texture if url was null during construction.
  7643. * @param url the url of the texture
  7644. * @param forcedExtension defines the extension to use
  7645. * @param onLoad callback called when the texture is loaded (defaults to null)
  7646. */
  7647. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7648. /**
  7649. * Delays loading of the cube texture
  7650. * @param forcedExtension defines the extension to use
  7651. */
  7652. delayLoad(forcedExtension?: string): void;
  7653. /**
  7654. * Returns the reflection texture matrix
  7655. * @returns the reflection texture matrix
  7656. */
  7657. getReflectionTextureMatrix(): Matrix;
  7658. /**
  7659. * Sets the reflection texture matrix
  7660. * @param value Reflection texture matrix
  7661. */
  7662. setReflectionTextureMatrix(value: Matrix): void;
  7663. /**
  7664. * Parses text to create a cube texture
  7665. * @param parsedTexture define the serialized text to read from
  7666. * @param scene defines the hosting scene
  7667. * @param rootUrl defines the root url of the cube texture
  7668. * @returns a cube texture
  7669. */
  7670. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7671. /**
  7672. * Makes a clone, or deep copy, of the cube texture
  7673. * @returns a new cube texture
  7674. */
  7675. clone(): CubeTexture;
  7676. }
  7677. }
  7678. declare module "babylonjs/Materials/materialDefines" {
  7679. /**
  7680. * Manages the defines for the Material
  7681. */
  7682. export class MaterialDefines {
  7683. /** @hidden */
  7684. protected _keys: string[];
  7685. private _isDirty;
  7686. /** @hidden */
  7687. _renderId: number;
  7688. /** @hidden */
  7689. _areLightsDirty: boolean;
  7690. /** @hidden */
  7691. _areAttributesDirty: boolean;
  7692. /** @hidden */
  7693. _areTexturesDirty: boolean;
  7694. /** @hidden */
  7695. _areFresnelDirty: boolean;
  7696. /** @hidden */
  7697. _areMiscDirty: boolean;
  7698. /** @hidden */
  7699. _areImageProcessingDirty: boolean;
  7700. /** @hidden */
  7701. _normals: boolean;
  7702. /** @hidden */
  7703. _uvs: boolean;
  7704. /** @hidden */
  7705. _needNormals: boolean;
  7706. /** @hidden */
  7707. _needUVs: boolean;
  7708. [id: string]: any;
  7709. /**
  7710. * Specifies if the material needs to be re-calculated
  7711. */
  7712. readonly isDirty: boolean;
  7713. /**
  7714. * Marks the material to indicate that it has been re-calculated
  7715. */
  7716. markAsProcessed(): void;
  7717. /**
  7718. * Marks the material to indicate that it needs to be re-calculated
  7719. */
  7720. markAsUnprocessed(): void;
  7721. /**
  7722. * Marks the material to indicate all of its defines need to be re-calculated
  7723. */
  7724. markAllAsDirty(): void;
  7725. /**
  7726. * Marks the material to indicate that image processing needs to be re-calculated
  7727. */
  7728. markAsImageProcessingDirty(): void;
  7729. /**
  7730. * Marks the material to indicate the lights need to be re-calculated
  7731. */
  7732. markAsLightDirty(): void;
  7733. /**
  7734. * Marks the attribute state as changed
  7735. */
  7736. markAsAttributesDirty(): void;
  7737. /**
  7738. * Marks the texture state as changed
  7739. */
  7740. markAsTexturesDirty(): void;
  7741. /**
  7742. * Marks the fresnel state as changed
  7743. */
  7744. markAsFresnelDirty(): void;
  7745. /**
  7746. * Marks the misc state as changed
  7747. */
  7748. markAsMiscDirty(): void;
  7749. /**
  7750. * Rebuilds the material defines
  7751. */
  7752. rebuild(): void;
  7753. /**
  7754. * Specifies if two material defines are equal
  7755. * @param other - A material define instance to compare to
  7756. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7757. */
  7758. isEqual(other: MaterialDefines): boolean;
  7759. /**
  7760. * Clones this instance's defines to another instance
  7761. * @param other - material defines to clone values to
  7762. */
  7763. cloneTo(other: MaterialDefines): void;
  7764. /**
  7765. * Resets the material define values
  7766. */
  7767. reset(): void;
  7768. /**
  7769. * Converts the material define values to a string
  7770. * @returns - String of material define information
  7771. */
  7772. toString(): string;
  7773. }
  7774. }
  7775. declare module "babylonjs/Materials/colorCurves" {
  7776. import { Effect } from "babylonjs/Materials/effect";
  7777. /**
  7778. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7779. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7780. * 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;
  7781. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7782. */
  7783. export class ColorCurves {
  7784. private _dirty;
  7785. private _tempColor;
  7786. private _globalCurve;
  7787. private _highlightsCurve;
  7788. private _midtonesCurve;
  7789. private _shadowsCurve;
  7790. private _positiveCurve;
  7791. private _negativeCurve;
  7792. private _globalHue;
  7793. private _globalDensity;
  7794. private _globalSaturation;
  7795. private _globalExposure;
  7796. /**
  7797. * Gets the global Hue value.
  7798. * 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).
  7799. */
  7800. /**
  7801. * Sets the global Hue value.
  7802. * 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).
  7803. */
  7804. globalHue: number;
  7805. /**
  7806. * Gets the global Density value.
  7807. * 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.
  7808. * Values less than zero provide a filter of opposite hue.
  7809. */
  7810. /**
  7811. * Sets the global Density value.
  7812. * 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.
  7813. * Values less than zero provide a filter of opposite hue.
  7814. */
  7815. globalDensity: number;
  7816. /**
  7817. * Gets the global Saturation value.
  7818. * 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.
  7819. */
  7820. /**
  7821. * Sets the global Saturation value.
  7822. * 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.
  7823. */
  7824. globalSaturation: number;
  7825. /**
  7826. * Gets the global Exposure value.
  7827. * 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.
  7828. */
  7829. /**
  7830. * Sets the global Exposure value.
  7831. * 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.
  7832. */
  7833. globalExposure: number;
  7834. private _highlightsHue;
  7835. private _highlightsDensity;
  7836. private _highlightsSaturation;
  7837. private _highlightsExposure;
  7838. /**
  7839. * Gets the highlights Hue value.
  7840. * 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).
  7841. */
  7842. /**
  7843. * Sets the highlights Hue value.
  7844. * 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).
  7845. */
  7846. highlightsHue: number;
  7847. /**
  7848. * Gets the highlights Density value.
  7849. * 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.
  7850. * Values less than zero provide a filter of opposite hue.
  7851. */
  7852. /**
  7853. * Sets the highlights Density value.
  7854. * 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.
  7855. * Values less than zero provide a filter of opposite hue.
  7856. */
  7857. highlightsDensity: number;
  7858. /**
  7859. * Gets the highlights Saturation value.
  7860. * 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.
  7861. */
  7862. /**
  7863. * Sets the highlights Saturation value.
  7864. * 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.
  7865. */
  7866. highlightsSaturation: number;
  7867. /**
  7868. * Gets the highlights Exposure value.
  7869. * 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.
  7870. */
  7871. /**
  7872. * Sets the highlights Exposure value.
  7873. * 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.
  7874. */
  7875. highlightsExposure: number;
  7876. private _midtonesHue;
  7877. private _midtonesDensity;
  7878. private _midtonesSaturation;
  7879. private _midtonesExposure;
  7880. /**
  7881. * Gets the midtones Hue value.
  7882. * 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).
  7883. */
  7884. /**
  7885. * Sets the midtones Hue value.
  7886. * 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).
  7887. */
  7888. midtonesHue: number;
  7889. /**
  7890. * Gets the midtones Density value.
  7891. * 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.
  7892. * Values less than zero provide a filter of opposite hue.
  7893. */
  7894. /**
  7895. * Sets the midtones Density value.
  7896. * 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.
  7897. * Values less than zero provide a filter of opposite hue.
  7898. */
  7899. midtonesDensity: number;
  7900. /**
  7901. * Gets the midtones Saturation value.
  7902. * 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.
  7903. */
  7904. /**
  7905. * Sets the midtones Saturation value.
  7906. * 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.
  7907. */
  7908. midtonesSaturation: number;
  7909. /**
  7910. * Gets the midtones Exposure value.
  7911. * 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.
  7912. */
  7913. /**
  7914. * Sets the midtones Exposure value.
  7915. * 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.
  7916. */
  7917. midtonesExposure: number;
  7918. private _shadowsHue;
  7919. private _shadowsDensity;
  7920. private _shadowsSaturation;
  7921. private _shadowsExposure;
  7922. /**
  7923. * Gets the shadows Hue value.
  7924. * 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).
  7925. */
  7926. /**
  7927. * Sets the shadows Hue value.
  7928. * 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).
  7929. */
  7930. shadowsHue: number;
  7931. /**
  7932. * Gets the shadows Density value.
  7933. * 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.
  7934. * Values less than zero provide a filter of opposite hue.
  7935. */
  7936. /**
  7937. * Sets the shadows Density value.
  7938. * 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.
  7939. * Values less than zero provide a filter of opposite hue.
  7940. */
  7941. shadowsDensity: number;
  7942. /**
  7943. * Gets the shadows Saturation value.
  7944. * 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.
  7945. */
  7946. /**
  7947. * Sets the shadows Saturation value.
  7948. * 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.
  7949. */
  7950. shadowsSaturation: number;
  7951. /**
  7952. * Gets the shadows Exposure value.
  7953. * 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.
  7954. */
  7955. /**
  7956. * Sets the shadows Exposure value.
  7957. * 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.
  7958. */
  7959. shadowsExposure: number;
  7960. /**
  7961. * Returns the class name
  7962. * @returns The class name
  7963. */
  7964. getClassName(): string;
  7965. /**
  7966. * Binds the color curves to the shader.
  7967. * @param colorCurves The color curve to bind
  7968. * @param effect The effect to bind to
  7969. * @param positiveUniform The positive uniform shader parameter
  7970. * @param neutralUniform The neutral uniform shader parameter
  7971. * @param negativeUniform The negative uniform shader parameter
  7972. */
  7973. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7974. /**
  7975. * Prepare the list of uniforms associated with the ColorCurves effects.
  7976. * @param uniformsList The list of uniforms used in the effect
  7977. */
  7978. static PrepareUniforms(uniformsList: string[]): void;
  7979. /**
  7980. * Returns color grading data based on a hue, density, saturation and exposure value.
  7981. * @param filterHue The hue of the color filter.
  7982. * @param filterDensity The density of the color filter.
  7983. * @param saturation The saturation.
  7984. * @param exposure The exposure.
  7985. * @param result The result data container.
  7986. */
  7987. private getColorGradingDataToRef;
  7988. /**
  7989. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7990. * @param value The input slider value in range [-100,100].
  7991. * @returns Adjusted value.
  7992. */
  7993. private static applyColorGradingSliderNonlinear;
  7994. /**
  7995. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7996. * @param hue The hue (H) input.
  7997. * @param saturation The saturation (S) input.
  7998. * @param brightness The brightness (B) input.
  7999. * @result An RGBA color represented as Vector4.
  8000. */
  8001. private static fromHSBToRef;
  8002. /**
  8003. * Returns a value clamped between min and max
  8004. * @param value The value to clamp
  8005. * @param min The minimum of value
  8006. * @param max The maximum of value
  8007. * @returns The clamped value.
  8008. */
  8009. private static clamp;
  8010. /**
  8011. * Clones the current color curve instance.
  8012. * @return The cloned curves
  8013. */
  8014. clone(): ColorCurves;
  8015. /**
  8016. * Serializes the current color curve instance to a json representation.
  8017. * @return a JSON representation
  8018. */
  8019. serialize(): any;
  8020. /**
  8021. * Parses the color curve from a json representation.
  8022. * @param source the JSON source to parse
  8023. * @return The parsed curves
  8024. */
  8025. static Parse(source: any): ColorCurves;
  8026. }
  8027. }
  8028. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8029. import { Observable } from "babylonjs/Misc/observable";
  8030. import { Nullable } from "babylonjs/types";
  8031. import { Color4 } from "babylonjs/Maths/math.color";
  8032. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8033. import { Effect } from "babylonjs/Materials/effect";
  8034. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8035. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8036. /**
  8037. * Interface to follow in your material defines to integrate easily the
  8038. * Image proccessing functions.
  8039. * @hidden
  8040. */
  8041. export interface IImageProcessingConfigurationDefines {
  8042. IMAGEPROCESSING: boolean;
  8043. VIGNETTE: boolean;
  8044. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8045. VIGNETTEBLENDMODEOPAQUE: boolean;
  8046. TONEMAPPING: boolean;
  8047. TONEMAPPING_ACES: boolean;
  8048. CONTRAST: boolean;
  8049. EXPOSURE: boolean;
  8050. COLORCURVES: boolean;
  8051. COLORGRADING: boolean;
  8052. COLORGRADING3D: boolean;
  8053. SAMPLER3DGREENDEPTH: boolean;
  8054. SAMPLER3DBGRMAP: boolean;
  8055. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8056. }
  8057. /**
  8058. * @hidden
  8059. */
  8060. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8061. IMAGEPROCESSING: boolean;
  8062. VIGNETTE: boolean;
  8063. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8064. VIGNETTEBLENDMODEOPAQUE: boolean;
  8065. TONEMAPPING: boolean;
  8066. TONEMAPPING_ACES: boolean;
  8067. CONTRAST: boolean;
  8068. COLORCURVES: boolean;
  8069. COLORGRADING: boolean;
  8070. COLORGRADING3D: boolean;
  8071. SAMPLER3DGREENDEPTH: boolean;
  8072. SAMPLER3DBGRMAP: boolean;
  8073. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8074. EXPOSURE: boolean;
  8075. constructor();
  8076. }
  8077. /**
  8078. * This groups together the common properties used for image processing either in direct forward pass
  8079. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8080. * or not.
  8081. */
  8082. export class ImageProcessingConfiguration {
  8083. /**
  8084. * Default tone mapping applied in BabylonJS.
  8085. */
  8086. static readonly TONEMAPPING_STANDARD: number;
  8087. /**
  8088. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8089. * to other engines rendering to increase portability.
  8090. */
  8091. static readonly TONEMAPPING_ACES: number;
  8092. /**
  8093. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8094. */
  8095. colorCurves: Nullable<ColorCurves>;
  8096. private _colorCurvesEnabled;
  8097. /**
  8098. * Gets wether the color curves effect is enabled.
  8099. */
  8100. /**
  8101. * Sets wether the color curves effect is enabled.
  8102. */
  8103. colorCurvesEnabled: boolean;
  8104. private _colorGradingTexture;
  8105. /**
  8106. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8107. */
  8108. /**
  8109. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8110. */
  8111. colorGradingTexture: Nullable<BaseTexture>;
  8112. private _colorGradingEnabled;
  8113. /**
  8114. * Gets wether the color grading effect is enabled.
  8115. */
  8116. /**
  8117. * Sets wether the color grading effect is enabled.
  8118. */
  8119. colorGradingEnabled: boolean;
  8120. private _colorGradingWithGreenDepth;
  8121. /**
  8122. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8123. */
  8124. /**
  8125. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8126. */
  8127. colorGradingWithGreenDepth: boolean;
  8128. private _colorGradingBGR;
  8129. /**
  8130. * Gets wether the color grading texture contains BGR values.
  8131. */
  8132. /**
  8133. * Sets wether the color grading texture contains BGR values.
  8134. */
  8135. colorGradingBGR: boolean;
  8136. /** @hidden */
  8137. _exposure: number;
  8138. /**
  8139. * Gets the Exposure used in the effect.
  8140. */
  8141. /**
  8142. * Sets the Exposure used in the effect.
  8143. */
  8144. exposure: number;
  8145. private _toneMappingEnabled;
  8146. /**
  8147. * Gets wether the tone mapping effect is enabled.
  8148. */
  8149. /**
  8150. * Sets wether the tone mapping effect is enabled.
  8151. */
  8152. toneMappingEnabled: boolean;
  8153. private _toneMappingType;
  8154. /**
  8155. * Gets the type of tone mapping effect.
  8156. */
  8157. /**
  8158. * Sets the type of tone mapping effect used in BabylonJS.
  8159. */
  8160. toneMappingType: number;
  8161. protected _contrast: number;
  8162. /**
  8163. * Gets the contrast used in the effect.
  8164. */
  8165. /**
  8166. * Sets the contrast used in the effect.
  8167. */
  8168. contrast: number;
  8169. /**
  8170. * Vignette stretch size.
  8171. */
  8172. vignetteStretch: number;
  8173. /**
  8174. * Vignette centre X Offset.
  8175. */
  8176. vignetteCentreX: number;
  8177. /**
  8178. * Vignette centre Y Offset.
  8179. */
  8180. vignetteCentreY: number;
  8181. /**
  8182. * Vignette weight or intensity of the vignette effect.
  8183. */
  8184. vignetteWeight: number;
  8185. /**
  8186. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8187. * if vignetteEnabled is set to true.
  8188. */
  8189. vignetteColor: Color4;
  8190. /**
  8191. * Camera field of view used by the Vignette effect.
  8192. */
  8193. vignetteCameraFov: number;
  8194. private _vignetteBlendMode;
  8195. /**
  8196. * Gets the vignette blend mode allowing different kind of effect.
  8197. */
  8198. /**
  8199. * Sets the vignette blend mode allowing different kind of effect.
  8200. */
  8201. vignetteBlendMode: number;
  8202. private _vignetteEnabled;
  8203. /**
  8204. * Gets wether the vignette effect is enabled.
  8205. */
  8206. /**
  8207. * Sets wether the vignette effect is enabled.
  8208. */
  8209. vignetteEnabled: boolean;
  8210. private _applyByPostProcess;
  8211. /**
  8212. * Gets wether the image processing is applied through a post process or not.
  8213. */
  8214. /**
  8215. * Sets wether the image processing is applied through a post process or not.
  8216. */
  8217. applyByPostProcess: boolean;
  8218. private _isEnabled;
  8219. /**
  8220. * Gets wether the image processing is enabled or not.
  8221. */
  8222. /**
  8223. * Sets wether the image processing is enabled or not.
  8224. */
  8225. isEnabled: boolean;
  8226. /**
  8227. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8228. */
  8229. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8230. /**
  8231. * Method called each time the image processing information changes requires to recompile the effect.
  8232. */
  8233. protected _updateParameters(): void;
  8234. /**
  8235. * Gets the current class name.
  8236. * @return "ImageProcessingConfiguration"
  8237. */
  8238. getClassName(): string;
  8239. /**
  8240. * Prepare the list of uniforms associated with the Image Processing effects.
  8241. * @param uniforms The list of uniforms used in the effect
  8242. * @param defines the list of defines currently in use
  8243. */
  8244. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8245. /**
  8246. * Prepare the list of samplers associated with the Image Processing effects.
  8247. * @param samplersList The list of uniforms used in the effect
  8248. * @param defines the list of defines currently in use
  8249. */
  8250. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8251. /**
  8252. * Prepare the list of defines associated to the shader.
  8253. * @param defines the list of defines to complete
  8254. * @param forPostProcess Define if we are currently in post process mode or not
  8255. */
  8256. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8257. /**
  8258. * Returns true if all the image processing information are ready.
  8259. * @returns True if ready, otherwise, false
  8260. */
  8261. isReady(): boolean;
  8262. /**
  8263. * Binds the image processing to the shader.
  8264. * @param effect The effect to bind to
  8265. * @param aspectRatio Define the current aspect ratio of the effect
  8266. */
  8267. bind(effect: Effect, aspectRatio?: number): void;
  8268. /**
  8269. * Clones the current image processing instance.
  8270. * @return The cloned image processing
  8271. */
  8272. clone(): ImageProcessingConfiguration;
  8273. /**
  8274. * Serializes the current image processing instance to a json representation.
  8275. * @return a JSON representation
  8276. */
  8277. serialize(): any;
  8278. /**
  8279. * Parses the image processing from a json representation.
  8280. * @param source the JSON source to parse
  8281. * @return The parsed image processing
  8282. */
  8283. static Parse(source: any): ImageProcessingConfiguration;
  8284. private static _VIGNETTEMODE_MULTIPLY;
  8285. private static _VIGNETTEMODE_OPAQUE;
  8286. /**
  8287. * Used to apply the vignette as a mix with the pixel color.
  8288. */
  8289. static readonly VIGNETTEMODE_MULTIPLY: number;
  8290. /**
  8291. * Used to apply the vignette as a replacement of the pixel color.
  8292. */
  8293. static readonly VIGNETTEMODE_OPAQUE: number;
  8294. }
  8295. }
  8296. declare module "babylonjs/Shaders/postprocess.vertex" {
  8297. /** @hidden */
  8298. export var postprocessVertexShader: {
  8299. name: string;
  8300. shader: string;
  8301. };
  8302. }
  8303. declare module "babylonjs/Maths/math.axis" {
  8304. import { Vector3 } from "babylonjs/Maths/math.vector";
  8305. /** Defines supported spaces */
  8306. export enum Space {
  8307. /** Local (object) space */
  8308. LOCAL = 0,
  8309. /** World space */
  8310. WORLD = 1,
  8311. /** Bone space */
  8312. BONE = 2
  8313. }
  8314. /** Defines the 3 main axes */
  8315. export class Axis {
  8316. /** X axis */
  8317. static X: Vector3;
  8318. /** Y axis */
  8319. static Y: Vector3;
  8320. /** Z axis */
  8321. static Z: Vector3;
  8322. }
  8323. }
  8324. declare module "babylonjs/Cameras/targetCamera" {
  8325. import { Nullable } from "babylonjs/types";
  8326. import { Camera } from "babylonjs/Cameras/camera";
  8327. import { Scene } from "babylonjs/scene";
  8328. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8329. /**
  8330. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8331. * This is the base of the follow, arc rotate cameras and Free camera
  8332. * @see http://doc.babylonjs.com/features/cameras
  8333. */
  8334. export class TargetCamera extends Camera {
  8335. private static _RigCamTransformMatrix;
  8336. private static _TargetTransformMatrix;
  8337. private static _TargetFocalPoint;
  8338. /**
  8339. * Define the current direction the camera is moving to
  8340. */
  8341. cameraDirection: Vector3;
  8342. /**
  8343. * Define the current rotation the camera is rotating to
  8344. */
  8345. cameraRotation: Vector2;
  8346. /**
  8347. * When set, the up vector of the camera will be updated by the rotation of the camera
  8348. */
  8349. updateUpVectorFromRotation: boolean;
  8350. private _tmpQuaternion;
  8351. /**
  8352. * Define the current rotation of the camera
  8353. */
  8354. rotation: Vector3;
  8355. /**
  8356. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8357. */
  8358. rotationQuaternion: Quaternion;
  8359. /**
  8360. * Define the current speed of the camera
  8361. */
  8362. speed: number;
  8363. /**
  8364. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8365. * around all axis.
  8366. */
  8367. noRotationConstraint: boolean;
  8368. /**
  8369. * Define the current target of the camera as an object or a position.
  8370. */
  8371. lockedTarget: any;
  8372. /** @hidden */
  8373. _currentTarget: Vector3;
  8374. /** @hidden */
  8375. _initialFocalDistance: number;
  8376. /** @hidden */
  8377. _viewMatrix: Matrix;
  8378. /** @hidden */
  8379. _camMatrix: Matrix;
  8380. /** @hidden */
  8381. _cameraTransformMatrix: Matrix;
  8382. /** @hidden */
  8383. _cameraRotationMatrix: Matrix;
  8384. /** @hidden */
  8385. _referencePoint: Vector3;
  8386. /** @hidden */
  8387. _transformedReferencePoint: Vector3;
  8388. protected _globalCurrentTarget: Vector3;
  8389. protected _globalCurrentUpVector: Vector3;
  8390. /** @hidden */
  8391. _reset: () => void;
  8392. private _defaultUp;
  8393. /**
  8394. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8395. * This is the base of the follow, arc rotate cameras and Free camera
  8396. * @see http://doc.babylonjs.com/features/cameras
  8397. * @param name Defines the name of the camera in the scene
  8398. * @param position Defines the start position of the camera in the scene
  8399. * @param scene Defines the scene the camera belongs to
  8400. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8401. */
  8402. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8403. /**
  8404. * Gets the position in front of the camera at a given distance.
  8405. * @param distance The distance from the camera we want the position to be
  8406. * @returns the position
  8407. */
  8408. getFrontPosition(distance: number): Vector3;
  8409. /** @hidden */
  8410. _getLockedTargetPosition(): Nullable<Vector3>;
  8411. private _storedPosition;
  8412. private _storedRotation;
  8413. private _storedRotationQuaternion;
  8414. /**
  8415. * Store current camera state of the camera (fov, position, rotation, etc..)
  8416. * @returns the camera
  8417. */
  8418. storeState(): Camera;
  8419. /**
  8420. * Restored camera state. You must call storeState() first
  8421. * @returns whether it was successful or not
  8422. * @hidden
  8423. */
  8424. _restoreStateValues(): boolean;
  8425. /** @hidden */
  8426. _initCache(): void;
  8427. /** @hidden */
  8428. _updateCache(ignoreParentClass?: boolean): void;
  8429. /** @hidden */
  8430. _isSynchronizedViewMatrix(): boolean;
  8431. /** @hidden */
  8432. _computeLocalCameraSpeed(): number;
  8433. /**
  8434. * Defines the target the camera should look at.
  8435. * @param target Defines the new target as a Vector or a mesh
  8436. */
  8437. setTarget(target: Vector3): void;
  8438. /**
  8439. * Return the current target position of the camera. This value is expressed in local space.
  8440. * @returns the target position
  8441. */
  8442. getTarget(): Vector3;
  8443. /** @hidden */
  8444. _decideIfNeedsToMove(): boolean;
  8445. /** @hidden */
  8446. _updatePosition(): void;
  8447. /** @hidden */
  8448. _checkInputs(): void;
  8449. protected _updateCameraRotationMatrix(): void;
  8450. /**
  8451. * 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)
  8452. * @returns the current camera
  8453. */
  8454. private _rotateUpVectorWithCameraRotationMatrix;
  8455. private _cachedRotationZ;
  8456. private _cachedQuaternionRotationZ;
  8457. /** @hidden */
  8458. _getViewMatrix(): Matrix;
  8459. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8460. /**
  8461. * @hidden
  8462. */
  8463. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8464. /**
  8465. * @hidden
  8466. */
  8467. _updateRigCameras(): void;
  8468. private _getRigCamPositionAndTarget;
  8469. /**
  8470. * Gets the current object class name.
  8471. * @return the class name
  8472. */
  8473. getClassName(): string;
  8474. }
  8475. }
  8476. declare module "babylonjs/Events/keyboardEvents" {
  8477. /**
  8478. * Gather the list of keyboard event types as constants.
  8479. */
  8480. export class KeyboardEventTypes {
  8481. /**
  8482. * The keydown event is fired when a key becomes active (pressed).
  8483. */
  8484. static readonly KEYDOWN: number;
  8485. /**
  8486. * The keyup event is fired when a key has been released.
  8487. */
  8488. static readonly KEYUP: number;
  8489. }
  8490. /**
  8491. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8492. */
  8493. export class KeyboardInfo {
  8494. /**
  8495. * Defines the type of event (KeyboardEventTypes)
  8496. */
  8497. type: number;
  8498. /**
  8499. * Defines the related dom event
  8500. */
  8501. event: KeyboardEvent;
  8502. /**
  8503. * Instantiates a new keyboard info.
  8504. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8505. * @param type Defines the type of event (KeyboardEventTypes)
  8506. * @param event Defines the related dom event
  8507. */
  8508. constructor(
  8509. /**
  8510. * Defines the type of event (KeyboardEventTypes)
  8511. */
  8512. type: number,
  8513. /**
  8514. * Defines the related dom event
  8515. */
  8516. event: KeyboardEvent);
  8517. }
  8518. /**
  8519. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8520. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8521. */
  8522. export class KeyboardInfoPre extends KeyboardInfo {
  8523. /**
  8524. * Defines the type of event (KeyboardEventTypes)
  8525. */
  8526. type: number;
  8527. /**
  8528. * Defines the related dom event
  8529. */
  8530. event: KeyboardEvent;
  8531. /**
  8532. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8533. */
  8534. skipOnPointerObservable: boolean;
  8535. /**
  8536. * Instantiates a new keyboard pre info.
  8537. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8538. * @param type Defines the type of event (KeyboardEventTypes)
  8539. * @param event Defines the related dom event
  8540. */
  8541. constructor(
  8542. /**
  8543. * Defines the type of event (KeyboardEventTypes)
  8544. */
  8545. type: number,
  8546. /**
  8547. * Defines the related dom event
  8548. */
  8549. event: KeyboardEvent);
  8550. }
  8551. }
  8552. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8553. import { Nullable } from "babylonjs/types";
  8554. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8555. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8556. /**
  8557. * Manage the keyboard inputs to control the movement of a free camera.
  8558. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8559. */
  8560. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8561. /**
  8562. * Defines the camera the input is attached to.
  8563. */
  8564. camera: FreeCamera;
  8565. /**
  8566. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8567. */
  8568. keysUp: number[];
  8569. /**
  8570. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8571. */
  8572. keysDown: number[];
  8573. /**
  8574. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8575. */
  8576. keysLeft: number[];
  8577. /**
  8578. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8579. */
  8580. keysRight: number[];
  8581. private _keys;
  8582. private _onCanvasBlurObserver;
  8583. private _onKeyboardObserver;
  8584. private _engine;
  8585. private _scene;
  8586. /**
  8587. * Attach the input controls to a specific dom element to get the input from.
  8588. * @param element Defines the element the controls should be listened from
  8589. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8590. */
  8591. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8592. /**
  8593. * Detach the current controls from the specified dom element.
  8594. * @param element Defines the element to stop listening the inputs from
  8595. */
  8596. detachControl(element: Nullable<HTMLElement>): void;
  8597. /**
  8598. * Update the current camera state depending on the inputs that have been used this frame.
  8599. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8600. */
  8601. checkInputs(): void;
  8602. /**
  8603. * Gets the class name of the current intput.
  8604. * @returns the class name
  8605. */
  8606. getClassName(): string;
  8607. /** @hidden */
  8608. _onLostFocus(): void;
  8609. /**
  8610. * Get the friendly name associated with the input class.
  8611. * @returns the input friendly name
  8612. */
  8613. getSimpleName(): string;
  8614. }
  8615. }
  8616. declare module "babylonjs/Lights/shadowLight" {
  8617. import { Camera } from "babylonjs/Cameras/camera";
  8618. import { Scene } from "babylonjs/scene";
  8619. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8621. import { Light } from "babylonjs/Lights/light";
  8622. /**
  8623. * Interface describing all the common properties and methods a shadow light needs to implement.
  8624. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8625. * as well as binding the different shadow properties to the effects.
  8626. */
  8627. export interface IShadowLight extends Light {
  8628. /**
  8629. * The light id in the scene (used in scene.findLighById for instance)
  8630. */
  8631. id: string;
  8632. /**
  8633. * The position the shdow will be casted from.
  8634. */
  8635. position: Vector3;
  8636. /**
  8637. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8638. */
  8639. direction: Vector3;
  8640. /**
  8641. * The transformed position. Position of the light in world space taking parenting in account.
  8642. */
  8643. transformedPosition: Vector3;
  8644. /**
  8645. * The transformed direction. Direction of the light in world space taking parenting in account.
  8646. */
  8647. transformedDirection: Vector3;
  8648. /**
  8649. * The friendly name of the light in the scene.
  8650. */
  8651. name: string;
  8652. /**
  8653. * Defines the shadow projection clipping minimum z value.
  8654. */
  8655. shadowMinZ: number;
  8656. /**
  8657. * Defines the shadow projection clipping maximum z value.
  8658. */
  8659. shadowMaxZ: number;
  8660. /**
  8661. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8662. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8663. */
  8664. computeTransformedInformation(): boolean;
  8665. /**
  8666. * Gets the scene the light belongs to.
  8667. * @returns The scene
  8668. */
  8669. getScene(): Scene;
  8670. /**
  8671. * Callback defining a custom Projection Matrix Builder.
  8672. * This can be used to override the default projection matrix computation.
  8673. */
  8674. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8675. /**
  8676. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8677. * @param matrix The materix to updated with the projection information
  8678. * @param viewMatrix The transform matrix of the light
  8679. * @param renderList The list of mesh to render in the map
  8680. * @returns The current light
  8681. */
  8682. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8683. /**
  8684. * Gets the current depth scale used in ESM.
  8685. * @returns The scale
  8686. */
  8687. getDepthScale(): number;
  8688. /**
  8689. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8690. * @returns true if a cube texture needs to be use
  8691. */
  8692. needCube(): boolean;
  8693. /**
  8694. * Detects if the projection matrix requires to be recomputed this frame.
  8695. * @returns true if it requires to be recomputed otherwise, false.
  8696. */
  8697. needProjectionMatrixCompute(): boolean;
  8698. /**
  8699. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8700. */
  8701. forceProjectionMatrixCompute(): void;
  8702. /**
  8703. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8704. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8705. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8706. */
  8707. getShadowDirection(faceIndex?: number): Vector3;
  8708. /**
  8709. * Gets the minZ used for shadow according to both the scene and the light.
  8710. * @param activeCamera The camera we are returning the min for
  8711. * @returns the depth min z
  8712. */
  8713. getDepthMinZ(activeCamera: Camera): number;
  8714. /**
  8715. * Gets the maxZ used for shadow according to both the scene and the light.
  8716. * @param activeCamera The camera we are returning the max for
  8717. * @returns the depth max z
  8718. */
  8719. getDepthMaxZ(activeCamera: Camera): number;
  8720. }
  8721. /**
  8722. * Base implementation IShadowLight
  8723. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8724. */
  8725. export abstract class ShadowLight extends Light implements IShadowLight {
  8726. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8727. protected _position: Vector3;
  8728. protected _setPosition(value: Vector3): void;
  8729. /**
  8730. * Sets the position the shadow will be casted from. Also use as the light position for both
  8731. * point and spot lights.
  8732. */
  8733. /**
  8734. * Sets the position the shadow will be casted from. Also use as the light position for both
  8735. * point and spot lights.
  8736. */
  8737. position: Vector3;
  8738. protected _direction: Vector3;
  8739. protected _setDirection(value: Vector3): void;
  8740. /**
  8741. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8742. * Also use as the light direction on spot and directional lights.
  8743. */
  8744. /**
  8745. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8746. * Also use as the light direction on spot and directional lights.
  8747. */
  8748. direction: Vector3;
  8749. private _shadowMinZ;
  8750. /**
  8751. * Gets the shadow projection clipping minimum z value.
  8752. */
  8753. /**
  8754. * Sets the shadow projection clipping minimum z value.
  8755. */
  8756. shadowMinZ: number;
  8757. private _shadowMaxZ;
  8758. /**
  8759. * Sets the shadow projection clipping maximum z value.
  8760. */
  8761. /**
  8762. * Gets the shadow projection clipping maximum z value.
  8763. */
  8764. shadowMaxZ: number;
  8765. /**
  8766. * Callback defining a custom Projection Matrix Builder.
  8767. * This can be used to override the default projection matrix computation.
  8768. */
  8769. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8770. /**
  8771. * The transformed position. Position of the light in world space taking parenting in account.
  8772. */
  8773. transformedPosition: Vector3;
  8774. /**
  8775. * The transformed direction. Direction of the light in world space taking parenting in account.
  8776. */
  8777. transformedDirection: Vector3;
  8778. private _needProjectionMatrixCompute;
  8779. /**
  8780. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8781. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8782. */
  8783. computeTransformedInformation(): boolean;
  8784. /**
  8785. * Return the depth scale used for the shadow map.
  8786. * @returns the depth scale.
  8787. */
  8788. getDepthScale(): number;
  8789. /**
  8790. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8791. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8792. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8793. */
  8794. getShadowDirection(faceIndex?: number): Vector3;
  8795. /**
  8796. * Returns the ShadowLight absolute position in the World.
  8797. * @returns the position vector in world space
  8798. */
  8799. getAbsolutePosition(): Vector3;
  8800. /**
  8801. * Sets the ShadowLight direction toward the passed target.
  8802. * @param target The point to target in local space
  8803. * @returns the updated ShadowLight direction
  8804. */
  8805. setDirectionToTarget(target: Vector3): Vector3;
  8806. /**
  8807. * Returns the light rotation in euler definition.
  8808. * @returns the x y z rotation in local space.
  8809. */
  8810. getRotation(): Vector3;
  8811. /**
  8812. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8813. * @returns true if a cube texture needs to be use
  8814. */
  8815. needCube(): boolean;
  8816. /**
  8817. * Detects if the projection matrix requires to be recomputed this frame.
  8818. * @returns true if it requires to be recomputed otherwise, false.
  8819. */
  8820. needProjectionMatrixCompute(): boolean;
  8821. /**
  8822. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8823. */
  8824. forceProjectionMatrixCompute(): void;
  8825. /** @hidden */
  8826. _initCache(): void;
  8827. /** @hidden */
  8828. _isSynchronized(): boolean;
  8829. /**
  8830. * Computes the world matrix of the node
  8831. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8832. * @returns the world matrix
  8833. */
  8834. computeWorldMatrix(force?: boolean): Matrix;
  8835. /**
  8836. * Gets the minZ used for shadow according to both the scene and the light.
  8837. * @param activeCamera The camera we are returning the min for
  8838. * @returns the depth min z
  8839. */
  8840. getDepthMinZ(activeCamera: Camera): number;
  8841. /**
  8842. * Gets the maxZ used for shadow according to both the scene and the light.
  8843. * @param activeCamera The camera we are returning the max for
  8844. * @returns the depth max z
  8845. */
  8846. getDepthMaxZ(activeCamera: Camera): number;
  8847. /**
  8848. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8849. * @param matrix The materix to updated with the projection information
  8850. * @param viewMatrix The transform matrix of the light
  8851. * @param renderList The list of mesh to render in the map
  8852. * @returns The current light
  8853. */
  8854. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8855. }
  8856. }
  8857. declare module "babylonjs/Materials/materialHelper" {
  8858. import { Nullable } from "babylonjs/types";
  8859. import { Scene } from "babylonjs/scene";
  8860. import { Engine } from "babylonjs/Engines/engine";
  8861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8862. import { Light } from "babylonjs/Lights/light";
  8863. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8864. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  8865. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8866. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8867. /**
  8868. * "Static Class" containing the most commonly used helper while dealing with material for
  8869. * rendering purpose.
  8870. *
  8871. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8872. *
  8873. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8874. */
  8875. export class MaterialHelper {
  8876. /**
  8877. * Bind the current view position to an effect.
  8878. * @param effect The effect to be bound
  8879. * @param scene The scene the eyes position is used from
  8880. */
  8881. static BindEyePosition(effect: Effect, scene: Scene): void;
  8882. /**
  8883. * Helps preparing the defines values about the UVs in used in the effect.
  8884. * UVs are shared as much as we can accross channels in the shaders.
  8885. * @param texture The texture we are preparing the UVs for
  8886. * @param defines The defines to update
  8887. * @param key The channel key "diffuse", "specular"... used in the shader
  8888. */
  8889. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8890. /**
  8891. * Binds a texture matrix value to its corrsponding uniform
  8892. * @param texture The texture to bind the matrix for
  8893. * @param uniformBuffer The uniform buffer receivin the data
  8894. * @param key The channel key "diffuse", "specular"... used in the shader
  8895. */
  8896. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8897. /**
  8898. * Gets the current status of the fog (should it be enabled?)
  8899. * @param mesh defines the mesh to evaluate for fog support
  8900. * @param scene defines the hosting scene
  8901. * @returns true if fog must be enabled
  8902. */
  8903. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8904. /**
  8905. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8906. * @param mesh defines the current mesh
  8907. * @param scene defines the current scene
  8908. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8909. * @param pointsCloud defines if point cloud rendering has to be turned on
  8910. * @param fogEnabled defines if fog has to be turned on
  8911. * @param alphaTest defines if alpha testing has to be turned on
  8912. * @param defines defines the current list of defines
  8913. */
  8914. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8915. /**
  8916. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8917. * @param scene defines the current scene
  8918. * @param engine defines the current engine
  8919. * @param defines specifies the list of active defines
  8920. * @param useInstances defines if instances have to be turned on
  8921. * @param useClipPlane defines if clip plane have to be turned on
  8922. */
  8923. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8924. /**
  8925. * Prepares the defines for bones
  8926. * @param mesh The mesh containing the geometry data we will draw
  8927. * @param defines The defines to update
  8928. */
  8929. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8930. /**
  8931. * Prepares the defines for morph targets
  8932. * @param mesh The mesh containing the geometry data we will draw
  8933. * @param defines The defines to update
  8934. */
  8935. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8936. /**
  8937. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8938. * @param mesh The mesh containing the geometry data we will draw
  8939. * @param defines The defines to update
  8940. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8941. * @param useBones Precise whether bones should be used or not (override mesh info)
  8942. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8943. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8944. * @returns false if defines are considered not dirty and have not been checked
  8945. */
  8946. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8947. /**
  8948. * Prepares the defines related to multiview
  8949. * @param scene The scene we are intending to draw
  8950. * @param defines The defines to update
  8951. */
  8952. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8953. /**
  8954. * Prepares the defines related to the light information passed in parameter
  8955. * @param scene The scene we are intending to draw
  8956. * @param mesh The mesh the effect is compiling for
  8957. * @param light The light the effect is compiling for
  8958. * @param lightIndex The index of the light
  8959. * @param defines The defines to update
  8960. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8961. * @param state Defines the current state regarding what is needed (normals, etc...)
  8962. */
  8963. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8964. needNormals: boolean;
  8965. needRebuild: boolean;
  8966. shadowEnabled: boolean;
  8967. specularEnabled: boolean;
  8968. lightmapMode: boolean;
  8969. }): void;
  8970. /**
  8971. * Prepares the defines related to the light information passed in parameter
  8972. * @param scene The scene we are intending to draw
  8973. * @param mesh The mesh the effect is compiling for
  8974. * @param defines The defines to update
  8975. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8976. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8977. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8978. * @returns true if normals will be required for the rest of the effect
  8979. */
  8980. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8981. /**
  8982. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8983. * @param lightIndex defines the light index
  8984. * @param uniformsList The uniform list
  8985. * @param samplersList The sampler list
  8986. * @param projectedLightTexture defines if projected texture must be used
  8987. * @param uniformBuffersList defines an optional list of uniform buffers
  8988. */
  8989. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8990. /**
  8991. * Prepares the uniforms and samplers list to be used in the effect
  8992. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8993. * @param samplersList The sampler list
  8994. * @param defines The defines helping in the list generation
  8995. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8996. */
  8997. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8998. /**
  8999. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9000. * @param defines The defines to update while falling back
  9001. * @param fallbacks The authorized effect fallbacks
  9002. * @param maxSimultaneousLights The maximum number of lights allowed
  9003. * @param rank the current rank of the Effect
  9004. * @returns The newly affected rank
  9005. */
  9006. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9007. private static _TmpMorphInfluencers;
  9008. /**
  9009. * Prepares the list of attributes required for morph targets according to the effect defines.
  9010. * @param attribs The current list of supported attribs
  9011. * @param mesh The mesh to prepare the morph targets attributes for
  9012. * @param influencers The number of influencers
  9013. */
  9014. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9015. /**
  9016. * Prepares the list of attributes required for morph targets according to the effect defines.
  9017. * @param attribs The current list of supported attribs
  9018. * @param mesh The mesh to prepare the morph targets attributes for
  9019. * @param defines The current Defines of the effect
  9020. */
  9021. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9022. /**
  9023. * Prepares the list of attributes required for bones according to the effect defines.
  9024. * @param attribs The current list of supported attribs
  9025. * @param mesh The mesh to prepare the bones attributes for
  9026. * @param defines The current Defines of the effect
  9027. * @param fallbacks The current efffect fallback strategy
  9028. */
  9029. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9030. /**
  9031. * Check and prepare the list of attributes required for instances according to the effect defines.
  9032. * @param attribs The current list of supported attribs
  9033. * @param defines The current MaterialDefines of the effect
  9034. */
  9035. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9036. /**
  9037. * Add the list of attributes required for instances to the attribs array.
  9038. * @param attribs The current list of supported attribs
  9039. */
  9040. static PushAttributesForInstances(attribs: string[]): void;
  9041. /**
  9042. * Binds the light shadow information to the effect for the given mesh.
  9043. * @param light The light containing the generator
  9044. * @param scene The scene the lights belongs to
  9045. * @param mesh The mesh we are binding the information to render
  9046. * @param lightIndex The light index in the effect used to render the mesh
  9047. * @param effect The effect we are binding the data to
  9048. */
  9049. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9050. /**
  9051. * Binds the light information to the effect.
  9052. * @param light The light containing the generator
  9053. * @param effect The effect we are binding the data to
  9054. * @param lightIndex The light index in the effect used to render
  9055. */
  9056. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9057. /**
  9058. * Binds the lights information from the scene to the effect for the given mesh.
  9059. * @param light Light to bind
  9060. * @param lightIndex Light index
  9061. * @param scene The scene where the light belongs to
  9062. * @param mesh The mesh we are binding the information to render
  9063. * @param effect The effect we are binding the data to
  9064. * @param useSpecular Defines if specular is supported
  9065. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9066. */
  9067. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  9068. /**
  9069. * Binds the lights information from the scene to the effect for the given mesh.
  9070. * @param scene The scene the lights belongs to
  9071. * @param mesh The mesh we are binding the information to render
  9072. * @param effect The effect we are binding the data to
  9073. * @param defines The generated defines for the effect
  9074. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9075. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9076. */
  9077. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9078. private static _tempFogColor;
  9079. /**
  9080. * Binds the fog information from the scene to the effect for the given mesh.
  9081. * @param scene The scene the lights belongs to
  9082. * @param mesh The mesh we are binding the information to render
  9083. * @param effect The effect we are binding the data to
  9084. * @param linearSpace Defines if the fog effect is applied in linear space
  9085. */
  9086. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9087. /**
  9088. * Binds the bones information from the mesh to the effect.
  9089. * @param mesh The mesh we are binding the information to render
  9090. * @param effect The effect we are binding the data to
  9091. */
  9092. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9093. /**
  9094. * Binds the morph targets information from the mesh to the effect.
  9095. * @param abstractMesh The mesh we are binding the information to render
  9096. * @param effect The effect we are binding the data to
  9097. */
  9098. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9099. /**
  9100. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9101. * @param defines The generated defines used in the effect
  9102. * @param effect The effect we are binding the data to
  9103. * @param scene The scene we are willing to render with logarithmic scale for
  9104. */
  9105. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9106. /**
  9107. * Binds the clip plane information from the scene to the effect.
  9108. * @param scene The scene the clip plane information are extracted from
  9109. * @param effect The effect we are binding the data to
  9110. */
  9111. static BindClipPlane(effect: Effect, scene: Scene): void;
  9112. }
  9113. }
  9114. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9115. /** @hidden */
  9116. export var packingFunctions: {
  9117. name: string;
  9118. shader: string;
  9119. };
  9120. }
  9121. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9122. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9123. /** @hidden */
  9124. export var shadowMapPixelShader: {
  9125. name: string;
  9126. shader: string;
  9127. };
  9128. }
  9129. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9130. /** @hidden */
  9131. export var bonesDeclaration: {
  9132. name: string;
  9133. shader: string;
  9134. };
  9135. }
  9136. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9137. /** @hidden */
  9138. export var morphTargetsVertexGlobalDeclaration: {
  9139. name: string;
  9140. shader: string;
  9141. };
  9142. }
  9143. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9144. /** @hidden */
  9145. export var morphTargetsVertexDeclaration: {
  9146. name: string;
  9147. shader: string;
  9148. };
  9149. }
  9150. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9151. /** @hidden */
  9152. export var instancesDeclaration: {
  9153. name: string;
  9154. shader: string;
  9155. };
  9156. }
  9157. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9158. /** @hidden */
  9159. export var helperFunctions: {
  9160. name: string;
  9161. shader: string;
  9162. };
  9163. }
  9164. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9165. /** @hidden */
  9166. export var morphTargetsVertex: {
  9167. name: string;
  9168. shader: string;
  9169. };
  9170. }
  9171. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9172. /** @hidden */
  9173. export var instancesVertex: {
  9174. name: string;
  9175. shader: string;
  9176. };
  9177. }
  9178. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9179. /** @hidden */
  9180. export var bonesVertex: {
  9181. name: string;
  9182. shader: string;
  9183. };
  9184. }
  9185. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9186. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9187. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9188. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9189. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9190. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9191. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9192. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9193. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9194. /** @hidden */
  9195. export var shadowMapVertexShader: {
  9196. name: string;
  9197. shader: string;
  9198. };
  9199. }
  9200. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9201. /** @hidden */
  9202. export var depthBoxBlurPixelShader: {
  9203. name: string;
  9204. shader: string;
  9205. };
  9206. }
  9207. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9208. import { Nullable } from "babylonjs/types";
  9209. import { Scene } from "babylonjs/scene";
  9210. import { Matrix } from "babylonjs/Maths/math.vector";
  9211. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9213. import { Mesh } from "babylonjs/Meshes/mesh";
  9214. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9215. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9216. import { Effect } from "babylonjs/Materials/effect";
  9217. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9218. import "babylonjs/Shaders/shadowMap.fragment";
  9219. import "babylonjs/Shaders/shadowMap.vertex";
  9220. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9221. import { Observable } from "babylonjs/Misc/observable";
  9222. /**
  9223. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9224. */
  9225. export interface ICustomShaderOptions {
  9226. /**
  9227. * Gets or sets the custom shader name to use
  9228. */
  9229. shaderName: string;
  9230. /**
  9231. * The list of attribute names used in the shader
  9232. */
  9233. attributes?: string[];
  9234. /**
  9235. * The list of unifrom names used in the shader
  9236. */
  9237. uniforms?: string[];
  9238. /**
  9239. * The list of sampler names used in the shader
  9240. */
  9241. samplers?: string[];
  9242. /**
  9243. * The list of defines used in the shader
  9244. */
  9245. defines?: string[];
  9246. }
  9247. /**
  9248. * Interface to implement to create a shadow generator compatible with BJS.
  9249. */
  9250. export interface IShadowGenerator {
  9251. /**
  9252. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9253. * @returns The render target texture if present otherwise, null
  9254. */
  9255. getShadowMap(): Nullable<RenderTargetTexture>;
  9256. /**
  9257. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9258. * @returns The render target texture if the shadow map is present otherwise, null
  9259. */
  9260. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9261. /**
  9262. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9263. * @param subMesh The submesh we want to render in the shadow map
  9264. * @param useInstances Defines wether will draw in the map using instances
  9265. * @returns true if ready otherwise, false
  9266. */
  9267. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9268. /**
  9269. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9270. * @param defines Defines of the material we want to update
  9271. * @param lightIndex Index of the light in the enabled light list of the material
  9272. */
  9273. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9274. /**
  9275. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9276. * defined in the generator but impacting the effect).
  9277. * It implies the unifroms available on the materials are the standard BJS ones.
  9278. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9279. * @param effect The effect we are binfing the information for
  9280. */
  9281. bindShadowLight(lightIndex: string, effect: Effect): void;
  9282. /**
  9283. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9284. * (eq to shadow prjection matrix * light transform matrix)
  9285. * @returns The transform matrix used to create the shadow map
  9286. */
  9287. getTransformMatrix(): Matrix;
  9288. /**
  9289. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9290. * Cube and 2D textures for instance.
  9291. */
  9292. recreateShadowMap(): void;
  9293. /**
  9294. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9295. * @param onCompiled Callback triggered at the and of the effects compilation
  9296. * @param options Sets of optional options forcing the compilation with different modes
  9297. */
  9298. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9299. useInstances: boolean;
  9300. }>): void;
  9301. /**
  9302. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9303. * @param options Sets of optional options forcing the compilation with different modes
  9304. * @returns A promise that resolves when the compilation completes
  9305. */
  9306. forceCompilationAsync(options?: Partial<{
  9307. useInstances: boolean;
  9308. }>): Promise<void>;
  9309. /**
  9310. * Serializes the shadow generator setup to a json object.
  9311. * @returns The serialized JSON object
  9312. */
  9313. serialize(): any;
  9314. /**
  9315. * Disposes the Shadow map and related Textures and effects.
  9316. */
  9317. dispose(): void;
  9318. }
  9319. /**
  9320. * Default implementation IShadowGenerator.
  9321. * This is the main object responsible of generating shadows in the framework.
  9322. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9323. */
  9324. export class ShadowGenerator implements IShadowGenerator {
  9325. /**
  9326. * Shadow generator mode None: no filtering applied.
  9327. */
  9328. static readonly FILTER_NONE: number;
  9329. /**
  9330. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9331. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9332. */
  9333. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9334. /**
  9335. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9336. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9337. */
  9338. static readonly FILTER_POISSONSAMPLING: number;
  9339. /**
  9340. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9341. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9342. */
  9343. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9344. /**
  9345. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9346. * edge artifacts on steep falloff.
  9347. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9348. */
  9349. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9350. /**
  9351. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9352. * edge artifacts on steep falloff.
  9353. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9354. */
  9355. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9356. /**
  9357. * Shadow generator mode PCF: Percentage Closer Filtering
  9358. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9359. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9360. */
  9361. static readonly FILTER_PCF: number;
  9362. /**
  9363. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9364. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9365. * Contact Hardening
  9366. */
  9367. static readonly FILTER_PCSS: number;
  9368. /**
  9369. * Reserved for PCF and PCSS
  9370. * Highest Quality.
  9371. *
  9372. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9373. *
  9374. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9375. */
  9376. static readonly QUALITY_HIGH: number;
  9377. /**
  9378. * Reserved for PCF and PCSS
  9379. * Good tradeoff for quality/perf cross devices
  9380. *
  9381. * Execute PCF on a 3*3 kernel.
  9382. *
  9383. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9384. */
  9385. static readonly QUALITY_MEDIUM: number;
  9386. /**
  9387. * Reserved for PCF and PCSS
  9388. * The lowest quality but the fastest.
  9389. *
  9390. * Execute PCF on a 1*1 kernel.
  9391. *
  9392. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9393. */
  9394. static readonly QUALITY_LOW: number;
  9395. /** Gets or sets the custom shader name to use */
  9396. customShaderOptions: ICustomShaderOptions;
  9397. /**
  9398. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9399. */
  9400. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9401. /**
  9402. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9403. */
  9404. onAfterShadowMapRenderObservable: Observable<Effect>;
  9405. /**
  9406. * Observable triggered before a mesh is rendered in the shadow map.
  9407. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9408. */
  9409. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9410. /**
  9411. * Observable triggered after a mesh is rendered in the shadow map.
  9412. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9413. */
  9414. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9415. private _bias;
  9416. /**
  9417. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9418. */
  9419. /**
  9420. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9421. */
  9422. bias: number;
  9423. private _normalBias;
  9424. /**
  9425. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9426. */
  9427. /**
  9428. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9429. */
  9430. normalBias: number;
  9431. private _blurBoxOffset;
  9432. /**
  9433. * Gets the blur box offset: offset applied during the blur pass.
  9434. * Only useful if useKernelBlur = false
  9435. */
  9436. /**
  9437. * Sets the blur box offset: offset applied during the blur pass.
  9438. * Only useful if useKernelBlur = false
  9439. */
  9440. blurBoxOffset: number;
  9441. private _blurScale;
  9442. /**
  9443. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9444. * 2 means half of the size.
  9445. */
  9446. /**
  9447. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9448. * 2 means half of the size.
  9449. */
  9450. blurScale: number;
  9451. private _blurKernel;
  9452. /**
  9453. * Gets the blur kernel: kernel size of the blur pass.
  9454. * Only useful if useKernelBlur = true
  9455. */
  9456. /**
  9457. * Sets the blur kernel: kernel size of the blur pass.
  9458. * Only useful if useKernelBlur = true
  9459. */
  9460. blurKernel: number;
  9461. private _useKernelBlur;
  9462. /**
  9463. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9464. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9465. */
  9466. /**
  9467. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9468. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9469. */
  9470. useKernelBlur: boolean;
  9471. private _depthScale;
  9472. /**
  9473. * Gets the depth scale used in ESM mode.
  9474. */
  9475. /**
  9476. * Sets the depth scale used in ESM mode.
  9477. * This can override the scale stored on the light.
  9478. */
  9479. depthScale: number;
  9480. private _filter;
  9481. /**
  9482. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9483. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9484. */
  9485. /**
  9486. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9487. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9488. */
  9489. filter: number;
  9490. /**
  9491. * Gets if the current filter is set to Poisson Sampling.
  9492. */
  9493. /**
  9494. * Sets the current filter to Poisson Sampling.
  9495. */
  9496. usePoissonSampling: boolean;
  9497. /**
  9498. * Gets if the current filter is set to ESM.
  9499. */
  9500. /**
  9501. * Sets the current filter is to ESM.
  9502. */
  9503. useExponentialShadowMap: boolean;
  9504. /**
  9505. * Gets if the current filter is set to filtered ESM.
  9506. */
  9507. /**
  9508. * Gets if the current filter is set to filtered ESM.
  9509. */
  9510. useBlurExponentialShadowMap: boolean;
  9511. /**
  9512. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9513. * exponential to prevent steep falloff artifacts).
  9514. */
  9515. /**
  9516. * Sets the current filter to "close ESM" (using the inverse of the
  9517. * exponential to prevent steep falloff artifacts).
  9518. */
  9519. useCloseExponentialShadowMap: boolean;
  9520. /**
  9521. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9522. * exponential to prevent steep falloff artifacts).
  9523. */
  9524. /**
  9525. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9526. * exponential to prevent steep falloff artifacts).
  9527. */
  9528. useBlurCloseExponentialShadowMap: boolean;
  9529. /**
  9530. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9531. */
  9532. /**
  9533. * Sets the current filter to "PCF" (percentage closer filtering).
  9534. */
  9535. usePercentageCloserFiltering: boolean;
  9536. private _filteringQuality;
  9537. /**
  9538. * Gets the PCF or PCSS Quality.
  9539. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9540. */
  9541. /**
  9542. * Sets the PCF or PCSS Quality.
  9543. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9544. */
  9545. filteringQuality: number;
  9546. /**
  9547. * Gets if the current filter is set to "PCSS" (contact hardening).
  9548. */
  9549. /**
  9550. * Sets the current filter to "PCSS" (contact hardening).
  9551. */
  9552. useContactHardeningShadow: boolean;
  9553. private _contactHardeningLightSizeUVRatio;
  9554. /**
  9555. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9556. * Using a ratio helps keeping shape stability independently of the map size.
  9557. *
  9558. * It does not account for the light projection as it was having too much
  9559. * instability during the light setup or during light position changes.
  9560. *
  9561. * Only valid if useContactHardeningShadow is true.
  9562. */
  9563. /**
  9564. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9565. * Using a ratio helps keeping shape stability independently of the map size.
  9566. *
  9567. * It does not account for the light projection as it was having too much
  9568. * instability during the light setup or during light position changes.
  9569. *
  9570. * Only valid if useContactHardeningShadow is true.
  9571. */
  9572. contactHardeningLightSizeUVRatio: number;
  9573. private _darkness;
  9574. /** Gets or sets the actual darkness of a shadow */
  9575. darkness: number;
  9576. /**
  9577. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9578. * 0 means strongest and 1 would means no shadow.
  9579. * @returns the darkness.
  9580. */
  9581. getDarkness(): number;
  9582. /**
  9583. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9584. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9585. * @returns the shadow generator allowing fluent coding.
  9586. */
  9587. setDarkness(darkness: number): ShadowGenerator;
  9588. private _transparencyShadow;
  9589. /** Gets or sets the ability to have transparent shadow */
  9590. transparencyShadow: boolean;
  9591. /**
  9592. * Sets the ability to have transparent shadow (boolean).
  9593. * @param transparent True if transparent else False
  9594. * @returns the shadow generator allowing fluent coding
  9595. */
  9596. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9597. private _shadowMap;
  9598. private _shadowMap2;
  9599. /**
  9600. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9601. * @returns The render target texture if present otherwise, null
  9602. */
  9603. getShadowMap(): Nullable<RenderTargetTexture>;
  9604. /**
  9605. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9606. * @returns The render target texture if the shadow map is present otherwise, null
  9607. */
  9608. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9609. /**
  9610. * Gets the class name of that object
  9611. * @returns "ShadowGenerator"
  9612. */
  9613. getClassName(): string;
  9614. /**
  9615. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9616. * @param mesh Mesh to add
  9617. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9618. * @returns the Shadow Generator itself
  9619. */
  9620. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9621. /**
  9622. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9623. * @param mesh Mesh to remove
  9624. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9625. * @returns the Shadow Generator itself
  9626. */
  9627. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9628. /**
  9629. * Controls the extent to which the shadows fade out at the edge of the frustum
  9630. * Used only by directionals and spots
  9631. */
  9632. frustumEdgeFalloff: number;
  9633. private _light;
  9634. /**
  9635. * Returns the associated light object.
  9636. * @returns the light generating the shadow
  9637. */
  9638. getLight(): IShadowLight;
  9639. /**
  9640. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9641. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9642. * It might on the other hand introduce peter panning.
  9643. */
  9644. forceBackFacesOnly: boolean;
  9645. private _scene;
  9646. private _lightDirection;
  9647. private _effect;
  9648. private _viewMatrix;
  9649. private _projectionMatrix;
  9650. private _transformMatrix;
  9651. private _cachedPosition;
  9652. private _cachedDirection;
  9653. private _cachedDefines;
  9654. private _currentRenderID;
  9655. private _boxBlurPostprocess;
  9656. private _kernelBlurXPostprocess;
  9657. private _kernelBlurYPostprocess;
  9658. private _blurPostProcesses;
  9659. private _mapSize;
  9660. private _currentFaceIndex;
  9661. private _currentFaceIndexCache;
  9662. private _textureType;
  9663. private _defaultTextureMatrix;
  9664. /** @hidden */
  9665. static _SceneComponentInitialization: (scene: Scene) => void;
  9666. /**
  9667. * Creates a ShadowGenerator object.
  9668. * A ShadowGenerator is the required tool to use the shadows.
  9669. * Each light casting shadows needs to use its own ShadowGenerator.
  9670. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9671. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9672. * @param light The light object generating the shadows.
  9673. * @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.
  9674. */
  9675. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9676. private _initializeGenerator;
  9677. private _initializeShadowMap;
  9678. private _initializeBlurRTTAndPostProcesses;
  9679. private _renderForShadowMap;
  9680. private _renderSubMeshForShadowMap;
  9681. private _applyFilterValues;
  9682. /**
  9683. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9684. * @param onCompiled Callback triggered at the and of the effects compilation
  9685. * @param options Sets of optional options forcing the compilation with different modes
  9686. */
  9687. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9688. useInstances: boolean;
  9689. }>): void;
  9690. /**
  9691. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9692. * @param options Sets of optional options forcing the compilation with different modes
  9693. * @returns A promise that resolves when the compilation completes
  9694. */
  9695. forceCompilationAsync(options?: Partial<{
  9696. useInstances: boolean;
  9697. }>): Promise<void>;
  9698. /**
  9699. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9700. * @param subMesh The submesh we want to render in the shadow map
  9701. * @param useInstances Defines wether will draw in the map using instances
  9702. * @returns true if ready otherwise, false
  9703. */
  9704. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9705. /**
  9706. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9707. * @param defines Defines of the material we want to update
  9708. * @param lightIndex Index of the light in the enabled light list of the material
  9709. */
  9710. prepareDefines(defines: any, lightIndex: number): void;
  9711. /**
  9712. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9713. * defined in the generator but impacting the effect).
  9714. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9715. * @param effect The effect we are binfing the information for
  9716. */
  9717. bindShadowLight(lightIndex: string, effect: Effect): void;
  9718. /**
  9719. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9720. * (eq to shadow prjection matrix * light transform matrix)
  9721. * @returns The transform matrix used to create the shadow map
  9722. */
  9723. getTransformMatrix(): Matrix;
  9724. /**
  9725. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9726. * Cube and 2D textures for instance.
  9727. */
  9728. recreateShadowMap(): void;
  9729. private _disposeBlurPostProcesses;
  9730. private _disposeRTTandPostProcesses;
  9731. /**
  9732. * Disposes the ShadowGenerator.
  9733. * Returns nothing.
  9734. */
  9735. dispose(): void;
  9736. /**
  9737. * Serializes the shadow generator setup to a json object.
  9738. * @returns The serialized JSON object
  9739. */
  9740. serialize(): any;
  9741. /**
  9742. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9743. * @param parsedShadowGenerator The JSON object to parse
  9744. * @param scene The scene to create the shadow map for
  9745. * @returns The parsed shadow generator
  9746. */
  9747. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9748. }
  9749. }
  9750. declare module "babylonjs/Lights/light" {
  9751. import { Nullable } from "babylonjs/types";
  9752. import { Scene } from "babylonjs/scene";
  9753. import { Vector3 } from "babylonjs/Maths/math.vector";
  9754. import { Color3 } from "babylonjs/Maths/math.color";
  9755. import { Node } from "babylonjs/node";
  9756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9757. import { Effect } from "babylonjs/Materials/effect";
  9758. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9759. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9760. /**
  9761. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9762. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9763. * 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.
  9764. */
  9765. export abstract class Light extends Node {
  9766. /**
  9767. * Falloff Default: light is falling off following the material specification:
  9768. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9769. */
  9770. static readonly FALLOFF_DEFAULT: number;
  9771. /**
  9772. * Falloff Physical: light is falling off following the inverse squared distance law.
  9773. */
  9774. static readonly FALLOFF_PHYSICAL: number;
  9775. /**
  9776. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9777. * to enhance interoperability with other engines.
  9778. */
  9779. static readonly FALLOFF_GLTF: number;
  9780. /**
  9781. * Falloff Standard: light is falling off like in the standard material
  9782. * to enhance interoperability with other materials.
  9783. */
  9784. static readonly FALLOFF_STANDARD: number;
  9785. /**
  9786. * If every light affecting the material is in this lightmapMode,
  9787. * material.lightmapTexture adds or multiplies
  9788. * (depends on material.useLightmapAsShadowmap)
  9789. * after every other light calculations.
  9790. */
  9791. static readonly LIGHTMAP_DEFAULT: number;
  9792. /**
  9793. * material.lightmapTexture as only diffuse lighting from this light
  9794. * adds only specular lighting from this light
  9795. * adds dynamic shadows
  9796. */
  9797. static readonly LIGHTMAP_SPECULAR: number;
  9798. /**
  9799. * material.lightmapTexture as only lighting
  9800. * no light calculation from this light
  9801. * only adds dynamic shadows from this light
  9802. */
  9803. static readonly LIGHTMAP_SHADOWSONLY: number;
  9804. /**
  9805. * Each light type uses the default quantity according to its type:
  9806. * point/spot lights use luminous intensity
  9807. * directional lights use illuminance
  9808. */
  9809. static readonly INTENSITYMODE_AUTOMATIC: number;
  9810. /**
  9811. * lumen (lm)
  9812. */
  9813. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9814. /**
  9815. * candela (lm/sr)
  9816. */
  9817. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9818. /**
  9819. * lux (lm/m^2)
  9820. */
  9821. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9822. /**
  9823. * nit (cd/m^2)
  9824. */
  9825. static readonly INTENSITYMODE_LUMINANCE: number;
  9826. /**
  9827. * Light type const id of the point light.
  9828. */
  9829. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9830. /**
  9831. * Light type const id of the directional light.
  9832. */
  9833. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9834. /**
  9835. * Light type const id of the spot light.
  9836. */
  9837. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9838. /**
  9839. * Light type const id of the hemispheric light.
  9840. */
  9841. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9842. /**
  9843. * Diffuse gives the basic color to an object.
  9844. */
  9845. diffuse: Color3;
  9846. /**
  9847. * Specular produces a highlight color on an object.
  9848. * Note: This is note affecting PBR materials.
  9849. */
  9850. specular: Color3;
  9851. /**
  9852. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9853. * falling off base on range or angle.
  9854. * This can be set to any values in Light.FALLOFF_x.
  9855. *
  9856. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9857. * other types of materials.
  9858. */
  9859. falloffType: number;
  9860. /**
  9861. * Strength of the light.
  9862. * Note: By default it is define in the framework own unit.
  9863. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9864. */
  9865. intensity: number;
  9866. private _range;
  9867. protected _inverseSquaredRange: number;
  9868. /**
  9869. * Defines how far from the source the light is impacting in scene units.
  9870. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9871. */
  9872. /**
  9873. * Defines how far from the source the light is impacting in scene units.
  9874. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9875. */
  9876. range: number;
  9877. /**
  9878. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9879. * of light.
  9880. */
  9881. private _photometricScale;
  9882. private _intensityMode;
  9883. /**
  9884. * Gets the photometric scale used to interpret the intensity.
  9885. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9886. */
  9887. /**
  9888. * Sets the photometric scale used to interpret the intensity.
  9889. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9890. */
  9891. intensityMode: number;
  9892. private _radius;
  9893. /**
  9894. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9895. */
  9896. /**
  9897. * sets the light radius used by PBR Materials to simulate soft area lights.
  9898. */
  9899. radius: number;
  9900. private _renderPriority;
  9901. /**
  9902. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9903. * exceeding the number allowed of the materials.
  9904. */
  9905. renderPriority: number;
  9906. private _shadowEnabled;
  9907. /**
  9908. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9909. * the current shadow generator.
  9910. */
  9911. /**
  9912. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9913. * the current shadow generator.
  9914. */
  9915. shadowEnabled: boolean;
  9916. private _includedOnlyMeshes;
  9917. /**
  9918. * Gets the only meshes impacted by this light.
  9919. */
  9920. /**
  9921. * Sets the only meshes impacted by this light.
  9922. */
  9923. includedOnlyMeshes: AbstractMesh[];
  9924. private _excludedMeshes;
  9925. /**
  9926. * Gets the meshes not impacted by this light.
  9927. */
  9928. /**
  9929. * Sets the meshes not impacted by this light.
  9930. */
  9931. excludedMeshes: AbstractMesh[];
  9932. private _excludeWithLayerMask;
  9933. /**
  9934. * Gets the layer id use to find what meshes are not impacted by the light.
  9935. * Inactive if 0
  9936. */
  9937. /**
  9938. * Sets the layer id use to find what meshes are not impacted by the light.
  9939. * Inactive if 0
  9940. */
  9941. excludeWithLayerMask: number;
  9942. private _includeOnlyWithLayerMask;
  9943. /**
  9944. * Gets the layer id use to find what meshes are impacted by the light.
  9945. * Inactive if 0
  9946. */
  9947. /**
  9948. * Sets the layer id use to find what meshes are impacted by the light.
  9949. * Inactive if 0
  9950. */
  9951. includeOnlyWithLayerMask: number;
  9952. private _lightmapMode;
  9953. /**
  9954. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9955. */
  9956. /**
  9957. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9958. */
  9959. lightmapMode: number;
  9960. /**
  9961. * Shadow generator associted to the light.
  9962. * @hidden Internal use only.
  9963. */
  9964. _shadowGenerator: Nullable<IShadowGenerator>;
  9965. /**
  9966. * @hidden Internal use only.
  9967. */
  9968. _excludedMeshesIds: string[];
  9969. /**
  9970. * @hidden Internal use only.
  9971. */
  9972. _includedOnlyMeshesIds: string[];
  9973. /**
  9974. * The current light unifom buffer.
  9975. * @hidden Internal use only.
  9976. */
  9977. _uniformBuffer: UniformBuffer;
  9978. /**
  9979. * Creates a Light object in the scene.
  9980. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9981. * @param name The firendly name of the light
  9982. * @param scene The scene the light belongs too
  9983. */
  9984. constructor(name: string, scene: Scene);
  9985. protected abstract _buildUniformLayout(): void;
  9986. /**
  9987. * Sets the passed Effect "effect" with the Light information.
  9988. * @param effect The effect to update
  9989. * @param lightIndex The index of the light in the effect to update
  9990. * @returns The light
  9991. */
  9992. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9993. /**
  9994. * Returns the string "Light".
  9995. * @returns the class name
  9996. */
  9997. getClassName(): string;
  9998. /** @hidden */
  9999. readonly _isLight: boolean;
  10000. /**
  10001. * Converts the light information to a readable string for debug purpose.
  10002. * @param fullDetails Supports for multiple levels of logging within scene loading
  10003. * @returns the human readable light info
  10004. */
  10005. toString(fullDetails?: boolean): string;
  10006. /** @hidden */
  10007. protected _syncParentEnabledState(): void;
  10008. /**
  10009. * Set the enabled state of this node.
  10010. * @param value - the new enabled state
  10011. */
  10012. setEnabled(value: boolean): void;
  10013. /**
  10014. * Returns the Light associated shadow generator if any.
  10015. * @return the associated shadow generator.
  10016. */
  10017. getShadowGenerator(): Nullable<IShadowGenerator>;
  10018. /**
  10019. * Returns a Vector3, the absolute light position in the World.
  10020. * @returns the world space position of the light
  10021. */
  10022. getAbsolutePosition(): Vector3;
  10023. /**
  10024. * Specifies if the light will affect the passed mesh.
  10025. * @param mesh The mesh to test against the light
  10026. * @return true the mesh is affected otherwise, false.
  10027. */
  10028. canAffectMesh(mesh: AbstractMesh): boolean;
  10029. /**
  10030. * Sort function to order lights for rendering.
  10031. * @param a First Light object to compare to second.
  10032. * @param b Second Light object to compare first.
  10033. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10034. */
  10035. static CompareLightsPriority(a: Light, b: Light): number;
  10036. /**
  10037. * Releases resources associated with this node.
  10038. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10039. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10040. */
  10041. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10042. /**
  10043. * Returns the light type ID (integer).
  10044. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10045. */
  10046. getTypeID(): number;
  10047. /**
  10048. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10049. * @returns the scaled intensity in intensity mode unit
  10050. */
  10051. getScaledIntensity(): number;
  10052. /**
  10053. * Returns a new Light object, named "name", from the current one.
  10054. * @param name The name of the cloned light
  10055. * @returns the new created light
  10056. */
  10057. clone(name: string): Nullable<Light>;
  10058. /**
  10059. * Serializes the current light into a Serialization object.
  10060. * @returns the serialized object.
  10061. */
  10062. serialize(): any;
  10063. /**
  10064. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10065. * This new light is named "name" and added to the passed scene.
  10066. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10067. * @param name The friendly name of the light
  10068. * @param scene The scene the new light will belong to
  10069. * @returns the constructor function
  10070. */
  10071. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10072. /**
  10073. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10074. * @param parsedLight The JSON representation of the light
  10075. * @param scene The scene to create the parsed light in
  10076. * @returns the created light after parsing
  10077. */
  10078. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10079. private _hookArrayForExcluded;
  10080. private _hookArrayForIncludedOnly;
  10081. private _resyncMeshes;
  10082. /**
  10083. * Forces the meshes to update their light related information in their rendering used effects
  10084. * @hidden Internal Use Only
  10085. */
  10086. _markMeshesAsLightDirty(): void;
  10087. /**
  10088. * Recomputes the cached photometric scale if needed.
  10089. */
  10090. private _computePhotometricScale;
  10091. /**
  10092. * Returns the Photometric Scale according to the light type and intensity mode.
  10093. */
  10094. private _getPhotometricScale;
  10095. /**
  10096. * Reorder the light in the scene according to their defined priority.
  10097. * @hidden Internal Use Only
  10098. */
  10099. _reorderLightsInScene(): void;
  10100. /**
  10101. * Prepares the list of defines specific to the light type.
  10102. * @param defines the list of defines
  10103. * @param lightIndex defines the index of the light for the effect
  10104. */
  10105. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10106. }
  10107. }
  10108. declare module "babylonjs/Actions/action" {
  10109. import { Observable } from "babylonjs/Misc/observable";
  10110. import { Condition } from "babylonjs/Actions/condition";
  10111. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10112. import { ActionManager } from "babylonjs/Actions/actionManager";
  10113. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10114. /**
  10115. * Interface used to define Action
  10116. */
  10117. export interface IAction {
  10118. /**
  10119. * Trigger for the action
  10120. */
  10121. trigger: number;
  10122. /** Options of the trigger */
  10123. triggerOptions: any;
  10124. /**
  10125. * Gets the trigger parameters
  10126. * @returns the trigger parameters
  10127. */
  10128. getTriggerParameter(): any;
  10129. /**
  10130. * Internal only - executes current action event
  10131. * @hidden
  10132. */
  10133. _executeCurrent(evt?: ActionEvent): void;
  10134. /**
  10135. * Serialize placeholder for child classes
  10136. * @param parent of child
  10137. * @returns the serialized object
  10138. */
  10139. serialize(parent: any): any;
  10140. /**
  10141. * Internal only
  10142. * @hidden
  10143. */
  10144. _prepare(): void;
  10145. /**
  10146. * Internal only - manager for action
  10147. * @hidden
  10148. */
  10149. _actionManager: AbstractActionManager;
  10150. /**
  10151. * Adds action to chain of actions, may be a DoNothingAction
  10152. * @param action defines the next action to execute
  10153. * @returns The action passed in
  10154. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10155. */
  10156. then(action: IAction): IAction;
  10157. }
  10158. /**
  10159. * The action to be carried out following a trigger
  10160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10161. */
  10162. export class Action implements IAction {
  10163. /** the trigger, with or without parameters, for the action */
  10164. triggerOptions: any;
  10165. /**
  10166. * Trigger for the action
  10167. */
  10168. trigger: number;
  10169. /**
  10170. * Internal only - manager for action
  10171. * @hidden
  10172. */
  10173. _actionManager: ActionManager;
  10174. private _nextActiveAction;
  10175. private _child;
  10176. private _condition?;
  10177. private _triggerParameter;
  10178. /**
  10179. * An event triggered prior to action being executed.
  10180. */
  10181. onBeforeExecuteObservable: Observable<Action>;
  10182. /**
  10183. * Creates a new Action
  10184. * @param triggerOptions the trigger, with or without parameters, for the action
  10185. * @param condition an optional determinant of action
  10186. */
  10187. constructor(
  10188. /** the trigger, with or without parameters, for the action */
  10189. triggerOptions: any, condition?: Condition);
  10190. /**
  10191. * Internal only
  10192. * @hidden
  10193. */
  10194. _prepare(): void;
  10195. /**
  10196. * Gets the trigger parameters
  10197. * @returns the trigger parameters
  10198. */
  10199. getTriggerParameter(): any;
  10200. /**
  10201. * Internal only - executes current action event
  10202. * @hidden
  10203. */
  10204. _executeCurrent(evt?: ActionEvent): void;
  10205. /**
  10206. * Execute placeholder for child classes
  10207. * @param evt optional action event
  10208. */
  10209. execute(evt?: ActionEvent): void;
  10210. /**
  10211. * Skips to next active action
  10212. */
  10213. skipToNextActiveAction(): void;
  10214. /**
  10215. * Adds action to chain of actions, may be a DoNothingAction
  10216. * @param action defines the next action to execute
  10217. * @returns The action passed in
  10218. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10219. */
  10220. then(action: Action): Action;
  10221. /**
  10222. * Internal only
  10223. * @hidden
  10224. */
  10225. _getProperty(propertyPath: string): string;
  10226. /**
  10227. * Internal only
  10228. * @hidden
  10229. */
  10230. _getEffectiveTarget(target: any, propertyPath: string): any;
  10231. /**
  10232. * Serialize placeholder for child classes
  10233. * @param parent of child
  10234. * @returns the serialized object
  10235. */
  10236. serialize(parent: any): any;
  10237. /**
  10238. * Internal only called by serialize
  10239. * @hidden
  10240. */
  10241. protected _serialize(serializedAction: any, parent?: any): any;
  10242. /**
  10243. * Internal only
  10244. * @hidden
  10245. */
  10246. static _SerializeValueAsString: (value: any) => string;
  10247. /**
  10248. * Internal only
  10249. * @hidden
  10250. */
  10251. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10252. name: string;
  10253. targetType: string;
  10254. value: string;
  10255. };
  10256. }
  10257. }
  10258. declare module "babylonjs/Actions/condition" {
  10259. import { ActionManager } from "babylonjs/Actions/actionManager";
  10260. /**
  10261. * A Condition applied to an Action
  10262. */
  10263. export class Condition {
  10264. /**
  10265. * Internal only - manager for action
  10266. * @hidden
  10267. */
  10268. _actionManager: ActionManager;
  10269. /**
  10270. * Internal only
  10271. * @hidden
  10272. */
  10273. _evaluationId: number;
  10274. /**
  10275. * Internal only
  10276. * @hidden
  10277. */
  10278. _currentResult: boolean;
  10279. /**
  10280. * Creates a new Condition
  10281. * @param actionManager the manager of the action the condition is applied to
  10282. */
  10283. constructor(actionManager: ActionManager);
  10284. /**
  10285. * Check if the current condition is valid
  10286. * @returns a boolean
  10287. */
  10288. isValid(): boolean;
  10289. /**
  10290. * Internal only
  10291. * @hidden
  10292. */
  10293. _getProperty(propertyPath: string): string;
  10294. /**
  10295. * Internal only
  10296. * @hidden
  10297. */
  10298. _getEffectiveTarget(target: any, propertyPath: string): any;
  10299. /**
  10300. * Serialize placeholder for child classes
  10301. * @returns the serialized object
  10302. */
  10303. serialize(): any;
  10304. /**
  10305. * Internal only
  10306. * @hidden
  10307. */
  10308. protected _serialize(serializedCondition: any): any;
  10309. }
  10310. /**
  10311. * Defines specific conditional operators as extensions of Condition
  10312. */
  10313. export class ValueCondition extends Condition {
  10314. /** path to specify the property of the target the conditional operator uses */
  10315. propertyPath: string;
  10316. /** the value compared by the conditional operator against the current value of the property */
  10317. value: any;
  10318. /** the conditional operator, default ValueCondition.IsEqual */
  10319. operator: number;
  10320. /**
  10321. * Internal only
  10322. * @hidden
  10323. */
  10324. private static _IsEqual;
  10325. /**
  10326. * Internal only
  10327. * @hidden
  10328. */
  10329. private static _IsDifferent;
  10330. /**
  10331. * Internal only
  10332. * @hidden
  10333. */
  10334. private static _IsGreater;
  10335. /**
  10336. * Internal only
  10337. * @hidden
  10338. */
  10339. private static _IsLesser;
  10340. /**
  10341. * returns the number for IsEqual
  10342. */
  10343. static readonly IsEqual: number;
  10344. /**
  10345. * Returns the number for IsDifferent
  10346. */
  10347. static readonly IsDifferent: number;
  10348. /**
  10349. * Returns the number for IsGreater
  10350. */
  10351. static readonly IsGreater: number;
  10352. /**
  10353. * Returns the number for IsLesser
  10354. */
  10355. static readonly IsLesser: number;
  10356. /**
  10357. * Internal only The action manager for the condition
  10358. * @hidden
  10359. */
  10360. _actionManager: ActionManager;
  10361. /**
  10362. * Internal only
  10363. * @hidden
  10364. */
  10365. private _target;
  10366. /**
  10367. * Internal only
  10368. * @hidden
  10369. */
  10370. private _effectiveTarget;
  10371. /**
  10372. * Internal only
  10373. * @hidden
  10374. */
  10375. private _property;
  10376. /**
  10377. * Creates a new ValueCondition
  10378. * @param actionManager manager for the action the condition applies to
  10379. * @param target for the action
  10380. * @param propertyPath path to specify the property of the target the conditional operator uses
  10381. * @param value the value compared by the conditional operator against the current value of the property
  10382. * @param operator the conditional operator, default ValueCondition.IsEqual
  10383. */
  10384. constructor(actionManager: ActionManager, target: any,
  10385. /** path to specify the property of the target the conditional operator uses */
  10386. propertyPath: string,
  10387. /** the value compared by the conditional operator against the current value of the property */
  10388. value: any,
  10389. /** the conditional operator, default ValueCondition.IsEqual */
  10390. operator?: number);
  10391. /**
  10392. * Compares the given value with the property value for the specified conditional operator
  10393. * @returns the result of the comparison
  10394. */
  10395. isValid(): boolean;
  10396. /**
  10397. * Serialize the ValueCondition into a JSON compatible object
  10398. * @returns serialization object
  10399. */
  10400. serialize(): any;
  10401. /**
  10402. * Gets the name of the conditional operator for the ValueCondition
  10403. * @param operator the conditional operator
  10404. * @returns the name
  10405. */
  10406. static GetOperatorName(operator: number): string;
  10407. }
  10408. /**
  10409. * Defines a predicate condition as an extension of Condition
  10410. */
  10411. export class PredicateCondition extends Condition {
  10412. /** defines the predicate function used to validate the condition */
  10413. predicate: () => boolean;
  10414. /**
  10415. * Internal only - manager for action
  10416. * @hidden
  10417. */
  10418. _actionManager: ActionManager;
  10419. /**
  10420. * Creates a new PredicateCondition
  10421. * @param actionManager manager for the action the condition applies to
  10422. * @param predicate defines the predicate function used to validate the condition
  10423. */
  10424. constructor(actionManager: ActionManager,
  10425. /** defines the predicate function used to validate the condition */
  10426. predicate: () => boolean);
  10427. /**
  10428. * @returns the validity of the predicate condition
  10429. */
  10430. isValid(): boolean;
  10431. }
  10432. /**
  10433. * Defines a state condition as an extension of Condition
  10434. */
  10435. export class StateCondition extends Condition {
  10436. /** Value to compare with target state */
  10437. value: string;
  10438. /**
  10439. * Internal only - manager for action
  10440. * @hidden
  10441. */
  10442. _actionManager: ActionManager;
  10443. /**
  10444. * Internal only
  10445. * @hidden
  10446. */
  10447. private _target;
  10448. /**
  10449. * Creates a new StateCondition
  10450. * @param actionManager manager for the action the condition applies to
  10451. * @param target of the condition
  10452. * @param value to compare with target state
  10453. */
  10454. constructor(actionManager: ActionManager, target: any,
  10455. /** Value to compare with target state */
  10456. value: string);
  10457. /**
  10458. * Gets a boolean indicating if the current condition is met
  10459. * @returns the validity of the state
  10460. */
  10461. isValid(): boolean;
  10462. /**
  10463. * Serialize the StateCondition into a JSON compatible object
  10464. * @returns serialization object
  10465. */
  10466. serialize(): any;
  10467. }
  10468. }
  10469. declare module "babylonjs/Actions/directActions" {
  10470. import { Action } from "babylonjs/Actions/action";
  10471. import { Condition } from "babylonjs/Actions/condition";
  10472. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10473. /**
  10474. * This defines an action responsible to toggle a boolean once triggered.
  10475. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10476. */
  10477. export class SwitchBooleanAction extends Action {
  10478. /**
  10479. * The path to the boolean property in the target object
  10480. */
  10481. propertyPath: string;
  10482. private _target;
  10483. private _effectiveTarget;
  10484. private _property;
  10485. /**
  10486. * Instantiate the action
  10487. * @param triggerOptions defines the trigger options
  10488. * @param target defines the object containing the boolean
  10489. * @param propertyPath defines the path to the boolean property in the target object
  10490. * @param condition defines the trigger related conditions
  10491. */
  10492. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10493. /** @hidden */
  10494. _prepare(): void;
  10495. /**
  10496. * Execute the action toggle the boolean value.
  10497. */
  10498. execute(): void;
  10499. /**
  10500. * Serializes the actions and its related information.
  10501. * @param parent defines the object to serialize in
  10502. * @returns the serialized object
  10503. */
  10504. serialize(parent: any): any;
  10505. }
  10506. /**
  10507. * This defines an action responsible to set a the state field of the target
  10508. * to a desired value once triggered.
  10509. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10510. */
  10511. export class SetStateAction extends Action {
  10512. /**
  10513. * The value to store in the state field.
  10514. */
  10515. value: string;
  10516. private _target;
  10517. /**
  10518. * Instantiate the action
  10519. * @param triggerOptions defines the trigger options
  10520. * @param target defines the object containing the state property
  10521. * @param value defines the value to store in the state field
  10522. * @param condition defines the trigger related conditions
  10523. */
  10524. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10525. /**
  10526. * Execute the action and store the value on the target state property.
  10527. */
  10528. execute(): void;
  10529. /**
  10530. * Serializes the actions and its related information.
  10531. * @param parent defines the object to serialize in
  10532. * @returns the serialized object
  10533. */
  10534. serialize(parent: any): any;
  10535. }
  10536. /**
  10537. * This defines an action responsible to set a property of the target
  10538. * to a desired value once triggered.
  10539. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10540. */
  10541. export class SetValueAction extends Action {
  10542. /**
  10543. * The path of the property to set in the target.
  10544. */
  10545. propertyPath: string;
  10546. /**
  10547. * The value to set in the property
  10548. */
  10549. value: any;
  10550. private _target;
  10551. private _effectiveTarget;
  10552. private _property;
  10553. /**
  10554. * Instantiate the action
  10555. * @param triggerOptions defines the trigger options
  10556. * @param target defines the object containing the property
  10557. * @param propertyPath defines the path of the property to set in the target
  10558. * @param value defines the value to set in the property
  10559. * @param condition defines the trigger related conditions
  10560. */
  10561. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10562. /** @hidden */
  10563. _prepare(): void;
  10564. /**
  10565. * Execute the action and set the targetted property to the desired value.
  10566. */
  10567. execute(): void;
  10568. /**
  10569. * Serializes the actions and its related information.
  10570. * @param parent defines the object to serialize in
  10571. * @returns the serialized object
  10572. */
  10573. serialize(parent: any): any;
  10574. }
  10575. /**
  10576. * This defines an action responsible to increment the target value
  10577. * to a desired value once triggered.
  10578. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10579. */
  10580. export class IncrementValueAction extends Action {
  10581. /**
  10582. * The path of the property to increment in the target.
  10583. */
  10584. propertyPath: string;
  10585. /**
  10586. * The value we should increment the property by.
  10587. */
  10588. value: any;
  10589. private _target;
  10590. private _effectiveTarget;
  10591. private _property;
  10592. /**
  10593. * Instantiate the action
  10594. * @param triggerOptions defines the trigger options
  10595. * @param target defines the object containing the property
  10596. * @param propertyPath defines the path of the property to increment in the target
  10597. * @param value defines the value value we should increment the property by
  10598. * @param condition defines the trigger related conditions
  10599. */
  10600. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10601. /** @hidden */
  10602. _prepare(): void;
  10603. /**
  10604. * Execute the action and increment the target of the value amount.
  10605. */
  10606. execute(): void;
  10607. /**
  10608. * Serializes the actions and its related information.
  10609. * @param parent defines the object to serialize in
  10610. * @returns the serialized object
  10611. */
  10612. serialize(parent: any): any;
  10613. }
  10614. /**
  10615. * This defines an action responsible to start an animation once triggered.
  10616. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10617. */
  10618. export class PlayAnimationAction extends Action {
  10619. /**
  10620. * Where the animation should start (animation frame)
  10621. */
  10622. from: number;
  10623. /**
  10624. * Where the animation should stop (animation frame)
  10625. */
  10626. to: number;
  10627. /**
  10628. * Define if the animation should loop or stop after the first play.
  10629. */
  10630. loop?: boolean;
  10631. private _target;
  10632. /**
  10633. * Instantiate the action
  10634. * @param triggerOptions defines the trigger options
  10635. * @param target defines the target animation or animation name
  10636. * @param from defines from where the animation should start (animation frame)
  10637. * @param end defines where the animation should stop (animation frame)
  10638. * @param loop defines if the animation should loop or stop after the first play
  10639. * @param condition defines the trigger related conditions
  10640. */
  10641. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10642. /** @hidden */
  10643. _prepare(): void;
  10644. /**
  10645. * Execute the action and play the animation.
  10646. */
  10647. execute(): void;
  10648. /**
  10649. * Serializes the actions and its related information.
  10650. * @param parent defines the object to serialize in
  10651. * @returns the serialized object
  10652. */
  10653. serialize(parent: any): any;
  10654. }
  10655. /**
  10656. * This defines an action responsible to stop an animation once triggered.
  10657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10658. */
  10659. export class StopAnimationAction extends Action {
  10660. private _target;
  10661. /**
  10662. * Instantiate the action
  10663. * @param triggerOptions defines the trigger options
  10664. * @param target defines the target animation or animation name
  10665. * @param condition defines the trigger related conditions
  10666. */
  10667. constructor(triggerOptions: any, target: any, condition?: Condition);
  10668. /** @hidden */
  10669. _prepare(): void;
  10670. /**
  10671. * Execute the action and stop the animation.
  10672. */
  10673. execute(): void;
  10674. /**
  10675. * Serializes the actions and its related information.
  10676. * @param parent defines the object to serialize in
  10677. * @returns the serialized object
  10678. */
  10679. serialize(parent: any): any;
  10680. }
  10681. /**
  10682. * This defines an action responsible that does nothing once triggered.
  10683. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10684. */
  10685. export class DoNothingAction extends Action {
  10686. /**
  10687. * Instantiate the action
  10688. * @param triggerOptions defines the trigger options
  10689. * @param condition defines the trigger related conditions
  10690. */
  10691. constructor(triggerOptions?: any, condition?: Condition);
  10692. /**
  10693. * Execute the action and do nothing.
  10694. */
  10695. execute(): void;
  10696. /**
  10697. * Serializes the actions and its related information.
  10698. * @param parent defines the object to serialize in
  10699. * @returns the serialized object
  10700. */
  10701. serialize(parent: any): any;
  10702. }
  10703. /**
  10704. * This defines an action responsible to trigger several actions once triggered.
  10705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10706. */
  10707. export class CombineAction extends Action {
  10708. /**
  10709. * The list of aggregated animations to run.
  10710. */
  10711. children: Action[];
  10712. /**
  10713. * Instantiate the action
  10714. * @param triggerOptions defines the trigger options
  10715. * @param children defines the list of aggregated animations to run
  10716. * @param condition defines the trigger related conditions
  10717. */
  10718. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10719. /** @hidden */
  10720. _prepare(): void;
  10721. /**
  10722. * Execute the action and executes all the aggregated actions.
  10723. */
  10724. execute(evt: ActionEvent): void;
  10725. /**
  10726. * Serializes the actions and its related information.
  10727. * @param parent defines the object to serialize in
  10728. * @returns the serialized object
  10729. */
  10730. serialize(parent: any): any;
  10731. }
  10732. /**
  10733. * This defines an action responsible to run code (external event) once triggered.
  10734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10735. */
  10736. export class ExecuteCodeAction extends Action {
  10737. /**
  10738. * The callback function to run.
  10739. */
  10740. func: (evt: ActionEvent) => void;
  10741. /**
  10742. * Instantiate the action
  10743. * @param triggerOptions defines the trigger options
  10744. * @param func defines the callback function to run
  10745. * @param condition defines the trigger related conditions
  10746. */
  10747. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10748. /**
  10749. * Execute the action and run the attached code.
  10750. */
  10751. execute(evt: ActionEvent): void;
  10752. }
  10753. /**
  10754. * This defines an action responsible to set the parent property of the target once triggered.
  10755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10756. */
  10757. export class SetParentAction extends Action {
  10758. private _parent;
  10759. private _target;
  10760. /**
  10761. * Instantiate the action
  10762. * @param triggerOptions defines the trigger options
  10763. * @param target defines the target containing the parent property
  10764. * @param parent defines from where the animation should start (animation frame)
  10765. * @param condition defines the trigger related conditions
  10766. */
  10767. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10768. /** @hidden */
  10769. _prepare(): void;
  10770. /**
  10771. * Execute the action and set the parent property.
  10772. */
  10773. execute(): void;
  10774. /**
  10775. * Serializes the actions and its related information.
  10776. * @param parent defines the object to serialize in
  10777. * @returns the serialized object
  10778. */
  10779. serialize(parent: any): any;
  10780. }
  10781. }
  10782. declare module "babylonjs/Actions/actionManager" {
  10783. import { Nullable } from "babylonjs/types";
  10784. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10785. import { Scene } from "babylonjs/scene";
  10786. import { IAction } from "babylonjs/Actions/action";
  10787. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10788. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10789. /**
  10790. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10791. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10793. */
  10794. export class ActionManager extends AbstractActionManager {
  10795. /**
  10796. * Nothing
  10797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10798. */
  10799. static readonly NothingTrigger: number;
  10800. /**
  10801. * On pick
  10802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10803. */
  10804. static readonly OnPickTrigger: number;
  10805. /**
  10806. * On left pick
  10807. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10808. */
  10809. static readonly OnLeftPickTrigger: number;
  10810. /**
  10811. * On right pick
  10812. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10813. */
  10814. static readonly OnRightPickTrigger: number;
  10815. /**
  10816. * On center pick
  10817. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10818. */
  10819. static readonly OnCenterPickTrigger: number;
  10820. /**
  10821. * On pick down
  10822. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10823. */
  10824. static readonly OnPickDownTrigger: number;
  10825. /**
  10826. * On double pick
  10827. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10828. */
  10829. static readonly OnDoublePickTrigger: number;
  10830. /**
  10831. * On pick up
  10832. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10833. */
  10834. static readonly OnPickUpTrigger: number;
  10835. /**
  10836. * On pick out.
  10837. * This trigger will only be raised if you also declared a OnPickDown
  10838. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10839. */
  10840. static readonly OnPickOutTrigger: number;
  10841. /**
  10842. * On long press
  10843. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10844. */
  10845. static readonly OnLongPressTrigger: number;
  10846. /**
  10847. * On pointer over
  10848. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10849. */
  10850. static readonly OnPointerOverTrigger: number;
  10851. /**
  10852. * On pointer out
  10853. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10854. */
  10855. static readonly OnPointerOutTrigger: number;
  10856. /**
  10857. * On every frame
  10858. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10859. */
  10860. static readonly OnEveryFrameTrigger: number;
  10861. /**
  10862. * On intersection enter
  10863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10864. */
  10865. static readonly OnIntersectionEnterTrigger: number;
  10866. /**
  10867. * On intersection exit
  10868. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10869. */
  10870. static readonly OnIntersectionExitTrigger: number;
  10871. /**
  10872. * On key down
  10873. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10874. */
  10875. static readonly OnKeyDownTrigger: number;
  10876. /**
  10877. * On key up
  10878. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10879. */
  10880. static readonly OnKeyUpTrigger: number;
  10881. private _scene;
  10882. /**
  10883. * Creates a new action manager
  10884. * @param scene defines the hosting scene
  10885. */
  10886. constructor(scene: Scene);
  10887. /**
  10888. * Releases all associated resources
  10889. */
  10890. dispose(): void;
  10891. /**
  10892. * Gets hosting scene
  10893. * @returns the hosting scene
  10894. */
  10895. getScene(): Scene;
  10896. /**
  10897. * Does this action manager handles actions of any of the given triggers
  10898. * @param triggers defines the triggers to be tested
  10899. * @return a boolean indicating whether one (or more) of the triggers is handled
  10900. */
  10901. hasSpecificTriggers(triggers: number[]): boolean;
  10902. /**
  10903. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10904. * speed.
  10905. * @param triggerA defines the trigger to be tested
  10906. * @param triggerB defines the trigger to be tested
  10907. * @return a boolean indicating whether one (or more) of the triggers is handled
  10908. */
  10909. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10910. /**
  10911. * Does this action manager handles actions of a given trigger
  10912. * @param trigger defines the trigger to be tested
  10913. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10914. * @return whether the trigger is handled
  10915. */
  10916. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10917. /**
  10918. * Does this action manager has pointer triggers
  10919. */
  10920. readonly hasPointerTriggers: boolean;
  10921. /**
  10922. * Does this action manager has pick triggers
  10923. */
  10924. readonly hasPickTriggers: boolean;
  10925. /**
  10926. * Registers an action to this action manager
  10927. * @param action defines the action to be registered
  10928. * @return the action amended (prepared) after registration
  10929. */
  10930. registerAction(action: IAction): Nullable<IAction>;
  10931. /**
  10932. * Unregisters an action to this action manager
  10933. * @param action defines the action to be unregistered
  10934. * @return a boolean indicating whether the action has been unregistered
  10935. */
  10936. unregisterAction(action: IAction): Boolean;
  10937. /**
  10938. * Process a specific trigger
  10939. * @param trigger defines the trigger to process
  10940. * @param evt defines the event details to be processed
  10941. */
  10942. processTrigger(trigger: number, evt?: IActionEvent): void;
  10943. /** @hidden */
  10944. _getEffectiveTarget(target: any, propertyPath: string): any;
  10945. /** @hidden */
  10946. _getProperty(propertyPath: string): string;
  10947. /**
  10948. * Serialize this manager to a JSON object
  10949. * @param name defines the property name to store this manager
  10950. * @returns a JSON representation of this manager
  10951. */
  10952. serialize(name: string): any;
  10953. /**
  10954. * Creates a new ActionManager from a JSON data
  10955. * @param parsedActions defines the JSON data to read from
  10956. * @param object defines the hosting mesh
  10957. * @param scene defines the hosting scene
  10958. */
  10959. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10960. /**
  10961. * Get a trigger name by index
  10962. * @param trigger defines the trigger index
  10963. * @returns a trigger name
  10964. */
  10965. static GetTriggerName(trigger: number): string;
  10966. }
  10967. }
  10968. declare module "babylonjs/Culling/ray" {
  10969. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10970. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10971. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10972. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10973. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10974. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10975. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10976. import { Plane } from "babylonjs/Maths/math.plane";
  10977. /**
  10978. * Class representing a ray with position and direction
  10979. */
  10980. export class Ray {
  10981. /** origin point */
  10982. origin: Vector3;
  10983. /** direction */
  10984. direction: Vector3;
  10985. /** length of the ray */
  10986. length: number;
  10987. private static readonly TmpVector3;
  10988. private _tmpRay;
  10989. /**
  10990. * Creates a new ray
  10991. * @param origin origin point
  10992. * @param direction direction
  10993. * @param length length of the ray
  10994. */
  10995. constructor(
  10996. /** origin point */
  10997. origin: Vector3,
  10998. /** direction */
  10999. direction: Vector3,
  11000. /** length of the ray */
  11001. length?: number);
  11002. /**
  11003. * Checks if the ray intersects a box
  11004. * @param minimum bound of the box
  11005. * @param maximum bound of the box
  11006. * @param intersectionTreshold extra extend to be added to the box in all direction
  11007. * @returns if the box was hit
  11008. */
  11009. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11010. /**
  11011. * Checks if the ray intersects a box
  11012. * @param box the bounding box to check
  11013. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11014. * @returns if the box was hit
  11015. */
  11016. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11017. /**
  11018. * If the ray hits a sphere
  11019. * @param sphere the bounding sphere to check
  11020. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11021. * @returns true if it hits the sphere
  11022. */
  11023. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11024. /**
  11025. * If the ray hits a triange
  11026. * @param vertex0 triangle vertex
  11027. * @param vertex1 triangle vertex
  11028. * @param vertex2 triangle vertex
  11029. * @returns intersection information if hit
  11030. */
  11031. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11032. /**
  11033. * Checks if ray intersects a plane
  11034. * @param plane the plane to check
  11035. * @returns the distance away it was hit
  11036. */
  11037. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11038. /**
  11039. * Calculate the intercept of a ray on a given axis
  11040. * @param axis to check 'x' | 'y' | 'z'
  11041. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11042. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11043. */
  11044. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11045. /**
  11046. * Checks if ray intersects a mesh
  11047. * @param mesh the mesh to check
  11048. * @param fastCheck if only the bounding box should checked
  11049. * @returns picking info of the intersecton
  11050. */
  11051. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11052. /**
  11053. * Checks if ray intersects a mesh
  11054. * @param meshes the meshes to check
  11055. * @param fastCheck if only the bounding box should checked
  11056. * @param results array to store result in
  11057. * @returns Array of picking infos
  11058. */
  11059. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11060. private _comparePickingInfo;
  11061. private static smallnum;
  11062. private static rayl;
  11063. /**
  11064. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11065. * @param sega the first point of the segment to test the intersection against
  11066. * @param segb the second point of the segment to test the intersection against
  11067. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11068. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11069. */
  11070. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11071. /**
  11072. * Update the ray from viewport position
  11073. * @param x position
  11074. * @param y y position
  11075. * @param viewportWidth viewport width
  11076. * @param viewportHeight viewport height
  11077. * @param world world matrix
  11078. * @param view view matrix
  11079. * @param projection projection matrix
  11080. * @returns this ray updated
  11081. */
  11082. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11083. /**
  11084. * Creates a ray with origin and direction of 0,0,0
  11085. * @returns the new ray
  11086. */
  11087. static Zero(): Ray;
  11088. /**
  11089. * Creates a new ray from screen space and viewport
  11090. * @param x position
  11091. * @param y y position
  11092. * @param viewportWidth viewport width
  11093. * @param viewportHeight viewport height
  11094. * @param world world matrix
  11095. * @param view view matrix
  11096. * @param projection projection matrix
  11097. * @returns new ray
  11098. */
  11099. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11100. /**
  11101. * 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
  11102. * transformed to the given world matrix.
  11103. * @param origin The origin point
  11104. * @param end The end point
  11105. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11106. * @returns the new ray
  11107. */
  11108. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11109. /**
  11110. * Transforms a ray by a matrix
  11111. * @param ray ray to transform
  11112. * @param matrix matrix to apply
  11113. * @returns the resulting new ray
  11114. */
  11115. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11116. /**
  11117. * Transforms a ray by a matrix
  11118. * @param ray ray to transform
  11119. * @param matrix matrix to apply
  11120. * @param result ray to store result in
  11121. */
  11122. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11123. /**
  11124. * Unproject a ray from screen space to object space
  11125. * @param sourceX defines the screen space x coordinate to use
  11126. * @param sourceY defines the screen space y coordinate to use
  11127. * @param viewportWidth defines the current width of the viewport
  11128. * @param viewportHeight defines the current height of the viewport
  11129. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11130. * @param view defines the view matrix to use
  11131. * @param projection defines the projection matrix to use
  11132. */
  11133. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11134. }
  11135. /**
  11136. * Type used to define predicate used to select faces when a mesh intersection is detected
  11137. */
  11138. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11139. module "babylonjs/scene" {
  11140. interface Scene {
  11141. /** @hidden */
  11142. _tempPickingRay: Nullable<Ray>;
  11143. /** @hidden */
  11144. _cachedRayForTransform: Ray;
  11145. /** @hidden */
  11146. _pickWithRayInverseMatrix: Matrix;
  11147. /** @hidden */
  11148. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11149. /** @hidden */
  11150. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11151. }
  11152. }
  11153. }
  11154. declare module "babylonjs/sceneComponent" {
  11155. import { Scene } from "babylonjs/scene";
  11156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11157. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11158. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11159. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11160. import { Nullable } from "babylonjs/types";
  11161. import { Camera } from "babylonjs/Cameras/camera";
  11162. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11163. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11164. import { AbstractScene } from "babylonjs/abstractScene";
  11165. /**
  11166. * Groups all the scene component constants in one place to ease maintenance.
  11167. * @hidden
  11168. */
  11169. export class SceneComponentConstants {
  11170. static readonly NAME_EFFECTLAYER: string;
  11171. static readonly NAME_LAYER: string;
  11172. static readonly NAME_LENSFLARESYSTEM: string;
  11173. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11174. static readonly NAME_PARTICLESYSTEM: string;
  11175. static readonly NAME_GAMEPAD: string;
  11176. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11177. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11178. static readonly NAME_DEPTHRENDERER: string;
  11179. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11180. static readonly NAME_SPRITE: string;
  11181. static readonly NAME_OUTLINERENDERER: string;
  11182. static readonly NAME_PROCEDURALTEXTURE: string;
  11183. static readonly NAME_SHADOWGENERATOR: string;
  11184. static readonly NAME_OCTREE: string;
  11185. static readonly NAME_PHYSICSENGINE: string;
  11186. static readonly NAME_AUDIO: string;
  11187. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11188. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11189. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11190. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11191. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11192. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11193. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11194. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11195. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11196. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11197. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11198. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11199. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11200. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11201. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11202. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11203. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11204. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11205. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11206. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11207. static readonly STEP_AFTERRENDER_AUDIO: number;
  11208. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11209. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11210. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11211. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11212. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11213. static readonly STEP_POINTERMOVE_SPRITE: number;
  11214. static readonly STEP_POINTERDOWN_SPRITE: number;
  11215. static readonly STEP_POINTERUP_SPRITE: number;
  11216. }
  11217. /**
  11218. * This represents a scene component.
  11219. *
  11220. * This is used to decouple the dependency the scene is having on the different workloads like
  11221. * layers, post processes...
  11222. */
  11223. export interface ISceneComponent {
  11224. /**
  11225. * The name of the component. Each component must have a unique name.
  11226. */
  11227. name: string;
  11228. /**
  11229. * The scene the component belongs to.
  11230. */
  11231. scene: Scene;
  11232. /**
  11233. * Register the component to one instance of a scene.
  11234. */
  11235. register(): void;
  11236. /**
  11237. * Rebuilds the elements related to this component in case of
  11238. * context lost for instance.
  11239. */
  11240. rebuild(): void;
  11241. /**
  11242. * Disposes the component and the associated ressources.
  11243. */
  11244. dispose(): void;
  11245. }
  11246. /**
  11247. * This represents a SERIALIZABLE scene component.
  11248. *
  11249. * This extends Scene Component to add Serialization methods on top.
  11250. */
  11251. export interface ISceneSerializableComponent extends ISceneComponent {
  11252. /**
  11253. * Adds all the elements from the container to the scene
  11254. * @param container the container holding the elements
  11255. */
  11256. addFromContainer(container: AbstractScene): void;
  11257. /**
  11258. * Removes all the elements in the container from the scene
  11259. * @param container contains the elements to remove
  11260. * @param dispose if the removed element should be disposed (default: false)
  11261. */
  11262. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11263. /**
  11264. * Serializes the component data to the specified json object
  11265. * @param serializationObject The object to serialize to
  11266. */
  11267. serialize(serializationObject: any): void;
  11268. }
  11269. /**
  11270. * Strong typing of a Mesh related stage step action
  11271. */
  11272. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11273. /**
  11274. * Strong typing of a Evaluate Sub Mesh related stage step action
  11275. */
  11276. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11277. /**
  11278. * Strong typing of a Active Mesh related stage step action
  11279. */
  11280. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11281. /**
  11282. * Strong typing of a Camera related stage step action
  11283. */
  11284. export type CameraStageAction = (camera: Camera) => void;
  11285. /**
  11286. * Strong typing of a Camera Frame buffer related stage step action
  11287. */
  11288. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11289. /**
  11290. * Strong typing of a Render Target related stage step action
  11291. */
  11292. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11293. /**
  11294. * Strong typing of a RenderingGroup related stage step action
  11295. */
  11296. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11297. /**
  11298. * Strong typing of a Mesh Render related stage step action
  11299. */
  11300. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11301. /**
  11302. * Strong typing of a simple stage step action
  11303. */
  11304. export type SimpleStageAction = () => void;
  11305. /**
  11306. * Strong typing of a render target action.
  11307. */
  11308. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11309. /**
  11310. * Strong typing of a pointer move action.
  11311. */
  11312. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11313. /**
  11314. * Strong typing of a pointer up/down action.
  11315. */
  11316. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11317. /**
  11318. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11319. * @hidden
  11320. */
  11321. export class Stage<T extends Function> extends Array<{
  11322. index: number;
  11323. component: ISceneComponent;
  11324. action: T;
  11325. }> {
  11326. /**
  11327. * Hide ctor from the rest of the world.
  11328. * @param items The items to add.
  11329. */
  11330. private constructor();
  11331. /**
  11332. * Creates a new Stage.
  11333. * @returns A new instance of a Stage
  11334. */
  11335. static Create<T extends Function>(): Stage<T>;
  11336. /**
  11337. * Registers a step in an ordered way in the targeted stage.
  11338. * @param index Defines the position to register the step in
  11339. * @param component Defines the component attached to the step
  11340. * @param action Defines the action to launch during the step
  11341. */
  11342. registerStep(index: number, component: ISceneComponent, action: T): void;
  11343. /**
  11344. * Clears all the steps from the stage.
  11345. */
  11346. clear(): void;
  11347. }
  11348. }
  11349. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11350. import { Nullable } from "babylonjs/types";
  11351. import { Observable } from "babylonjs/Misc/observable";
  11352. import { Scene } from "babylonjs/scene";
  11353. import { Sprite } from "babylonjs/Sprites/sprite";
  11354. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11355. import { Ray } from "babylonjs/Culling/ray";
  11356. import { Camera } from "babylonjs/Cameras/camera";
  11357. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11358. import { ISceneComponent } from "babylonjs/sceneComponent";
  11359. module "babylonjs/scene" {
  11360. interface Scene {
  11361. /** @hidden */
  11362. _pointerOverSprite: Nullable<Sprite>;
  11363. /** @hidden */
  11364. _pickedDownSprite: Nullable<Sprite>;
  11365. /** @hidden */
  11366. _tempSpritePickingRay: Nullable<Ray>;
  11367. /**
  11368. * All of the sprite managers added to this scene
  11369. * @see http://doc.babylonjs.com/babylon101/sprites
  11370. */
  11371. spriteManagers: Array<ISpriteManager>;
  11372. /**
  11373. * An event triggered when sprites rendering is about to start
  11374. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11375. */
  11376. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11377. /**
  11378. * An event triggered when sprites rendering is done
  11379. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11380. */
  11381. onAfterSpritesRenderingObservable: Observable<Scene>;
  11382. /** @hidden */
  11383. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11384. /** Launch a ray to try to pick a sprite in the scene
  11385. * @param x position on screen
  11386. * @param y position on screen
  11387. * @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
  11388. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11389. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11390. * @returns a PickingInfo
  11391. */
  11392. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11393. /** Use the given ray to pick a sprite in the scene
  11394. * @param ray The ray (in world space) to use to pick meshes
  11395. * @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
  11396. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11397. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11398. * @returns a PickingInfo
  11399. */
  11400. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11401. /**
  11402. * Force the sprite under the pointer
  11403. * @param sprite defines the sprite to use
  11404. */
  11405. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11406. /**
  11407. * Gets the sprite under the pointer
  11408. * @returns a Sprite or null if no sprite is under the pointer
  11409. */
  11410. getPointerOverSprite(): Nullable<Sprite>;
  11411. }
  11412. }
  11413. /**
  11414. * Defines the sprite scene component responsible to manage sprites
  11415. * in a given scene.
  11416. */
  11417. export class SpriteSceneComponent implements ISceneComponent {
  11418. /**
  11419. * The component name helpfull to identify the component in the list of scene components.
  11420. */
  11421. readonly name: string;
  11422. /**
  11423. * The scene the component belongs to.
  11424. */
  11425. scene: Scene;
  11426. /** @hidden */
  11427. private _spritePredicate;
  11428. /**
  11429. * Creates a new instance of the component for the given scene
  11430. * @param scene Defines the scene to register the component in
  11431. */
  11432. constructor(scene: Scene);
  11433. /**
  11434. * Registers the component in a given scene
  11435. */
  11436. register(): void;
  11437. /**
  11438. * Rebuilds the elements related to this component in case of
  11439. * context lost for instance.
  11440. */
  11441. rebuild(): void;
  11442. /**
  11443. * Disposes the component and the associated ressources.
  11444. */
  11445. dispose(): void;
  11446. private _pickSpriteButKeepRay;
  11447. private _pointerMove;
  11448. private _pointerDown;
  11449. private _pointerUp;
  11450. }
  11451. }
  11452. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11453. /** @hidden */
  11454. export var fogFragmentDeclaration: {
  11455. name: string;
  11456. shader: string;
  11457. };
  11458. }
  11459. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11460. /** @hidden */
  11461. export var fogFragment: {
  11462. name: string;
  11463. shader: string;
  11464. };
  11465. }
  11466. declare module "babylonjs/Shaders/sprites.fragment" {
  11467. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11468. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11469. /** @hidden */
  11470. export var spritesPixelShader: {
  11471. name: string;
  11472. shader: string;
  11473. };
  11474. }
  11475. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11476. /** @hidden */
  11477. export var fogVertexDeclaration: {
  11478. name: string;
  11479. shader: string;
  11480. };
  11481. }
  11482. declare module "babylonjs/Shaders/sprites.vertex" {
  11483. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11484. /** @hidden */
  11485. export var spritesVertexShader: {
  11486. name: string;
  11487. shader: string;
  11488. };
  11489. }
  11490. declare module "babylonjs/Sprites/spriteManager" {
  11491. import { IDisposable, Scene } from "babylonjs/scene";
  11492. import { Nullable } from "babylonjs/types";
  11493. import { Observable } from "babylonjs/Misc/observable";
  11494. import { Sprite } from "babylonjs/Sprites/sprite";
  11495. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11496. import { Camera } from "babylonjs/Cameras/camera";
  11497. import { Texture } from "babylonjs/Materials/Textures/texture";
  11498. import "babylonjs/Shaders/sprites.fragment";
  11499. import "babylonjs/Shaders/sprites.vertex";
  11500. import { Ray } from "babylonjs/Culling/ray";
  11501. /**
  11502. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11503. */
  11504. export interface ISpriteManager extends IDisposable {
  11505. /**
  11506. * Restricts the camera to viewing objects with the same layerMask.
  11507. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11508. */
  11509. layerMask: number;
  11510. /**
  11511. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11512. */
  11513. isPickable: boolean;
  11514. /**
  11515. * Specifies the rendering group id for this mesh (0 by default)
  11516. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11517. */
  11518. renderingGroupId: number;
  11519. /**
  11520. * Defines the list of sprites managed by the manager.
  11521. */
  11522. sprites: Array<Sprite>;
  11523. /**
  11524. * Tests the intersection of a sprite with a specific ray.
  11525. * @param ray The ray we are sending to test the collision
  11526. * @param camera The camera space we are sending rays in
  11527. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11528. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11529. * @returns picking info or null.
  11530. */
  11531. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11532. /**
  11533. * Renders the list of sprites on screen.
  11534. */
  11535. render(): void;
  11536. }
  11537. /**
  11538. * Class used to manage multiple sprites on the same spritesheet
  11539. * @see http://doc.babylonjs.com/babylon101/sprites
  11540. */
  11541. export class SpriteManager implements ISpriteManager {
  11542. /** defines the manager's name */
  11543. name: string;
  11544. /** Gets the list of sprites */
  11545. sprites: Sprite[];
  11546. /** Gets or sets the rendering group id (0 by default) */
  11547. renderingGroupId: number;
  11548. /** Gets or sets camera layer mask */
  11549. layerMask: number;
  11550. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11551. fogEnabled: boolean;
  11552. /** Gets or sets a boolean indicating if the sprites are pickable */
  11553. isPickable: boolean;
  11554. /** Defines the default width of a cell in the spritesheet */
  11555. cellWidth: number;
  11556. /** Defines the default height of a cell in the spritesheet */
  11557. cellHeight: number;
  11558. /**
  11559. * An event triggered when the manager is disposed.
  11560. */
  11561. onDisposeObservable: Observable<SpriteManager>;
  11562. private _onDisposeObserver;
  11563. /**
  11564. * Callback called when the manager is disposed
  11565. */
  11566. onDispose: () => void;
  11567. private _capacity;
  11568. private _spriteTexture;
  11569. private _epsilon;
  11570. private _scene;
  11571. private _vertexData;
  11572. private _buffer;
  11573. private _vertexBuffers;
  11574. private _indexBuffer;
  11575. private _effectBase;
  11576. private _effectFog;
  11577. /**
  11578. * Gets or sets the spritesheet texture
  11579. */
  11580. texture: Texture;
  11581. /**
  11582. * Creates a new sprite manager
  11583. * @param name defines the manager's name
  11584. * @param imgUrl defines the sprite sheet url
  11585. * @param capacity defines the maximum allowed number of sprites
  11586. * @param cellSize defines the size of a sprite cell
  11587. * @param scene defines the hosting scene
  11588. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11589. * @param samplingMode defines the smapling mode to use with spritesheet
  11590. */
  11591. constructor(
  11592. /** defines the manager's name */
  11593. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11594. private _appendSpriteVertex;
  11595. /**
  11596. * Intersects the sprites with a ray
  11597. * @param ray defines the ray to intersect with
  11598. * @param camera defines the current active camera
  11599. * @param predicate defines a predicate used to select candidate sprites
  11600. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11601. * @returns null if no hit or a PickingInfo
  11602. */
  11603. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11604. /**
  11605. * Render all child sprites
  11606. */
  11607. render(): void;
  11608. /**
  11609. * Release associated resources
  11610. */
  11611. dispose(): void;
  11612. }
  11613. }
  11614. declare module "babylonjs/Sprites/sprite" {
  11615. import { Vector3 } from "babylonjs/Maths/math.vector";
  11616. import { Nullable } from "babylonjs/types";
  11617. import { ActionManager } from "babylonjs/Actions/actionManager";
  11618. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11619. import { Color4 } from "babylonjs/Maths/math.color";
  11620. /**
  11621. * Class used to represent a sprite
  11622. * @see http://doc.babylonjs.com/babylon101/sprites
  11623. */
  11624. export class Sprite {
  11625. /** defines the name */
  11626. name: string;
  11627. /** Gets or sets the current world position */
  11628. position: Vector3;
  11629. /** Gets or sets the main color */
  11630. color: Color4;
  11631. /** Gets or sets the width */
  11632. width: number;
  11633. /** Gets or sets the height */
  11634. height: number;
  11635. /** Gets or sets rotation angle */
  11636. angle: number;
  11637. /** Gets or sets the cell index in the sprite sheet */
  11638. cellIndex: number;
  11639. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11640. invertU: number;
  11641. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11642. invertV: number;
  11643. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11644. disposeWhenFinishedAnimating: boolean;
  11645. /** Gets the list of attached animations */
  11646. animations: Animation[];
  11647. /** Gets or sets a boolean indicating if the sprite can be picked */
  11648. isPickable: boolean;
  11649. /**
  11650. * Gets or sets the associated action manager
  11651. */
  11652. actionManager: Nullable<ActionManager>;
  11653. private _animationStarted;
  11654. private _loopAnimation;
  11655. private _fromIndex;
  11656. private _toIndex;
  11657. private _delay;
  11658. private _direction;
  11659. private _manager;
  11660. private _time;
  11661. private _onAnimationEnd;
  11662. /**
  11663. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11664. */
  11665. isVisible: boolean;
  11666. /**
  11667. * Gets or sets the sprite size
  11668. */
  11669. size: number;
  11670. /**
  11671. * Creates a new Sprite
  11672. * @param name defines the name
  11673. * @param manager defines the manager
  11674. */
  11675. constructor(
  11676. /** defines the name */
  11677. name: string, manager: ISpriteManager);
  11678. /**
  11679. * Starts an animation
  11680. * @param from defines the initial key
  11681. * @param to defines the end key
  11682. * @param loop defines if the animation must loop
  11683. * @param delay defines the start delay (in ms)
  11684. * @param onAnimationEnd defines a callback to call when animation ends
  11685. */
  11686. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11687. /** Stops current animation (if any) */
  11688. stopAnimation(): void;
  11689. /** @hidden */
  11690. _animate(deltaTime: number): void;
  11691. /** Release associated resources */
  11692. dispose(): void;
  11693. }
  11694. }
  11695. declare module "babylonjs/Collisions/pickingInfo" {
  11696. import { Nullable } from "babylonjs/types";
  11697. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11698. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11699. import { Sprite } from "babylonjs/Sprites/sprite";
  11700. import { Ray } from "babylonjs/Culling/ray";
  11701. /**
  11702. * Information about the result of picking within a scene
  11703. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11704. */
  11705. export class PickingInfo {
  11706. /** @hidden */
  11707. _pickingUnavailable: boolean;
  11708. /**
  11709. * If the pick collided with an object
  11710. */
  11711. hit: boolean;
  11712. /**
  11713. * Distance away where the pick collided
  11714. */
  11715. distance: number;
  11716. /**
  11717. * The location of pick collision
  11718. */
  11719. pickedPoint: Nullable<Vector3>;
  11720. /**
  11721. * The mesh corresponding the the pick collision
  11722. */
  11723. pickedMesh: Nullable<AbstractMesh>;
  11724. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11725. bu: number;
  11726. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11727. bv: number;
  11728. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11729. faceId: number;
  11730. /** Id of the the submesh that was picked */
  11731. subMeshId: number;
  11732. /** If a sprite was picked, this will be the sprite the pick collided with */
  11733. pickedSprite: Nullable<Sprite>;
  11734. /**
  11735. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11736. */
  11737. originMesh: Nullable<AbstractMesh>;
  11738. /**
  11739. * The ray that was used to perform the picking.
  11740. */
  11741. ray: Nullable<Ray>;
  11742. /**
  11743. * Gets the normal correspodning to the face the pick collided with
  11744. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11745. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11746. * @returns The normal correspodning to the face the pick collided with
  11747. */
  11748. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11749. /**
  11750. * Gets the texture coordinates of where the pick occured
  11751. * @returns the vector containing the coordnates of the texture
  11752. */
  11753. getTextureCoordinates(): Nullable<Vector2>;
  11754. }
  11755. }
  11756. declare module "babylonjs/Events/pointerEvents" {
  11757. import { Nullable } from "babylonjs/types";
  11758. import { Vector2 } from "babylonjs/Maths/math.vector";
  11759. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11760. import { Ray } from "babylonjs/Culling/ray";
  11761. /**
  11762. * Gather the list of pointer event types as constants.
  11763. */
  11764. export class PointerEventTypes {
  11765. /**
  11766. * 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.
  11767. */
  11768. static readonly POINTERDOWN: number;
  11769. /**
  11770. * The pointerup event is fired when a pointer is no longer active.
  11771. */
  11772. static readonly POINTERUP: number;
  11773. /**
  11774. * The pointermove event is fired when a pointer changes coordinates.
  11775. */
  11776. static readonly POINTERMOVE: number;
  11777. /**
  11778. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11779. */
  11780. static readonly POINTERWHEEL: number;
  11781. /**
  11782. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11783. */
  11784. static readonly POINTERPICK: number;
  11785. /**
  11786. * The pointertap event is fired when a the object has been touched and released without drag.
  11787. */
  11788. static readonly POINTERTAP: number;
  11789. /**
  11790. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11791. */
  11792. static readonly POINTERDOUBLETAP: number;
  11793. }
  11794. /**
  11795. * Base class of pointer info types.
  11796. */
  11797. export class PointerInfoBase {
  11798. /**
  11799. * Defines the type of event (PointerEventTypes)
  11800. */
  11801. type: number;
  11802. /**
  11803. * Defines the related dom event
  11804. */
  11805. event: PointerEvent | MouseWheelEvent;
  11806. /**
  11807. * Instantiates the base class of pointers info.
  11808. * @param type Defines the type of event (PointerEventTypes)
  11809. * @param event Defines the related dom event
  11810. */
  11811. constructor(
  11812. /**
  11813. * Defines the type of event (PointerEventTypes)
  11814. */
  11815. type: number,
  11816. /**
  11817. * Defines the related dom event
  11818. */
  11819. event: PointerEvent | MouseWheelEvent);
  11820. }
  11821. /**
  11822. * This class is used to store pointer related info for the onPrePointerObservable event.
  11823. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11824. */
  11825. export class PointerInfoPre extends PointerInfoBase {
  11826. /**
  11827. * Ray from a pointer if availible (eg. 6dof controller)
  11828. */
  11829. ray: Nullable<Ray>;
  11830. /**
  11831. * Defines the local position of the pointer on the canvas.
  11832. */
  11833. localPosition: Vector2;
  11834. /**
  11835. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11836. */
  11837. skipOnPointerObservable: boolean;
  11838. /**
  11839. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11840. * @param type Defines the type of event (PointerEventTypes)
  11841. * @param event Defines the related dom event
  11842. * @param localX Defines the local x coordinates of the pointer when the event occured
  11843. * @param localY Defines the local y coordinates of the pointer when the event occured
  11844. */
  11845. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11846. }
  11847. /**
  11848. * This type contains all the data related to a pointer event in Babylon.js.
  11849. * 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.
  11850. */
  11851. export class PointerInfo extends PointerInfoBase {
  11852. /**
  11853. * Defines the picking info associated to the info (if any)\
  11854. */
  11855. pickInfo: Nullable<PickingInfo>;
  11856. /**
  11857. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11858. * @param type Defines the type of event (PointerEventTypes)
  11859. * @param event Defines the related dom event
  11860. * @param pickInfo Defines the picking info associated to the info (if any)\
  11861. */
  11862. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11863. /**
  11864. * Defines the picking info associated to the info (if any)\
  11865. */
  11866. pickInfo: Nullable<PickingInfo>);
  11867. }
  11868. /**
  11869. * Data relating to a touch event on the screen.
  11870. */
  11871. export interface PointerTouch {
  11872. /**
  11873. * X coordinate of touch.
  11874. */
  11875. x: number;
  11876. /**
  11877. * Y coordinate of touch.
  11878. */
  11879. y: number;
  11880. /**
  11881. * Id of touch. Unique for each finger.
  11882. */
  11883. pointerId: number;
  11884. /**
  11885. * Event type passed from DOM.
  11886. */
  11887. type: any;
  11888. }
  11889. }
  11890. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  11891. import { Observable } from "babylonjs/Misc/observable";
  11892. import { Nullable } from "babylonjs/types";
  11893. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11894. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11895. /**
  11896. * Manage the mouse inputs to control the movement of a free camera.
  11897. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11898. */
  11899. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11900. /**
  11901. * Define if touch is enabled in the mouse input
  11902. */
  11903. touchEnabled: boolean;
  11904. /**
  11905. * Defines the camera the input is attached to.
  11906. */
  11907. camera: FreeCamera;
  11908. /**
  11909. * Defines the buttons associated with the input to handle camera move.
  11910. */
  11911. buttons: number[];
  11912. /**
  11913. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11914. */
  11915. angularSensibility: number;
  11916. private _pointerInput;
  11917. private _onMouseMove;
  11918. private _observer;
  11919. private previousPosition;
  11920. /**
  11921. * Observable for when a pointer move event occurs containing the move offset
  11922. */
  11923. onPointerMovedObservable: Observable<{
  11924. offsetX: number;
  11925. offsetY: number;
  11926. }>;
  11927. /**
  11928. * @hidden
  11929. * If the camera should be rotated automatically based on pointer movement
  11930. */
  11931. _allowCameraRotation: boolean;
  11932. /**
  11933. * Manage the mouse inputs to control the movement of a free camera.
  11934. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11935. * @param touchEnabled Defines if touch is enabled or not
  11936. */
  11937. constructor(
  11938. /**
  11939. * Define if touch is enabled in the mouse input
  11940. */
  11941. touchEnabled?: boolean);
  11942. /**
  11943. * Attach the input controls to a specific dom element to get the input from.
  11944. * @param element Defines the element the controls should be listened from
  11945. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11946. */
  11947. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11948. /**
  11949. * Called on JS contextmenu event.
  11950. * Override this method to provide functionality.
  11951. */
  11952. protected onContextMenu(evt: PointerEvent): void;
  11953. /**
  11954. * Detach the current controls from the specified dom element.
  11955. * @param element Defines the element to stop listening the inputs from
  11956. */
  11957. detachControl(element: Nullable<HTMLElement>): void;
  11958. /**
  11959. * Gets the class name of the current intput.
  11960. * @returns the class name
  11961. */
  11962. getClassName(): string;
  11963. /**
  11964. * Get the friendly name associated with the input class.
  11965. * @returns the input friendly name
  11966. */
  11967. getSimpleName(): string;
  11968. }
  11969. }
  11970. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  11971. import { Nullable } from "babylonjs/types";
  11972. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11973. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11974. /**
  11975. * Manage the touch inputs to control the movement of a free camera.
  11976. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11977. */
  11978. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11979. /**
  11980. * Defines the camera the input is attached to.
  11981. */
  11982. camera: FreeCamera;
  11983. /**
  11984. * Defines the touch sensibility for rotation.
  11985. * The higher the faster.
  11986. */
  11987. touchAngularSensibility: number;
  11988. /**
  11989. * Defines the touch sensibility for move.
  11990. * The higher the faster.
  11991. */
  11992. touchMoveSensibility: number;
  11993. private _offsetX;
  11994. private _offsetY;
  11995. private _pointerPressed;
  11996. private _pointerInput;
  11997. private _observer;
  11998. private _onLostFocus;
  11999. /**
  12000. * Attach the input controls to a specific dom element to get the input from.
  12001. * @param element Defines the element the controls should be listened from
  12002. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12003. */
  12004. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12005. /**
  12006. * Detach the current controls from the specified dom element.
  12007. * @param element Defines the element to stop listening the inputs from
  12008. */
  12009. detachControl(element: Nullable<HTMLElement>): void;
  12010. /**
  12011. * Update the current camera state depending on the inputs that have been used this frame.
  12012. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12013. */
  12014. checkInputs(): void;
  12015. /**
  12016. * Gets the class name of the current intput.
  12017. * @returns the class name
  12018. */
  12019. getClassName(): string;
  12020. /**
  12021. * Get the friendly name associated with the input class.
  12022. * @returns the input friendly name
  12023. */
  12024. getSimpleName(): string;
  12025. }
  12026. }
  12027. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12028. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12029. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12030. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12031. import { Nullable } from "babylonjs/types";
  12032. /**
  12033. * Default Inputs manager for the FreeCamera.
  12034. * It groups all the default supported inputs for ease of use.
  12035. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12036. */
  12037. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12038. /**
  12039. * @hidden
  12040. */
  12041. _mouseInput: Nullable<FreeCameraMouseInput>;
  12042. /**
  12043. * Instantiates a new FreeCameraInputsManager.
  12044. * @param camera Defines the camera the inputs belong to
  12045. */
  12046. constructor(camera: FreeCamera);
  12047. /**
  12048. * Add keyboard input support to the input manager.
  12049. * @returns the current input manager
  12050. */
  12051. addKeyboard(): FreeCameraInputsManager;
  12052. /**
  12053. * Add mouse input support to the input manager.
  12054. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12055. * @returns the current input manager
  12056. */
  12057. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12058. /**
  12059. * Removes the mouse input support from the manager
  12060. * @returns the current input manager
  12061. */
  12062. removeMouse(): FreeCameraInputsManager;
  12063. /**
  12064. * Add touch input support to the input manager.
  12065. * @returns the current input manager
  12066. */
  12067. addTouch(): FreeCameraInputsManager;
  12068. /**
  12069. * Remove all attached input methods from a camera
  12070. */
  12071. clear(): void;
  12072. }
  12073. }
  12074. declare module "babylonjs/Cameras/freeCamera" {
  12075. import { Vector3 } from "babylonjs/Maths/math.vector";
  12076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12077. import { Scene } from "babylonjs/scene";
  12078. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12079. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12080. /**
  12081. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12082. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12083. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12084. */
  12085. export class FreeCamera extends TargetCamera {
  12086. /**
  12087. * Define the collision ellipsoid of the camera.
  12088. * This is helpful to simulate a camera body like the player body around the camera
  12089. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12090. */
  12091. ellipsoid: Vector3;
  12092. /**
  12093. * Define an offset for the position of the ellipsoid around the camera.
  12094. * This can be helpful to determine the center of the body near the gravity center of the body
  12095. * instead of its head.
  12096. */
  12097. ellipsoidOffset: Vector3;
  12098. /**
  12099. * Enable or disable collisions of the camera with the rest of the scene objects.
  12100. */
  12101. checkCollisions: boolean;
  12102. /**
  12103. * Enable or disable gravity on the camera.
  12104. */
  12105. applyGravity: boolean;
  12106. /**
  12107. * Define the input manager associated to the camera.
  12108. */
  12109. inputs: FreeCameraInputsManager;
  12110. /**
  12111. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12112. * Higher values reduce sensitivity.
  12113. */
  12114. /**
  12115. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12116. * Higher values reduce sensitivity.
  12117. */
  12118. angularSensibility: number;
  12119. /**
  12120. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12121. */
  12122. keysUp: number[];
  12123. /**
  12124. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12125. */
  12126. keysDown: number[];
  12127. /**
  12128. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12129. */
  12130. keysLeft: number[];
  12131. /**
  12132. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12133. */
  12134. keysRight: number[];
  12135. /**
  12136. * Event raised when the camera collide with a mesh in the scene.
  12137. */
  12138. onCollide: (collidedMesh: AbstractMesh) => void;
  12139. private _collider;
  12140. private _needMoveForGravity;
  12141. private _oldPosition;
  12142. private _diffPosition;
  12143. private _newPosition;
  12144. /** @hidden */
  12145. _localDirection: Vector3;
  12146. /** @hidden */
  12147. _transformedDirection: Vector3;
  12148. /**
  12149. * Instantiates a Free Camera.
  12150. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12151. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12152. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12153. * @param name Define the name of the camera in the scene
  12154. * @param position Define the start position of the camera in the scene
  12155. * @param scene Define the scene the camera belongs to
  12156. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12157. */
  12158. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12159. /**
  12160. * Attached controls to the current camera.
  12161. * @param element Defines the element the controls should be listened from
  12162. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12163. */
  12164. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12165. /**
  12166. * Detach the current controls from the camera.
  12167. * The camera will stop reacting to inputs.
  12168. * @param element Defines the element to stop listening the inputs from
  12169. */
  12170. detachControl(element: HTMLElement): void;
  12171. private _collisionMask;
  12172. /**
  12173. * Define a collision mask to limit the list of object the camera can collide with
  12174. */
  12175. collisionMask: number;
  12176. /** @hidden */
  12177. _collideWithWorld(displacement: Vector3): void;
  12178. private _onCollisionPositionChange;
  12179. /** @hidden */
  12180. _checkInputs(): void;
  12181. /** @hidden */
  12182. _decideIfNeedsToMove(): boolean;
  12183. /** @hidden */
  12184. _updatePosition(): void;
  12185. /**
  12186. * Destroy the camera and release the current resources hold by it.
  12187. */
  12188. dispose(): void;
  12189. /**
  12190. * Gets the current object class name.
  12191. * @return the class name
  12192. */
  12193. getClassName(): string;
  12194. }
  12195. }
  12196. declare module "babylonjs/Gamepads/gamepad" {
  12197. import { Observable } from "babylonjs/Misc/observable";
  12198. /**
  12199. * Represents a gamepad control stick position
  12200. */
  12201. export class StickValues {
  12202. /**
  12203. * The x component of the control stick
  12204. */
  12205. x: number;
  12206. /**
  12207. * The y component of the control stick
  12208. */
  12209. y: number;
  12210. /**
  12211. * Initializes the gamepad x and y control stick values
  12212. * @param x The x component of the gamepad control stick value
  12213. * @param y The y component of the gamepad control stick value
  12214. */
  12215. constructor(
  12216. /**
  12217. * The x component of the control stick
  12218. */
  12219. x: number,
  12220. /**
  12221. * The y component of the control stick
  12222. */
  12223. y: number);
  12224. }
  12225. /**
  12226. * An interface which manages callbacks for gamepad button changes
  12227. */
  12228. export interface GamepadButtonChanges {
  12229. /**
  12230. * Called when a gamepad has been changed
  12231. */
  12232. changed: boolean;
  12233. /**
  12234. * Called when a gamepad press event has been triggered
  12235. */
  12236. pressChanged: boolean;
  12237. /**
  12238. * Called when a touch event has been triggered
  12239. */
  12240. touchChanged: boolean;
  12241. /**
  12242. * Called when a value has changed
  12243. */
  12244. valueChanged: boolean;
  12245. }
  12246. /**
  12247. * Represents a gamepad
  12248. */
  12249. export class Gamepad {
  12250. /**
  12251. * The id of the gamepad
  12252. */
  12253. id: string;
  12254. /**
  12255. * The index of the gamepad
  12256. */
  12257. index: number;
  12258. /**
  12259. * The browser gamepad
  12260. */
  12261. browserGamepad: any;
  12262. /**
  12263. * Specifies what type of gamepad this represents
  12264. */
  12265. type: number;
  12266. private _leftStick;
  12267. private _rightStick;
  12268. /** @hidden */
  12269. _isConnected: boolean;
  12270. private _leftStickAxisX;
  12271. private _leftStickAxisY;
  12272. private _rightStickAxisX;
  12273. private _rightStickAxisY;
  12274. /**
  12275. * Triggered when the left control stick has been changed
  12276. */
  12277. private _onleftstickchanged;
  12278. /**
  12279. * Triggered when the right control stick has been changed
  12280. */
  12281. private _onrightstickchanged;
  12282. /**
  12283. * Represents a gamepad controller
  12284. */
  12285. static GAMEPAD: number;
  12286. /**
  12287. * Represents a generic controller
  12288. */
  12289. static GENERIC: number;
  12290. /**
  12291. * Represents an XBox controller
  12292. */
  12293. static XBOX: number;
  12294. /**
  12295. * Represents a pose-enabled controller
  12296. */
  12297. static POSE_ENABLED: number;
  12298. /**
  12299. * Specifies whether the left control stick should be Y-inverted
  12300. */
  12301. protected _invertLeftStickY: boolean;
  12302. /**
  12303. * Specifies if the gamepad has been connected
  12304. */
  12305. readonly isConnected: boolean;
  12306. /**
  12307. * Initializes the gamepad
  12308. * @param id The id of the gamepad
  12309. * @param index The index of the gamepad
  12310. * @param browserGamepad The browser gamepad
  12311. * @param leftStickX The x component of the left joystick
  12312. * @param leftStickY The y component of the left joystick
  12313. * @param rightStickX The x component of the right joystick
  12314. * @param rightStickY The y component of the right joystick
  12315. */
  12316. constructor(
  12317. /**
  12318. * The id of the gamepad
  12319. */
  12320. id: string,
  12321. /**
  12322. * The index of the gamepad
  12323. */
  12324. index: number,
  12325. /**
  12326. * The browser gamepad
  12327. */
  12328. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12329. /**
  12330. * Callback triggered when the left joystick has changed
  12331. * @param callback
  12332. */
  12333. onleftstickchanged(callback: (values: StickValues) => void): void;
  12334. /**
  12335. * Callback triggered when the right joystick has changed
  12336. * @param callback
  12337. */
  12338. onrightstickchanged(callback: (values: StickValues) => void): void;
  12339. /**
  12340. * Gets the left joystick
  12341. */
  12342. /**
  12343. * Sets the left joystick values
  12344. */
  12345. leftStick: StickValues;
  12346. /**
  12347. * Gets the right joystick
  12348. */
  12349. /**
  12350. * Sets the right joystick value
  12351. */
  12352. rightStick: StickValues;
  12353. /**
  12354. * Updates the gamepad joystick positions
  12355. */
  12356. update(): void;
  12357. /**
  12358. * Disposes the gamepad
  12359. */
  12360. dispose(): void;
  12361. }
  12362. /**
  12363. * Represents a generic gamepad
  12364. */
  12365. export class GenericPad extends Gamepad {
  12366. private _buttons;
  12367. private _onbuttondown;
  12368. private _onbuttonup;
  12369. /**
  12370. * Observable triggered when a button has been pressed
  12371. */
  12372. onButtonDownObservable: Observable<number>;
  12373. /**
  12374. * Observable triggered when a button has been released
  12375. */
  12376. onButtonUpObservable: Observable<number>;
  12377. /**
  12378. * Callback triggered when a button has been pressed
  12379. * @param callback Called when a button has been pressed
  12380. */
  12381. onbuttondown(callback: (buttonPressed: number) => void): void;
  12382. /**
  12383. * Callback triggered when a button has been released
  12384. * @param callback Called when a button has been released
  12385. */
  12386. onbuttonup(callback: (buttonReleased: number) => void): void;
  12387. /**
  12388. * Initializes the generic gamepad
  12389. * @param id The id of the generic gamepad
  12390. * @param index The index of the generic gamepad
  12391. * @param browserGamepad The browser gamepad
  12392. */
  12393. constructor(id: string, index: number, browserGamepad: any);
  12394. private _setButtonValue;
  12395. /**
  12396. * Updates the generic gamepad
  12397. */
  12398. update(): void;
  12399. /**
  12400. * Disposes the generic gamepad
  12401. */
  12402. dispose(): void;
  12403. }
  12404. }
  12405. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12406. import { Nullable } from "babylonjs/types";
  12407. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12408. import { Scene } from "babylonjs/scene";
  12409. module "babylonjs/Engines/engine" {
  12410. interface Engine {
  12411. /**
  12412. * Creates a raw texture
  12413. * @param data defines the data to store in the texture
  12414. * @param width defines the width of the texture
  12415. * @param height defines the height of the texture
  12416. * @param format defines the format of the data
  12417. * @param generateMipMaps defines if the engine should generate the mip levels
  12418. * @param invertY defines if data must be stored with Y axis inverted
  12419. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12420. * @param compression defines the compression used (null by default)
  12421. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12422. * @returns the raw texture inside an InternalTexture
  12423. */
  12424. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12425. /**
  12426. * Update a raw texture
  12427. * @param texture defines the texture to update
  12428. * @param data defines the data to store in the texture
  12429. * @param format defines the format of the data
  12430. * @param invertY defines if data must be stored with Y axis inverted
  12431. */
  12432. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12433. /**
  12434. * Update a raw texture
  12435. * @param texture defines the texture to update
  12436. * @param data defines the data to store in the texture
  12437. * @param format defines the format of the data
  12438. * @param invertY defines if data must be stored with Y axis inverted
  12439. * @param compression defines the compression used (null by default)
  12440. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12441. */
  12442. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12443. /**
  12444. * Creates a new raw cube texture
  12445. * @param data defines the array of data to use to create each face
  12446. * @param size defines the size of the textures
  12447. * @param format defines the format of the data
  12448. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12449. * @param generateMipMaps defines if the engine should generate the mip levels
  12450. * @param invertY defines if data must be stored with Y axis inverted
  12451. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12452. * @param compression defines the compression used (null by default)
  12453. * @returns the cube texture as an InternalTexture
  12454. */
  12455. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12456. /**
  12457. * Update a raw cube texture
  12458. * @param texture defines the texture to udpdate
  12459. * @param data defines the data to store
  12460. * @param format defines the data format
  12461. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12462. * @param invertY defines if data must be stored with Y axis inverted
  12463. */
  12464. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12465. /**
  12466. * Update a raw cube texture
  12467. * @param texture defines the texture to udpdate
  12468. * @param data defines the data to store
  12469. * @param format defines the data format
  12470. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12471. * @param invertY defines if data must be stored with Y axis inverted
  12472. * @param compression defines the compression used (null by default)
  12473. */
  12474. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12475. /**
  12476. * Update a raw cube texture
  12477. * @param texture defines the texture to udpdate
  12478. * @param data defines the data to store
  12479. * @param format defines the data format
  12480. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12481. * @param invertY defines if data must be stored with Y axis inverted
  12482. * @param compression defines the compression used (null by default)
  12483. * @param level defines which level of the texture to update
  12484. */
  12485. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12486. /**
  12487. * Creates a new raw cube texture from a specified url
  12488. * @param url defines the url where the data is located
  12489. * @param scene defines the current scene
  12490. * @param size defines the size of the textures
  12491. * @param format defines the format of the data
  12492. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12493. * @param noMipmap defines if the engine should avoid generating the mip levels
  12494. * @param callback defines a callback used to extract texture data from loaded data
  12495. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12496. * @param onLoad defines a callback called when texture is loaded
  12497. * @param onError defines a callback called if there is an error
  12498. * @returns the cube texture as an InternalTexture
  12499. */
  12500. 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;
  12501. /**
  12502. * Creates a new raw cube texture from a specified url
  12503. * @param url defines the url where the data is located
  12504. * @param scene defines the current scene
  12505. * @param size defines the size of the textures
  12506. * @param format defines the format of the data
  12507. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12508. * @param noMipmap defines if the engine should avoid generating the mip levels
  12509. * @param callback defines a callback used to extract texture data from loaded data
  12510. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12511. * @param onLoad defines a callback called when texture is loaded
  12512. * @param onError defines a callback called if there is an error
  12513. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12514. * @param invertY defines if data must be stored with Y axis inverted
  12515. * @returns the cube texture as an InternalTexture
  12516. */
  12517. 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;
  12518. /**
  12519. * Creates a new raw 3D texture
  12520. * @param data defines the data used to create the texture
  12521. * @param width defines the width of the texture
  12522. * @param height defines the height of the texture
  12523. * @param depth defines the depth of the texture
  12524. * @param format defines the format of the texture
  12525. * @param generateMipMaps defines if the engine must generate mip levels
  12526. * @param invertY defines if data must be stored with Y axis inverted
  12527. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12528. * @param compression defines the compressed used (can be null)
  12529. * @param textureType defines the compressed used (can be null)
  12530. * @returns a new raw 3D texture (stored in an InternalTexture)
  12531. */
  12532. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12533. /**
  12534. * Update a raw 3D texture
  12535. * @param texture defines the texture to update
  12536. * @param data defines the data to store
  12537. * @param format defines the data format
  12538. * @param invertY defines if data must be stored with Y axis inverted
  12539. */
  12540. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12541. /**
  12542. * Update a raw 3D texture
  12543. * @param texture defines the texture to update
  12544. * @param data defines the data to store
  12545. * @param format defines the data format
  12546. * @param invertY defines if data must be stored with Y axis inverted
  12547. * @param compression defines the used compression (can be null)
  12548. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12549. */
  12550. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12551. }
  12552. }
  12553. }
  12554. declare module "babylonjs/Materials/Textures/rawTexture" {
  12555. import { Scene } from "babylonjs/scene";
  12556. import { Texture } from "babylonjs/Materials/Textures/texture";
  12557. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12558. /**
  12559. * Raw texture can help creating a texture directly from an array of data.
  12560. * This can be super useful if you either get the data from an uncompressed source or
  12561. * if you wish to create your texture pixel by pixel.
  12562. */
  12563. export class RawTexture extends Texture {
  12564. /**
  12565. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12566. */
  12567. format: number;
  12568. private _engine;
  12569. /**
  12570. * Instantiates a new RawTexture.
  12571. * Raw texture can help creating a texture directly from an array of data.
  12572. * This can be super useful if you either get the data from an uncompressed source or
  12573. * if you wish to create your texture pixel by pixel.
  12574. * @param data define the array of data to use to create the texture
  12575. * @param width define the width of the texture
  12576. * @param height define the height of the texture
  12577. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12578. * @param scene define the scene the texture belongs to
  12579. * @param generateMipMaps define whether mip maps should be generated or not
  12580. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12581. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12582. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12583. */
  12584. constructor(data: ArrayBufferView, width: number, height: number,
  12585. /**
  12586. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12587. */
  12588. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12589. /**
  12590. * Updates the texture underlying data.
  12591. * @param data Define the new data of the texture
  12592. */
  12593. update(data: ArrayBufferView): void;
  12594. /**
  12595. * Creates a luminance texture from some data.
  12596. * @param data Define the texture data
  12597. * @param width Define the width of the texture
  12598. * @param height Define the height of the texture
  12599. * @param scene Define the scene the texture belongs to
  12600. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12601. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12602. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12603. * @returns the luminance texture
  12604. */
  12605. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12606. /**
  12607. * Creates a luminance alpha texture from some data.
  12608. * @param data Define the texture data
  12609. * @param width Define the width of the texture
  12610. * @param height Define the height of the texture
  12611. * @param scene Define the scene the texture belongs to
  12612. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12613. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12614. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12615. * @returns the luminance alpha texture
  12616. */
  12617. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12618. /**
  12619. * Creates an alpha texture from some data.
  12620. * @param data Define the texture data
  12621. * @param width Define the width of the texture
  12622. * @param height Define the height of the texture
  12623. * @param scene Define the scene the texture belongs to
  12624. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12625. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12626. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12627. * @returns the alpha texture
  12628. */
  12629. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12630. /**
  12631. * Creates a RGB texture from some data.
  12632. * @param data Define the texture data
  12633. * @param width Define the width of the texture
  12634. * @param height Define the height of the texture
  12635. * @param scene Define the scene the texture belongs to
  12636. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12637. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12638. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12639. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12640. * @returns the RGB alpha texture
  12641. */
  12642. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12643. /**
  12644. * Creates a RGBA texture from some data.
  12645. * @param data Define the texture data
  12646. * @param width Define the width of the texture
  12647. * @param height Define the height of the texture
  12648. * @param scene Define the scene the texture belongs to
  12649. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12650. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12651. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12652. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12653. * @returns the RGBA texture
  12654. */
  12655. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12656. /**
  12657. * Creates a R texture from some data.
  12658. * @param data Define the texture data
  12659. * @param width Define the width of the texture
  12660. * @param height Define the height of the texture
  12661. * @param scene Define the scene the texture belongs to
  12662. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12663. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12664. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12665. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12666. * @returns the R texture
  12667. */
  12668. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12669. }
  12670. }
  12671. declare module "babylonjs/Maths/math.size" {
  12672. /**
  12673. * Interface for the size containing width and height
  12674. */
  12675. export interface ISize {
  12676. /**
  12677. * Width
  12678. */
  12679. width: number;
  12680. /**
  12681. * Heighht
  12682. */
  12683. height: number;
  12684. }
  12685. /**
  12686. * Size containing widht and height
  12687. */
  12688. export class Size implements ISize {
  12689. /**
  12690. * Width
  12691. */
  12692. width: number;
  12693. /**
  12694. * Height
  12695. */
  12696. height: number;
  12697. /**
  12698. * Creates a Size object from the given width and height (floats).
  12699. * @param width width of the new size
  12700. * @param height height of the new size
  12701. */
  12702. constructor(width: number, height: number);
  12703. /**
  12704. * Returns a string with the Size width and height
  12705. * @returns a string with the Size width and height
  12706. */
  12707. toString(): string;
  12708. /**
  12709. * "Size"
  12710. * @returns the string "Size"
  12711. */
  12712. getClassName(): string;
  12713. /**
  12714. * Returns the Size hash code.
  12715. * @returns a hash code for a unique width and height
  12716. */
  12717. getHashCode(): number;
  12718. /**
  12719. * Updates the current size from the given one.
  12720. * @param src the given size
  12721. */
  12722. copyFrom(src: Size): void;
  12723. /**
  12724. * Updates in place the current Size from the given floats.
  12725. * @param width width of the new size
  12726. * @param height height of the new size
  12727. * @returns the updated Size.
  12728. */
  12729. copyFromFloats(width: number, height: number): Size;
  12730. /**
  12731. * Updates in place the current Size from the given floats.
  12732. * @param width width to set
  12733. * @param height height to set
  12734. * @returns the updated Size.
  12735. */
  12736. set(width: number, height: number): Size;
  12737. /**
  12738. * Multiplies the width and height by numbers
  12739. * @param w factor to multiple the width by
  12740. * @param h factor to multiple the height by
  12741. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12742. */
  12743. multiplyByFloats(w: number, h: number): Size;
  12744. /**
  12745. * Clones the size
  12746. * @returns a new Size copied from the given one.
  12747. */
  12748. clone(): Size;
  12749. /**
  12750. * True if the current Size and the given one width and height are strictly equal.
  12751. * @param other the other size to compare against
  12752. * @returns True if the current Size and the given one width and height are strictly equal.
  12753. */
  12754. equals(other: Size): boolean;
  12755. /**
  12756. * The surface of the Size : width * height (float).
  12757. */
  12758. readonly surface: number;
  12759. /**
  12760. * Create a new size of zero
  12761. * @returns a new Size set to (0.0, 0.0)
  12762. */
  12763. static Zero(): Size;
  12764. /**
  12765. * Sums the width and height of two sizes
  12766. * @param otherSize size to add to this size
  12767. * @returns a new Size set as the addition result of the current Size and the given one.
  12768. */
  12769. add(otherSize: Size): Size;
  12770. /**
  12771. * Subtracts the width and height of two
  12772. * @param otherSize size to subtract to this size
  12773. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12774. */
  12775. subtract(otherSize: Size): Size;
  12776. /**
  12777. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12778. * @param start starting size to lerp between
  12779. * @param end end size to lerp between
  12780. * @param amount amount to lerp between the start and end values
  12781. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12782. */
  12783. static Lerp(start: Size, end: Size, amount: number): Size;
  12784. }
  12785. }
  12786. declare module "babylonjs/Animations/runtimeAnimation" {
  12787. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12788. import { Animatable } from "babylonjs/Animations/animatable";
  12789. import { Scene } from "babylonjs/scene";
  12790. /**
  12791. * Defines a runtime animation
  12792. */
  12793. export class RuntimeAnimation {
  12794. private _events;
  12795. /**
  12796. * The current frame of the runtime animation
  12797. */
  12798. private _currentFrame;
  12799. /**
  12800. * The animation used by the runtime animation
  12801. */
  12802. private _animation;
  12803. /**
  12804. * The target of the runtime animation
  12805. */
  12806. private _target;
  12807. /**
  12808. * The initiating animatable
  12809. */
  12810. private _host;
  12811. /**
  12812. * The original value of the runtime animation
  12813. */
  12814. private _originalValue;
  12815. /**
  12816. * The original blend value of the runtime animation
  12817. */
  12818. private _originalBlendValue;
  12819. /**
  12820. * The offsets cache of the runtime animation
  12821. */
  12822. private _offsetsCache;
  12823. /**
  12824. * The high limits cache of the runtime animation
  12825. */
  12826. private _highLimitsCache;
  12827. /**
  12828. * Specifies if the runtime animation has been stopped
  12829. */
  12830. private _stopped;
  12831. /**
  12832. * The blending factor of the runtime animation
  12833. */
  12834. private _blendingFactor;
  12835. /**
  12836. * The BabylonJS scene
  12837. */
  12838. private _scene;
  12839. /**
  12840. * The current value of the runtime animation
  12841. */
  12842. private _currentValue;
  12843. /** @hidden */
  12844. _animationState: _IAnimationState;
  12845. /**
  12846. * The active target of the runtime animation
  12847. */
  12848. private _activeTargets;
  12849. private _currentActiveTarget;
  12850. private _directTarget;
  12851. /**
  12852. * The target path of the runtime animation
  12853. */
  12854. private _targetPath;
  12855. /**
  12856. * The weight of the runtime animation
  12857. */
  12858. private _weight;
  12859. /**
  12860. * The ratio offset of the runtime animation
  12861. */
  12862. private _ratioOffset;
  12863. /**
  12864. * The previous delay of the runtime animation
  12865. */
  12866. private _previousDelay;
  12867. /**
  12868. * The previous ratio of the runtime animation
  12869. */
  12870. private _previousRatio;
  12871. private _enableBlending;
  12872. private _keys;
  12873. private _minFrame;
  12874. private _maxFrame;
  12875. private _minValue;
  12876. private _maxValue;
  12877. private _targetIsArray;
  12878. /**
  12879. * Gets the current frame of the runtime animation
  12880. */
  12881. readonly currentFrame: number;
  12882. /**
  12883. * Gets the weight of the runtime animation
  12884. */
  12885. readonly weight: number;
  12886. /**
  12887. * Gets the current value of the runtime animation
  12888. */
  12889. readonly currentValue: any;
  12890. /**
  12891. * Gets the target path of the runtime animation
  12892. */
  12893. readonly targetPath: string;
  12894. /**
  12895. * Gets the actual target of the runtime animation
  12896. */
  12897. readonly target: any;
  12898. /** @hidden */
  12899. _onLoop: () => void;
  12900. /**
  12901. * Create a new RuntimeAnimation object
  12902. * @param target defines the target of the animation
  12903. * @param animation defines the source animation object
  12904. * @param scene defines the hosting scene
  12905. * @param host defines the initiating Animatable
  12906. */
  12907. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12908. private _preparePath;
  12909. /**
  12910. * Gets the animation from the runtime animation
  12911. */
  12912. readonly animation: Animation;
  12913. /**
  12914. * Resets the runtime animation to the beginning
  12915. * @param restoreOriginal defines whether to restore the target property to the original value
  12916. */
  12917. reset(restoreOriginal?: boolean): void;
  12918. /**
  12919. * Specifies if the runtime animation is stopped
  12920. * @returns Boolean specifying if the runtime animation is stopped
  12921. */
  12922. isStopped(): boolean;
  12923. /**
  12924. * Disposes of the runtime animation
  12925. */
  12926. dispose(): void;
  12927. /**
  12928. * Apply the interpolated value to the target
  12929. * @param currentValue defines the value computed by the animation
  12930. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12931. */
  12932. setValue(currentValue: any, weight: number): void;
  12933. private _getOriginalValues;
  12934. private _setValue;
  12935. /**
  12936. * Gets the loop pmode of the runtime animation
  12937. * @returns Loop Mode
  12938. */
  12939. private _getCorrectLoopMode;
  12940. /**
  12941. * Move the current animation to a given frame
  12942. * @param frame defines the frame to move to
  12943. */
  12944. goToFrame(frame: number): void;
  12945. /**
  12946. * @hidden Internal use only
  12947. */
  12948. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12949. /**
  12950. * Execute the current animation
  12951. * @param delay defines the delay to add to the current frame
  12952. * @param from defines the lower bound of the animation range
  12953. * @param to defines the upper bound of the animation range
  12954. * @param loop defines if the current animation must loop
  12955. * @param speedRatio defines the current speed ratio
  12956. * @param weight defines the weight of the animation (default is -1 so no weight)
  12957. * @param onLoop optional callback called when animation loops
  12958. * @returns a boolean indicating if the animation is running
  12959. */
  12960. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12961. }
  12962. }
  12963. declare module "babylonjs/Animations/animatable" {
  12964. import { Animation } from "babylonjs/Animations/animation";
  12965. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  12966. import { Nullable } from "babylonjs/types";
  12967. import { Observable } from "babylonjs/Misc/observable";
  12968. import { Scene } from "babylonjs/scene";
  12969. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  12970. import { Node } from "babylonjs/node";
  12971. /**
  12972. * Class used to store an actual running animation
  12973. */
  12974. export class Animatable {
  12975. /** defines the target object */
  12976. target: any;
  12977. /** defines the starting frame number (default is 0) */
  12978. fromFrame: number;
  12979. /** defines the ending frame number (default is 100) */
  12980. toFrame: number;
  12981. /** defines if the animation must loop (default is false) */
  12982. loopAnimation: boolean;
  12983. /** defines a callback to call when animation ends if it is not looping */
  12984. onAnimationEnd?: (() => void) | null | undefined;
  12985. /** defines a callback to call when animation loops */
  12986. onAnimationLoop?: (() => void) | null | undefined;
  12987. private _localDelayOffset;
  12988. private _pausedDelay;
  12989. private _runtimeAnimations;
  12990. private _paused;
  12991. private _scene;
  12992. private _speedRatio;
  12993. private _weight;
  12994. private _syncRoot;
  12995. /**
  12996. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12997. * This will only apply for non looping animation (default is true)
  12998. */
  12999. disposeOnEnd: boolean;
  13000. /**
  13001. * Gets a boolean indicating if the animation has started
  13002. */
  13003. animationStarted: boolean;
  13004. /**
  13005. * Observer raised when the animation ends
  13006. */
  13007. onAnimationEndObservable: Observable<Animatable>;
  13008. /**
  13009. * Observer raised when the animation loops
  13010. */
  13011. onAnimationLoopObservable: Observable<Animatable>;
  13012. /**
  13013. * Gets the root Animatable used to synchronize and normalize animations
  13014. */
  13015. readonly syncRoot: Nullable<Animatable>;
  13016. /**
  13017. * Gets the current frame of the first RuntimeAnimation
  13018. * Used to synchronize Animatables
  13019. */
  13020. readonly masterFrame: number;
  13021. /**
  13022. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13023. */
  13024. weight: number;
  13025. /**
  13026. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13027. */
  13028. speedRatio: number;
  13029. /**
  13030. * Creates a new Animatable
  13031. * @param scene defines the hosting scene
  13032. * @param target defines the target object
  13033. * @param fromFrame defines the starting frame number (default is 0)
  13034. * @param toFrame defines the ending frame number (default is 100)
  13035. * @param loopAnimation defines if the animation must loop (default is false)
  13036. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13037. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13038. * @param animations defines a group of animation to add to the new Animatable
  13039. * @param onAnimationLoop defines a callback to call when animation loops
  13040. */
  13041. constructor(scene: Scene,
  13042. /** defines the target object */
  13043. target: any,
  13044. /** defines the starting frame number (default is 0) */
  13045. fromFrame?: number,
  13046. /** defines the ending frame number (default is 100) */
  13047. toFrame?: number,
  13048. /** defines if the animation must loop (default is false) */
  13049. loopAnimation?: boolean, speedRatio?: number,
  13050. /** defines a callback to call when animation ends if it is not looping */
  13051. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13052. /** defines a callback to call when animation loops */
  13053. onAnimationLoop?: (() => void) | null | undefined);
  13054. /**
  13055. * Synchronize and normalize current Animatable with a source Animatable
  13056. * This is useful when using animation weights and when animations are not of the same length
  13057. * @param root defines the root Animatable to synchronize with
  13058. * @returns the current Animatable
  13059. */
  13060. syncWith(root: Animatable): Animatable;
  13061. /**
  13062. * Gets the list of runtime animations
  13063. * @returns an array of RuntimeAnimation
  13064. */
  13065. getAnimations(): RuntimeAnimation[];
  13066. /**
  13067. * Adds more animations to the current animatable
  13068. * @param target defines the target of the animations
  13069. * @param animations defines the new animations to add
  13070. */
  13071. appendAnimations(target: any, animations: Animation[]): void;
  13072. /**
  13073. * Gets the source animation for a specific property
  13074. * @param property defines the propertyu to look for
  13075. * @returns null or the source animation for the given property
  13076. */
  13077. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13078. /**
  13079. * Gets the runtime animation for a specific property
  13080. * @param property defines the propertyu to look for
  13081. * @returns null or the runtime animation for the given property
  13082. */
  13083. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13084. /**
  13085. * Resets the animatable to its original state
  13086. */
  13087. reset(): void;
  13088. /**
  13089. * Allows the animatable to blend with current running animations
  13090. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13091. * @param blendingSpeed defines the blending speed to use
  13092. */
  13093. enableBlending(blendingSpeed: number): void;
  13094. /**
  13095. * Disable animation blending
  13096. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13097. */
  13098. disableBlending(): void;
  13099. /**
  13100. * Jump directly to a given frame
  13101. * @param frame defines the frame to jump to
  13102. */
  13103. goToFrame(frame: number): void;
  13104. /**
  13105. * Pause the animation
  13106. */
  13107. pause(): void;
  13108. /**
  13109. * Restart the animation
  13110. */
  13111. restart(): void;
  13112. private _raiseOnAnimationEnd;
  13113. /**
  13114. * Stop and delete the current animation
  13115. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13116. * @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)
  13117. */
  13118. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13119. /**
  13120. * Wait asynchronously for the animation to end
  13121. * @returns a promise which will be fullfilled when the animation ends
  13122. */
  13123. waitAsync(): Promise<Animatable>;
  13124. /** @hidden */
  13125. _animate(delay: number): boolean;
  13126. }
  13127. module "babylonjs/scene" {
  13128. interface Scene {
  13129. /** @hidden */
  13130. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13131. /** @hidden */
  13132. _processLateAnimationBindingsForMatrices(holder: {
  13133. totalWeight: number;
  13134. animations: RuntimeAnimation[];
  13135. originalValue: Matrix;
  13136. }): any;
  13137. /** @hidden */
  13138. _processLateAnimationBindingsForQuaternions(holder: {
  13139. totalWeight: number;
  13140. animations: RuntimeAnimation[];
  13141. originalValue: Quaternion;
  13142. }, refQuaternion: Quaternion): Quaternion;
  13143. /** @hidden */
  13144. _processLateAnimationBindings(): void;
  13145. /**
  13146. * Will start the animation sequence of a given target
  13147. * @param target defines the target
  13148. * @param from defines from which frame should animation start
  13149. * @param to defines until which frame should animation run.
  13150. * @param weight defines the weight to apply to the animation (1.0 by default)
  13151. * @param loop defines if the animation loops
  13152. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13153. * @param onAnimationEnd defines the function to be executed when the animation ends
  13154. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13155. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13156. * @param onAnimationLoop defines the callback to call when an animation loops
  13157. * @returns the animatable object created for this animation
  13158. */
  13159. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13160. /**
  13161. * Will start the animation sequence of a given target
  13162. * @param target defines the target
  13163. * @param from defines from which frame should animation start
  13164. * @param to defines until which frame should animation run.
  13165. * @param loop defines if the animation loops
  13166. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13167. * @param onAnimationEnd defines the function to be executed when the animation ends
  13168. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13169. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13170. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13171. * @param onAnimationLoop defines the callback to call when an animation loops
  13172. * @returns the animatable object created for this animation
  13173. */
  13174. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13175. /**
  13176. * Will start the animation sequence of a given target and its hierarchy
  13177. * @param target defines the target
  13178. * @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.
  13179. * @param from defines from which frame should animation start
  13180. * @param to defines until which frame should animation run.
  13181. * @param loop defines if the animation loops
  13182. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13183. * @param onAnimationEnd defines the function to be executed when the animation ends
  13184. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13185. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13186. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13187. * @param onAnimationLoop defines the callback to call when an animation loops
  13188. * @returns the list of created animatables
  13189. */
  13190. 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[];
  13191. /**
  13192. * Begin a new animation on a given node
  13193. * @param target defines the target where the animation will take place
  13194. * @param animations defines the list of animations to start
  13195. * @param from defines the initial value
  13196. * @param to defines the final value
  13197. * @param loop defines if you want animation to loop (off by default)
  13198. * @param speedRatio defines the speed ratio to apply to all animations
  13199. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13200. * @param onAnimationLoop defines the callback to call when an animation loops
  13201. * @returns the list of created animatables
  13202. */
  13203. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13204. /**
  13205. * Begin a new animation on a given node and its hierarchy
  13206. * @param target defines the root node where the animation will take place
  13207. * @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.
  13208. * @param animations defines the list of animations to start
  13209. * @param from defines the initial value
  13210. * @param to defines the final value
  13211. * @param loop defines if you want animation to loop (off by default)
  13212. * @param speedRatio defines the speed ratio to apply to all animations
  13213. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13214. * @param onAnimationLoop defines the callback to call when an animation loops
  13215. * @returns the list of animatables created for all nodes
  13216. */
  13217. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13218. /**
  13219. * Gets the animatable associated with a specific target
  13220. * @param target defines the target of the animatable
  13221. * @returns the required animatable if found
  13222. */
  13223. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13224. /**
  13225. * Gets all animatables associated with a given target
  13226. * @param target defines the target to look animatables for
  13227. * @returns an array of Animatables
  13228. */
  13229. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13230. /**
  13231. * Stops and removes all animations that have been applied to the scene
  13232. */
  13233. stopAllAnimations(): void;
  13234. }
  13235. }
  13236. module "babylonjs/Bones/bone" {
  13237. interface Bone {
  13238. /**
  13239. * Copy an animation range from another bone
  13240. * @param source defines the source bone
  13241. * @param rangeName defines the range name to copy
  13242. * @param frameOffset defines the frame offset
  13243. * @param rescaleAsRequired defines if rescaling must be applied if required
  13244. * @param skelDimensionsRatio defines the scaling ratio
  13245. * @returns true if operation was successful
  13246. */
  13247. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13248. }
  13249. }
  13250. }
  13251. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13252. /**
  13253. * Class used to override all child animations of a given target
  13254. */
  13255. export class AnimationPropertiesOverride {
  13256. /**
  13257. * Gets or sets a value indicating if animation blending must be used
  13258. */
  13259. enableBlending: boolean;
  13260. /**
  13261. * Gets or sets the blending speed to use when enableBlending is true
  13262. */
  13263. blendingSpeed: number;
  13264. /**
  13265. * Gets or sets the default loop mode to use
  13266. */
  13267. loopMode: number;
  13268. }
  13269. }
  13270. declare module "babylonjs/Bones/skeleton" {
  13271. import { Bone } from "babylonjs/Bones/bone";
  13272. import { Observable } from "babylonjs/Misc/observable";
  13273. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13274. import { Scene } from "babylonjs/scene";
  13275. import { Nullable } from "babylonjs/types";
  13276. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13277. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13278. import { Animatable } from "babylonjs/Animations/animatable";
  13279. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13280. import { Animation } from "babylonjs/Animations/animation";
  13281. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13282. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13283. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13284. /**
  13285. * Class used to handle skinning animations
  13286. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13287. */
  13288. export class Skeleton implements IAnimatable {
  13289. /** defines the skeleton name */
  13290. name: string;
  13291. /** defines the skeleton Id */
  13292. id: string;
  13293. /**
  13294. * Defines the list of child bones
  13295. */
  13296. bones: Bone[];
  13297. /**
  13298. * Defines an estimate of the dimension of the skeleton at rest
  13299. */
  13300. dimensionsAtRest: Vector3;
  13301. /**
  13302. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13303. */
  13304. needInitialSkinMatrix: boolean;
  13305. /**
  13306. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13307. */
  13308. overrideMesh: Nullable<AbstractMesh>;
  13309. /**
  13310. * Gets the list of animations attached to this skeleton
  13311. */
  13312. animations: Array<Animation>;
  13313. private _scene;
  13314. private _isDirty;
  13315. private _transformMatrices;
  13316. private _transformMatrixTexture;
  13317. private _meshesWithPoseMatrix;
  13318. private _animatables;
  13319. private _identity;
  13320. private _synchronizedWithMesh;
  13321. private _ranges;
  13322. private _lastAbsoluteTransformsUpdateId;
  13323. private _canUseTextureForBones;
  13324. private _uniqueId;
  13325. /** @hidden */
  13326. _numBonesWithLinkedTransformNode: number;
  13327. /** @hidden */
  13328. _hasWaitingData: Nullable<boolean>;
  13329. /**
  13330. * Specifies if the skeleton should be serialized
  13331. */
  13332. doNotSerialize: boolean;
  13333. private _useTextureToStoreBoneMatrices;
  13334. /**
  13335. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13336. * Please note that this option is not available if the hardware does not support it
  13337. */
  13338. useTextureToStoreBoneMatrices: boolean;
  13339. private _animationPropertiesOverride;
  13340. /**
  13341. * Gets or sets the animation properties override
  13342. */
  13343. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13344. /**
  13345. * List of inspectable custom properties (used by the Inspector)
  13346. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13347. */
  13348. inspectableCustomProperties: IInspectable[];
  13349. /**
  13350. * An observable triggered before computing the skeleton's matrices
  13351. */
  13352. onBeforeComputeObservable: Observable<Skeleton>;
  13353. /**
  13354. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13355. */
  13356. readonly isUsingTextureForMatrices: boolean;
  13357. /**
  13358. * Gets the unique ID of this skeleton
  13359. */
  13360. readonly uniqueId: number;
  13361. /**
  13362. * Creates a new skeleton
  13363. * @param name defines the skeleton name
  13364. * @param id defines the skeleton Id
  13365. * @param scene defines the hosting scene
  13366. */
  13367. constructor(
  13368. /** defines the skeleton name */
  13369. name: string,
  13370. /** defines the skeleton Id */
  13371. id: string, scene: Scene);
  13372. /**
  13373. * Gets the current object class name.
  13374. * @return the class name
  13375. */
  13376. getClassName(): string;
  13377. /**
  13378. * Returns an array containing the root bones
  13379. * @returns an array containing the root bones
  13380. */
  13381. getChildren(): Array<Bone>;
  13382. /**
  13383. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13384. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13385. * @returns a Float32Array containing matrices data
  13386. */
  13387. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13388. /**
  13389. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13390. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13391. * @returns a raw texture containing the data
  13392. */
  13393. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13394. /**
  13395. * Gets the current hosting scene
  13396. * @returns a scene object
  13397. */
  13398. getScene(): Scene;
  13399. /**
  13400. * Gets a string representing the current skeleton data
  13401. * @param fullDetails defines a boolean indicating if we want a verbose version
  13402. * @returns a string representing the current skeleton data
  13403. */
  13404. toString(fullDetails?: boolean): string;
  13405. /**
  13406. * Get bone's index searching by name
  13407. * @param name defines bone's name to search for
  13408. * @return the indice of the bone. Returns -1 if not found
  13409. */
  13410. getBoneIndexByName(name: string): number;
  13411. /**
  13412. * Creater a new animation range
  13413. * @param name defines the name of the range
  13414. * @param from defines the start key
  13415. * @param to defines the end key
  13416. */
  13417. createAnimationRange(name: string, from: number, to: number): void;
  13418. /**
  13419. * Delete a specific animation range
  13420. * @param name defines the name of the range
  13421. * @param deleteFrames defines if frames must be removed as well
  13422. */
  13423. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13424. /**
  13425. * Gets a specific animation range
  13426. * @param name defines the name of the range to look for
  13427. * @returns the requested animation range or null if not found
  13428. */
  13429. getAnimationRange(name: string): Nullable<AnimationRange>;
  13430. /**
  13431. * Gets the list of all animation ranges defined on this skeleton
  13432. * @returns an array
  13433. */
  13434. getAnimationRanges(): Nullable<AnimationRange>[];
  13435. /**
  13436. * Copy animation range from a source skeleton.
  13437. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13438. * @param source defines the source skeleton
  13439. * @param name defines the name of the range to copy
  13440. * @param rescaleAsRequired defines if rescaling must be applied if required
  13441. * @returns true if operation was successful
  13442. */
  13443. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13444. /**
  13445. * Forces the skeleton to go to rest pose
  13446. */
  13447. returnToRest(): void;
  13448. private _getHighestAnimationFrame;
  13449. /**
  13450. * Begin a specific animation range
  13451. * @param name defines the name of the range to start
  13452. * @param loop defines if looping must be turned on (false by default)
  13453. * @param speedRatio defines the speed ratio to apply (1 by default)
  13454. * @param onAnimationEnd defines a callback which will be called when animation will end
  13455. * @returns a new animatable
  13456. */
  13457. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13458. /** @hidden */
  13459. _markAsDirty(): void;
  13460. /** @hidden */
  13461. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13462. /** @hidden */
  13463. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13464. private _computeTransformMatrices;
  13465. /**
  13466. * Build all resources required to render a skeleton
  13467. */
  13468. prepare(): void;
  13469. /**
  13470. * Gets the list of animatables currently running for this skeleton
  13471. * @returns an array of animatables
  13472. */
  13473. getAnimatables(): IAnimatable[];
  13474. /**
  13475. * Clone the current skeleton
  13476. * @param name defines the name of the new skeleton
  13477. * @param id defines the id of the new skeleton
  13478. * @returns the new skeleton
  13479. */
  13480. clone(name: string, id: string): Skeleton;
  13481. /**
  13482. * Enable animation blending for this skeleton
  13483. * @param blendingSpeed defines the blending speed to apply
  13484. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13485. */
  13486. enableBlending(blendingSpeed?: number): void;
  13487. /**
  13488. * Releases all resources associated with the current skeleton
  13489. */
  13490. dispose(): void;
  13491. /**
  13492. * Serialize the skeleton in a JSON object
  13493. * @returns a JSON object
  13494. */
  13495. serialize(): any;
  13496. /**
  13497. * Creates a new skeleton from serialized data
  13498. * @param parsedSkeleton defines the serialized data
  13499. * @param scene defines the hosting scene
  13500. * @returns a new skeleton
  13501. */
  13502. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13503. /**
  13504. * Compute all node absolute transforms
  13505. * @param forceUpdate defines if computation must be done even if cache is up to date
  13506. */
  13507. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13508. /**
  13509. * Gets the root pose matrix
  13510. * @returns a matrix
  13511. */
  13512. getPoseMatrix(): Nullable<Matrix>;
  13513. /**
  13514. * Sorts bones per internal index
  13515. */
  13516. sortBones(): void;
  13517. private _sortBones;
  13518. }
  13519. }
  13520. declare module "babylonjs/Bones/bone" {
  13521. import { Skeleton } from "babylonjs/Bones/skeleton";
  13522. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13523. import { Nullable } from "babylonjs/types";
  13524. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13525. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13526. import { Node } from "babylonjs/node";
  13527. import { Space } from "babylonjs/Maths/math.axis";
  13528. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13529. /**
  13530. * Class used to store bone information
  13531. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13532. */
  13533. export class Bone extends Node {
  13534. /**
  13535. * defines the bone name
  13536. */
  13537. name: string;
  13538. private static _tmpVecs;
  13539. private static _tmpQuat;
  13540. private static _tmpMats;
  13541. /**
  13542. * Gets the list of child bones
  13543. */
  13544. children: Bone[];
  13545. /** Gets the animations associated with this bone */
  13546. animations: import("babylonjs/Animations/animation").Animation[];
  13547. /**
  13548. * Gets or sets bone length
  13549. */
  13550. length: number;
  13551. /**
  13552. * @hidden Internal only
  13553. * Set this value to map this bone to a different index in the transform matrices
  13554. * Set this value to -1 to exclude the bone from the transform matrices
  13555. */
  13556. _index: Nullable<number>;
  13557. private _skeleton;
  13558. private _localMatrix;
  13559. private _restPose;
  13560. private _baseMatrix;
  13561. private _absoluteTransform;
  13562. private _invertedAbsoluteTransform;
  13563. private _parent;
  13564. private _scalingDeterminant;
  13565. private _worldTransform;
  13566. private _localScaling;
  13567. private _localRotation;
  13568. private _localPosition;
  13569. private _needToDecompose;
  13570. private _needToCompose;
  13571. /** @hidden */
  13572. _linkedTransformNode: Nullable<TransformNode>;
  13573. /** @hidden */
  13574. _waitingTransformNodeId: Nullable<string>;
  13575. /** @hidden */
  13576. /** @hidden */
  13577. _matrix: Matrix;
  13578. /**
  13579. * Create a new bone
  13580. * @param name defines the bone name
  13581. * @param skeleton defines the parent skeleton
  13582. * @param parentBone defines the parent (can be null if the bone is the root)
  13583. * @param localMatrix defines the local matrix
  13584. * @param restPose defines the rest pose matrix
  13585. * @param baseMatrix defines the base matrix
  13586. * @param index defines index of the bone in the hiearchy
  13587. */
  13588. constructor(
  13589. /**
  13590. * defines the bone name
  13591. */
  13592. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13593. /**
  13594. * Gets the current object class name.
  13595. * @return the class name
  13596. */
  13597. getClassName(): string;
  13598. /**
  13599. * Gets the parent skeleton
  13600. * @returns a skeleton
  13601. */
  13602. getSkeleton(): Skeleton;
  13603. /**
  13604. * Gets parent bone
  13605. * @returns a bone or null if the bone is the root of the bone hierarchy
  13606. */
  13607. getParent(): Nullable<Bone>;
  13608. /**
  13609. * Returns an array containing the root bones
  13610. * @returns an array containing the root bones
  13611. */
  13612. getChildren(): Array<Bone>;
  13613. /**
  13614. * Sets the parent bone
  13615. * @param parent defines the parent (can be null if the bone is the root)
  13616. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13617. */
  13618. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13619. /**
  13620. * Gets the local matrix
  13621. * @returns a matrix
  13622. */
  13623. getLocalMatrix(): Matrix;
  13624. /**
  13625. * Gets the base matrix (initial matrix which remains unchanged)
  13626. * @returns a matrix
  13627. */
  13628. getBaseMatrix(): Matrix;
  13629. /**
  13630. * Gets the rest pose matrix
  13631. * @returns a matrix
  13632. */
  13633. getRestPose(): Matrix;
  13634. /**
  13635. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13636. */
  13637. getWorldMatrix(): Matrix;
  13638. /**
  13639. * Sets the local matrix to rest pose matrix
  13640. */
  13641. returnToRest(): void;
  13642. /**
  13643. * Gets the inverse of the absolute transform matrix.
  13644. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13645. * @returns a matrix
  13646. */
  13647. getInvertedAbsoluteTransform(): Matrix;
  13648. /**
  13649. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13650. * @returns a matrix
  13651. */
  13652. getAbsoluteTransform(): Matrix;
  13653. /**
  13654. * Links with the given transform node.
  13655. * The local matrix of this bone is copied from the transform node every frame.
  13656. * @param transformNode defines the transform node to link to
  13657. */
  13658. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13659. /** Gets or sets current position (in local space) */
  13660. position: Vector3;
  13661. /** Gets or sets current rotation (in local space) */
  13662. rotation: Vector3;
  13663. /** Gets or sets current rotation quaternion (in local space) */
  13664. rotationQuaternion: Quaternion;
  13665. /** Gets or sets current scaling (in local space) */
  13666. scaling: Vector3;
  13667. /**
  13668. * Gets the animation properties override
  13669. */
  13670. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13671. private _decompose;
  13672. private _compose;
  13673. /**
  13674. * Update the base and local matrices
  13675. * @param matrix defines the new base or local matrix
  13676. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13677. * @param updateLocalMatrix defines if the local matrix should be updated
  13678. */
  13679. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13680. /** @hidden */
  13681. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13682. /**
  13683. * Flag the bone as dirty (Forcing it to update everything)
  13684. */
  13685. markAsDirty(): void;
  13686. /** @hidden */
  13687. _markAsDirtyAndCompose(): void;
  13688. private _markAsDirtyAndDecompose;
  13689. /**
  13690. * Translate the bone in local or world space
  13691. * @param vec The amount to translate the bone
  13692. * @param space The space that the translation is in
  13693. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13694. */
  13695. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13696. /**
  13697. * Set the postion of the bone in local or world space
  13698. * @param position The position to set the bone
  13699. * @param space The space that the position is in
  13700. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13701. */
  13702. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13703. /**
  13704. * Set the absolute position of the bone (world space)
  13705. * @param position The position to set the bone
  13706. * @param mesh The mesh that this bone is attached to
  13707. */
  13708. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13709. /**
  13710. * Scale the bone on the x, y and z axes (in local space)
  13711. * @param x The amount to scale the bone on the x axis
  13712. * @param y The amount to scale the bone on the y axis
  13713. * @param z The amount to scale the bone on the z axis
  13714. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13715. */
  13716. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13717. /**
  13718. * Set the bone scaling in local space
  13719. * @param scale defines the scaling vector
  13720. */
  13721. setScale(scale: Vector3): void;
  13722. /**
  13723. * Gets the current scaling in local space
  13724. * @returns the current scaling vector
  13725. */
  13726. getScale(): Vector3;
  13727. /**
  13728. * Gets the current scaling in local space and stores it in a target vector
  13729. * @param result defines the target vector
  13730. */
  13731. getScaleToRef(result: Vector3): void;
  13732. /**
  13733. * Set the yaw, pitch, and roll of the bone in local or world space
  13734. * @param yaw The rotation of the bone on the y axis
  13735. * @param pitch The rotation of the bone on the x axis
  13736. * @param roll The rotation of the bone on the z axis
  13737. * @param space The space that the axes of rotation are in
  13738. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13739. */
  13740. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13741. /**
  13742. * Add a rotation to the bone on an axis in local or world space
  13743. * @param axis The axis to rotate the bone on
  13744. * @param amount The amount to rotate the bone
  13745. * @param space The space that the axis is in
  13746. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13747. */
  13748. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13749. /**
  13750. * Set the rotation of the bone to a particular axis angle in local or world space
  13751. * @param axis The axis to rotate the bone on
  13752. * @param angle The angle that the bone should be rotated to
  13753. * @param space The space that the axis is in
  13754. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13755. */
  13756. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13757. /**
  13758. * Set the euler rotation of the bone in local of world space
  13759. * @param rotation The euler rotation that the bone should be set to
  13760. * @param space The space that the rotation is in
  13761. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13762. */
  13763. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13764. /**
  13765. * Set the quaternion rotation of the bone in local of world space
  13766. * @param quat The quaternion rotation that the bone should be set to
  13767. * @param space The space that the rotation is in
  13768. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13769. */
  13770. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13771. /**
  13772. * Set the rotation matrix of the bone in local of world space
  13773. * @param rotMat The rotation matrix that the bone should be set to
  13774. * @param space The space that the rotation is in
  13775. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13776. */
  13777. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13778. private _rotateWithMatrix;
  13779. private _getNegativeRotationToRef;
  13780. /**
  13781. * Get the position of the bone in local or world space
  13782. * @param space The space that the returned position is in
  13783. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13784. * @returns The position of the bone
  13785. */
  13786. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13787. /**
  13788. * Copy the position of the bone to a vector3 in local or world space
  13789. * @param space The space that the returned position is in
  13790. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13791. * @param result The vector3 to copy the position to
  13792. */
  13793. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13794. /**
  13795. * Get the absolute position of the bone (world space)
  13796. * @param mesh The mesh that this bone is attached to
  13797. * @returns The absolute position of the bone
  13798. */
  13799. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13800. /**
  13801. * Copy the absolute position of the bone (world space) to the result param
  13802. * @param mesh The mesh that this bone is attached to
  13803. * @param result The vector3 to copy the absolute position to
  13804. */
  13805. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13806. /**
  13807. * Compute the absolute transforms of this bone and its children
  13808. */
  13809. computeAbsoluteTransforms(): void;
  13810. /**
  13811. * Get the world direction from an axis that is in the local space of the bone
  13812. * @param localAxis The local direction that is used to compute the world direction
  13813. * @param mesh The mesh that this bone is attached to
  13814. * @returns The world direction
  13815. */
  13816. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13817. /**
  13818. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13819. * @param localAxis The local direction that is used to compute the world direction
  13820. * @param mesh The mesh that this bone is attached to
  13821. * @param result The vector3 that the world direction will be copied to
  13822. */
  13823. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13824. /**
  13825. * Get the euler rotation of the bone in local or world space
  13826. * @param space The space that the rotation should be in
  13827. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13828. * @returns The euler rotation
  13829. */
  13830. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13831. /**
  13832. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13833. * @param space The space that the rotation should be in
  13834. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13835. * @param result The vector3 that the rotation should be copied to
  13836. */
  13837. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13838. /**
  13839. * Get the quaternion rotation of the bone in either local or world space
  13840. * @param space The space that the rotation should be in
  13841. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13842. * @returns The quaternion rotation
  13843. */
  13844. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13845. /**
  13846. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13847. * @param space The space that the rotation should be in
  13848. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13849. * @param result The quaternion that the rotation should be copied to
  13850. */
  13851. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13852. /**
  13853. * Get the rotation matrix of the bone in local or world space
  13854. * @param space The space that the rotation should be in
  13855. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13856. * @returns The rotation matrix
  13857. */
  13858. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13859. /**
  13860. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13861. * @param space The space that the rotation should be in
  13862. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13863. * @param result The quaternion that the rotation should be copied to
  13864. */
  13865. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13866. /**
  13867. * Get the world position of a point that is in the local space of the bone
  13868. * @param position The local position
  13869. * @param mesh The mesh that this bone is attached to
  13870. * @returns The world position
  13871. */
  13872. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13873. /**
  13874. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13875. * @param position The local position
  13876. * @param mesh The mesh that this bone is attached to
  13877. * @param result The vector3 that the world position should be copied to
  13878. */
  13879. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13880. /**
  13881. * Get the local position of a point that is in world space
  13882. * @param position The world position
  13883. * @param mesh The mesh that this bone is attached to
  13884. * @returns The local position
  13885. */
  13886. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13887. /**
  13888. * Get the local position of a point that is in world space and copy it to the result param
  13889. * @param position The world position
  13890. * @param mesh The mesh that this bone is attached to
  13891. * @param result The vector3 that the local position should be copied to
  13892. */
  13893. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13894. }
  13895. }
  13896. declare module "babylonjs/Meshes/transformNode" {
  13897. import { DeepImmutable } from "babylonjs/types";
  13898. import { Observable } from "babylonjs/Misc/observable";
  13899. import { Nullable } from "babylonjs/types";
  13900. import { Camera } from "babylonjs/Cameras/camera";
  13901. import { Scene } from "babylonjs/scene";
  13902. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13903. import { Node } from "babylonjs/node";
  13904. import { Bone } from "babylonjs/Bones/bone";
  13905. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13906. import { Space } from "babylonjs/Maths/math.axis";
  13907. /**
  13908. * 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.
  13909. * @see https://doc.babylonjs.com/how_to/transformnode
  13910. */
  13911. export class TransformNode extends Node {
  13912. /**
  13913. * Object will not rotate to face the camera
  13914. */
  13915. static BILLBOARDMODE_NONE: number;
  13916. /**
  13917. * Object will rotate to face the camera but only on the x axis
  13918. */
  13919. static BILLBOARDMODE_X: number;
  13920. /**
  13921. * Object will rotate to face the camera but only on the y axis
  13922. */
  13923. static BILLBOARDMODE_Y: number;
  13924. /**
  13925. * Object will rotate to face the camera but only on the z axis
  13926. */
  13927. static BILLBOARDMODE_Z: number;
  13928. /**
  13929. * Object will rotate to face the camera
  13930. */
  13931. static BILLBOARDMODE_ALL: number;
  13932. private _forward;
  13933. private _forwardInverted;
  13934. private _up;
  13935. private _right;
  13936. private _rightInverted;
  13937. private _position;
  13938. private _rotation;
  13939. private _rotationQuaternion;
  13940. protected _scaling: Vector3;
  13941. protected _isDirty: boolean;
  13942. private _transformToBoneReferal;
  13943. private _billboardMode;
  13944. /**
  13945. * Gets or sets the billboard mode. Default is 0.
  13946. *
  13947. * | Value | Type | Description |
  13948. * | --- | --- | --- |
  13949. * | 0 | BILLBOARDMODE_NONE | |
  13950. * | 1 | BILLBOARDMODE_X | |
  13951. * | 2 | BILLBOARDMODE_Y | |
  13952. * | 4 | BILLBOARDMODE_Z | |
  13953. * | 7 | BILLBOARDMODE_ALL | |
  13954. *
  13955. */
  13956. billboardMode: number;
  13957. private _preserveParentRotationForBillboard;
  13958. /**
  13959. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13960. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13961. */
  13962. preserveParentRotationForBillboard: boolean;
  13963. /**
  13964. * 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
  13965. */
  13966. scalingDeterminant: number;
  13967. private _infiniteDistance;
  13968. /**
  13969. * Gets or sets the distance of the object to max, often used by skybox
  13970. */
  13971. infiniteDistance: boolean;
  13972. /**
  13973. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13974. * By default the system will update normals to compensate
  13975. */
  13976. ignoreNonUniformScaling: boolean;
  13977. /**
  13978. * 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
  13979. */
  13980. reIntegrateRotationIntoRotationQuaternion: boolean;
  13981. /** @hidden */
  13982. _poseMatrix: Nullable<Matrix>;
  13983. /** @hidden */
  13984. _localMatrix: Matrix;
  13985. private _usePivotMatrix;
  13986. private _absolutePosition;
  13987. private _pivotMatrix;
  13988. private _pivotMatrixInverse;
  13989. protected _postMultiplyPivotMatrix: boolean;
  13990. protected _isWorldMatrixFrozen: boolean;
  13991. /** @hidden */
  13992. _indexInSceneTransformNodesArray: number;
  13993. /**
  13994. * An event triggered after the world matrix is updated
  13995. */
  13996. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13997. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13998. /**
  13999. * Gets a string identifying the name of the class
  14000. * @returns "TransformNode" string
  14001. */
  14002. getClassName(): string;
  14003. /**
  14004. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14005. */
  14006. position: Vector3;
  14007. /**
  14008. * 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)).
  14009. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14010. */
  14011. rotation: Vector3;
  14012. /**
  14013. * 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)).
  14014. */
  14015. scaling: Vector3;
  14016. /**
  14017. * 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).
  14018. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14019. */
  14020. rotationQuaternion: Nullable<Quaternion>;
  14021. /**
  14022. * The forward direction of that transform in world space.
  14023. */
  14024. readonly forward: Vector3;
  14025. /**
  14026. * The up direction of that transform in world space.
  14027. */
  14028. readonly up: Vector3;
  14029. /**
  14030. * The right direction of that transform in world space.
  14031. */
  14032. readonly right: Vector3;
  14033. /**
  14034. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14035. * @param matrix the matrix to copy the pose from
  14036. * @returns this TransformNode.
  14037. */
  14038. updatePoseMatrix(matrix: Matrix): TransformNode;
  14039. /**
  14040. * Returns the mesh Pose matrix.
  14041. * @returns the pose matrix
  14042. */
  14043. getPoseMatrix(): Matrix;
  14044. /** @hidden */
  14045. _isSynchronized(): boolean;
  14046. /** @hidden */
  14047. _initCache(): void;
  14048. /**
  14049. * Flag the transform node as dirty (Forcing it to update everything)
  14050. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14051. * @returns this transform node
  14052. */
  14053. markAsDirty(property: string): TransformNode;
  14054. /**
  14055. * Returns the current mesh absolute position.
  14056. * Returns a Vector3.
  14057. */
  14058. readonly absolutePosition: Vector3;
  14059. /**
  14060. * Sets a new matrix to apply before all other transformation
  14061. * @param matrix defines the transform matrix
  14062. * @returns the current TransformNode
  14063. */
  14064. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14065. /**
  14066. * Sets a new pivot matrix to the current node
  14067. * @param matrix defines the new pivot matrix to use
  14068. * @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
  14069. * @returns the current TransformNode
  14070. */
  14071. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14072. /**
  14073. * Returns the mesh pivot matrix.
  14074. * Default : Identity.
  14075. * @returns the matrix
  14076. */
  14077. getPivotMatrix(): Matrix;
  14078. /**
  14079. * Prevents the World matrix to be computed any longer.
  14080. * @returns the TransformNode.
  14081. */
  14082. freezeWorldMatrix(): TransformNode;
  14083. /**
  14084. * Allows back the World matrix computation.
  14085. * @returns the TransformNode.
  14086. */
  14087. unfreezeWorldMatrix(): this;
  14088. /**
  14089. * True if the World matrix has been frozen.
  14090. */
  14091. readonly isWorldMatrixFrozen: boolean;
  14092. /**
  14093. * Retuns the mesh absolute position in the World.
  14094. * @returns a Vector3.
  14095. */
  14096. getAbsolutePosition(): Vector3;
  14097. /**
  14098. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14099. * @param absolutePosition the absolute position to set
  14100. * @returns the TransformNode.
  14101. */
  14102. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14103. /**
  14104. * Sets the mesh position in its local space.
  14105. * @param vector3 the position to set in localspace
  14106. * @returns the TransformNode.
  14107. */
  14108. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14109. /**
  14110. * Returns the mesh position in the local space from the current World matrix values.
  14111. * @returns a new Vector3.
  14112. */
  14113. getPositionExpressedInLocalSpace(): Vector3;
  14114. /**
  14115. * Translates the mesh along the passed Vector3 in its local space.
  14116. * @param vector3 the distance to translate in localspace
  14117. * @returns the TransformNode.
  14118. */
  14119. locallyTranslate(vector3: Vector3): TransformNode;
  14120. private static _lookAtVectorCache;
  14121. /**
  14122. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14123. * @param targetPoint the position (must be in same space as current mesh) to look at
  14124. * @param yawCor optional yaw (y-axis) correction in radians
  14125. * @param pitchCor optional pitch (x-axis) correction in radians
  14126. * @param rollCor optional roll (z-axis) correction in radians
  14127. * @param space the choosen space of the target
  14128. * @returns the TransformNode.
  14129. */
  14130. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14131. /**
  14132. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14133. * This Vector3 is expressed in the World space.
  14134. * @param localAxis axis to rotate
  14135. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14136. */
  14137. getDirection(localAxis: Vector3): Vector3;
  14138. /**
  14139. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14140. * localAxis is expressed in the mesh local space.
  14141. * result is computed in the Wordl space from the mesh World matrix.
  14142. * @param localAxis axis to rotate
  14143. * @param result the resulting transformnode
  14144. * @returns this TransformNode.
  14145. */
  14146. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14147. /**
  14148. * Sets this transform node rotation to the given local axis.
  14149. * @param localAxis the axis in local space
  14150. * @param yawCor optional yaw (y-axis) correction in radians
  14151. * @param pitchCor optional pitch (x-axis) correction in radians
  14152. * @param rollCor optional roll (z-axis) correction in radians
  14153. * @returns this TransformNode
  14154. */
  14155. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14156. /**
  14157. * Sets a new pivot point to the current node
  14158. * @param point defines the new pivot point to use
  14159. * @param space defines if the point is in world or local space (local by default)
  14160. * @returns the current TransformNode
  14161. */
  14162. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14163. /**
  14164. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14165. * @returns the pivot point
  14166. */
  14167. getPivotPoint(): Vector3;
  14168. /**
  14169. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14170. * @param result the vector3 to store the result
  14171. * @returns this TransformNode.
  14172. */
  14173. getPivotPointToRef(result: Vector3): TransformNode;
  14174. /**
  14175. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14176. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14177. */
  14178. getAbsolutePivotPoint(): Vector3;
  14179. /**
  14180. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14181. * @param result vector3 to store the result
  14182. * @returns this TransformNode.
  14183. */
  14184. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14185. /**
  14186. * Defines the passed node as the parent of the current node.
  14187. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14188. * @see https://doc.babylonjs.com/how_to/parenting
  14189. * @param node the node ot set as the parent
  14190. * @returns this TransformNode.
  14191. */
  14192. setParent(node: Nullable<Node>): TransformNode;
  14193. private _nonUniformScaling;
  14194. /**
  14195. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14196. */
  14197. readonly nonUniformScaling: boolean;
  14198. /** @hidden */
  14199. _updateNonUniformScalingState(value: boolean): boolean;
  14200. /**
  14201. * Attach the current TransformNode to another TransformNode associated with a bone
  14202. * @param bone Bone affecting the TransformNode
  14203. * @param affectedTransformNode TransformNode associated with the bone
  14204. * @returns this object
  14205. */
  14206. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14207. /**
  14208. * Detach the transform node if its associated with a bone
  14209. * @returns this object
  14210. */
  14211. detachFromBone(): TransformNode;
  14212. private static _rotationAxisCache;
  14213. /**
  14214. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14215. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14216. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14217. * The passed axis is also normalized.
  14218. * @param axis the axis to rotate around
  14219. * @param amount the amount to rotate in radians
  14220. * @param space Space to rotate in (Default: local)
  14221. * @returns the TransformNode.
  14222. */
  14223. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14224. /**
  14225. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14226. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14227. * The passed axis is also normalized. .
  14228. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14229. * @param point the point to rotate around
  14230. * @param axis the axis to rotate around
  14231. * @param amount the amount to rotate in radians
  14232. * @returns the TransformNode
  14233. */
  14234. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14235. /**
  14236. * Translates the mesh along the axis vector for the passed distance in the given space.
  14237. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14238. * @param axis the axis to translate in
  14239. * @param distance the distance to translate
  14240. * @param space Space to rotate in (Default: local)
  14241. * @returns the TransformNode.
  14242. */
  14243. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14244. /**
  14245. * Adds a rotation step to the mesh current rotation.
  14246. * x, y, z are Euler angles expressed in radians.
  14247. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14248. * This means this rotation is made in the mesh local space only.
  14249. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14250. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14251. * ```javascript
  14252. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14253. * ```
  14254. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14255. * 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.
  14256. * @param x Rotation to add
  14257. * @param y Rotation to add
  14258. * @param z Rotation to add
  14259. * @returns the TransformNode.
  14260. */
  14261. addRotation(x: number, y: number, z: number): TransformNode;
  14262. /**
  14263. * @hidden
  14264. */
  14265. protected _getEffectiveParent(): Nullable<Node>;
  14266. /**
  14267. * Computes the world matrix of the node
  14268. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14269. * @returns the world matrix
  14270. */
  14271. computeWorldMatrix(force?: boolean): Matrix;
  14272. protected _afterComputeWorldMatrix(): void;
  14273. /**
  14274. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14275. * @param func callback function to add
  14276. *
  14277. * @returns the TransformNode.
  14278. */
  14279. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14280. /**
  14281. * Removes a registered callback function.
  14282. * @param func callback function to remove
  14283. * @returns the TransformNode.
  14284. */
  14285. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14286. /**
  14287. * Gets the position of the current mesh in camera space
  14288. * @param camera defines the camera to use
  14289. * @returns a position
  14290. */
  14291. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14292. /**
  14293. * Returns the distance from the mesh to the active camera
  14294. * @param camera defines the camera to use
  14295. * @returns the distance
  14296. */
  14297. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14298. /**
  14299. * Clone the current transform node
  14300. * @param name Name of the new clone
  14301. * @param newParent New parent for the clone
  14302. * @param doNotCloneChildren Do not clone children hierarchy
  14303. * @returns the new transform node
  14304. */
  14305. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14306. /**
  14307. * Serializes the objects information.
  14308. * @param currentSerializationObject defines the object to serialize in
  14309. * @returns the serialized object
  14310. */
  14311. serialize(currentSerializationObject?: any): any;
  14312. /**
  14313. * Returns a new TransformNode object parsed from the source provided.
  14314. * @param parsedTransformNode is the source.
  14315. * @param scene the scne the object belongs to
  14316. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14317. * @returns a new TransformNode object parsed from the source provided.
  14318. */
  14319. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14320. /**
  14321. * Get all child-transformNodes of this node
  14322. * @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
  14323. * @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
  14324. * @returns an array of TransformNode
  14325. */
  14326. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14327. /**
  14328. * Releases resources associated with this transform node.
  14329. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14330. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14331. */
  14332. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14333. /**
  14334. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14335. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14336. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14337. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14338. * @returns the current mesh
  14339. */
  14340. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14341. }
  14342. }
  14343. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14344. import { Observable } from "babylonjs/Misc/observable";
  14345. import { Nullable } from "babylonjs/types";
  14346. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14347. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14348. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14349. import { Ray } from "babylonjs/Culling/ray";
  14350. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14351. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14352. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14353. /**
  14354. * Defines the types of pose enabled controllers that are supported
  14355. */
  14356. export enum PoseEnabledControllerType {
  14357. /**
  14358. * HTC Vive
  14359. */
  14360. VIVE = 0,
  14361. /**
  14362. * Oculus Rift
  14363. */
  14364. OCULUS = 1,
  14365. /**
  14366. * Windows mixed reality
  14367. */
  14368. WINDOWS = 2,
  14369. /**
  14370. * Samsung gear VR
  14371. */
  14372. GEAR_VR = 3,
  14373. /**
  14374. * Google Daydream
  14375. */
  14376. DAYDREAM = 4,
  14377. /**
  14378. * Generic
  14379. */
  14380. GENERIC = 5
  14381. }
  14382. /**
  14383. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14384. */
  14385. export interface MutableGamepadButton {
  14386. /**
  14387. * Value of the button/trigger
  14388. */
  14389. value: number;
  14390. /**
  14391. * If the button/trigger is currently touched
  14392. */
  14393. touched: boolean;
  14394. /**
  14395. * If the button/trigger is currently pressed
  14396. */
  14397. pressed: boolean;
  14398. }
  14399. /**
  14400. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14401. * @hidden
  14402. */
  14403. export interface ExtendedGamepadButton extends GamepadButton {
  14404. /**
  14405. * If the button/trigger is currently pressed
  14406. */
  14407. readonly pressed: boolean;
  14408. /**
  14409. * If the button/trigger is currently touched
  14410. */
  14411. readonly touched: boolean;
  14412. /**
  14413. * Value of the button/trigger
  14414. */
  14415. readonly value: number;
  14416. }
  14417. /** @hidden */
  14418. export interface _GamePadFactory {
  14419. /**
  14420. * Returns wether or not the current gamepad can be created for this type of controller.
  14421. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14422. * @returns true if it can be created, otherwise false
  14423. */
  14424. canCreate(gamepadInfo: any): boolean;
  14425. /**
  14426. * Creates a new instance of the Gamepad.
  14427. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14428. * @returns the new gamepad instance
  14429. */
  14430. create(gamepadInfo: any): Gamepad;
  14431. }
  14432. /**
  14433. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14434. */
  14435. export class PoseEnabledControllerHelper {
  14436. /** @hidden */
  14437. static _ControllerFactories: _GamePadFactory[];
  14438. /** @hidden */
  14439. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14440. /**
  14441. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14442. * @param vrGamepad the gamepad to initialized
  14443. * @returns a vr controller of the type the gamepad identified as
  14444. */
  14445. static InitiateController(vrGamepad: any): Gamepad;
  14446. }
  14447. /**
  14448. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14449. */
  14450. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14451. /**
  14452. * If the controller is used in a webXR session
  14453. */
  14454. isXR: boolean;
  14455. private _deviceRoomPosition;
  14456. private _deviceRoomRotationQuaternion;
  14457. /**
  14458. * The device position in babylon space
  14459. */
  14460. devicePosition: Vector3;
  14461. /**
  14462. * The device rotation in babylon space
  14463. */
  14464. deviceRotationQuaternion: Quaternion;
  14465. /**
  14466. * The scale factor of the device in babylon space
  14467. */
  14468. deviceScaleFactor: number;
  14469. /**
  14470. * (Likely devicePosition should be used instead) The device position in its room space
  14471. */
  14472. position: Vector3;
  14473. /**
  14474. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14475. */
  14476. rotationQuaternion: Quaternion;
  14477. /**
  14478. * The type of controller (Eg. Windows mixed reality)
  14479. */
  14480. controllerType: PoseEnabledControllerType;
  14481. protected _calculatedPosition: Vector3;
  14482. private _calculatedRotation;
  14483. /**
  14484. * The raw pose from the device
  14485. */
  14486. rawPose: DevicePose;
  14487. private _trackPosition;
  14488. private _maxRotationDistFromHeadset;
  14489. private _draggedRoomRotation;
  14490. /**
  14491. * @hidden
  14492. */
  14493. _disableTrackPosition(fixedPosition: Vector3): void;
  14494. /**
  14495. * Internal, the mesh attached to the controller
  14496. * @hidden
  14497. */
  14498. _mesh: Nullable<AbstractMesh>;
  14499. private _poseControlledCamera;
  14500. private _leftHandSystemQuaternion;
  14501. /**
  14502. * Internal, matrix used to convert room space to babylon space
  14503. * @hidden
  14504. */
  14505. _deviceToWorld: Matrix;
  14506. /**
  14507. * Node to be used when casting a ray from the controller
  14508. * @hidden
  14509. */
  14510. _pointingPoseNode: Nullable<TransformNode>;
  14511. /**
  14512. * Name of the child mesh that can be used to cast a ray from the controller
  14513. */
  14514. static readonly POINTING_POSE: string;
  14515. /**
  14516. * Creates a new PoseEnabledController from a gamepad
  14517. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14518. */
  14519. constructor(browserGamepad: any);
  14520. private _workingMatrix;
  14521. /**
  14522. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14523. */
  14524. update(): void;
  14525. /**
  14526. * Updates only the pose device and mesh without doing any button event checking
  14527. */
  14528. protected _updatePoseAndMesh(): void;
  14529. /**
  14530. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14531. * @param poseData raw pose fromthe device
  14532. */
  14533. updateFromDevice(poseData: DevicePose): void;
  14534. /**
  14535. * @hidden
  14536. */
  14537. _meshAttachedObservable: Observable<AbstractMesh>;
  14538. /**
  14539. * Attaches a mesh to the controller
  14540. * @param mesh the mesh to be attached
  14541. */
  14542. attachToMesh(mesh: AbstractMesh): void;
  14543. /**
  14544. * Attaches the controllers mesh to a camera
  14545. * @param camera the camera the mesh should be attached to
  14546. */
  14547. attachToPoseControlledCamera(camera: TargetCamera): void;
  14548. /**
  14549. * Disposes of the controller
  14550. */
  14551. dispose(): void;
  14552. /**
  14553. * The mesh that is attached to the controller
  14554. */
  14555. readonly mesh: Nullable<AbstractMesh>;
  14556. /**
  14557. * Gets the ray of the controller in the direction the controller is pointing
  14558. * @param length the length the resulting ray should be
  14559. * @returns a ray in the direction the controller is pointing
  14560. */
  14561. getForwardRay(length?: number): Ray;
  14562. }
  14563. }
  14564. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14565. import { Observable } from "babylonjs/Misc/observable";
  14566. import { Scene } from "babylonjs/scene";
  14567. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14568. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14569. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14570. /**
  14571. * Defines the WebVRController object that represents controllers tracked in 3D space
  14572. */
  14573. export abstract class WebVRController extends PoseEnabledController {
  14574. /**
  14575. * Internal, the default controller model for the controller
  14576. */
  14577. protected _defaultModel: AbstractMesh;
  14578. /**
  14579. * Fired when the trigger state has changed
  14580. */
  14581. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14582. /**
  14583. * Fired when the main button state has changed
  14584. */
  14585. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14586. /**
  14587. * Fired when the secondary button state has changed
  14588. */
  14589. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14590. /**
  14591. * Fired when the pad state has changed
  14592. */
  14593. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14594. /**
  14595. * Fired when controllers stick values have changed
  14596. */
  14597. onPadValuesChangedObservable: Observable<StickValues>;
  14598. /**
  14599. * Array of button availible on the controller
  14600. */
  14601. protected _buttons: Array<MutableGamepadButton>;
  14602. private _onButtonStateChange;
  14603. /**
  14604. * Fired when a controller button's state has changed
  14605. * @param callback the callback containing the button that was modified
  14606. */
  14607. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14608. /**
  14609. * X and Y axis corresponding to the controllers joystick
  14610. */
  14611. pad: StickValues;
  14612. /**
  14613. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14614. */
  14615. hand: string;
  14616. /**
  14617. * The default controller model for the controller
  14618. */
  14619. readonly defaultModel: AbstractMesh;
  14620. /**
  14621. * Creates a new WebVRController from a gamepad
  14622. * @param vrGamepad the gamepad that the WebVRController should be created from
  14623. */
  14624. constructor(vrGamepad: any);
  14625. /**
  14626. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14627. */
  14628. update(): void;
  14629. /**
  14630. * Function to be called when a button is modified
  14631. */
  14632. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14633. /**
  14634. * Loads a mesh and attaches it to the controller
  14635. * @param scene the scene the mesh should be added to
  14636. * @param meshLoaded callback for when the mesh has been loaded
  14637. */
  14638. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14639. private _setButtonValue;
  14640. private _changes;
  14641. private _checkChanges;
  14642. /**
  14643. * Disposes of th webVRCOntroller
  14644. */
  14645. dispose(): void;
  14646. }
  14647. }
  14648. declare module "babylonjs/Lights/hemisphericLight" {
  14649. import { Nullable } from "babylonjs/types";
  14650. import { Scene } from "babylonjs/scene";
  14651. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14652. import { Color3 } from "babylonjs/Maths/math.color";
  14653. import { Effect } from "babylonjs/Materials/effect";
  14654. import { Light } from "babylonjs/Lights/light";
  14655. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14656. /**
  14657. * The HemisphericLight simulates the ambient environment light,
  14658. * so the passed direction is the light reflection direction, not the incoming direction.
  14659. */
  14660. export class HemisphericLight extends Light {
  14661. /**
  14662. * The groundColor is the light in the opposite direction to the one specified during creation.
  14663. * 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.
  14664. */
  14665. groundColor: Color3;
  14666. /**
  14667. * The light reflection direction, not the incoming direction.
  14668. */
  14669. direction: Vector3;
  14670. /**
  14671. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14672. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14673. * The HemisphericLight can't cast shadows.
  14674. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14675. * @param name The friendly name of the light
  14676. * @param direction The direction of the light reflection
  14677. * @param scene The scene the light belongs to
  14678. */
  14679. constructor(name: string, direction: Vector3, scene: Scene);
  14680. protected _buildUniformLayout(): void;
  14681. /**
  14682. * Returns the string "HemisphericLight".
  14683. * @return The class name
  14684. */
  14685. getClassName(): string;
  14686. /**
  14687. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14688. * Returns the updated direction.
  14689. * @param target The target the direction should point to
  14690. * @return The computed direction
  14691. */
  14692. setDirectionToTarget(target: Vector3): Vector3;
  14693. /**
  14694. * Returns the shadow generator associated to the light.
  14695. * @returns Always null for hemispheric lights because it does not support shadows.
  14696. */
  14697. getShadowGenerator(): Nullable<IShadowGenerator>;
  14698. /**
  14699. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14700. * @param effect The effect to update
  14701. * @param lightIndex The index of the light in the effect to update
  14702. * @returns The hemispheric light
  14703. */
  14704. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14705. /**
  14706. * Computes the world matrix of the node
  14707. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14708. * @param useWasUpdatedFlag defines a reserved property
  14709. * @returns the world matrix
  14710. */
  14711. computeWorldMatrix(): Matrix;
  14712. /**
  14713. * Returns the integer 3.
  14714. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14715. */
  14716. getTypeID(): number;
  14717. /**
  14718. * Prepares the list of defines specific to the light type.
  14719. * @param defines the list of defines
  14720. * @param lightIndex defines the index of the light for the effect
  14721. */
  14722. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14723. }
  14724. }
  14725. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14726. /** @hidden */
  14727. export var vrMultiviewToSingleviewPixelShader: {
  14728. name: string;
  14729. shader: string;
  14730. };
  14731. }
  14732. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14733. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14734. import { Scene } from "babylonjs/scene";
  14735. /**
  14736. * Renders to multiple views with a single draw call
  14737. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14738. */
  14739. export class MultiviewRenderTarget extends RenderTargetTexture {
  14740. /**
  14741. * Creates a multiview render target
  14742. * @param scene scene used with the render target
  14743. * @param size the size of the render target (used for each view)
  14744. */
  14745. constructor(scene: Scene, size?: number | {
  14746. width: number;
  14747. height: number;
  14748. } | {
  14749. ratio: number;
  14750. });
  14751. /**
  14752. * @hidden
  14753. * @param faceIndex the face index, if its a cube texture
  14754. */
  14755. _bindFrameBuffer(faceIndex?: number): void;
  14756. /**
  14757. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14758. * @returns the view count
  14759. */
  14760. getViewCount(): number;
  14761. }
  14762. }
  14763. declare module "babylonjs/Maths/math.frustum" {
  14764. import { Matrix } from "babylonjs/Maths/math.vector";
  14765. import { DeepImmutable } from "babylonjs/types";
  14766. import { Plane } from "babylonjs/Maths/math.plane";
  14767. /**
  14768. * Reprasents a camera frustum
  14769. */
  14770. export class Frustum {
  14771. /**
  14772. * Gets the planes representing the frustum
  14773. * @param transform matrix to be applied to the returned planes
  14774. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14775. */
  14776. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14777. /**
  14778. * Gets the near frustum plane transformed by the transform matrix
  14779. * @param transform transformation matrix to be applied to the resulting frustum plane
  14780. * @param frustumPlane the resuling frustum plane
  14781. */
  14782. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14783. /**
  14784. * Gets the far frustum plane transformed by the transform matrix
  14785. * @param transform transformation matrix to be applied to the resulting frustum plane
  14786. * @param frustumPlane the resuling frustum plane
  14787. */
  14788. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14789. /**
  14790. * Gets the left frustum plane transformed by the transform matrix
  14791. * @param transform transformation matrix to be applied to the resulting frustum plane
  14792. * @param frustumPlane the resuling frustum plane
  14793. */
  14794. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14795. /**
  14796. * Gets the right frustum plane transformed by the transform matrix
  14797. * @param transform transformation matrix to be applied to the resulting frustum plane
  14798. * @param frustumPlane the resuling frustum plane
  14799. */
  14800. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14801. /**
  14802. * Gets the top frustum plane transformed by the transform matrix
  14803. * @param transform transformation matrix to be applied to the resulting frustum plane
  14804. * @param frustumPlane the resuling frustum plane
  14805. */
  14806. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14807. /**
  14808. * Gets the bottom frustum plane transformed by the transform matrix
  14809. * @param transform transformation matrix to be applied to the resulting frustum plane
  14810. * @param frustumPlane the resuling frustum plane
  14811. */
  14812. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14813. /**
  14814. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14815. * @param transform transformation matrix to be applied to the resulting frustum planes
  14816. * @param frustumPlanes the resuling frustum planes
  14817. */
  14818. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14819. }
  14820. }
  14821. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  14822. import { Camera } from "babylonjs/Cameras/camera";
  14823. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14824. import { Nullable } from "babylonjs/types";
  14825. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14826. import { Matrix } from "babylonjs/Maths/math.vector";
  14827. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  14828. module "babylonjs/Engines/engine" {
  14829. interface Engine {
  14830. /**
  14831. * Creates a new multiview render target
  14832. * @param width defines the width of the texture
  14833. * @param height defines the height of the texture
  14834. * @returns the created multiview texture
  14835. */
  14836. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14837. /**
  14838. * Binds a multiview framebuffer to be drawn to
  14839. * @param multiviewTexture texture to bind
  14840. */
  14841. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14842. }
  14843. }
  14844. module "babylonjs/Cameras/camera" {
  14845. interface Camera {
  14846. /**
  14847. * @hidden
  14848. * 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)
  14849. */
  14850. _useMultiviewToSingleView: boolean;
  14851. /**
  14852. * @hidden
  14853. * 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)
  14854. */
  14855. _multiviewTexture: Nullable<RenderTargetTexture>;
  14856. /**
  14857. * @hidden
  14858. * ensures the multiview texture of the camera exists and has the specified width/height
  14859. * @param width height to set on the multiview texture
  14860. * @param height width to set on the multiview texture
  14861. */
  14862. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14863. }
  14864. }
  14865. module "babylonjs/scene" {
  14866. interface Scene {
  14867. /** @hidden */
  14868. _transformMatrixR: Matrix;
  14869. /** @hidden */
  14870. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14871. /** @hidden */
  14872. _createMultiviewUbo(): void;
  14873. /** @hidden */
  14874. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14875. /** @hidden */
  14876. _renderMultiviewToSingleView(camera: Camera): void;
  14877. }
  14878. }
  14879. }
  14880. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  14881. import { Camera } from "babylonjs/Cameras/camera";
  14882. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14883. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  14884. import "babylonjs/Engines/Extensions/engine.multiview";
  14885. /**
  14886. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14887. * This will not be used for webXR as it supports displaying texture arrays directly
  14888. */
  14889. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14890. /**
  14891. * Initializes a VRMultiviewToSingleview
  14892. * @param name name of the post process
  14893. * @param camera camera to be applied to
  14894. * @param scaleFactor scaling factor to the size of the output texture
  14895. */
  14896. constructor(name: string, camera: Camera, scaleFactor: number);
  14897. }
  14898. }
  14899. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  14900. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  14901. import { Nullable } from "babylonjs/types";
  14902. import { Size } from "babylonjs/Maths/math.size";
  14903. import { Observable } from "babylonjs/Misc/observable";
  14904. module "babylonjs/Engines/engine" {
  14905. interface Engine {
  14906. /** @hidden */
  14907. _vrDisplay: any;
  14908. /** @hidden */
  14909. _vrSupported: boolean;
  14910. /** @hidden */
  14911. _oldSize: Size;
  14912. /** @hidden */
  14913. _oldHardwareScaleFactor: number;
  14914. /** @hidden */
  14915. _vrExclusivePointerMode: boolean;
  14916. /** @hidden */
  14917. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14918. /** @hidden */
  14919. _onVRDisplayPointerRestricted: () => void;
  14920. /** @hidden */
  14921. _onVRDisplayPointerUnrestricted: () => void;
  14922. /** @hidden */
  14923. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14924. /** @hidden */
  14925. _onVrDisplayDisconnect: Nullable<() => void>;
  14926. /** @hidden */
  14927. _onVrDisplayPresentChange: Nullable<() => void>;
  14928. /**
  14929. * Observable signaled when VR display mode changes
  14930. */
  14931. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14932. /**
  14933. * Observable signaled when VR request present is complete
  14934. */
  14935. onVRRequestPresentComplete: Observable<boolean>;
  14936. /**
  14937. * Observable signaled when VR request present starts
  14938. */
  14939. onVRRequestPresentStart: Observable<Engine>;
  14940. /**
  14941. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14942. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14943. */
  14944. isInVRExclusivePointerMode: boolean;
  14945. /**
  14946. * Gets a boolean indicating if a webVR device was detected
  14947. * @returns true if a webVR device was detected
  14948. */
  14949. isVRDevicePresent(): boolean;
  14950. /**
  14951. * Gets the current webVR device
  14952. * @returns the current webVR device (or null)
  14953. */
  14954. getVRDevice(): any;
  14955. /**
  14956. * Initializes a webVR display and starts listening to display change events
  14957. * The onVRDisplayChangedObservable will be notified upon these changes
  14958. * @returns A promise containing a VRDisplay and if vr is supported
  14959. */
  14960. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14961. /** @hidden */
  14962. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14963. /**
  14964. * Call this function to switch to webVR mode
  14965. * Will do nothing if webVR is not supported or if there is no webVR device
  14966. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14967. */
  14968. enableVR(): void;
  14969. /** @hidden */
  14970. _onVRFullScreenTriggered(): void;
  14971. }
  14972. }
  14973. }
  14974. declare module "babylonjs/Cameras/VR/webVRCamera" {
  14975. import { Nullable } from "babylonjs/types";
  14976. import { Observable } from "babylonjs/Misc/observable";
  14977. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  14978. import { Scene } from "babylonjs/scene";
  14979. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14980. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  14981. import { Node } from "babylonjs/node";
  14982. import { Ray } from "babylonjs/Culling/ray";
  14983. import "babylonjs/Cameras/RigModes/webVRRigMode";
  14984. import "babylonjs/Engines/Extensions/engine.webVR";
  14985. /**
  14986. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14987. * IMPORTANT!! The data is right-hand data.
  14988. * @export
  14989. * @interface DevicePose
  14990. */
  14991. export interface DevicePose {
  14992. /**
  14993. * The position of the device, values in array are [x,y,z].
  14994. */
  14995. readonly position: Nullable<Float32Array>;
  14996. /**
  14997. * The linearVelocity of the device, values in array are [x,y,z].
  14998. */
  14999. readonly linearVelocity: Nullable<Float32Array>;
  15000. /**
  15001. * The linearAcceleration of the device, values in array are [x,y,z].
  15002. */
  15003. readonly linearAcceleration: Nullable<Float32Array>;
  15004. /**
  15005. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15006. */
  15007. readonly orientation: Nullable<Float32Array>;
  15008. /**
  15009. * The angularVelocity of the device, values in array are [x,y,z].
  15010. */
  15011. readonly angularVelocity: Nullable<Float32Array>;
  15012. /**
  15013. * The angularAcceleration of the device, values in array are [x,y,z].
  15014. */
  15015. readonly angularAcceleration: Nullable<Float32Array>;
  15016. }
  15017. /**
  15018. * Interface representing a pose controlled object in Babylon.
  15019. * A pose controlled object has both regular pose values as well as pose values
  15020. * from an external device such as a VR head mounted display
  15021. */
  15022. export interface PoseControlled {
  15023. /**
  15024. * The position of the object in babylon space.
  15025. */
  15026. position: Vector3;
  15027. /**
  15028. * The rotation quaternion of the object in babylon space.
  15029. */
  15030. rotationQuaternion: Quaternion;
  15031. /**
  15032. * The position of the device in babylon space.
  15033. */
  15034. devicePosition?: Vector3;
  15035. /**
  15036. * The rotation quaternion of the device in babylon space.
  15037. */
  15038. deviceRotationQuaternion: Quaternion;
  15039. /**
  15040. * The raw pose coming from the device.
  15041. */
  15042. rawPose: Nullable<DevicePose>;
  15043. /**
  15044. * The scale of the device to be used when translating from device space to babylon space.
  15045. */
  15046. deviceScaleFactor: number;
  15047. /**
  15048. * Updates the poseControlled values based on the input device pose.
  15049. * @param poseData the pose data to update the object with
  15050. */
  15051. updateFromDevice(poseData: DevicePose): void;
  15052. }
  15053. /**
  15054. * Set of options to customize the webVRCamera
  15055. */
  15056. export interface WebVROptions {
  15057. /**
  15058. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15059. */
  15060. trackPosition?: boolean;
  15061. /**
  15062. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15063. */
  15064. positionScale?: number;
  15065. /**
  15066. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15067. */
  15068. displayName?: string;
  15069. /**
  15070. * Should the native controller meshes be initialized. (default: true)
  15071. */
  15072. controllerMeshes?: boolean;
  15073. /**
  15074. * Creating a default HemiLight only on controllers. (default: true)
  15075. */
  15076. defaultLightingOnControllers?: boolean;
  15077. /**
  15078. * If you don't want to use the default VR button of the helper. (default: false)
  15079. */
  15080. useCustomVRButton?: boolean;
  15081. /**
  15082. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15083. */
  15084. customVRButton?: HTMLButtonElement;
  15085. /**
  15086. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15087. */
  15088. rayLength?: number;
  15089. /**
  15090. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15091. */
  15092. defaultHeight?: number;
  15093. /**
  15094. * If multiview should be used if availible (default: false)
  15095. */
  15096. useMultiview?: boolean;
  15097. }
  15098. /**
  15099. * This represents a WebVR camera.
  15100. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15101. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15102. */
  15103. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15104. private webVROptions;
  15105. /**
  15106. * @hidden
  15107. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15108. */
  15109. _vrDevice: any;
  15110. /**
  15111. * The rawPose of the vrDevice.
  15112. */
  15113. rawPose: Nullable<DevicePose>;
  15114. private _onVREnabled;
  15115. private _specsVersion;
  15116. private _attached;
  15117. private _frameData;
  15118. protected _descendants: Array<Node>;
  15119. private _deviceRoomPosition;
  15120. /** @hidden */
  15121. _deviceRoomRotationQuaternion: Quaternion;
  15122. private _standingMatrix;
  15123. /**
  15124. * Represents device position in babylon space.
  15125. */
  15126. devicePosition: Vector3;
  15127. /**
  15128. * Represents device rotation in babylon space.
  15129. */
  15130. deviceRotationQuaternion: Quaternion;
  15131. /**
  15132. * The scale of the device to be used when translating from device space to babylon space.
  15133. */
  15134. deviceScaleFactor: number;
  15135. private _deviceToWorld;
  15136. private _worldToDevice;
  15137. /**
  15138. * References to the webVR controllers for the vrDevice.
  15139. */
  15140. controllers: Array<WebVRController>;
  15141. /**
  15142. * Emits an event when a controller is attached.
  15143. */
  15144. onControllersAttachedObservable: Observable<WebVRController[]>;
  15145. /**
  15146. * Emits an event when a controller's mesh has been loaded;
  15147. */
  15148. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15149. /**
  15150. * Emits an event when the HMD's pose has been updated.
  15151. */
  15152. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15153. private _poseSet;
  15154. /**
  15155. * If the rig cameras be used as parent instead of this camera.
  15156. */
  15157. rigParenting: boolean;
  15158. private _lightOnControllers;
  15159. private _defaultHeight?;
  15160. /**
  15161. * Instantiates a WebVRFreeCamera.
  15162. * @param name The name of the WebVRFreeCamera
  15163. * @param position The starting anchor position for the camera
  15164. * @param scene The scene the camera belongs to
  15165. * @param webVROptions a set of customizable options for the webVRCamera
  15166. */
  15167. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15168. /**
  15169. * Gets the device distance from the ground in meters.
  15170. * @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.
  15171. */
  15172. deviceDistanceToRoomGround(): number;
  15173. /**
  15174. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15175. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15176. */
  15177. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15178. /**
  15179. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15180. * @returns A promise with a boolean set to if the standing matrix is supported.
  15181. */
  15182. useStandingMatrixAsync(): Promise<boolean>;
  15183. /**
  15184. * Disposes the camera
  15185. */
  15186. dispose(): void;
  15187. /**
  15188. * Gets a vrController by name.
  15189. * @param name The name of the controller to retreive
  15190. * @returns the controller matching the name specified or null if not found
  15191. */
  15192. getControllerByName(name: string): Nullable<WebVRController>;
  15193. private _leftController;
  15194. /**
  15195. * The controller corresponding to the users left hand.
  15196. */
  15197. readonly leftController: Nullable<WebVRController>;
  15198. private _rightController;
  15199. /**
  15200. * The controller corresponding to the users right hand.
  15201. */
  15202. readonly rightController: Nullable<WebVRController>;
  15203. /**
  15204. * Casts a ray forward from the vrCamera's gaze.
  15205. * @param length Length of the ray (default: 100)
  15206. * @returns the ray corresponding to the gaze
  15207. */
  15208. getForwardRay(length?: number): Ray;
  15209. /**
  15210. * @hidden
  15211. * Updates the camera based on device's frame data
  15212. */
  15213. _checkInputs(): void;
  15214. /**
  15215. * Updates the poseControlled values based on the input device pose.
  15216. * @param poseData Pose coming from the device
  15217. */
  15218. updateFromDevice(poseData: DevicePose): void;
  15219. private _htmlElementAttached;
  15220. private _detachIfAttached;
  15221. /**
  15222. * WebVR's attach control will start broadcasting frames to the device.
  15223. * Note that in certain browsers (chrome for example) this function must be called
  15224. * within a user-interaction callback. Example:
  15225. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15226. *
  15227. * @param element html element to attach the vrDevice to
  15228. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15229. */
  15230. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15231. /**
  15232. * Detaches the camera from the html element and disables VR
  15233. *
  15234. * @param element html element to detach from
  15235. */
  15236. detachControl(element: HTMLElement): void;
  15237. /**
  15238. * @returns the name of this class
  15239. */
  15240. getClassName(): string;
  15241. /**
  15242. * Calls resetPose on the vrDisplay
  15243. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15244. */
  15245. resetToCurrentRotation(): void;
  15246. /**
  15247. * @hidden
  15248. * Updates the rig cameras (left and right eye)
  15249. */
  15250. _updateRigCameras(): void;
  15251. private _workingVector;
  15252. private _oneVector;
  15253. private _workingMatrix;
  15254. private updateCacheCalled;
  15255. private _correctPositionIfNotTrackPosition;
  15256. /**
  15257. * @hidden
  15258. * Updates the cached values of the camera
  15259. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15260. */
  15261. _updateCache(ignoreParentClass?: boolean): void;
  15262. /**
  15263. * @hidden
  15264. * Get current device position in babylon world
  15265. */
  15266. _computeDevicePosition(): void;
  15267. /**
  15268. * Updates the current device position and rotation in the babylon world
  15269. */
  15270. update(): void;
  15271. /**
  15272. * @hidden
  15273. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15274. * @returns an identity matrix
  15275. */
  15276. _getViewMatrix(): Matrix;
  15277. private _tmpMatrix;
  15278. /**
  15279. * This function is called by the two RIG cameras.
  15280. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15281. * @hidden
  15282. */
  15283. _getWebVRViewMatrix(): Matrix;
  15284. /** @hidden */
  15285. _getWebVRProjectionMatrix(): Matrix;
  15286. private _onGamepadConnectedObserver;
  15287. private _onGamepadDisconnectedObserver;
  15288. private _updateCacheWhenTrackingDisabledObserver;
  15289. /**
  15290. * Initializes the controllers and their meshes
  15291. */
  15292. initControllers(): void;
  15293. }
  15294. }
  15295. declare module "babylonjs/PostProcesses/postProcess" {
  15296. import { Nullable } from "babylonjs/types";
  15297. import { SmartArray } from "babylonjs/Misc/smartArray";
  15298. import { Observable } from "babylonjs/Misc/observable";
  15299. import { Vector2 } from "babylonjs/Maths/math.vector";
  15300. import { Camera } from "babylonjs/Cameras/camera";
  15301. import { Effect } from "babylonjs/Materials/effect";
  15302. import "babylonjs/Shaders/postprocess.vertex";
  15303. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15304. import { Engine } from "babylonjs/Engines/engine";
  15305. import { Color4 } from "babylonjs/Maths/math.color";
  15306. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15307. /**
  15308. * Size options for a post process
  15309. */
  15310. export type PostProcessOptions = {
  15311. width: number;
  15312. height: number;
  15313. };
  15314. /**
  15315. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15316. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15317. */
  15318. export class PostProcess {
  15319. /** Name of the PostProcess. */
  15320. name: string;
  15321. /**
  15322. * Gets or sets the unique id of the post process
  15323. */
  15324. uniqueId: number;
  15325. /**
  15326. * Width of the texture to apply the post process on
  15327. */
  15328. width: number;
  15329. /**
  15330. * Height of the texture to apply the post process on
  15331. */
  15332. height: number;
  15333. /**
  15334. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15335. * @hidden
  15336. */
  15337. _outputTexture: Nullable<InternalTexture>;
  15338. /**
  15339. * Sampling mode used by the shader
  15340. * See https://doc.babylonjs.com/classes/3.1/texture
  15341. */
  15342. renderTargetSamplingMode: number;
  15343. /**
  15344. * Clear color to use when screen clearing
  15345. */
  15346. clearColor: Color4;
  15347. /**
  15348. * If the buffer needs to be cleared before applying the post process. (default: true)
  15349. * Should be set to false if shader will overwrite all previous pixels.
  15350. */
  15351. autoClear: boolean;
  15352. /**
  15353. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15354. */
  15355. alphaMode: number;
  15356. /**
  15357. * Sets the setAlphaBlendConstants of the babylon engine
  15358. */
  15359. alphaConstants: Color4;
  15360. /**
  15361. * Animations to be used for the post processing
  15362. */
  15363. animations: import("babylonjs/Animations/animation").Animation[];
  15364. /**
  15365. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15366. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15367. */
  15368. enablePixelPerfectMode: boolean;
  15369. /**
  15370. * Force the postprocess to be applied without taking in account viewport
  15371. */
  15372. forceFullscreenViewport: boolean;
  15373. /**
  15374. * List of inspectable custom properties (used by the Inspector)
  15375. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15376. */
  15377. inspectableCustomProperties: IInspectable[];
  15378. /**
  15379. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15380. *
  15381. * | Value | Type | Description |
  15382. * | ----- | ----------------------------------- | ----------- |
  15383. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15384. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15385. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15386. *
  15387. */
  15388. scaleMode: number;
  15389. /**
  15390. * Force textures to be a power of two (default: false)
  15391. */
  15392. alwaysForcePOT: boolean;
  15393. private _samples;
  15394. /**
  15395. * Number of sample textures (default: 1)
  15396. */
  15397. samples: number;
  15398. /**
  15399. * Modify the scale of the post process to be the same as the viewport (default: false)
  15400. */
  15401. adaptScaleToCurrentViewport: boolean;
  15402. private _camera;
  15403. private _scene;
  15404. private _engine;
  15405. private _options;
  15406. private _reusable;
  15407. private _textureType;
  15408. /**
  15409. * Smart array of input and output textures for the post process.
  15410. * @hidden
  15411. */
  15412. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15413. /**
  15414. * The index in _textures that corresponds to the output texture.
  15415. * @hidden
  15416. */
  15417. _currentRenderTextureInd: number;
  15418. private _effect;
  15419. private _samplers;
  15420. private _fragmentUrl;
  15421. private _vertexUrl;
  15422. private _parameters;
  15423. private _scaleRatio;
  15424. protected _indexParameters: any;
  15425. private _shareOutputWithPostProcess;
  15426. private _texelSize;
  15427. private _forcedOutputTexture;
  15428. /**
  15429. * Returns the fragment url or shader name used in the post process.
  15430. * @returns the fragment url or name in the shader store.
  15431. */
  15432. getEffectName(): string;
  15433. /**
  15434. * An event triggered when the postprocess is activated.
  15435. */
  15436. onActivateObservable: Observable<Camera>;
  15437. private _onActivateObserver;
  15438. /**
  15439. * A function that is added to the onActivateObservable
  15440. */
  15441. onActivate: Nullable<(camera: Camera) => void>;
  15442. /**
  15443. * An event triggered when the postprocess changes its size.
  15444. */
  15445. onSizeChangedObservable: Observable<PostProcess>;
  15446. private _onSizeChangedObserver;
  15447. /**
  15448. * A function that is added to the onSizeChangedObservable
  15449. */
  15450. onSizeChanged: (postProcess: PostProcess) => void;
  15451. /**
  15452. * An event triggered when the postprocess applies its effect.
  15453. */
  15454. onApplyObservable: Observable<Effect>;
  15455. private _onApplyObserver;
  15456. /**
  15457. * A function that is added to the onApplyObservable
  15458. */
  15459. onApply: (effect: Effect) => void;
  15460. /**
  15461. * An event triggered before rendering the postprocess
  15462. */
  15463. onBeforeRenderObservable: Observable<Effect>;
  15464. private _onBeforeRenderObserver;
  15465. /**
  15466. * A function that is added to the onBeforeRenderObservable
  15467. */
  15468. onBeforeRender: (effect: Effect) => void;
  15469. /**
  15470. * An event triggered after rendering the postprocess
  15471. */
  15472. onAfterRenderObservable: Observable<Effect>;
  15473. private _onAfterRenderObserver;
  15474. /**
  15475. * A function that is added to the onAfterRenderObservable
  15476. */
  15477. onAfterRender: (efect: Effect) => void;
  15478. /**
  15479. * 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
  15480. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15481. */
  15482. inputTexture: InternalTexture;
  15483. /**
  15484. * Gets the camera which post process is applied to.
  15485. * @returns The camera the post process is applied to.
  15486. */
  15487. getCamera(): Camera;
  15488. /**
  15489. * Gets the texel size of the postprocess.
  15490. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15491. */
  15492. readonly texelSize: Vector2;
  15493. /**
  15494. * Creates a new instance PostProcess
  15495. * @param name The name of the PostProcess.
  15496. * @param fragmentUrl The url of the fragment shader to be used.
  15497. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15498. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15499. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15500. * @param camera The camera to apply the render pass to.
  15501. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15502. * @param engine The engine which the post process will be applied. (default: current engine)
  15503. * @param reusable If the post process can be reused on the same frame. (default: false)
  15504. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15505. * @param textureType Type of textures used when performing the post process. (default: 0)
  15506. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15507. * @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
  15508. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15509. */
  15510. constructor(
  15511. /** Name of the PostProcess. */
  15512. 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);
  15513. /**
  15514. * Gets a string idenfifying the name of the class
  15515. * @returns "PostProcess" string
  15516. */
  15517. getClassName(): string;
  15518. /**
  15519. * Gets the engine which this post process belongs to.
  15520. * @returns The engine the post process was enabled with.
  15521. */
  15522. getEngine(): Engine;
  15523. /**
  15524. * The effect that is created when initializing the post process.
  15525. * @returns The created effect corresponding the the postprocess.
  15526. */
  15527. getEffect(): Effect;
  15528. /**
  15529. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15530. * @param postProcess The post process to share the output with.
  15531. * @returns This post process.
  15532. */
  15533. shareOutputWith(postProcess: PostProcess): PostProcess;
  15534. /**
  15535. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15536. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15537. */
  15538. useOwnOutput(): void;
  15539. /**
  15540. * Updates the effect with the current post process compile time values and recompiles the shader.
  15541. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15542. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15543. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15544. * @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
  15545. * @param onCompiled Called when the shader has been compiled.
  15546. * @param onError Called if there is an error when compiling a shader.
  15547. */
  15548. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15549. /**
  15550. * The post process is reusable if it can be used multiple times within one frame.
  15551. * @returns If the post process is reusable
  15552. */
  15553. isReusable(): boolean;
  15554. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15555. markTextureDirty(): void;
  15556. /**
  15557. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15558. * 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.
  15559. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15560. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15561. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15562. * @returns The target texture that was bound to be written to.
  15563. */
  15564. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15565. /**
  15566. * If the post process is supported.
  15567. */
  15568. readonly isSupported: boolean;
  15569. /**
  15570. * The aspect ratio of the output texture.
  15571. */
  15572. readonly aspectRatio: number;
  15573. /**
  15574. * Get a value indicating if the post-process is ready to be used
  15575. * @returns true if the post-process is ready (shader is compiled)
  15576. */
  15577. isReady(): boolean;
  15578. /**
  15579. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15580. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15581. */
  15582. apply(): Nullable<Effect>;
  15583. private _disposeTextures;
  15584. /**
  15585. * Disposes the post process.
  15586. * @param camera The camera to dispose the post process on.
  15587. */
  15588. dispose(camera?: Camera): void;
  15589. }
  15590. }
  15591. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15592. /** @hidden */
  15593. export var kernelBlurVaryingDeclaration: {
  15594. name: string;
  15595. shader: string;
  15596. };
  15597. }
  15598. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15599. /** @hidden */
  15600. export var kernelBlurFragment: {
  15601. name: string;
  15602. shader: string;
  15603. };
  15604. }
  15605. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15606. /** @hidden */
  15607. export var kernelBlurFragment2: {
  15608. name: string;
  15609. shader: string;
  15610. };
  15611. }
  15612. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15613. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15614. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15615. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15616. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15617. /** @hidden */
  15618. export var kernelBlurPixelShader: {
  15619. name: string;
  15620. shader: string;
  15621. };
  15622. }
  15623. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15624. /** @hidden */
  15625. export var kernelBlurVertex: {
  15626. name: string;
  15627. shader: string;
  15628. };
  15629. }
  15630. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15631. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15632. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15633. /** @hidden */
  15634. export var kernelBlurVertexShader: {
  15635. name: string;
  15636. shader: string;
  15637. };
  15638. }
  15639. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15640. import { Vector2 } from "babylonjs/Maths/math.vector";
  15641. import { Nullable } from "babylonjs/types";
  15642. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15643. import { Camera } from "babylonjs/Cameras/camera";
  15644. import { Effect } from "babylonjs/Materials/effect";
  15645. import { Engine } from "babylonjs/Engines/engine";
  15646. import "babylonjs/Shaders/kernelBlur.fragment";
  15647. import "babylonjs/Shaders/kernelBlur.vertex";
  15648. /**
  15649. * The Blur Post Process which blurs an image based on a kernel and direction.
  15650. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15651. */
  15652. export class BlurPostProcess extends PostProcess {
  15653. /** The direction in which to blur the image. */
  15654. direction: Vector2;
  15655. private blockCompilation;
  15656. protected _kernel: number;
  15657. protected _idealKernel: number;
  15658. protected _packedFloat: boolean;
  15659. private _staticDefines;
  15660. /**
  15661. * Sets the length in pixels of the blur sample region
  15662. */
  15663. /**
  15664. * Gets the length in pixels of the blur sample region
  15665. */
  15666. kernel: number;
  15667. /**
  15668. * Sets wether or not the blur needs to unpack/repack floats
  15669. */
  15670. /**
  15671. * Gets wether or not the blur is unpacking/repacking floats
  15672. */
  15673. packedFloat: boolean;
  15674. /**
  15675. * Creates a new instance BlurPostProcess
  15676. * @param name The name of the effect.
  15677. * @param direction The direction in which to blur the image.
  15678. * @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.
  15679. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15680. * @param camera The camera to apply the render pass to.
  15681. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15682. * @param engine The engine which the post process will be applied. (default: current engine)
  15683. * @param reusable If the post process can be reused on the same frame. (default: false)
  15684. * @param textureType Type of textures used when performing the post process. (default: 0)
  15685. * @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)
  15686. */
  15687. constructor(name: string,
  15688. /** The direction in which to blur the image. */
  15689. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15690. /**
  15691. * Updates the effect with the current post process compile time values and recompiles the shader.
  15692. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15693. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15694. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15695. * @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
  15696. * @param onCompiled Called when the shader has been compiled.
  15697. * @param onError Called if there is an error when compiling a shader.
  15698. */
  15699. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15700. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15701. /**
  15702. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15703. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15704. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15705. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15706. * The gaps between physical kernels are compensated for in the weighting of the samples
  15707. * @param idealKernel Ideal blur kernel.
  15708. * @return Nearest best kernel.
  15709. */
  15710. protected _nearestBestKernel(idealKernel: number): number;
  15711. /**
  15712. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15713. * @param x The point on the Gaussian distribution to sample.
  15714. * @return the value of the Gaussian function at x.
  15715. */
  15716. protected _gaussianWeight(x: number): number;
  15717. /**
  15718. * Generates a string that can be used as a floating point number in GLSL.
  15719. * @param x Value to print.
  15720. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15721. * @return GLSL float string.
  15722. */
  15723. protected _glslFloat(x: number, decimalFigures?: number): string;
  15724. }
  15725. }
  15726. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15727. import { Scene } from "babylonjs/scene";
  15728. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15729. import { Plane } from "babylonjs/Maths/math.plane";
  15730. /**
  15731. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15732. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15733. * You can then easily use it as a reflectionTexture on a flat surface.
  15734. * In case the surface is not a plane, please consider relying on reflection probes.
  15735. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15736. */
  15737. export class MirrorTexture extends RenderTargetTexture {
  15738. private scene;
  15739. /**
  15740. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15741. * 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.
  15742. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15743. */
  15744. mirrorPlane: Plane;
  15745. /**
  15746. * Define the blur ratio used to blur the reflection if needed.
  15747. */
  15748. blurRatio: number;
  15749. /**
  15750. * Define the adaptive blur kernel used to blur the reflection if needed.
  15751. * This will autocompute the closest best match for the `blurKernel`
  15752. */
  15753. adaptiveBlurKernel: number;
  15754. /**
  15755. * Define the blur kernel used to blur the reflection if needed.
  15756. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15757. */
  15758. blurKernel: number;
  15759. /**
  15760. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15761. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15762. */
  15763. blurKernelX: number;
  15764. /**
  15765. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15766. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15767. */
  15768. blurKernelY: number;
  15769. private _autoComputeBlurKernel;
  15770. protected _onRatioRescale(): void;
  15771. private _updateGammaSpace;
  15772. private _imageProcessingConfigChangeObserver;
  15773. private _transformMatrix;
  15774. private _mirrorMatrix;
  15775. private _savedViewMatrix;
  15776. private _blurX;
  15777. private _blurY;
  15778. private _adaptiveBlurKernel;
  15779. private _blurKernelX;
  15780. private _blurKernelY;
  15781. private _blurRatio;
  15782. /**
  15783. * Instantiates a Mirror Texture.
  15784. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15785. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15786. * You can then easily use it as a reflectionTexture on a flat surface.
  15787. * In case the surface is not a plane, please consider relying on reflection probes.
  15788. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15789. * @param name
  15790. * @param size
  15791. * @param scene
  15792. * @param generateMipMaps
  15793. * @param type
  15794. * @param samplingMode
  15795. * @param generateDepthBuffer
  15796. */
  15797. constructor(name: string, size: number | {
  15798. width: number;
  15799. height: number;
  15800. } | {
  15801. ratio: number;
  15802. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15803. private _preparePostProcesses;
  15804. /**
  15805. * Clone the mirror texture.
  15806. * @returns the cloned texture
  15807. */
  15808. clone(): MirrorTexture;
  15809. /**
  15810. * Serialize the texture to a JSON representation you could use in Parse later on
  15811. * @returns the serialized JSON representation
  15812. */
  15813. serialize(): any;
  15814. /**
  15815. * Dispose the texture and release its associated resources.
  15816. */
  15817. dispose(): void;
  15818. }
  15819. }
  15820. declare module "babylonjs/Materials/Textures/texture" {
  15821. import { Observable } from "babylonjs/Misc/observable";
  15822. import { Nullable } from "babylonjs/types";
  15823. import { Scene } from "babylonjs/scene";
  15824. import { Matrix } from "babylonjs/Maths/math.vector";
  15825. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15826. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15827. import { Engine } from "babylonjs/Engines/engine";
  15828. /**
  15829. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15830. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15831. */
  15832. export class Texture extends BaseTexture {
  15833. /** @hidden */
  15834. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  15835. /** @hidden */
  15836. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  15837. /** @hidden */
  15838. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  15839. /** nearest is mag = nearest and min = nearest and mip = linear */
  15840. static readonly NEAREST_SAMPLINGMODE: number;
  15841. /** nearest is mag = nearest and min = nearest and mip = linear */
  15842. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15843. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15844. static readonly BILINEAR_SAMPLINGMODE: number;
  15845. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15846. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15847. /** Trilinear is mag = linear and min = linear and mip = linear */
  15848. static readonly TRILINEAR_SAMPLINGMODE: number;
  15849. /** Trilinear is mag = linear and min = linear and mip = linear */
  15850. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15851. /** mag = nearest and min = nearest and mip = nearest */
  15852. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15853. /** mag = nearest and min = linear and mip = nearest */
  15854. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15855. /** mag = nearest and min = linear and mip = linear */
  15856. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15857. /** mag = nearest and min = linear and mip = none */
  15858. static readonly NEAREST_LINEAR: number;
  15859. /** mag = nearest and min = nearest and mip = none */
  15860. static readonly NEAREST_NEAREST: number;
  15861. /** mag = linear and min = nearest and mip = nearest */
  15862. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15863. /** mag = linear and min = nearest and mip = linear */
  15864. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15865. /** mag = linear and min = linear and mip = none */
  15866. static readonly LINEAR_LINEAR: number;
  15867. /** mag = linear and min = nearest and mip = none */
  15868. static readonly LINEAR_NEAREST: number;
  15869. /** Explicit coordinates mode */
  15870. static readonly EXPLICIT_MODE: number;
  15871. /** Spherical coordinates mode */
  15872. static readonly SPHERICAL_MODE: number;
  15873. /** Planar coordinates mode */
  15874. static readonly PLANAR_MODE: number;
  15875. /** Cubic coordinates mode */
  15876. static readonly CUBIC_MODE: number;
  15877. /** Projection coordinates mode */
  15878. static readonly PROJECTION_MODE: number;
  15879. /** Inverse Cubic coordinates mode */
  15880. static readonly SKYBOX_MODE: number;
  15881. /** Inverse Cubic coordinates mode */
  15882. static readonly INVCUBIC_MODE: number;
  15883. /** Equirectangular coordinates mode */
  15884. static readonly EQUIRECTANGULAR_MODE: number;
  15885. /** Equirectangular Fixed coordinates mode */
  15886. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15887. /** Equirectangular Fixed Mirrored coordinates mode */
  15888. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15889. /** Texture is not repeating outside of 0..1 UVs */
  15890. static readonly CLAMP_ADDRESSMODE: number;
  15891. /** Texture is repeating outside of 0..1 UVs */
  15892. static readonly WRAP_ADDRESSMODE: number;
  15893. /** Texture is repeating and mirrored */
  15894. static readonly MIRROR_ADDRESSMODE: number;
  15895. /**
  15896. * 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
  15897. */
  15898. static UseSerializedUrlIfAny: boolean;
  15899. /**
  15900. * Define the url of the texture.
  15901. */
  15902. url: Nullable<string>;
  15903. /**
  15904. * Define an offset on the texture to offset the u coordinates of the UVs
  15905. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15906. */
  15907. uOffset: number;
  15908. /**
  15909. * Define an offset on the texture to offset the v coordinates of the UVs
  15910. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15911. */
  15912. vOffset: number;
  15913. /**
  15914. * Define an offset on the texture to scale the u coordinates of the UVs
  15915. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15916. */
  15917. uScale: number;
  15918. /**
  15919. * Define an offset on the texture to scale the v coordinates of the UVs
  15920. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15921. */
  15922. vScale: number;
  15923. /**
  15924. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15925. * @see http://doc.babylonjs.com/how_to/more_materials
  15926. */
  15927. uAng: number;
  15928. /**
  15929. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15930. * @see http://doc.babylonjs.com/how_to/more_materials
  15931. */
  15932. vAng: number;
  15933. /**
  15934. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15935. * @see http://doc.babylonjs.com/how_to/more_materials
  15936. */
  15937. wAng: number;
  15938. /**
  15939. * Defines the center of rotation (U)
  15940. */
  15941. uRotationCenter: number;
  15942. /**
  15943. * Defines the center of rotation (V)
  15944. */
  15945. vRotationCenter: number;
  15946. /**
  15947. * Defines the center of rotation (W)
  15948. */
  15949. wRotationCenter: number;
  15950. /**
  15951. * Are mip maps generated for this texture or not.
  15952. */
  15953. readonly noMipmap: boolean;
  15954. /**
  15955. * List of inspectable custom properties (used by the Inspector)
  15956. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15957. */
  15958. inspectableCustomProperties: Nullable<IInspectable[]>;
  15959. private _noMipmap;
  15960. /** @hidden */
  15961. _invertY: boolean;
  15962. private _rowGenerationMatrix;
  15963. private _cachedTextureMatrix;
  15964. private _projectionModeMatrix;
  15965. private _t0;
  15966. private _t1;
  15967. private _t2;
  15968. private _cachedUOffset;
  15969. private _cachedVOffset;
  15970. private _cachedUScale;
  15971. private _cachedVScale;
  15972. private _cachedUAng;
  15973. private _cachedVAng;
  15974. private _cachedWAng;
  15975. private _cachedProjectionMatrixId;
  15976. private _cachedCoordinatesMode;
  15977. /** @hidden */
  15978. protected _initialSamplingMode: number;
  15979. /** @hidden */
  15980. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  15981. private _deleteBuffer;
  15982. protected _format: Nullable<number>;
  15983. private _delayedOnLoad;
  15984. private _delayedOnError;
  15985. /**
  15986. * Observable triggered once the texture has been loaded.
  15987. */
  15988. onLoadObservable: Observable<Texture>;
  15989. protected _isBlocking: boolean;
  15990. /**
  15991. * Is the texture preventing material to render while loading.
  15992. * If false, a default texture will be used instead of the loading one during the preparation step.
  15993. */
  15994. isBlocking: boolean;
  15995. /**
  15996. * Get the current sampling mode associated with the texture.
  15997. */
  15998. readonly samplingMode: number;
  15999. /**
  16000. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16001. */
  16002. readonly invertY: boolean;
  16003. /**
  16004. * Instantiates a new texture.
  16005. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16006. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16007. * @param url define the url of the picture to load as a texture
  16008. * @param scene define the scene or engine the texture will belong to
  16009. * @param noMipmap define if the texture will require mip maps or not
  16010. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16011. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16012. * @param onLoad define a callback triggered when the texture has been loaded
  16013. * @param onError define a callback triggered when an error occurred during the loading session
  16014. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16015. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16016. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16017. */
  16018. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  16019. /**
  16020. * Update the url (and optional buffer) of this texture if url was null during construction.
  16021. * @param url the url of the texture
  16022. * @param buffer the buffer of the texture (defaults to null)
  16023. * @param onLoad callback called when the texture is loaded (defaults to null)
  16024. */
  16025. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16026. /**
  16027. * Finish the loading sequence of a texture flagged as delayed load.
  16028. * @hidden
  16029. */
  16030. delayLoad(): void;
  16031. private _prepareRowForTextureGeneration;
  16032. /**
  16033. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16034. * @returns the transform matrix of the texture.
  16035. */
  16036. getTextureMatrix(): Matrix;
  16037. /**
  16038. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16039. * @returns The reflection texture transform
  16040. */
  16041. getReflectionTextureMatrix(): Matrix;
  16042. /**
  16043. * Clones the texture.
  16044. * @returns the cloned texture
  16045. */
  16046. clone(): Texture;
  16047. /**
  16048. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16049. * @returns The JSON representation of the texture
  16050. */
  16051. serialize(): any;
  16052. /**
  16053. * Get the current class name of the texture useful for serialization or dynamic coding.
  16054. * @returns "Texture"
  16055. */
  16056. getClassName(): string;
  16057. /**
  16058. * Dispose the texture and release its associated resources.
  16059. */
  16060. dispose(): void;
  16061. /**
  16062. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16063. * @param parsedTexture Define the JSON representation of the texture
  16064. * @param scene Define the scene the parsed texture should be instantiated in
  16065. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16066. * @returns The parsed texture if successful
  16067. */
  16068. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16069. /**
  16070. * Creates a texture from its base 64 representation.
  16071. * @param data Define the base64 payload without the data: prefix
  16072. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16073. * @param scene Define the scene the texture should belong to
  16074. * @param noMipmap Forces the texture to not create mip map information if true
  16075. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16076. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16077. * @param onLoad define a callback triggered when the texture has been loaded
  16078. * @param onError define a callback triggered when an error occurred during the loading session
  16079. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16080. * @returns the created texture
  16081. */
  16082. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16083. /**
  16084. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16085. * @param data Define the base64 payload without the data: prefix
  16086. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16087. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16088. * @param scene Define the scene the texture should belong to
  16089. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16090. * @param noMipmap Forces the texture to not create mip map information if true
  16091. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16092. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16093. * @param onLoad define a callback triggered when the texture has been loaded
  16094. * @param onError define a callback triggered when an error occurred during the loading session
  16095. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16096. * @returns the created texture
  16097. */
  16098. 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;
  16099. }
  16100. }
  16101. declare module "babylonjs/PostProcesses/postProcessManager" {
  16102. import { Nullable } from "babylonjs/types";
  16103. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16104. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16105. import { Scene } from "babylonjs/scene";
  16106. /**
  16107. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16108. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16109. */
  16110. export class PostProcessManager {
  16111. private _scene;
  16112. private _indexBuffer;
  16113. private _vertexBuffers;
  16114. /**
  16115. * Creates a new instance PostProcess
  16116. * @param scene The scene that the post process is associated with.
  16117. */
  16118. constructor(scene: Scene);
  16119. private _prepareBuffers;
  16120. private _buildIndexBuffer;
  16121. /**
  16122. * Rebuilds the vertex buffers of the manager.
  16123. * @hidden
  16124. */
  16125. _rebuild(): void;
  16126. /**
  16127. * Prepares a frame to be run through a post process.
  16128. * @param sourceTexture The input texture to the post procesess. (default: null)
  16129. * @param postProcesses An array of post processes to be run. (default: null)
  16130. * @returns True if the post processes were able to be run.
  16131. * @hidden
  16132. */
  16133. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16134. /**
  16135. * Manually render a set of post processes to a texture.
  16136. * @param postProcesses An array of post processes to be run.
  16137. * @param targetTexture The target texture to render to.
  16138. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16139. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16140. * @param lodLevel defines which lod of the texture to render to
  16141. */
  16142. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16143. /**
  16144. * Finalize the result of the output of the postprocesses.
  16145. * @param doNotPresent If true the result will not be displayed to the screen.
  16146. * @param targetTexture The target texture to render to.
  16147. * @param faceIndex The index of the face to bind the target texture to.
  16148. * @param postProcesses The array of post processes to render.
  16149. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16150. * @hidden
  16151. */
  16152. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16153. /**
  16154. * Disposes of the post process manager.
  16155. */
  16156. dispose(): void;
  16157. }
  16158. }
  16159. declare module "babylonjs/Misc/gradients" {
  16160. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16161. /** Interface used by value gradients (color, factor, ...) */
  16162. export interface IValueGradient {
  16163. /**
  16164. * Gets or sets the gradient value (between 0 and 1)
  16165. */
  16166. gradient: number;
  16167. }
  16168. /** Class used to store color4 gradient */
  16169. export class ColorGradient implements IValueGradient {
  16170. /**
  16171. * Gets or sets the gradient value (between 0 and 1)
  16172. */
  16173. gradient: number;
  16174. /**
  16175. * Gets or sets first associated color
  16176. */
  16177. color1: Color4;
  16178. /**
  16179. * Gets or sets second associated color
  16180. */
  16181. color2?: Color4;
  16182. /**
  16183. * Will get a color picked randomly between color1 and color2.
  16184. * If color2 is undefined then color1 will be used
  16185. * @param result defines the target Color4 to store the result in
  16186. */
  16187. getColorToRef(result: Color4): void;
  16188. }
  16189. /** Class used to store color 3 gradient */
  16190. export class Color3Gradient implements IValueGradient {
  16191. /**
  16192. * Gets or sets the gradient value (between 0 and 1)
  16193. */
  16194. gradient: number;
  16195. /**
  16196. * Gets or sets the associated color
  16197. */
  16198. color: Color3;
  16199. }
  16200. /** Class used to store factor gradient */
  16201. export class FactorGradient implements IValueGradient {
  16202. /**
  16203. * Gets or sets the gradient value (between 0 and 1)
  16204. */
  16205. gradient: number;
  16206. /**
  16207. * Gets or sets first associated factor
  16208. */
  16209. factor1: number;
  16210. /**
  16211. * Gets or sets second associated factor
  16212. */
  16213. factor2?: number;
  16214. /**
  16215. * Will get a number picked randomly between factor1 and factor2.
  16216. * If factor2 is undefined then factor1 will be used
  16217. * @returns the picked number
  16218. */
  16219. getFactor(): number;
  16220. }
  16221. /**
  16222. * Helper used to simplify some generic gradient tasks
  16223. */
  16224. export class GradientHelper {
  16225. /**
  16226. * Gets the current gradient from an array of IValueGradient
  16227. * @param ratio defines the current ratio to get
  16228. * @param gradients defines the array of IValueGradient
  16229. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16230. */
  16231. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16232. }
  16233. }
  16234. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16235. import { Scene } from "babylonjs/scene";
  16236. import { ISceneComponent } from "babylonjs/sceneComponent";
  16237. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16238. module "babylonjs/abstractScene" {
  16239. interface AbstractScene {
  16240. /**
  16241. * The list of procedural textures added to the scene
  16242. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16243. */
  16244. proceduralTextures: Array<ProceduralTexture>;
  16245. }
  16246. }
  16247. /**
  16248. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16249. * in a given scene.
  16250. */
  16251. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16252. /**
  16253. * The component name helpfull to identify the component in the list of scene components.
  16254. */
  16255. readonly name: string;
  16256. /**
  16257. * The scene the component belongs to.
  16258. */
  16259. scene: Scene;
  16260. /**
  16261. * Creates a new instance of the component for the given scene
  16262. * @param scene Defines the scene to register the component in
  16263. */
  16264. constructor(scene: Scene);
  16265. /**
  16266. * Registers the component in a given scene
  16267. */
  16268. register(): void;
  16269. /**
  16270. * Rebuilds the elements related to this component in case of
  16271. * context lost for instance.
  16272. */
  16273. rebuild(): void;
  16274. /**
  16275. * Disposes the component and the associated ressources.
  16276. */
  16277. dispose(): void;
  16278. private _beforeClear;
  16279. }
  16280. }
  16281. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  16282. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16283. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16284. module "babylonjs/Engines/engine" {
  16285. interface Engine {
  16286. /**
  16287. * Creates a new render target cube texture
  16288. * @param size defines the size of the texture
  16289. * @param options defines the options used to create the texture
  16290. * @returns a new render target cube texture stored in an InternalTexture
  16291. */
  16292. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16293. }
  16294. }
  16295. }
  16296. declare module "babylonjs/Shaders/procedural.vertex" {
  16297. /** @hidden */
  16298. export var proceduralVertexShader: {
  16299. name: string;
  16300. shader: string;
  16301. };
  16302. }
  16303. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16304. import { Observable } from "babylonjs/Misc/observable";
  16305. import { Nullable } from "babylonjs/types";
  16306. import { Scene } from "babylonjs/scene";
  16307. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16308. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16309. import { Effect } from "babylonjs/Materials/effect";
  16310. import { Texture } from "babylonjs/Materials/Textures/texture";
  16311. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16312. import "babylonjs/Shaders/procedural.vertex";
  16313. /**
  16314. * 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.
  16315. * This is the base class of any Procedural texture and contains most of the shareable code.
  16316. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16317. */
  16318. export class ProceduralTexture extends Texture {
  16319. isCube: boolean;
  16320. /**
  16321. * Define if the texture is enabled or not (disabled texture will not render)
  16322. */
  16323. isEnabled: boolean;
  16324. /**
  16325. * Define if the texture must be cleared before rendering (default is true)
  16326. */
  16327. autoClear: boolean;
  16328. /**
  16329. * Callback called when the texture is generated
  16330. */
  16331. onGenerated: () => void;
  16332. /**
  16333. * Event raised when the texture is generated
  16334. */
  16335. onGeneratedObservable: Observable<ProceduralTexture>;
  16336. /** @hidden */
  16337. _generateMipMaps: boolean;
  16338. /** @hidden **/
  16339. _effect: Effect;
  16340. /** @hidden */
  16341. _textures: {
  16342. [key: string]: Texture;
  16343. };
  16344. private _size;
  16345. private _currentRefreshId;
  16346. private _refreshRate;
  16347. private _vertexBuffers;
  16348. private _indexBuffer;
  16349. private _uniforms;
  16350. private _samplers;
  16351. private _fragment;
  16352. private _floats;
  16353. private _ints;
  16354. private _floatsArrays;
  16355. private _colors3;
  16356. private _colors4;
  16357. private _vectors2;
  16358. private _vectors3;
  16359. private _matrices;
  16360. private _fallbackTexture;
  16361. private _fallbackTextureUsed;
  16362. private _engine;
  16363. private _cachedDefines;
  16364. private _contentUpdateId;
  16365. private _contentData;
  16366. /**
  16367. * Instantiates a new procedural texture.
  16368. * 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.
  16369. * This is the base class of any Procedural texture and contains most of the shareable code.
  16370. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16371. * @param name Define the name of the texture
  16372. * @param size Define the size of the texture to create
  16373. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16374. * @param scene Define the scene the texture belongs to
  16375. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16376. * @param generateMipMaps Define if the texture should creates mip maps or not
  16377. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16378. */
  16379. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16380. /**
  16381. * The effect that is created when initializing the post process.
  16382. * @returns The created effect corresponding the the postprocess.
  16383. */
  16384. getEffect(): Effect;
  16385. /**
  16386. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16387. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16388. */
  16389. getContent(): Nullable<ArrayBufferView>;
  16390. private _createIndexBuffer;
  16391. /** @hidden */
  16392. _rebuild(): void;
  16393. /**
  16394. * Resets the texture in order to recreate its associated resources.
  16395. * This can be called in case of context loss
  16396. */
  16397. reset(): void;
  16398. protected _getDefines(): string;
  16399. /**
  16400. * Is the texture ready to be used ? (rendered at least once)
  16401. * @returns true if ready, otherwise, false.
  16402. */
  16403. isReady(): boolean;
  16404. /**
  16405. * Resets the refresh counter of the texture and start bak from scratch.
  16406. * Could be useful to regenerate the texture if it is setup to render only once.
  16407. */
  16408. resetRefreshCounter(): void;
  16409. /**
  16410. * Set the fragment shader to use in order to render the texture.
  16411. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16412. */
  16413. setFragment(fragment: any): void;
  16414. /**
  16415. * Define the refresh rate of the texture or the rendering frequency.
  16416. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16417. */
  16418. refreshRate: number;
  16419. /** @hidden */
  16420. _shouldRender(): boolean;
  16421. /**
  16422. * Get the size the texture is rendering at.
  16423. * @returns the size (texture is always squared)
  16424. */
  16425. getRenderSize(): number;
  16426. /**
  16427. * Resize the texture to new value.
  16428. * @param size Define the new size the texture should have
  16429. * @param generateMipMaps Define whether the new texture should create mip maps
  16430. */
  16431. resize(size: number, generateMipMaps: boolean): void;
  16432. private _checkUniform;
  16433. /**
  16434. * Set a texture in the shader program used to render.
  16435. * @param name Define the name of the uniform samplers as defined in the shader
  16436. * @param texture Define the texture to bind to this sampler
  16437. * @return the texture itself allowing "fluent" like uniform updates
  16438. */
  16439. setTexture(name: string, texture: Texture): ProceduralTexture;
  16440. /**
  16441. * Set a float in the shader.
  16442. * @param name Define the name of the uniform as defined in the shader
  16443. * @param value Define the value to give to the uniform
  16444. * @return the texture itself allowing "fluent" like uniform updates
  16445. */
  16446. setFloat(name: string, value: number): ProceduralTexture;
  16447. /**
  16448. * Set a int in the shader.
  16449. * @param name Define the name of the uniform as defined in the shader
  16450. * @param value Define the value to give to the uniform
  16451. * @return the texture itself allowing "fluent" like uniform updates
  16452. */
  16453. setInt(name: string, value: number): ProceduralTexture;
  16454. /**
  16455. * Set an array of floats in the shader.
  16456. * @param name Define the name of the uniform as defined in the shader
  16457. * @param value Define the value to give to the uniform
  16458. * @return the texture itself allowing "fluent" like uniform updates
  16459. */
  16460. setFloats(name: string, value: number[]): ProceduralTexture;
  16461. /**
  16462. * Set a vec3 in the shader from a Color3.
  16463. * @param name Define the name of the uniform as defined in the shader
  16464. * @param value Define the value to give to the uniform
  16465. * @return the texture itself allowing "fluent" like uniform updates
  16466. */
  16467. setColor3(name: string, value: Color3): ProceduralTexture;
  16468. /**
  16469. * Set a vec4 in the shader from a Color4.
  16470. * @param name Define the name of the uniform as defined in the shader
  16471. * @param value Define the value to give to the uniform
  16472. * @return the texture itself allowing "fluent" like uniform updates
  16473. */
  16474. setColor4(name: string, value: Color4): ProceduralTexture;
  16475. /**
  16476. * Set a vec2 in the shader from a Vector2.
  16477. * @param name Define the name of the uniform as defined in the shader
  16478. * @param value Define the value to give to the uniform
  16479. * @return the texture itself allowing "fluent" like uniform updates
  16480. */
  16481. setVector2(name: string, value: Vector2): ProceduralTexture;
  16482. /**
  16483. * Set a vec3 in the shader from a Vector3.
  16484. * @param name Define the name of the uniform as defined in the shader
  16485. * @param value Define the value to give to the uniform
  16486. * @return the texture itself allowing "fluent" like uniform updates
  16487. */
  16488. setVector3(name: string, value: Vector3): ProceduralTexture;
  16489. /**
  16490. * Set a mat4 in the shader from a MAtrix.
  16491. * @param name Define the name of the uniform as defined in the shader
  16492. * @param value Define the value to give to the uniform
  16493. * @return the texture itself allowing "fluent" like uniform updates
  16494. */
  16495. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16496. /**
  16497. * Render the texture to its associated render target.
  16498. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16499. */
  16500. render(useCameraPostProcess?: boolean): void;
  16501. /**
  16502. * Clone the texture.
  16503. * @returns the cloned texture
  16504. */
  16505. clone(): ProceduralTexture;
  16506. /**
  16507. * Dispose the texture and release its asoociated resources.
  16508. */
  16509. dispose(): void;
  16510. }
  16511. }
  16512. declare module "babylonjs/Particles/baseParticleSystem" {
  16513. import { Nullable } from "babylonjs/types";
  16514. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16516. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16517. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16518. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16519. import { Scene } from "babylonjs/scene";
  16520. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16521. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16522. import { Texture } from "babylonjs/Materials/Textures/texture";
  16523. import { Color4 } from "babylonjs/Maths/math.color";
  16524. import { Animation } from "babylonjs/Animations/animation";
  16525. /**
  16526. * This represents the base class for particle system in Babylon.
  16527. * 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.
  16528. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16529. * @example https://doc.babylonjs.com/babylon101/particles
  16530. */
  16531. export class BaseParticleSystem {
  16532. /**
  16533. * Source color is added to the destination color without alpha affecting the result
  16534. */
  16535. static BLENDMODE_ONEONE: number;
  16536. /**
  16537. * Blend current color and particle color using particle’s alpha
  16538. */
  16539. static BLENDMODE_STANDARD: number;
  16540. /**
  16541. * Add current color and particle color multiplied by particle’s alpha
  16542. */
  16543. static BLENDMODE_ADD: number;
  16544. /**
  16545. * Multiply current color with particle color
  16546. */
  16547. static BLENDMODE_MULTIPLY: number;
  16548. /**
  16549. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16550. */
  16551. static BLENDMODE_MULTIPLYADD: number;
  16552. /**
  16553. * List of animations used by the particle system.
  16554. */
  16555. animations: Animation[];
  16556. /**
  16557. * The id of the Particle system.
  16558. */
  16559. id: string;
  16560. /**
  16561. * The friendly name of the Particle system.
  16562. */
  16563. name: string;
  16564. /**
  16565. * The rendering group used by the Particle system to chose when to render.
  16566. */
  16567. renderingGroupId: number;
  16568. /**
  16569. * The emitter represents the Mesh or position we are attaching the particle system to.
  16570. */
  16571. emitter: Nullable<AbstractMesh | Vector3>;
  16572. /**
  16573. * The maximum number of particles to emit per frame
  16574. */
  16575. emitRate: number;
  16576. /**
  16577. * If you want to launch only a few particles at once, that can be done, as well.
  16578. */
  16579. manualEmitCount: number;
  16580. /**
  16581. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16582. */
  16583. updateSpeed: number;
  16584. /**
  16585. * The amount of time the particle system is running (depends of the overall update speed).
  16586. */
  16587. targetStopDuration: number;
  16588. /**
  16589. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16590. */
  16591. disposeOnStop: boolean;
  16592. /**
  16593. * Minimum power of emitting particles.
  16594. */
  16595. minEmitPower: number;
  16596. /**
  16597. * Maximum power of emitting particles.
  16598. */
  16599. maxEmitPower: number;
  16600. /**
  16601. * Minimum life time of emitting particles.
  16602. */
  16603. minLifeTime: number;
  16604. /**
  16605. * Maximum life time of emitting particles.
  16606. */
  16607. maxLifeTime: number;
  16608. /**
  16609. * Minimum Size of emitting particles.
  16610. */
  16611. minSize: number;
  16612. /**
  16613. * Maximum Size of emitting particles.
  16614. */
  16615. maxSize: number;
  16616. /**
  16617. * Minimum scale of emitting particles on X axis.
  16618. */
  16619. minScaleX: number;
  16620. /**
  16621. * Maximum scale of emitting particles on X axis.
  16622. */
  16623. maxScaleX: number;
  16624. /**
  16625. * Minimum scale of emitting particles on Y axis.
  16626. */
  16627. minScaleY: number;
  16628. /**
  16629. * Maximum scale of emitting particles on Y axis.
  16630. */
  16631. maxScaleY: number;
  16632. /**
  16633. * Gets or sets the minimal initial rotation in radians.
  16634. */
  16635. minInitialRotation: number;
  16636. /**
  16637. * Gets or sets the maximal initial rotation in radians.
  16638. */
  16639. maxInitialRotation: number;
  16640. /**
  16641. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16642. */
  16643. minAngularSpeed: number;
  16644. /**
  16645. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16646. */
  16647. maxAngularSpeed: number;
  16648. /**
  16649. * The texture used to render each particle. (this can be a spritesheet)
  16650. */
  16651. particleTexture: Nullable<Texture>;
  16652. /**
  16653. * The layer mask we are rendering the particles through.
  16654. */
  16655. layerMask: number;
  16656. /**
  16657. * This can help using your own shader to render the particle system.
  16658. * The according effect will be created
  16659. */
  16660. customShader: any;
  16661. /**
  16662. * By default particle system starts as soon as they are created. This prevents the
  16663. * automatic start to happen and let you decide when to start emitting particles.
  16664. */
  16665. preventAutoStart: boolean;
  16666. private _noiseTexture;
  16667. /**
  16668. * Gets or sets a texture used to add random noise to particle positions
  16669. */
  16670. noiseTexture: Nullable<ProceduralTexture>;
  16671. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16672. noiseStrength: Vector3;
  16673. /**
  16674. * Callback triggered when the particle animation is ending.
  16675. */
  16676. onAnimationEnd: Nullable<() => void>;
  16677. /**
  16678. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16679. */
  16680. blendMode: number;
  16681. /**
  16682. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16683. * to override the particles.
  16684. */
  16685. forceDepthWrite: boolean;
  16686. /** 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 */
  16687. preWarmCycles: number;
  16688. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16689. preWarmStepOffset: number;
  16690. /**
  16691. * 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)
  16692. */
  16693. spriteCellChangeSpeed: number;
  16694. /**
  16695. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16696. */
  16697. startSpriteCellID: number;
  16698. /**
  16699. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16700. */
  16701. endSpriteCellID: number;
  16702. /**
  16703. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16704. */
  16705. spriteCellWidth: number;
  16706. /**
  16707. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16708. */
  16709. spriteCellHeight: number;
  16710. /**
  16711. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16712. */
  16713. spriteRandomStartCell: boolean;
  16714. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16715. translationPivot: Vector2;
  16716. /** @hidden */
  16717. protected _isAnimationSheetEnabled: boolean;
  16718. /**
  16719. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16720. */
  16721. beginAnimationOnStart: boolean;
  16722. /**
  16723. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16724. */
  16725. beginAnimationFrom: number;
  16726. /**
  16727. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16728. */
  16729. beginAnimationTo: number;
  16730. /**
  16731. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16732. */
  16733. beginAnimationLoop: boolean;
  16734. /**
  16735. * Gets or sets a world offset applied to all particles
  16736. */
  16737. worldOffset: Vector3;
  16738. /**
  16739. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16740. */
  16741. isAnimationSheetEnabled: boolean;
  16742. /**
  16743. * Get hosting scene
  16744. * @returns the scene
  16745. */
  16746. getScene(): Scene;
  16747. /**
  16748. * You can use gravity if you want to give an orientation to your particles.
  16749. */
  16750. gravity: Vector3;
  16751. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16752. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16753. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16754. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16755. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16756. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16757. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16758. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16759. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16760. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16761. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16762. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16763. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16764. /**
  16765. * Defines the delay in milliseconds before starting the system (0 by default)
  16766. */
  16767. startDelay: number;
  16768. /**
  16769. * Gets the current list of drag gradients.
  16770. * You must use addDragGradient and removeDragGradient to udpate this list
  16771. * @returns the list of drag gradients
  16772. */
  16773. getDragGradients(): Nullable<Array<FactorGradient>>;
  16774. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16775. limitVelocityDamping: number;
  16776. /**
  16777. * Gets the current list of limit velocity gradients.
  16778. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16779. * @returns the list of limit velocity gradients
  16780. */
  16781. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16782. /**
  16783. * Gets the current list of color gradients.
  16784. * You must use addColorGradient and removeColorGradient to udpate this list
  16785. * @returns the list of color gradients
  16786. */
  16787. getColorGradients(): Nullable<Array<ColorGradient>>;
  16788. /**
  16789. * Gets the current list of size gradients.
  16790. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16791. * @returns the list of size gradients
  16792. */
  16793. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16794. /**
  16795. * Gets the current list of color remap gradients.
  16796. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16797. * @returns the list of color remap gradients
  16798. */
  16799. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16800. /**
  16801. * Gets the current list of alpha remap gradients.
  16802. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16803. * @returns the list of alpha remap gradients
  16804. */
  16805. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16806. /**
  16807. * Gets the current list of life time gradients.
  16808. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16809. * @returns the list of life time gradients
  16810. */
  16811. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16812. /**
  16813. * Gets the current list of angular speed gradients.
  16814. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16815. * @returns the list of angular speed gradients
  16816. */
  16817. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16818. /**
  16819. * Gets the current list of velocity gradients.
  16820. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16821. * @returns the list of velocity gradients
  16822. */
  16823. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16824. /**
  16825. * Gets the current list of start size gradients.
  16826. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16827. * @returns the list of start size gradients
  16828. */
  16829. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16830. /**
  16831. * Gets the current list of emit rate gradients.
  16832. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16833. * @returns the list of emit rate gradients
  16834. */
  16835. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16836. /**
  16837. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16838. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16839. */
  16840. direction1: Vector3;
  16841. /**
  16842. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16843. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16844. */
  16845. direction2: Vector3;
  16846. /**
  16847. * 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.
  16848. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16849. */
  16850. minEmitBox: Vector3;
  16851. /**
  16852. * 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.
  16853. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16854. */
  16855. maxEmitBox: Vector3;
  16856. /**
  16857. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16858. */
  16859. color1: Color4;
  16860. /**
  16861. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16862. */
  16863. color2: Color4;
  16864. /**
  16865. * Color the particle will have at the end of its lifetime
  16866. */
  16867. colorDead: Color4;
  16868. /**
  16869. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16870. */
  16871. textureMask: Color4;
  16872. /**
  16873. * The particle emitter type defines the emitter used by the particle system.
  16874. * It can be for example box, sphere, or cone...
  16875. */
  16876. particleEmitterType: IParticleEmitterType;
  16877. /** @hidden */
  16878. _isSubEmitter: boolean;
  16879. /**
  16880. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16881. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16882. */
  16883. billboardMode: number;
  16884. protected _isBillboardBased: boolean;
  16885. /**
  16886. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16887. */
  16888. isBillboardBased: boolean;
  16889. /**
  16890. * The scene the particle system belongs to.
  16891. */
  16892. protected _scene: Scene;
  16893. /**
  16894. * Local cache of defines for image processing.
  16895. */
  16896. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16897. /**
  16898. * Default configuration related to image processing available in the standard Material.
  16899. */
  16900. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16901. /**
  16902. * Gets the image processing configuration used either in this material.
  16903. */
  16904. /**
  16905. * Sets the Default image processing configuration used either in the this material.
  16906. *
  16907. * If sets to null, the scene one is in use.
  16908. */
  16909. imageProcessingConfiguration: ImageProcessingConfiguration;
  16910. /**
  16911. * Attaches a new image processing configuration to the Standard Material.
  16912. * @param configuration
  16913. */
  16914. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16915. /** @hidden */
  16916. protected _reset(): void;
  16917. /** @hidden */
  16918. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16919. /**
  16920. * Instantiates a particle system.
  16921. * 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.
  16922. * @param name The name of the particle system
  16923. */
  16924. constructor(name: string);
  16925. /**
  16926. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16927. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16928. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16929. * @returns the emitter
  16930. */
  16931. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16932. /**
  16933. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16934. * @param radius The radius of the hemisphere to emit from
  16935. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16936. * @returns the emitter
  16937. */
  16938. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16939. /**
  16940. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16941. * @param radius The radius of the sphere to emit from
  16942. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16943. * @returns the emitter
  16944. */
  16945. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16946. /**
  16947. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16948. * @param radius The radius of the sphere to emit from
  16949. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16950. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16951. * @returns the emitter
  16952. */
  16953. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16954. /**
  16955. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16956. * @param radius The radius of the emission cylinder
  16957. * @param height The height of the emission cylinder
  16958. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16959. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16960. * @returns the emitter
  16961. */
  16962. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16963. /**
  16964. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16965. * @param radius The radius of the cylinder to emit from
  16966. * @param height The height of the emission cylinder
  16967. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16968. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16969. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16970. * @returns the emitter
  16971. */
  16972. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16973. /**
  16974. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16975. * @param radius The radius of the cone to emit from
  16976. * @param angle The base angle of the cone
  16977. * @returns the emitter
  16978. */
  16979. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16980. /**
  16981. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16982. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16983. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16984. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16985. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16986. * @returns the emitter
  16987. */
  16988. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16989. }
  16990. }
  16991. declare module "babylonjs/Particles/subEmitter" {
  16992. import { Scene } from "babylonjs/scene";
  16993. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  16994. /**
  16995. * Type of sub emitter
  16996. */
  16997. export enum SubEmitterType {
  16998. /**
  16999. * Attached to the particle over it's lifetime
  17000. */
  17001. ATTACHED = 0,
  17002. /**
  17003. * Created when the particle dies
  17004. */
  17005. END = 1
  17006. }
  17007. /**
  17008. * Sub emitter class used to emit particles from an existing particle
  17009. */
  17010. export class SubEmitter {
  17011. /**
  17012. * the particle system to be used by the sub emitter
  17013. */
  17014. particleSystem: ParticleSystem;
  17015. /**
  17016. * Type of the submitter (Default: END)
  17017. */
  17018. type: SubEmitterType;
  17019. /**
  17020. * 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)
  17021. * Note: This only is supported when using an emitter of type Mesh
  17022. */
  17023. inheritDirection: boolean;
  17024. /**
  17025. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17026. */
  17027. inheritedVelocityAmount: number;
  17028. /**
  17029. * Creates a sub emitter
  17030. * @param particleSystem the particle system to be used by the sub emitter
  17031. */
  17032. constructor(
  17033. /**
  17034. * the particle system to be used by the sub emitter
  17035. */
  17036. particleSystem: ParticleSystem);
  17037. /**
  17038. * Clones the sub emitter
  17039. * @returns the cloned sub emitter
  17040. */
  17041. clone(): SubEmitter;
  17042. /**
  17043. * Serialize current object to a JSON object
  17044. * @returns the serialized object
  17045. */
  17046. serialize(): any;
  17047. /** @hidden */
  17048. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17049. /**
  17050. * Creates a new SubEmitter from a serialized JSON version
  17051. * @param serializationObject defines the JSON object to read from
  17052. * @param scene defines the hosting scene
  17053. * @param rootUrl defines the rootUrl for data loading
  17054. * @returns a new SubEmitter
  17055. */
  17056. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17057. /** Release associated resources */
  17058. dispose(): void;
  17059. }
  17060. }
  17061. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17062. /** @hidden */
  17063. export var clipPlaneFragmentDeclaration: {
  17064. name: string;
  17065. shader: string;
  17066. };
  17067. }
  17068. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17069. /** @hidden */
  17070. export var imageProcessingDeclaration: {
  17071. name: string;
  17072. shader: string;
  17073. };
  17074. }
  17075. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17076. /** @hidden */
  17077. export var imageProcessingFunctions: {
  17078. name: string;
  17079. shader: string;
  17080. };
  17081. }
  17082. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17083. /** @hidden */
  17084. export var clipPlaneFragment: {
  17085. name: string;
  17086. shader: string;
  17087. };
  17088. }
  17089. declare module "babylonjs/Shaders/particles.fragment" {
  17090. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17091. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17092. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17093. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17094. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17095. /** @hidden */
  17096. export var particlesPixelShader: {
  17097. name: string;
  17098. shader: string;
  17099. };
  17100. }
  17101. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17102. /** @hidden */
  17103. export var clipPlaneVertexDeclaration: {
  17104. name: string;
  17105. shader: string;
  17106. };
  17107. }
  17108. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17109. /** @hidden */
  17110. export var clipPlaneVertex: {
  17111. name: string;
  17112. shader: string;
  17113. };
  17114. }
  17115. declare module "babylonjs/Shaders/particles.vertex" {
  17116. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17117. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17118. /** @hidden */
  17119. export var particlesVertexShader: {
  17120. name: string;
  17121. shader: string;
  17122. };
  17123. }
  17124. declare module "babylonjs/Particles/particleSystem" {
  17125. import { Nullable } from "babylonjs/types";
  17126. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17127. import { Observable } from "babylonjs/Misc/observable";
  17128. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17129. import { Effect } from "babylonjs/Materials/effect";
  17130. import { Scene, IDisposable } from "babylonjs/scene";
  17131. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17132. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17133. import { Particle } from "babylonjs/Particles/particle";
  17134. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17135. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17136. import "babylonjs/Shaders/particles.fragment";
  17137. import "babylonjs/Shaders/particles.vertex";
  17138. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17139. /**
  17140. * This represents a particle system in Babylon.
  17141. * 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.
  17142. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17143. * @example https://doc.babylonjs.com/babylon101/particles
  17144. */
  17145. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17146. /**
  17147. * Billboard mode will only apply to Y axis
  17148. */
  17149. static readonly BILLBOARDMODE_Y: number;
  17150. /**
  17151. * Billboard mode will apply to all axes
  17152. */
  17153. static readonly BILLBOARDMODE_ALL: number;
  17154. /**
  17155. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17156. */
  17157. static readonly BILLBOARDMODE_STRETCHED: number;
  17158. /**
  17159. * This function can be defined to provide custom update for active particles.
  17160. * This function will be called instead of regular update (age, position, color, etc.).
  17161. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17162. */
  17163. updateFunction: (particles: Particle[]) => void;
  17164. private _emitterWorldMatrix;
  17165. /**
  17166. * This function can be defined to specify initial direction for every new particle.
  17167. * It by default use the emitterType defined function
  17168. */
  17169. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17170. /**
  17171. * This function can be defined to specify initial position for every new particle.
  17172. * It by default use the emitterType defined function
  17173. */
  17174. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17175. /**
  17176. * @hidden
  17177. */
  17178. _inheritedVelocityOffset: Vector3;
  17179. /**
  17180. * An event triggered when the system is disposed
  17181. */
  17182. onDisposeObservable: Observable<ParticleSystem>;
  17183. private _onDisposeObserver;
  17184. /**
  17185. * Sets a callback that will be triggered when the system is disposed
  17186. */
  17187. onDispose: () => void;
  17188. private _particles;
  17189. private _epsilon;
  17190. private _capacity;
  17191. private _stockParticles;
  17192. private _newPartsExcess;
  17193. private _vertexData;
  17194. private _vertexBuffer;
  17195. private _vertexBuffers;
  17196. private _spriteBuffer;
  17197. private _indexBuffer;
  17198. private _effect;
  17199. private _customEffect;
  17200. private _cachedDefines;
  17201. private _scaledColorStep;
  17202. private _colorDiff;
  17203. private _scaledDirection;
  17204. private _scaledGravity;
  17205. private _currentRenderId;
  17206. private _alive;
  17207. private _useInstancing;
  17208. private _started;
  17209. private _stopped;
  17210. private _actualFrame;
  17211. private _scaledUpdateSpeed;
  17212. private _vertexBufferSize;
  17213. /** @hidden */
  17214. _currentEmitRateGradient: Nullable<FactorGradient>;
  17215. /** @hidden */
  17216. _currentEmitRate1: number;
  17217. /** @hidden */
  17218. _currentEmitRate2: number;
  17219. /** @hidden */
  17220. _currentStartSizeGradient: Nullable<FactorGradient>;
  17221. /** @hidden */
  17222. _currentStartSize1: number;
  17223. /** @hidden */
  17224. _currentStartSize2: number;
  17225. private readonly _rawTextureWidth;
  17226. private _rampGradientsTexture;
  17227. private _useRampGradients;
  17228. /** Gets or sets a boolean indicating that ramp gradients must be used
  17229. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17230. */
  17231. useRampGradients: boolean;
  17232. /**
  17233. * 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.
  17234. * 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: [])
  17235. */
  17236. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17237. private _subEmitters;
  17238. /**
  17239. * @hidden
  17240. * If the particle systems emitter should be disposed when the particle system is disposed
  17241. */
  17242. _disposeEmitterOnDispose: boolean;
  17243. /**
  17244. * The current active Sub-systems, this property is used by the root particle system only.
  17245. */
  17246. activeSubSystems: Array<ParticleSystem>;
  17247. private _rootParticleSystem;
  17248. /**
  17249. * Gets the current list of active particles
  17250. */
  17251. readonly particles: Particle[];
  17252. /**
  17253. * Returns the string "ParticleSystem"
  17254. * @returns a string containing the class name
  17255. */
  17256. getClassName(): string;
  17257. /**
  17258. * Instantiates a particle system.
  17259. * 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.
  17260. * @param name The name of the particle system
  17261. * @param capacity The max number of particles alive at the same time
  17262. * @param scene The scene the particle system belongs to
  17263. * @param customEffect a custom effect used to change the way particles are rendered by default
  17264. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17265. * @param epsilon Offset used to render the particles
  17266. */
  17267. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17268. private _addFactorGradient;
  17269. private _removeFactorGradient;
  17270. /**
  17271. * Adds a new life time gradient
  17272. * @param gradient defines the gradient to use (between 0 and 1)
  17273. * @param factor defines the life time factor to affect to the specified gradient
  17274. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17275. * @returns the current particle system
  17276. */
  17277. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17278. /**
  17279. * Remove a specific life time gradient
  17280. * @param gradient defines the gradient to remove
  17281. * @returns the current particle system
  17282. */
  17283. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17284. /**
  17285. * Adds a new size gradient
  17286. * @param gradient defines the gradient to use (between 0 and 1)
  17287. * @param factor defines the size factor to affect to the specified gradient
  17288. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17289. * @returns the current particle system
  17290. */
  17291. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17292. /**
  17293. * Remove a specific size gradient
  17294. * @param gradient defines the gradient to remove
  17295. * @returns the current particle system
  17296. */
  17297. removeSizeGradient(gradient: number): IParticleSystem;
  17298. /**
  17299. * Adds a new color remap gradient
  17300. * @param gradient defines the gradient to use (between 0 and 1)
  17301. * @param min defines the color remap minimal range
  17302. * @param max defines the color remap maximal range
  17303. * @returns the current particle system
  17304. */
  17305. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17306. /**
  17307. * Remove a specific color remap gradient
  17308. * @param gradient defines the gradient to remove
  17309. * @returns the current particle system
  17310. */
  17311. removeColorRemapGradient(gradient: number): IParticleSystem;
  17312. /**
  17313. * Adds a new alpha remap gradient
  17314. * @param gradient defines the gradient to use (between 0 and 1)
  17315. * @param min defines the alpha remap minimal range
  17316. * @param max defines the alpha remap maximal range
  17317. * @returns the current particle system
  17318. */
  17319. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17320. /**
  17321. * Remove a specific alpha remap gradient
  17322. * @param gradient defines the gradient to remove
  17323. * @returns the current particle system
  17324. */
  17325. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17326. /**
  17327. * Adds a new angular speed gradient
  17328. * @param gradient defines the gradient to use (between 0 and 1)
  17329. * @param factor defines the angular speed to affect to the specified gradient
  17330. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17331. * @returns the current particle system
  17332. */
  17333. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17334. /**
  17335. * Remove a specific angular speed gradient
  17336. * @param gradient defines the gradient to remove
  17337. * @returns the current particle system
  17338. */
  17339. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17340. /**
  17341. * Adds a new velocity gradient
  17342. * @param gradient defines the gradient to use (between 0 and 1)
  17343. * @param factor defines the velocity to affect to the specified gradient
  17344. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17345. * @returns the current particle system
  17346. */
  17347. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17348. /**
  17349. * Remove a specific velocity gradient
  17350. * @param gradient defines the gradient to remove
  17351. * @returns the current particle system
  17352. */
  17353. removeVelocityGradient(gradient: number): IParticleSystem;
  17354. /**
  17355. * Adds a new limit velocity gradient
  17356. * @param gradient defines the gradient to use (between 0 and 1)
  17357. * @param factor defines the limit velocity value to affect to the specified gradient
  17358. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17359. * @returns the current particle system
  17360. */
  17361. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17362. /**
  17363. * Remove a specific limit velocity gradient
  17364. * @param gradient defines the gradient to remove
  17365. * @returns the current particle system
  17366. */
  17367. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17368. /**
  17369. * Adds a new drag gradient
  17370. * @param gradient defines the gradient to use (between 0 and 1)
  17371. * @param factor defines the drag value to affect to the specified gradient
  17372. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17373. * @returns the current particle system
  17374. */
  17375. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17376. /**
  17377. * Remove a specific drag gradient
  17378. * @param gradient defines the gradient to remove
  17379. * @returns the current particle system
  17380. */
  17381. removeDragGradient(gradient: number): IParticleSystem;
  17382. /**
  17383. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17384. * @param gradient defines the gradient to use (between 0 and 1)
  17385. * @param factor defines the emit rate value to affect to the specified gradient
  17386. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17387. * @returns the current particle system
  17388. */
  17389. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17390. /**
  17391. * Remove a specific emit rate gradient
  17392. * @param gradient defines the gradient to remove
  17393. * @returns the current particle system
  17394. */
  17395. removeEmitRateGradient(gradient: number): IParticleSystem;
  17396. /**
  17397. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17398. * @param gradient defines the gradient to use (between 0 and 1)
  17399. * @param factor defines the start size value to affect to the specified gradient
  17400. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17401. * @returns the current particle system
  17402. */
  17403. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17404. /**
  17405. * Remove a specific start size gradient
  17406. * @param gradient defines the gradient to remove
  17407. * @returns the current particle system
  17408. */
  17409. removeStartSizeGradient(gradient: number): IParticleSystem;
  17410. private _createRampGradientTexture;
  17411. /**
  17412. * Gets the current list of ramp gradients.
  17413. * You must use addRampGradient and removeRampGradient to udpate this list
  17414. * @returns the list of ramp gradients
  17415. */
  17416. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17417. /**
  17418. * Adds a new ramp gradient used to remap particle colors
  17419. * @param gradient defines the gradient to use (between 0 and 1)
  17420. * @param color defines the color to affect to the specified gradient
  17421. * @returns the current particle system
  17422. */
  17423. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17424. /**
  17425. * Remove a specific ramp gradient
  17426. * @param gradient defines the gradient to remove
  17427. * @returns the current particle system
  17428. */
  17429. removeRampGradient(gradient: number): ParticleSystem;
  17430. /**
  17431. * Adds a new color gradient
  17432. * @param gradient defines the gradient to use (between 0 and 1)
  17433. * @param color1 defines the color to affect to the specified gradient
  17434. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17435. * @returns this particle system
  17436. */
  17437. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17438. /**
  17439. * Remove a specific color gradient
  17440. * @param gradient defines the gradient to remove
  17441. * @returns this particle system
  17442. */
  17443. removeColorGradient(gradient: number): IParticleSystem;
  17444. private _fetchR;
  17445. protected _reset(): void;
  17446. private _resetEffect;
  17447. private _createVertexBuffers;
  17448. private _createIndexBuffer;
  17449. /**
  17450. * Gets the maximum number of particles active at the same time.
  17451. * @returns The max number of active particles.
  17452. */
  17453. getCapacity(): number;
  17454. /**
  17455. * Gets whether there are still active particles in the system.
  17456. * @returns True if it is alive, otherwise false.
  17457. */
  17458. isAlive(): boolean;
  17459. /**
  17460. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17461. * @returns True if it has been started, otherwise false.
  17462. */
  17463. isStarted(): boolean;
  17464. private _prepareSubEmitterInternalArray;
  17465. /**
  17466. * Starts the particle system and begins to emit
  17467. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17468. */
  17469. start(delay?: number): void;
  17470. /**
  17471. * Stops the particle system.
  17472. * @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.
  17473. */
  17474. stop(stopSubEmitters?: boolean): void;
  17475. /**
  17476. * Remove all active particles
  17477. */
  17478. reset(): void;
  17479. /**
  17480. * @hidden (for internal use only)
  17481. */
  17482. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17483. /**
  17484. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17485. * Its lifetime will start back at 0.
  17486. */
  17487. recycleParticle: (particle: Particle) => void;
  17488. private _stopSubEmitters;
  17489. private _createParticle;
  17490. private _removeFromRoot;
  17491. private _emitFromParticle;
  17492. private _update;
  17493. /** @hidden */
  17494. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17495. /** @hidden */
  17496. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17497. /** @hidden */
  17498. private _getEffect;
  17499. /**
  17500. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17501. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17502. */
  17503. animate(preWarmOnly?: boolean): void;
  17504. private _appendParticleVertices;
  17505. /**
  17506. * Rebuilds the particle system.
  17507. */
  17508. rebuild(): void;
  17509. /**
  17510. * Is this system ready to be used/rendered
  17511. * @return true if the system is ready
  17512. */
  17513. isReady(): boolean;
  17514. private _render;
  17515. /**
  17516. * Renders the particle system in its current state.
  17517. * @returns the current number of particles
  17518. */
  17519. render(): number;
  17520. /**
  17521. * Disposes the particle system and free the associated resources
  17522. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17523. */
  17524. dispose(disposeTexture?: boolean): void;
  17525. /**
  17526. * Clones the particle system.
  17527. * @param name The name of the cloned object
  17528. * @param newEmitter The new emitter to use
  17529. * @returns the cloned particle system
  17530. */
  17531. clone(name: string, newEmitter: any): ParticleSystem;
  17532. /**
  17533. * Serializes the particle system to a JSON object.
  17534. * @returns the JSON object
  17535. */
  17536. serialize(): any;
  17537. /** @hidden */
  17538. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17539. /** @hidden */
  17540. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17541. /**
  17542. * Parses a JSON object to create a particle system.
  17543. * @param parsedParticleSystem The JSON object to parse
  17544. * @param scene The scene to create the particle system in
  17545. * @param rootUrl The root url to use to load external dependencies like texture
  17546. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17547. * @returns the Parsed particle system
  17548. */
  17549. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17550. }
  17551. }
  17552. declare module "babylonjs/Particles/particle" {
  17553. import { Nullable } from "babylonjs/types";
  17554. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17555. import { Color4 } from "babylonjs/Maths/math.color";
  17556. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17557. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17558. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17559. /**
  17560. * A particle represents one of the element emitted by a particle system.
  17561. * This is mainly define by its coordinates, direction, velocity and age.
  17562. */
  17563. export class Particle {
  17564. /**
  17565. * The particle system the particle belongs to.
  17566. */
  17567. particleSystem: ParticleSystem;
  17568. private static _Count;
  17569. /**
  17570. * Unique ID of the particle
  17571. */
  17572. id: number;
  17573. /**
  17574. * The world position of the particle in the scene.
  17575. */
  17576. position: Vector3;
  17577. /**
  17578. * The world direction of the particle in the scene.
  17579. */
  17580. direction: Vector3;
  17581. /**
  17582. * The color of the particle.
  17583. */
  17584. color: Color4;
  17585. /**
  17586. * The color change of the particle per step.
  17587. */
  17588. colorStep: Color4;
  17589. /**
  17590. * Defines how long will the life of the particle be.
  17591. */
  17592. lifeTime: number;
  17593. /**
  17594. * The current age of the particle.
  17595. */
  17596. age: number;
  17597. /**
  17598. * The current size of the particle.
  17599. */
  17600. size: number;
  17601. /**
  17602. * The current scale of the particle.
  17603. */
  17604. scale: Vector2;
  17605. /**
  17606. * The current angle of the particle.
  17607. */
  17608. angle: number;
  17609. /**
  17610. * Defines how fast is the angle changing.
  17611. */
  17612. angularSpeed: number;
  17613. /**
  17614. * Defines the cell index used by the particle to be rendered from a sprite.
  17615. */
  17616. cellIndex: number;
  17617. /**
  17618. * The information required to support color remapping
  17619. */
  17620. remapData: Vector4;
  17621. /** @hidden */
  17622. _randomCellOffset?: number;
  17623. /** @hidden */
  17624. _initialDirection: Nullable<Vector3>;
  17625. /** @hidden */
  17626. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17627. /** @hidden */
  17628. _initialStartSpriteCellID: number;
  17629. /** @hidden */
  17630. _initialEndSpriteCellID: number;
  17631. /** @hidden */
  17632. _currentColorGradient: Nullable<ColorGradient>;
  17633. /** @hidden */
  17634. _currentColor1: Color4;
  17635. /** @hidden */
  17636. _currentColor2: Color4;
  17637. /** @hidden */
  17638. _currentSizeGradient: Nullable<FactorGradient>;
  17639. /** @hidden */
  17640. _currentSize1: number;
  17641. /** @hidden */
  17642. _currentSize2: number;
  17643. /** @hidden */
  17644. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17645. /** @hidden */
  17646. _currentAngularSpeed1: number;
  17647. /** @hidden */
  17648. _currentAngularSpeed2: number;
  17649. /** @hidden */
  17650. _currentVelocityGradient: Nullable<FactorGradient>;
  17651. /** @hidden */
  17652. _currentVelocity1: number;
  17653. /** @hidden */
  17654. _currentVelocity2: number;
  17655. /** @hidden */
  17656. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17657. /** @hidden */
  17658. _currentLimitVelocity1: number;
  17659. /** @hidden */
  17660. _currentLimitVelocity2: number;
  17661. /** @hidden */
  17662. _currentDragGradient: Nullable<FactorGradient>;
  17663. /** @hidden */
  17664. _currentDrag1: number;
  17665. /** @hidden */
  17666. _currentDrag2: number;
  17667. /** @hidden */
  17668. _randomNoiseCoordinates1: Vector3;
  17669. /** @hidden */
  17670. _randomNoiseCoordinates2: Vector3;
  17671. /**
  17672. * Creates a new instance Particle
  17673. * @param particleSystem the particle system the particle belongs to
  17674. */
  17675. constructor(
  17676. /**
  17677. * The particle system the particle belongs to.
  17678. */
  17679. particleSystem: ParticleSystem);
  17680. private updateCellInfoFromSystem;
  17681. /**
  17682. * Defines how the sprite cell index is updated for the particle
  17683. */
  17684. updateCellIndex(): void;
  17685. /** @hidden */
  17686. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17687. /** @hidden */
  17688. _inheritParticleInfoToSubEmitters(): void;
  17689. /** @hidden */
  17690. _reset(): void;
  17691. /**
  17692. * Copy the properties of particle to another one.
  17693. * @param other the particle to copy the information to.
  17694. */
  17695. copyTo(other: Particle): void;
  17696. }
  17697. }
  17698. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  17699. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17700. import { Effect } from "babylonjs/Materials/effect";
  17701. import { Particle } from "babylonjs/Particles/particle";
  17702. /**
  17703. * Particle emitter represents a volume emitting particles.
  17704. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17705. */
  17706. export interface IParticleEmitterType {
  17707. /**
  17708. * Called by the particle System when the direction is computed for the created particle.
  17709. * @param worldMatrix is the world matrix of the particle system
  17710. * @param directionToUpdate is the direction vector to update with the result
  17711. * @param particle is the particle we are computed the direction for
  17712. */
  17713. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17714. /**
  17715. * Called by the particle System when the position is computed for the created particle.
  17716. * @param worldMatrix is the world matrix of the particle system
  17717. * @param positionToUpdate is the position vector to update with the result
  17718. * @param particle is the particle we are computed the position for
  17719. */
  17720. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17721. /**
  17722. * Clones the current emitter and returns a copy of it
  17723. * @returns the new emitter
  17724. */
  17725. clone(): IParticleEmitterType;
  17726. /**
  17727. * Called by the GPUParticleSystem to setup the update shader
  17728. * @param effect defines the update shader
  17729. */
  17730. applyToShader(effect: Effect): void;
  17731. /**
  17732. * Returns a string to use to update the GPU particles update shader
  17733. * @returns the effect defines string
  17734. */
  17735. getEffectDefines(): string;
  17736. /**
  17737. * Returns a string representing the class name
  17738. * @returns a string containing the class name
  17739. */
  17740. getClassName(): string;
  17741. /**
  17742. * Serializes the particle system to a JSON object.
  17743. * @returns the JSON object
  17744. */
  17745. serialize(): any;
  17746. /**
  17747. * Parse properties from a JSON object
  17748. * @param serializationObject defines the JSON object
  17749. */
  17750. parse(serializationObject: any): void;
  17751. }
  17752. }
  17753. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  17754. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17755. import { Effect } from "babylonjs/Materials/effect";
  17756. import { Particle } from "babylonjs/Particles/particle";
  17757. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17758. /**
  17759. * Particle emitter emitting particles from the inside of a box.
  17760. * It emits the particles randomly between 2 given directions.
  17761. */
  17762. export class BoxParticleEmitter implements IParticleEmitterType {
  17763. /**
  17764. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17765. */
  17766. direction1: Vector3;
  17767. /**
  17768. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17769. */
  17770. direction2: Vector3;
  17771. /**
  17772. * 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.
  17773. */
  17774. minEmitBox: Vector3;
  17775. /**
  17776. * 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.
  17777. */
  17778. maxEmitBox: Vector3;
  17779. /**
  17780. * Creates a new instance BoxParticleEmitter
  17781. */
  17782. constructor();
  17783. /**
  17784. * Called by the particle System when the direction is computed for the created particle.
  17785. * @param worldMatrix is the world matrix of the particle system
  17786. * @param directionToUpdate is the direction vector to update with the result
  17787. * @param particle is the particle we are computed the direction for
  17788. */
  17789. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17790. /**
  17791. * Called by the particle System when the position is computed for the created particle.
  17792. * @param worldMatrix is the world matrix of the particle system
  17793. * @param positionToUpdate is the position vector to update with the result
  17794. * @param particle is the particle we are computed the position for
  17795. */
  17796. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17797. /**
  17798. * Clones the current emitter and returns a copy of it
  17799. * @returns the new emitter
  17800. */
  17801. clone(): BoxParticleEmitter;
  17802. /**
  17803. * Called by the GPUParticleSystem to setup the update shader
  17804. * @param effect defines the update shader
  17805. */
  17806. applyToShader(effect: Effect): void;
  17807. /**
  17808. * Returns a string to use to update the GPU particles update shader
  17809. * @returns a string containng the defines string
  17810. */
  17811. getEffectDefines(): string;
  17812. /**
  17813. * Returns the string "BoxParticleEmitter"
  17814. * @returns a string containing the class name
  17815. */
  17816. getClassName(): string;
  17817. /**
  17818. * Serializes the particle system to a JSON object.
  17819. * @returns the JSON object
  17820. */
  17821. serialize(): any;
  17822. /**
  17823. * Parse properties from a JSON object
  17824. * @param serializationObject defines the JSON object
  17825. */
  17826. parse(serializationObject: any): void;
  17827. }
  17828. }
  17829. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  17830. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17831. import { Effect } from "babylonjs/Materials/effect";
  17832. import { Particle } from "babylonjs/Particles/particle";
  17833. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17834. /**
  17835. * Particle emitter emitting particles from the inside of a cone.
  17836. * It emits the particles alongside the cone volume from the base to the particle.
  17837. * The emission direction might be randomized.
  17838. */
  17839. export class ConeParticleEmitter implements IParticleEmitterType {
  17840. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17841. directionRandomizer: number;
  17842. private _radius;
  17843. private _angle;
  17844. private _height;
  17845. /**
  17846. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17847. */
  17848. radiusRange: number;
  17849. /**
  17850. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17851. */
  17852. heightRange: number;
  17853. /**
  17854. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17855. */
  17856. emitFromSpawnPointOnly: boolean;
  17857. /**
  17858. * Gets or sets the radius of the emission cone
  17859. */
  17860. radius: number;
  17861. /**
  17862. * Gets or sets the angle of the emission cone
  17863. */
  17864. angle: number;
  17865. private _buildHeight;
  17866. /**
  17867. * Creates a new instance ConeParticleEmitter
  17868. * @param radius the radius of the emission cone (1 by default)
  17869. * @param angle the cone base angle (PI by default)
  17870. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17871. */
  17872. constructor(radius?: number, angle?: number,
  17873. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17874. directionRandomizer?: number);
  17875. /**
  17876. * Called by the particle System when the direction is computed for the created particle.
  17877. * @param worldMatrix is the world matrix of the particle system
  17878. * @param directionToUpdate is the direction vector to update with the result
  17879. * @param particle is the particle we are computed the direction for
  17880. */
  17881. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17882. /**
  17883. * Called by the particle System when the position is computed for the created particle.
  17884. * @param worldMatrix is the world matrix of the particle system
  17885. * @param positionToUpdate is the position vector to update with the result
  17886. * @param particle is the particle we are computed the position for
  17887. */
  17888. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17889. /**
  17890. * Clones the current emitter and returns a copy of it
  17891. * @returns the new emitter
  17892. */
  17893. clone(): ConeParticleEmitter;
  17894. /**
  17895. * Called by the GPUParticleSystem to setup the update shader
  17896. * @param effect defines the update shader
  17897. */
  17898. applyToShader(effect: Effect): void;
  17899. /**
  17900. * Returns a string to use to update the GPU particles update shader
  17901. * @returns a string containng the defines string
  17902. */
  17903. getEffectDefines(): string;
  17904. /**
  17905. * Returns the string "ConeParticleEmitter"
  17906. * @returns a string containing the class name
  17907. */
  17908. getClassName(): string;
  17909. /**
  17910. * Serializes the particle system to a JSON object.
  17911. * @returns the JSON object
  17912. */
  17913. serialize(): any;
  17914. /**
  17915. * Parse properties from a JSON object
  17916. * @param serializationObject defines the JSON object
  17917. */
  17918. parse(serializationObject: any): void;
  17919. }
  17920. }
  17921. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  17922. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17923. import { Effect } from "babylonjs/Materials/effect";
  17924. import { Particle } from "babylonjs/Particles/particle";
  17925. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17926. /**
  17927. * Particle emitter emitting particles from the inside of a cylinder.
  17928. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17929. */
  17930. export class CylinderParticleEmitter implements IParticleEmitterType {
  17931. /**
  17932. * The radius of the emission cylinder.
  17933. */
  17934. radius: number;
  17935. /**
  17936. * The height of the emission cylinder.
  17937. */
  17938. height: number;
  17939. /**
  17940. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17941. */
  17942. radiusRange: number;
  17943. /**
  17944. * How much to randomize the particle direction [0-1].
  17945. */
  17946. directionRandomizer: number;
  17947. /**
  17948. * Creates a new instance CylinderParticleEmitter
  17949. * @param radius the radius of the emission cylinder (1 by default)
  17950. * @param height the height of the emission cylinder (1 by default)
  17951. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17952. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17953. */
  17954. constructor(
  17955. /**
  17956. * The radius of the emission cylinder.
  17957. */
  17958. radius?: number,
  17959. /**
  17960. * The height of the emission cylinder.
  17961. */
  17962. height?: number,
  17963. /**
  17964. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17965. */
  17966. radiusRange?: number,
  17967. /**
  17968. * How much to randomize the particle direction [0-1].
  17969. */
  17970. directionRandomizer?: number);
  17971. /**
  17972. * Called by the particle System when the direction is computed for the created particle.
  17973. * @param worldMatrix is the world matrix of the particle system
  17974. * @param directionToUpdate is the direction vector to update with the result
  17975. * @param particle is the particle we are computed the direction for
  17976. */
  17977. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17978. /**
  17979. * Called by the particle System when the position is computed for the created particle.
  17980. * @param worldMatrix is the world matrix of the particle system
  17981. * @param positionToUpdate is the position vector to update with the result
  17982. * @param particle is the particle we are computed the position for
  17983. */
  17984. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17985. /**
  17986. * Clones the current emitter and returns a copy of it
  17987. * @returns the new emitter
  17988. */
  17989. clone(): CylinderParticleEmitter;
  17990. /**
  17991. * Called by the GPUParticleSystem to setup the update shader
  17992. * @param effect defines the update shader
  17993. */
  17994. applyToShader(effect: Effect): void;
  17995. /**
  17996. * Returns a string to use to update the GPU particles update shader
  17997. * @returns a string containng the defines string
  17998. */
  17999. getEffectDefines(): string;
  18000. /**
  18001. * Returns the string "CylinderParticleEmitter"
  18002. * @returns a string containing the class name
  18003. */
  18004. getClassName(): string;
  18005. /**
  18006. * Serializes the particle system to a JSON object.
  18007. * @returns the JSON object
  18008. */
  18009. serialize(): any;
  18010. /**
  18011. * Parse properties from a JSON object
  18012. * @param serializationObject defines the JSON object
  18013. */
  18014. parse(serializationObject: any): void;
  18015. }
  18016. /**
  18017. * Particle emitter emitting particles from the inside of a cylinder.
  18018. * It emits the particles randomly between two vectors.
  18019. */
  18020. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18021. /**
  18022. * The min limit of the emission direction.
  18023. */
  18024. direction1: Vector3;
  18025. /**
  18026. * The max limit of the emission direction.
  18027. */
  18028. direction2: Vector3;
  18029. /**
  18030. * Creates a new instance CylinderDirectedParticleEmitter
  18031. * @param radius the radius of the emission cylinder (1 by default)
  18032. * @param height the height of the emission cylinder (1 by default)
  18033. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18034. * @param direction1 the min limit of the emission direction (up vector by default)
  18035. * @param direction2 the max limit of the emission direction (up vector by default)
  18036. */
  18037. constructor(radius?: number, height?: number, radiusRange?: number,
  18038. /**
  18039. * The min limit of the emission direction.
  18040. */
  18041. direction1?: Vector3,
  18042. /**
  18043. * The max limit of the emission direction.
  18044. */
  18045. direction2?: Vector3);
  18046. /**
  18047. * Called by the particle System when the direction is computed for the created particle.
  18048. * @param worldMatrix is the world matrix of the particle system
  18049. * @param directionToUpdate is the direction vector to update with the result
  18050. * @param particle is the particle we are computed the direction for
  18051. */
  18052. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18053. /**
  18054. * Clones the current emitter and returns a copy of it
  18055. * @returns the new emitter
  18056. */
  18057. clone(): CylinderDirectedParticleEmitter;
  18058. /**
  18059. * Called by the GPUParticleSystem to setup the update shader
  18060. * @param effect defines the update shader
  18061. */
  18062. applyToShader(effect: Effect): void;
  18063. /**
  18064. * Returns a string to use to update the GPU particles update shader
  18065. * @returns a string containng the defines string
  18066. */
  18067. getEffectDefines(): string;
  18068. /**
  18069. * Returns the string "CylinderDirectedParticleEmitter"
  18070. * @returns a string containing the class name
  18071. */
  18072. getClassName(): string;
  18073. /**
  18074. * Serializes the particle system to a JSON object.
  18075. * @returns the JSON object
  18076. */
  18077. serialize(): any;
  18078. /**
  18079. * Parse properties from a JSON object
  18080. * @param serializationObject defines the JSON object
  18081. */
  18082. parse(serializationObject: any): void;
  18083. }
  18084. }
  18085. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18086. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18087. import { Effect } from "babylonjs/Materials/effect";
  18088. import { Particle } from "babylonjs/Particles/particle";
  18089. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18090. /**
  18091. * Particle emitter emitting particles from the inside of a hemisphere.
  18092. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18093. */
  18094. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18095. /**
  18096. * The radius of the emission hemisphere.
  18097. */
  18098. radius: number;
  18099. /**
  18100. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18101. */
  18102. radiusRange: number;
  18103. /**
  18104. * How much to randomize the particle direction [0-1].
  18105. */
  18106. directionRandomizer: number;
  18107. /**
  18108. * Creates a new instance HemisphericParticleEmitter
  18109. * @param radius the radius of the emission hemisphere (1 by default)
  18110. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18111. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18112. */
  18113. constructor(
  18114. /**
  18115. * The radius of the emission hemisphere.
  18116. */
  18117. radius?: number,
  18118. /**
  18119. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18120. */
  18121. radiusRange?: number,
  18122. /**
  18123. * How much to randomize the particle direction [0-1].
  18124. */
  18125. directionRandomizer?: number);
  18126. /**
  18127. * Called by the particle System when the direction is computed for the created particle.
  18128. * @param worldMatrix is the world matrix of the particle system
  18129. * @param directionToUpdate is the direction vector to update with the result
  18130. * @param particle is the particle we are computed the direction for
  18131. */
  18132. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18133. /**
  18134. * Called by the particle System when the position is computed for the created particle.
  18135. * @param worldMatrix is the world matrix of the particle system
  18136. * @param positionToUpdate is the position vector to update with the result
  18137. * @param particle is the particle we are computed the position for
  18138. */
  18139. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18140. /**
  18141. * Clones the current emitter and returns a copy of it
  18142. * @returns the new emitter
  18143. */
  18144. clone(): HemisphericParticleEmitter;
  18145. /**
  18146. * Called by the GPUParticleSystem to setup the update shader
  18147. * @param effect defines the update shader
  18148. */
  18149. applyToShader(effect: Effect): void;
  18150. /**
  18151. * Returns a string to use to update the GPU particles update shader
  18152. * @returns a string containng the defines string
  18153. */
  18154. getEffectDefines(): string;
  18155. /**
  18156. * Returns the string "HemisphericParticleEmitter"
  18157. * @returns a string containing the class name
  18158. */
  18159. getClassName(): string;
  18160. /**
  18161. * Serializes the particle system to a JSON object.
  18162. * @returns the JSON object
  18163. */
  18164. serialize(): any;
  18165. /**
  18166. * Parse properties from a JSON object
  18167. * @param serializationObject defines the JSON object
  18168. */
  18169. parse(serializationObject: any): void;
  18170. }
  18171. }
  18172. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18173. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18174. import { Effect } from "babylonjs/Materials/effect";
  18175. import { Particle } from "babylonjs/Particles/particle";
  18176. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18177. /**
  18178. * Particle emitter emitting particles from a point.
  18179. * It emits the particles randomly between 2 given directions.
  18180. */
  18181. export class PointParticleEmitter implements IParticleEmitterType {
  18182. /**
  18183. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18184. */
  18185. direction1: Vector3;
  18186. /**
  18187. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18188. */
  18189. direction2: Vector3;
  18190. /**
  18191. * Creates a new instance PointParticleEmitter
  18192. */
  18193. constructor();
  18194. /**
  18195. * Called by the particle System when the direction is computed for the created particle.
  18196. * @param worldMatrix is the world matrix of the particle system
  18197. * @param directionToUpdate is the direction vector to update with the result
  18198. * @param particle is the particle we are computed the direction for
  18199. */
  18200. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18201. /**
  18202. * Called by the particle System when the position is computed for the created particle.
  18203. * @param worldMatrix is the world matrix of the particle system
  18204. * @param positionToUpdate is the position vector to update with the result
  18205. * @param particle is the particle we are computed the position for
  18206. */
  18207. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18208. /**
  18209. * Clones the current emitter and returns a copy of it
  18210. * @returns the new emitter
  18211. */
  18212. clone(): PointParticleEmitter;
  18213. /**
  18214. * Called by the GPUParticleSystem to setup the update shader
  18215. * @param effect defines the update shader
  18216. */
  18217. applyToShader(effect: Effect): void;
  18218. /**
  18219. * Returns a string to use to update the GPU particles update shader
  18220. * @returns a string containng the defines string
  18221. */
  18222. getEffectDefines(): string;
  18223. /**
  18224. * Returns the string "PointParticleEmitter"
  18225. * @returns a string containing the class name
  18226. */
  18227. getClassName(): string;
  18228. /**
  18229. * Serializes the particle system to a JSON object.
  18230. * @returns the JSON object
  18231. */
  18232. serialize(): any;
  18233. /**
  18234. * Parse properties from a JSON object
  18235. * @param serializationObject defines the JSON object
  18236. */
  18237. parse(serializationObject: any): void;
  18238. }
  18239. }
  18240. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18241. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18242. import { Effect } from "babylonjs/Materials/effect";
  18243. import { Particle } from "babylonjs/Particles/particle";
  18244. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18245. /**
  18246. * Particle emitter emitting particles from the inside of a sphere.
  18247. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18248. */
  18249. export class SphereParticleEmitter implements IParticleEmitterType {
  18250. /**
  18251. * The radius of the emission sphere.
  18252. */
  18253. radius: number;
  18254. /**
  18255. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18256. */
  18257. radiusRange: number;
  18258. /**
  18259. * How much to randomize the particle direction [0-1].
  18260. */
  18261. directionRandomizer: number;
  18262. /**
  18263. * Creates a new instance SphereParticleEmitter
  18264. * @param radius the radius of the emission sphere (1 by default)
  18265. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18266. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18267. */
  18268. constructor(
  18269. /**
  18270. * The radius of the emission sphere.
  18271. */
  18272. radius?: number,
  18273. /**
  18274. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18275. */
  18276. radiusRange?: number,
  18277. /**
  18278. * How much to randomize the particle direction [0-1].
  18279. */
  18280. directionRandomizer?: number);
  18281. /**
  18282. * Called by the particle System when the direction is computed for the created particle.
  18283. * @param worldMatrix is the world matrix of the particle system
  18284. * @param directionToUpdate is the direction vector to update with the result
  18285. * @param particle is the particle we are computed the direction for
  18286. */
  18287. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18288. /**
  18289. * Called by the particle System when the position is computed for the created particle.
  18290. * @param worldMatrix is the world matrix of the particle system
  18291. * @param positionToUpdate is the position vector to update with the result
  18292. * @param particle is the particle we are computed the position for
  18293. */
  18294. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18295. /**
  18296. * Clones the current emitter and returns a copy of it
  18297. * @returns the new emitter
  18298. */
  18299. clone(): SphereParticleEmitter;
  18300. /**
  18301. * Called by the GPUParticleSystem to setup the update shader
  18302. * @param effect defines the update shader
  18303. */
  18304. applyToShader(effect: Effect): void;
  18305. /**
  18306. * Returns a string to use to update the GPU particles update shader
  18307. * @returns a string containng the defines string
  18308. */
  18309. getEffectDefines(): string;
  18310. /**
  18311. * Returns the string "SphereParticleEmitter"
  18312. * @returns a string containing the class name
  18313. */
  18314. getClassName(): string;
  18315. /**
  18316. * Serializes the particle system to a JSON object.
  18317. * @returns the JSON object
  18318. */
  18319. serialize(): any;
  18320. /**
  18321. * Parse properties from a JSON object
  18322. * @param serializationObject defines the JSON object
  18323. */
  18324. parse(serializationObject: any): void;
  18325. }
  18326. /**
  18327. * Particle emitter emitting particles from the inside of a sphere.
  18328. * It emits the particles randomly between two vectors.
  18329. */
  18330. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18331. /**
  18332. * The min limit of the emission direction.
  18333. */
  18334. direction1: Vector3;
  18335. /**
  18336. * The max limit of the emission direction.
  18337. */
  18338. direction2: Vector3;
  18339. /**
  18340. * Creates a new instance SphereDirectedParticleEmitter
  18341. * @param radius the radius of the emission sphere (1 by default)
  18342. * @param direction1 the min limit of the emission direction (up vector by default)
  18343. * @param direction2 the max limit of the emission direction (up vector by default)
  18344. */
  18345. constructor(radius?: number,
  18346. /**
  18347. * The min limit of the emission direction.
  18348. */
  18349. direction1?: Vector3,
  18350. /**
  18351. * The max limit of the emission direction.
  18352. */
  18353. direction2?: Vector3);
  18354. /**
  18355. * Called by the particle System when the direction is computed for the created particle.
  18356. * @param worldMatrix is the world matrix of the particle system
  18357. * @param directionToUpdate is the direction vector to update with the result
  18358. * @param particle is the particle we are computed the direction for
  18359. */
  18360. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18361. /**
  18362. * Clones the current emitter and returns a copy of it
  18363. * @returns the new emitter
  18364. */
  18365. clone(): SphereDirectedParticleEmitter;
  18366. /**
  18367. * Called by the GPUParticleSystem to setup the update shader
  18368. * @param effect defines the update shader
  18369. */
  18370. applyToShader(effect: Effect): void;
  18371. /**
  18372. * Returns a string to use to update the GPU particles update shader
  18373. * @returns a string containng the defines string
  18374. */
  18375. getEffectDefines(): string;
  18376. /**
  18377. * Returns the string "SphereDirectedParticleEmitter"
  18378. * @returns a string containing the class name
  18379. */
  18380. getClassName(): string;
  18381. /**
  18382. * Serializes the particle system to a JSON object.
  18383. * @returns the JSON object
  18384. */
  18385. serialize(): any;
  18386. /**
  18387. * Parse properties from a JSON object
  18388. * @param serializationObject defines the JSON object
  18389. */
  18390. parse(serializationObject: any): void;
  18391. }
  18392. }
  18393. declare module "babylonjs/Particles/EmitterTypes/index" {
  18394. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18395. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18396. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18397. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18398. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18399. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18400. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18401. }
  18402. declare module "babylonjs/Particles/IParticleSystem" {
  18403. import { Nullable } from "babylonjs/types";
  18404. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18405. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18406. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18407. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18408. import { Texture } from "babylonjs/Materials/Textures/texture";
  18409. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18410. import { Scene } from "babylonjs/scene";
  18411. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18412. import { Animation } from "babylonjs/Animations/animation";
  18413. /**
  18414. * Interface representing a particle system in Babylon.js.
  18415. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18416. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18417. */
  18418. export interface IParticleSystem {
  18419. /**
  18420. * List of animations used by the particle system.
  18421. */
  18422. animations: Animation[];
  18423. /**
  18424. * The id of the Particle system.
  18425. */
  18426. id: string;
  18427. /**
  18428. * The name of the Particle system.
  18429. */
  18430. name: string;
  18431. /**
  18432. * The emitter represents the Mesh or position we are attaching the particle system to.
  18433. */
  18434. emitter: Nullable<AbstractMesh | Vector3>;
  18435. /**
  18436. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18437. */
  18438. isBillboardBased: boolean;
  18439. /**
  18440. * The rendering group used by the Particle system to chose when to render.
  18441. */
  18442. renderingGroupId: number;
  18443. /**
  18444. * The layer mask we are rendering the particles through.
  18445. */
  18446. layerMask: number;
  18447. /**
  18448. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18449. */
  18450. updateSpeed: number;
  18451. /**
  18452. * The amount of time the particle system is running (depends of the overall update speed).
  18453. */
  18454. targetStopDuration: number;
  18455. /**
  18456. * The texture used to render each particle. (this can be a spritesheet)
  18457. */
  18458. particleTexture: Nullable<Texture>;
  18459. /**
  18460. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18461. */
  18462. blendMode: number;
  18463. /**
  18464. * Minimum life time of emitting particles.
  18465. */
  18466. minLifeTime: number;
  18467. /**
  18468. * Maximum life time of emitting particles.
  18469. */
  18470. maxLifeTime: number;
  18471. /**
  18472. * Minimum Size of emitting particles.
  18473. */
  18474. minSize: number;
  18475. /**
  18476. * Maximum Size of emitting particles.
  18477. */
  18478. maxSize: number;
  18479. /**
  18480. * Minimum scale of emitting particles on X axis.
  18481. */
  18482. minScaleX: number;
  18483. /**
  18484. * Maximum scale of emitting particles on X axis.
  18485. */
  18486. maxScaleX: number;
  18487. /**
  18488. * Minimum scale of emitting particles on Y axis.
  18489. */
  18490. minScaleY: number;
  18491. /**
  18492. * Maximum scale of emitting particles on Y axis.
  18493. */
  18494. maxScaleY: number;
  18495. /**
  18496. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18497. */
  18498. color1: Color4;
  18499. /**
  18500. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18501. */
  18502. color2: Color4;
  18503. /**
  18504. * Color the particle will have at the end of its lifetime.
  18505. */
  18506. colorDead: Color4;
  18507. /**
  18508. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18509. */
  18510. emitRate: number;
  18511. /**
  18512. * You can use gravity if you want to give an orientation to your particles.
  18513. */
  18514. gravity: Vector3;
  18515. /**
  18516. * Minimum power of emitting particles.
  18517. */
  18518. minEmitPower: number;
  18519. /**
  18520. * Maximum power of emitting particles.
  18521. */
  18522. maxEmitPower: number;
  18523. /**
  18524. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18525. */
  18526. minAngularSpeed: number;
  18527. /**
  18528. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18529. */
  18530. maxAngularSpeed: number;
  18531. /**
  18532. * Gets or sets the minimal initial rotation in radians.
  18533. */
  18534. minInitialRotation: number;
  18535. /**
  18536. * Gets or sets the maximal initial rotation in radians.
  18537. */
  18538. maxInitialRotation: number;
  18539. /**
  18540. * The particle emitter type defines the emitter used by the particle system.
  18541. * It can be for example box, sphere, or cone...
  18542. */
  18543. particleEmitterType: Nullable<IParticleEmitterType>;
  18544. /**
  18545. * Defines the delay in milliseconds before starting the system (0 by default)
  18546. */
  18547. startDelay: number;
  18548. /**
  18549. * 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
  18550. */
  18551. preWarmCycles: number;
  18552. /**
  18553. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18554. */
  18555. preWarmStepOffset: number;
  18556. /**
  18557. * 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)
  18558. */
  18559. spriteCellChangeSpeed: number;
  18560. /**
  18561. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18562. */
  18563. startSpriteCellID: number;
  18564. /**
  18565. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18566. */
  18567. endSpriteCellID: number;
  18568. /**
  18569. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18570. */
  18571. spriteCellWidth: number;
  18572. /**
  18573. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18574. */
  18575. spriteCellHeight: number;
  18576. /**
  18577. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18578. */
  18579. spriteRandomStartCell: boolean;
  18580. /**
  18581. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18582. */
  18583. isAnimationSheetEnabled: boolean;
  18584. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18585. translationPivot: Vector2;
  18586. /**
  18587. * Gets or sets a texture used to add random noise to particle positions
  18588. */
  18589. noiseTexture: Nullable<BaseTexture>;
  18590. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18591. noiseStrength: Vector3;
  18592. /**
  18593. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18594. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18595. */
  18596. billboardMode: number;
  18597. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18598. limitVelocityDamping: number;
  18599. /**
  18600. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18601. */
  18602. beginAnimationOnStart: boolean;
  18603. /**
  18604. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18605. */
  18606. beginAnimationFrom: number;
  18607. /**
  18608. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18609. */
  18610. beginAnimationTo: number;
  18611. /**
  18612. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18613. */
  18614. beginAnimationLoop: boolean;
  18615. /**
  18616. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18617. */
  18618. disposeOnStop: boolean;
  18619. /**
  18620. * Gets the maximum number of particles active at the same time.
  18621. * @returns The max number of active particles.
  18622. */
  18623. getCapacity(): number;
  18624. /**
  18625. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18626. * @returns True if it has been started, otherwise false.
  18627. */
  18628. isStarted(): boolean;
  18629. /**
  18630. * Animates the particle system for this frame.
  18631. */
  18632. animate(): void;
  18633. /**
  18634. * Renders the particle system in its current state.
  18635. * @returns the current number of particles
  18636. */
  18637. render(): number;
  18638. /**
  18639. * Dispose the particle system and frees its associated resources.
  18640. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18641. */
  18642. dispose(disposeTexture?: boolean): void;
  18643. /**
  18644. * Clones the particle system.
  18645. * @param name The name of the cloned object
  18646. * @param newEmitter The new emitter to use
  18647. * @returns the cloned particle system
  18648. */
  18649. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18650. /**
  18651. * Serializes the particle system to a JSON object.
  18652. * @returns the JSON object
  18653. */
  18654. serialize(): any;
  18655. /**
  18656. * Rebuild the particle system
  18657. */
  18658. rebuild(): void;
  18659. /**
  18660. * Starts the particle system and begins to emit
  18661. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18662. */
  18663. start(delay?: number): void;
  18664. /**
  18665. * Stops the particle system.
  18666. */
  18667. stop(): void;
  18668. /**
  18669. * Remove all active particles
  18670. */
  18671. reset(): void;
  18672. /**
  18673. * Is this system ready to be used/rendered
  18674. * @return true if the system is ready
  18675. */
  18676. isReady(): boolean;
  18677. /**
  18678. * Adds a new color gradient
  18679. * @param gradient defines the gradient to use (between 0 and 1)
  18680. * @param color1 defines the color to affect to the specified gradient
  18681. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18682. * @returns the current particle system
  18683. */
  18684. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18685. /**
  18686. * Remove a specific color gradient
  18687. * @param gradient defines the gradient to remove
  18688. * @returns the current particle system
  18689. */
  18690. removeColorGradient(gradient: number): IParticleSystem;
  18691. /**
  18692. * Adds a new size gradient
  18693. * @param gradient defines the gradient to use (between 0 and 1)
  18694. * @param factor defines the size factor to affect to the specified gradient
  18695. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18696. * @returns the current particle system
  18697. */
  18698. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18699. /**
  18700. * Remove a specific size gradient
  18701. * @param gradient defines the gradient to remove
  18702. * @returns the current particle system
  18703. */
  18704. removeSizeGradient(gradient: number): IParticleSystem;
  18705. /**
  18706. * Gets the current list of color gradients.
  18707. * You must use addColorGradient and removeColorGradient to udpate this list
  18708. * @returns the list of color gradients
  18709. */
  18710. getColorGradients(): Nullable<Array<ColorGradient>>;
  18711. /**
  18712. * Gets the current list of size gradients.
  18713. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18714. * @returns the list of size gradients
  18715. */
  18716. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18717. /**
  18718. * Gets the current list of angular speed gradients.
  18719. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18720. * @returns the list of angular speed gradients
  18721. */
  18722. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18723. /**
  18724. * Adds a new angular speed gradient
  18725. * @param gradient defines the gradient to use (between 0 and 1)
  18726. * @param factor defines the angular speed to affect to the specified gradient
  18727. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18728. * @returns the current particle system
  18729. */
  18730. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18731. /**
  18732. * Remove a specific angular speed gradient
  18733. * @param gradient defines the gradient to remove
  18734. * @returns the current particle system
  18735. */
  18736. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18737. /**
  18738. * Gets the current list of velocity gradients.
  18739. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18740. * @returns the list of velocity gradients
  18741. */
  18742. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18743. /**
  18744. * Adds a new velocity gradient
  18745. * @param gradient defines the gradient to use (between 0 and 1)
  18746. * @param factor defines the velocity to affect to the specified gradient
  18747. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18748. * @returns the current particle system
  18749. */
  18750. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18751. /**
  18752. * Remove a specific velocity gradient
  18753. * @param gradient defines the gradient to remove
  18754. * @returns the current particle system
  18755. */
  18756. removeVelocityGradient(gradient: number): IParticleSystem;
  18757. /**
  18758. * Gets the current list of limit velocity gradients.
  18759. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18760. * @returns the list of limit velocity gradients
  18761. */
  18762. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18763. /**
  18764. * Adds a new limit velocity gradient
  18765. * @param gradient defines the gradient to use (between 0 and 1)
  18766. * @param factor defines the limit velocity to affect to the specified gradient
  18767. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18768. * @returns the current particle system
  18769. */
  18770. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18771. /**
  18772. * Remove a specific limit velocity gradient
  18773. * @param gradient defines the gradient to remove
  18774. * @returns the current particle system
  18775. */
  18776. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18777. /**
  18778. * Adds a new drag gradient
  18779. * @param gradient defines the gradient to use (between 0 and 1)
  18780. * @param factor defines the drag to affect to the specified gradient
  18781. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18782. * @returns the current particle system
  18783. */
  18784. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18785. /**
  18786. * Remove a specific drag gradient
  18787. * @param gradient defines the gradient to remove
  18788. * @returns the current particle system
  18789. */
  18790. removeDragGradient(gradient: number): IParticleSystem;
  18791. /**
  18792. * Gets the current list of drag gradients.
  18793. * You must use addDragGradient and removeDragGradient to udpate this list
  18794. * @returns the list of drag gradients
  18795. */
  18796. getDragGradients(): Nullable<Array<FactorGradient>>;
  18797. /**
  18798. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18799. * @param gradient defines the gradient to use (between 0 and 1)
  18800. * @param factor defines the emit rate to affect to the specified gradient
  18801. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18802. * @returns the current particle system
  18803. */
  18804. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18805. /**
  18806. * Remove a specific emit rate gradient
  18807. * @param gradient defines the gradient to remove
  18808. * @returns the current particle system
  18809. */
  18810. removeEmitRateGradient(gradient: number): IParticleSystem;
  18811. /**
  18812. * Gets the current list of emit rate gradients.
  18813. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18814. * @returns the list of emit rate gradients
  18815. */
  18816. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18817. /**
  18818. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18819. * @param gradient defines the gradient to use (between 0 and 1)
  18820. * @param factor defines the start size to affect to the specified gradient
  18821. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18822. * @returns the current particle system
  18823. */
  18824. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18825. /**
  18826. * Remove a specific start size gradient
  18827. * @param gradient defines the gradient to remove
  18828. * @returns the current particle system
  18829. */
  18830. removeStartSizeGradient(gradient: number): IParticleSystem;
  18831. /**
  18832. * Gets the current list of start size gradients.
  18833. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18834. * @returns the list of start size gradients
  18835. */
  18836. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18837. /**
  18838. * Adds a new life time gradient
  18839. * @param gradient defines the gradient to use (between 0 and 1)
  18840. * @param factor defines the life time factor to affect to the specified gradient
  18841. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18842. * @returns the current particle system
  18843. */
  18844. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18845. /**
  18846. * Remove a specific life time gradient
  18847. * @param gradient defines the gradient to remove
  18848. * @returns the current particle system
  18849. */
  18850. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18851. /**
  18852. * Gets the current list of life time gradients.
  18853. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18854. * @returns the list of life time gradients
  18855. */
  18856. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18857. /**
  18858. * Gets the current list of color gradients.
  18859. * You must use addColorGradient and removeColorGradient to udpate this list
  18860. * @returns the list of color gradients
  18861. */
  18862. getColorGradients(): Nullable<Array<ColorGradient>>;
  18863. /**
  18864. * Adds a new ramp gradient used to remap particle colors
  18865. * @param gradient defines the gradient to use (between 0 and 1)
  18866. * @param color defines the color to affect to the specified gradient
  18867. * @returns the current particle system
  18868. */
  18869. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18870. /**
  18871. * Gets the current list of ramp gradients.
  18872. * You must use addRampGradient and removeRampGradient to udpate this list
  18873. * @returns the list of ramp gradients
  18874. */
  18875. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18876. /** Gets or sets a boolean indicating that ramp gradients must be used
  18877. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18878. */
  18879. useRampGradients: boolean;
  18880. /**
  18881. * Adds a new color remap gradient
  18882. * @param gradient defines the gradient to use (between 0 and 1)
  18883. * @param min defines the color remap minimal range
  18884. * @param max defines the color remap maximal range
  18885. * @returns the current particle system
  18886. */
  18887. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18888. /**
  18889. * Gets the current list of color remap gradients.
  18890. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18891. * @returns the list of color remap gradients
  18892. */
  18893. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18894. /**
  18895. * Adds a new alpha remap gradient
  18896. * @param gradient defines the gradient to use (between 0 and 1)
  18897. * @param min defines the alpha remap minimal range
  18898. * @param max defines the alpha remap maximal range
  18899. * @returns the current particle system
  18900. */
  18901. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18902. /**
  18903. * Gets the current list of alpha remap gradients.
  18904. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18905. * @returns the list of alpha remap gradients
  18906. */
  18907. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18908. /**
  18909. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18910. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18911. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18912. * @returns the emitter
  18913. */
  18914. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18915. /**
  18916. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18917. * @param radius The radius of the hemisphere to emit from
  18918. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18919. * @returns the emitter
  18920. */
  18921. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18922. /**
  18923. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18924. * @param radius The radius of the sphere to emit from
  18925. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18926. * @returns the emitter
  18927. */
  18928. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18929. /**
  18930. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18931. * @param radius The radius of the sphere to emit from
  18932. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18933. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18934. * @returns the emitter
  18935. */
  18936. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18937. /**
  18938. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18939. * @param radius The radius of the emission cylinder
  18940. * @param height The height of the emission cylinder
  18941. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18942. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18943. * @returns the emitter
  18944. */
  18945. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18946. /**
  18947. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18948. * @param radius The radius of the cylinder to emit from
  18949. * @param height The height of the emission cylinder
  18950. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18951. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18952. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18953. * @returns the emitter
  18954. */
  18955. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18956. /**
  18957. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18958. * @param radius The radius of the cone to emit from
  18959. * @param angle The base angle of the cone
  18960. * @returns the emitter
  18961. */
  18962. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18963. /**
  18964. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18965. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18966. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18967. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18968. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18969. * @returns the emitter
  18970. */
  18971. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18972. /**
  18973. * Get hosting scene
  18974. * @returns the scene
  18975. */
  18976. getScene(): Scene;
  18977. }
  18978. }
  18979. declare module "babylonjs/Meshes/instancedMesh" {
  18980. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  18981. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18982. import { Camera } from "babylonjs/Cameras/camera";
  18983. import { Node } from "babylonjs/node";
  18984. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18985. import { Mesh } from "babylonjs/Meshes/mesh";
  18986. import { Material } from "babylonjs/Materials/material";
  18987. import { Skeleton } from "babylonjs/Bones/skeleton";
  18988. import { Light } from "babylonjs/Lights/light";
  18989. /**
  18990. * Creates an instance based on a source mesh.
  18991. */
  18992. export class InstancedMesh extends AbstractMesh {
  18993. private _sourceMesh;
  18994. private _currentLOD;
  18995. /** @hidden */
  18996. _indexInSourceMeshInstanceArray: number;
  18997. constructor(name: string, source: Mesh);
  18998. /**
  18999. * Returns the string "InstancedMesh".
  19000. */
  19001. getClassName(): string;
  19002. /** Gets the list of lights affecting that mesh */
  19003. readonly lightSources: Light[];
  19004. _resyncLightSources(): void;
  19005. _resyncLighSource(light: Light): void;
  19006. _removeLightSource(light: Light): void;
  19007. /**
  19008. * If the source mesh receives shadows
  19009. */
  19010. readonly receiveShadows: boolean;
  19011. /**
  19012. * The material of the source mesh
  19013. */
  19014. readonly material: Nullable<Material>;
  19015. /**
  19016. * Visibility of the source mesh
  19017. */
  19018. readonly visibility: number;
  19019. /**
  19020. * Skeleton of the source mesh
  19021. */
  19022. readonly skeleton: Nullable<Skeleton>;
  19023. /**
  19024. * Rendering ground id of the source mesh
  19025. */
  19026. renderingGroupId: number;
  19027. /**
  19028. * Returns the total number of vertices (integer).
  19029. */
  19030. getTotalVertices(): number;
  19031. /**
  19032. * Returns a positive integer : the total number of indices in this mesh geometry.
  19033. * @returns the numner of indices or zero if the mesh has no geometry.
  19034. */
  19035. getTotalIndices(): number;
  19036. /**
  19037. * The source mesh of the instance
  19038. */
  19039. readonly sourceMesh: Mesh;
  19040. /**
  19041. * Is this node ready to be used/rendered
  19042. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19043. * @return {boolean} is it ready
  19044. */
  19045. isReady(completeCheck?: boolean): boolean;
  19046. /**
  19047. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19048. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19049. * @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.
  19050. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19051. */
  19052. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19053. /**
  19054. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19055. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19056. * The `data` are either a numeric array either a Float32Array.
  19057. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19058. * 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).
  19059. * Note that a new underlying VertexBuffer object is created each call.
  19060. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19061. *
  19062. * Possible `kind` values :
  19063. * - VertexBuffer.PositionKind
  19064. * - VertexBuffer.UVKind
  19065. * - VertexBuffer.UV2Kind
  19066. * - VertexBuffer.UV3Kind
  19067. * - VertexBuffer.UV4Kind
  19068. * - VertexBuffer.UV5Kind
  19069. * - VertexBuffer.UV6Kind
  19070. * - VertexBuffer.ColorKind
  19071. * - VertexBuffer.MatricesIndicesKind
  19072. * - VertexBuffer.MatricesIndicesExtraKind
  19073. * - VertexBuffer.MatricesWeightsKind
  19074. * - VertexBuffer.MatricesWeightsExtraKind
  19075. *
  19076. * Returns the Mesh.
  19077. */
  19078. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  19079. /**
  19080. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19081. * If the mesh has no geometry, it is simply returned as it is.
  19082. * The `data` are either a numeric array either a Float32Array.
  19083. * No new underlying VertexBuffer object is created.
  19084. * 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.
  19085. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19086. *
  19087. * Possible `kind` values :
  19088. * - VertexBuffer.PositionKind
  19089. * - VertexBuffer.UVKind
  19090. * - VertexBuffer.UV2Kind
  19091. * - VertexBuffer.UV3Kind
  19092. * - VertexBuffer.UV4Kind
  19093. * - VertexBuffer.UV5Kind
  19094. * - VertexBuffer.UV6Kind
  19095. * - VertexBuffer.ColorKind
  19096. * - VertexBuffer.MatricesIndicesKind
  19097. * - VertexBuffer.MatricesIndicesExtraKind
  19098. * - VertexBuffer.MatricesWeightsKind
  19099. * - VertexBuffer.MatricesWeightsExtraKind
  19100. *
  19101. * Returns the Mesh.
  19102. */
  19103. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19104. /**
  19105. * Sets the mesh indices.
  19106. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19107. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19108. * This method creates a new index buffer each call.
  19109. * Returns the Mesh.
  19110. */
  19111. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19112. /**
  19113. * Boolean : True if the mesh owns the requested kind of data.
  19114. */
  19115. isVerticesDataPresent(kind: string): boolean;
  19116. /**
  19117. * Returns an array of indices (IndicesArray).
  19118. */
  19119. getIndices(): Nullable<IndicesArray>;
  19120. readonly _positions: Nullable<Vector3[]>;
  19121. /**
  19122. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19123. * This means the mesh underlying bounding box and sphere are recomputed.
  19124. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19125. * @returns the current mesh
  19126. */
  19127. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19128. /** @hidden */
  19129. _preActivate(): InstancedMesh;
  19130. /** @hidden */
  19131. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19132. /** @hidden */
  19133. _postActivate(): void;
  19134. getWorldMatrix(): Matrix;
  19135. readonly isAnInstance: boolean;
  19136. /**
  19137. * Returns the current associated LOD AbstractMesh.
  19138. */
  19139. getLOD(camera: Camera): AbstractMesh;
  19140. /** @hidden */
  19141. _syncSubMeshes(): InstancedMesh;
  19142. /** @hidden */
  19143. _generatePointsArray(): boolean;
  19144. /**
  19145. * Creates a new InstancedMesh from the current mesh.
  19146. * - name (string) : the cloned mesh name
  19147. * - newParent (optional Node) : the optional Node to parent the clone to.
  19148. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19149. *
  19150. * Returns the clone.
  19151. */
  19152. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  19153. /**
  19154. * Disposes the InstancedMesh.
  19155. * Returns nothing.
  19156. */
  19157. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19158. }
  19159. }
  19160. declare module "babylonjs/Materials/shaderMaterial" {
  19161. import { Scene } from "babylonjs/scene";
  19162. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19163. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19164. import { Mesh } from "babylonjs/Meshes/mesh";
  19165. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19166. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19167. import { Texture } from "babylonjs/Materials/Textures/texture";
  19168. import { Material } from "babylonjs/Materials/material";
  19169. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19170. /**
  19171. * Defines the options associated with the creation of a shader material.
  19172. */
  19173. export interface IShaderMaterialOptions {
  19174. /**
  19175. * Does the material work in alpha blend mode
  19176. */
  19177. needAlphaBlending: boolean;
  19178. /**
  19179. * Does the material work in alpha test mode
  19180. */
  19181. needAlphaTesting: boolean;
  19182. /**
  19183. * The list of attribute names used in the shader
  19184. */
  19185. attributes: string[];
  19186. /**
  19187. * The list of unifrom names used in the shader
  19188. */
  19189. uniforms: string[];
  19190. /**
  19191. * The list of UBO names used in the shader
  19192. */
  19193. uniformBuffers: string[];
  19194. /**
  19195. * The list of sampler names used in the shader
  19196. */
  19197. samplers: string[];
  19198. /**
  19199. * The list of defines used in the shader
  19200. */
  19201. defines: string[];
  19202. }
  19203. /**
  19204. * 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.
  19205. *
  19206. * This returned material effects how the mesh will look based on the code in the shaders.
  19207. *
  19208. * @see http://doc.babylonjs.com/how_to/shader_material
  19209. */
  19210. export class ShaderMaterial extends Material {
  19211. private _shaderPath;
  19212. private _options;
  19213. private _textures;
  19214. private _textureArrays;
  19215. private _floats;
  19216. private _ints;
  19217. private _floatsArrays;
  19218. private _colors3;
  19219. private _colors3Arrays;
  19220. private _colors4;
  19221. private _colors4Arrays;
  19222. private _vectors2;
  19223. private _vectors3;
  19224. private _vectors4;
  19225. private _matrices;
  19226. private _matrices3x3;
  19227. private _matrices2x2;
  19228. private _vectors2Arrays;
  19229. private _vectors3Arrays;
  19230. private _vectors4Arrays;
  19231. private _cachedWorldViewMatrix;
  19232. private _cachedWorldViewProjectionMatrix;
  19233. private _renderId;
  19234. /**
  19235. * Instantiate a new shader material.
  19236. * 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.
  19237. * This returned material effects how the mesh will look based on the code in the shaders.
  19238. * @see http://doc.babylonjs.com/how_to/shader_material
  19239. * @param name Define the name of the material in the scene
  19240. * @param scene Define the scene the material belongs to
  19241. * @param shaderPath Defines the route to the shader code in one of three ways:
  19242. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19243. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  19244. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19245. * @param options Define the options used to create the shader
  19246. */
  19247. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19248. /**
  19249. * Gets the options used to compile the shader.
  19250. * They can be modified to trigger a new compilation
  19251. */
  19252. readonly options: IShaderMaterialOptions;
  19253. /**
  19254. * Gets the current class name of the material e.g. "ShaderMaterial"
  19255. * Mainly use in serialization.
  19256. * @returns the class name
  19257. */
  19258. getClassName(): string;
  19259. /**
  19260. * Specifies if the material will require alpha blending
  19261. * @returns a boolean specifying if alpha blending is needed
  19262. */
  19263. needAlphaBlending(): boolean;
  19264. /**
  19265. * Specifies if this material should be rendered in alpha test mode
  19266. * @returns a boolean specifying if an alpha test is needed.
  19267. */
  19268. needAlphaTesting(): boolean;
  19269. private _checkUniform;
  19270. /**
  19271. * Set a texture in the shader.
  19272. * @param name Define the name of the uniform samplers as defined in the shader
  19273. * @param texture Define the texture to bind to this sampler
  19274. * @return the material itself allowing "fluent" like uniform updates
  19275. */
  19276. setTexture(name: string, texture: Texture): ShaderMaterial;
  19277. /**
  19278. * Set a texture array in the shader.
  19279. * @param name Define the name of the uniform sampler array as defined in the shader
  19280. * @param textures Define the list of textures to bind to this sampler
  19281. * @return the material itself allowing "fluent" like uniform updates
  19282. */
  19283. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19284. /**
  19285. * Set a float in the shader.
  19286. * @param name Define the name of the uniform as defined in the shader
  19287. * @param value Define the value to give to the uniform
  19288. * @return the material itself allowing "fluent" like uniform updates
  19289. */
  19290. setFloat(name: string, value: number): ShaderMaterial;
  19291. /**
  19292. * Set a int in the shader.
  19293. * @param name Define the name of the uniform as defined in the shader
  19294. * @param value Define the value to give to the uniform
  19295. * @return the material itself allowing "fluent" like uniform updates
  19296. */
  19297. setInt(name: string, value: number): ShaderMaterial;
  19298. /**
  19299. * Set an array of floats in the shader.
  19300. * @param name Define the name of the uniform as defined in the shader
  19301. * @param value Define the value to give to the uniform
  19302. * @return the material itself allowing "fluent" like uniform updates
  19303. */
  19304. setFloats(name: string, value: number[]): ShaderMaterial;
  19305. /**
  19306. * Set a vec3 in the shader from a Color3.
  19307. * @param name Define the name of the uniform as defined in the shader
  19308. * @param value Define the value to give to the uniform
  19309. * @return the material itself allowing "fluent" like uniform updates
  19310. */
  19311. setColor3(name: string, value: Color3): ShaderMaterial;
  19312. /**
  19313. * Set a vec3 array in the shader from a Color3 array.
  19314. * @param name Define the name of the uniform as defined in the shader
  19315. * @param value Define the value to give to the uniform
  19316. * @return the material itself allowing "fluent" like uniform updates
  19317. */
  19318. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19319. /**
  19320. * Set a vec4 in the shader from a Color4.
  19321. * @param name Define the name of the uniform as defined in the shader
  19322. * @param value Define the value to give to the uniform
  19323. * @return the material itself allowing "fluent" like uniform updates
  19324. */
  19325. setColor4(name: string, value: Color4): ShaderMaterial;
  19326. /**
  19327. * Set a vec4 array in the shader from a Color4 array.
  19328. * @param name Define the name of the uniform as defined in the shader
  19329. * @param value Define the value to give to the uniform
  19330. * @return the material itself allowing "fluent" like uniform updates
  19331. */
  19332. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19333. /**
  19334. * Set a vec2 in the shader from a Vector2.
  19335. * @param name Define the name of the uniform as defined in the shader
  19336. * @param value Define the value to give to the uniform
  19337. * @return the material itself allowing "fluent" like uniform updates
  19338. */
  19339. setVector2(name: string, value: Vector2): ShaderMaterial;
  19340. /**
  19341. * Set a vec3 in the shader from a Vector3.
  19342. * @param name Define the name of the uniform as defined in the shader
  19343. * @param value Define the value to give to the uniform
  19344. * @return the material itself allowing "fluent" like uniform updates
  19345. */
  19346. setVector3(name: string, value: Vector3): ShaderMaterial;
  19347. /**
  19348. * Set a vec4 in the shader from a Vector4.
  19349. * @param name Define the name of the uniform as defined in the shader
  19350. * @param value Define the value to give to the uniform
  19351. * @return the material itself allowing "fluent" like uniform updates
  19352. */
  19353. setVector4(name: string, value: Vector4): ShaderMaterial;
  19354. /**
  19355. * Set a mat4 in the shader from a Matrix.
  19356. * @param name Define the name of the uniform as defined in the shader
  19357. * @param value Define the value to give to the uniform
  19358. * @return the material itself allowing "fluent" like uniform updates
  19359. */
  19360. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19361. /**
  19362. * Set a mat3 in the shader from a Float32Array.
  19363. * @param name Define the name of the uniform as defined in the shader
  19364. * @param value Define the value to give to the uniform
  19365. * @return the material itself allowing "fluent" like uniform updates
  19366. */
  19367. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19368. /**
  19369. * Set a mat2 in the shader from a Float32Array.
  19370. * @param name Define the name of the uniform as defined in the shader
  19371. * @param value Define the value to give to the uniform
  19372. * @return the material itself allowing "fluent" like uniform updates
  19373. */
  19374. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19375. /**
  19376. * Set a vec2 array in the shader from a number array.
  19377. * @param name Define the name of the uniform as defined in the shader
  19378. * @param value Define the value to give to the uniform
  19379. * @return the material itself allowing "fluent" like uniform updates
  19380. */
  19381. setArray2(name: string, value: number[]): ShaderMaterial;
  19382. /**
  19383. * Set a vec3 array in the shader from a number array.
  19384. * @param name Define the name of the uniform as defined in the shader
  19385. * @param value Define the value to give to the uniform
  19386. * @return the material itself allowing "fluent" like uniform updates
  19387. */
  19388. setArray3(name: string, value: number[]): ShaderMaterial;
  19389. /**
  19390. * Set a vec4 array in the shader from a number array.
  19391. * @param name Define the name of the uniform as defined in the shader
  19392. * @param value Define the value to give to the uniform
  19393. * @return the material itself allowing "fluent" like uniform updates
  19394. */
  19395. setArray4(name: string, value: number[]): ShaderMaterial;
  19396. private _checkCache;
  19397. /**
  19398. * Specifies that the submesh is ready to be used
  19399. * @param mesh defines the mesh to check
  19400. * @param subMesh defines which submesh to check
  19401. * @param useInstances specifies that instances should be used
  19402. * @returns a boolean indicating that the submesh is ready or not
  19403. */
  19404. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19405. /**
  19406. * Checks if the material is ready to render the requested mesh
  19407. * @param mesh Define the mesh to render
  19408. * @param useInstances Define whether or not the material is used with instances
  19409. * @returns true if ready, otherwise false
  19410. */
  19411. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19412. /**
  19413. * Binds the world matrix to the material
  19414. * @param world defines the world transformation matrix
  19415. */
  19416. bindOnlyWorldMatrix(world: Matrix): void;
  19417. /**
  19418. * Binds the material to the mesh
  19419. * @param world defines the world transformation matrix
  19420. * @param mesh defines the mesh to bind the material to
  19421. */
  19422. bind(world: Matrix, mesh?: Mesh): void;
  19423. /**
  19424. * Gets the active textures from the material
  19425. * @returns an array of textures
  19426. */
  19427. getActiveTextures(): BaseTexture[];
  19428. /**
  19429. * Specifies if the material uses a texture
  19430. * @param texture defines the texture to check against the material
  19431. * @returns a boolean specifying if the material uses the texture
  19432. */
  19433. hasTexture(texture: BaseTexture): boolean;
  19434. /**
  19435. * Makes a duplicate of the material, and gives it a new name
  19436. * @param name defines the new name for the duplicated material
  19437. * @returns the cloned material
  19438. */
  19439. clone(name: string): ShaderMaterial;
  19440. /**
  19441. * Disposes the material
  19442. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19443. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19444. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19445. */
  19446. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19447. /**
  19448. * Serializes this material in a JSON representation
  19449. * @returns the serialized material object
  19450. */
  19451. serialize(): any;
  19452. /**
  19453. * Creates a shader material from parsed shader material data
  19454. * @param source defines the JSON represnetation of the material
  19455. * @param scene defines the hosting scene
  19456. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19457. * @returns a new material
  19458. */
  19459. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19460. }
  19461. }
  19462. declare module "babylonjs/Shaders/color.fragment" {
  19463. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19464. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19465. /** @hidden */
  19466. export var colorPixelShader: {
  19467. name: string;
  19468. shader: string;
  19469. };
  19470. }
  19471. declare module "babylonjs/Shaders/color.vertex" {
  19472. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19473. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19474. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19475. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19476. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19477. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19478. /** @hidden */
  19479. export var colorVertexShader: {
  19480. name: string;
  19481. shader: string;
  19482. };
  19483. }
  19484. declare module "babylonjs/Meshes/linesMesh" {
  19485. import { Nullable } from "babylonjs/types";
  19486. import { Scene } from "babylonjs/scene";
  19487. import { Color3 } from "babylonjs/Maths/math.color";
  19488. import { Node } from "babylonjs/node";
  19489. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19490. import { Mesh } from "babylonjs/Meshes/mesh";
  19491. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19492. import { Effect } from "babylonjs/Materials/effect";
  19493. import { Material } from "babylonjs/Materials/material";
  19494. import "babylonjs/Shaders/color.fragment";
  19495. import "babylonjs/Shaders/color.vertex";
  19496. /**
  19497. * Line mesh
  19498. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19499. */
  19500. export class LinesMesh extends Mesh {
  19501. /**
  19502. * If vertex color should be applied to the mesh
  19503. */
  19504. readonly useVertexColor?: boolean | undefined;
  19505. /**
  19506. * If vertex alpha should be applied to the mesh
  19507. */
  19508. readonly useVertexAlpha?: boolean | undefined;
  19509. /**
  19510. * Color of the line (Default: White)
  19511. */
  19512. color: Color3;
  19513. /**
  19514. * Alpha of the line (Default: 1)
  19515. */
  19516. alpha: number;
  19517. /**
  19518. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19519. * This margin is expressed in world space coordinates, so its value may vary.
  19520. * Default value is 0.1
  19521. */
  19522. intersectionThreshold: number;
  19523. private _colorShader;
  19524. private color4;
  19525. /**
  19526. * Creates a new LinesMesh
  19527. * @param name defines the name
  19528. * @param scene defines the hosting scene
  19529. * @param parent defines the parent mesh if any
  19530. * @param source defines the optional source LinesMesh used to clone data from
  19531. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19532. * When false, achieved by calling a clone(), also passing False.
  19533. * This will make creation of children, recursive.
  19534. * @param useVertexColor defines if this LinesMesh supports vertex color
  19535. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19536. */
  19537. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  19538. /**
  19539. * If vertex color should be applied to the mesh
  19540. */
  19541. useVertexColor?: boolean | undefined,
  19542. /**
  19543. * If vertex alpha should be applied to the mesh
  19544. */
  19545. useVertexAlpha?: boolean | undefined);
  19546. private _addClipPlaneDefine;
  19547. private _removeClipPlaneDefine;
  19548. isReady(): boolean;
  19549. /**
  19550. * Returns the string "LineMesh"
  19551. */
  19552. getClassName(): string;
  19553. /**
  19554. * @hidden
  19555. */
  19556. /**
  19557. * @hidden
  19558. */
  19559. material: Material;
  19560. /**
  19561. * @hidden
  19562. */
  19563. readonly checkCollisions: boolean;
  19564. /** @hidden */
  19565. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  19566. /** @hidden */
  19567. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  19568. /**
  19569. * Disposes of the line mesh
  19570. * @param doNotRecurse If children should be disposed
  19571. */
  19572. dispose(doNotRecurse?: boolean): void;
  19573. /**
  19574. * Returns a new LineMesh object cloned from the current one.
  19575. */
  19576. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  19577. /**
  19578. * Creates a new InstancedLinesMesh object from the mesh model.
  19579. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19580. * @param name defines the name of the new instance
  19581. * @returns a new InstancedLinesMesh
  19582. */
  19583. createInstance(name: string): InstancedLinesMesh;
  19584. }
  19585. /**
  19586. * Creates an instance based on a source LinesMesh
  19587. */
  19588. export class InstancedLinesMesh extends InstancedMesh {
  19589. /**
  19590. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19591. * This margin is expressed in world space coordinates, so its value may vary.
  19592. * Initilized with the intersectionThreshold value of the source LinesMesh
  19593. */
  19594. intersectionThreshold: number;
  19595. constructor(name: string, source: LinesMesh);
  19596. /**
  19597. * Returns the string "InstancedLinesMesh".
  19598. */
  19599. getClassName(): string;
  19600. }
  19601. }
  19602. declare module "babylonjs/Shaders/line.fragment" {
  19603. /** @hidden */
  19604. export var linePixelShader: {
  19605. name: string;
  19606. shader: string;
  19607. };
  19608. }
  19609. declare module "babylonjs/Shaders/line.vertex" {
  19610. /** @hidden */
  19611. export var lineVertexShader: {
  19612. name: string;
  19613. shader: string;
  19614. };
  19615. }
  19616. declare module "babylonjs/Rendering/edgesRenderer" {
  19617. import { Nullable } from "babylonjs/types";
  19618. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19620. import { Vector3 } from "babylonjs/Maths/math.vector";
  19621. import { IDisposable } from "babylonjs/scene";
  19622. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19623. import "babylonjs/Shaders/line.fragment";
  19624. import "babylonjs/Shaders/line.vertex";
  19625. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19626. module "babylonjs/Meshes/abstractMesh" {
  19627. interface AbstractMesh {
  19628. /**
  19629. * Gets the edgesRenderer associated with the mesh
  19630. */
  19631. edgesRenderer: Nullable<EdgesRenderer>;
  19632. }
  19633. }
  19634. module "babylonjs/Meshes/linesMesh" {
  19635. interface LinesMesh {
  19636. /**
  19637. * Enables the edge rendering mode on the mesh.
  19638. * This mode makes the mesh edges visible
  19639. * @param epsilon defines the maximal distance between two angles to detect a face
  19640. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19641. * @returns the currentAbstractMesh
  19642. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19643. */
  19644. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19645. }
  19646. }
  19647. module "babylonjs/Meshes/linesMesh" {
  19648. interface InstancedLinesMesh {
  19649. /**
  19650. * Enables the edge rendering mode on the mesh.
  19651. * This mode makes the mesh edges visible
  19652. * @param epsilon defines the maximal distance between two angles to detect a face
  19653. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19654. * @returns the current InstancedLinesMesh
  19655. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19656. */
  19657. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19658. }
  19659. }
  19660. /**
  19661. * Defines the minimum contract an Edges renderer should follow.
  19662. */
  19663. export interface IEdgesRenderer extends IDisposable {
  19664. /**
  19665. * Gets or sets a boolean indicating if the edgesRenderer is active
  19666. */
  19667. isEnabled: boolean;
  19668. /**
  19669. * Renders the edges of the attached mesh,
  19670. */
  19671. render(): void;
  19672. /**
  19673. * Checks wether or not the edges renderer is ready to render.
  19674. * @return true if ready, otherwise false.
  19675. */
  19676. isReady(): boolean;
  19677. }
  19678. /**
  19679. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19680. */
  19681. export class EdgesRenderer implements IEdgesRenderer {
  19682. /**
  19683. * Define the size of the edges with an orthographic camera
  19684. */
  19685. edgesWidthScalerForOrthographic: number;
  19686. /**
  19687. * Define the size of the edges with a perspective camera
  19688. */
  19689. edgesWidthScalerForPerspective: number;
  19690. protected _source: AbstractMesh;
  19691. protected _linesPositions: number[];
  19692. protected _linesNormals: number[];
  19693. protected _linesIndices: number[];
  19694. protected _epsilon: number;
  19695. protected _indicesCount: number;
  19696. protected _lineShader: ShaderMaterial;
  19697. protected _ib: DataBuffer;
  19698. protected _buffers: {
  19699. [key: string]: Nullable<VertexBuffer>;
  19700. };
  19701. protected _checkVerticesInsteadOfIndices: boolean;
  19702. private _meshRebuildObserver;
  19703. private _meshDisposeObserver;
  19704. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19705. isEnabled: boolean;
  19706. /**
  19707. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19708. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19709. * @param source Mesh used to create edges
  19710. * @param epsilon sum of angles in adjacency to check for edge
  19711. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19712. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19713. */
  19714. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19715. protected _prepareRessources(): void;
  19716. /** @hidden */
  19717. _rebuild(): void;
  19718. /**
  19719. * Releases the required resources for the edges renderer
  19720. */
  19721. dispose(): void;
  19722. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19723. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19724. /**
  19725. * Checks if the pair of p0 and p1 is en edge
  19726. * @param faceIndex
  19727. * @param edge
  19728. * @param faceNormals
  19729. * @param p0
  19730. * @param p1
  19731. * @private
  19732. */
  19733. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19734. /**
  19735. * push line into the position, normal and index buffer
  19736. * @protected
  19737. */
  19738. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19739. /**
  19740. * Generates lines edges from adjacencjes
  19741. * @private
  19742. */
  19743. _generateEdgesLines(): void;
  19744. /**
  19745. * Checks wether or not the edges renderer is ready to render.
  19746. * @return true if ready, otherwise false.
  19747. */
  19748. isReady(): boolean;
  19749. /**
  19750. * Renders the edges of the attached mesh,
  19751. */
  19752. render(): void;
  19753. }
  19754. /**
  19755. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19756. */
  19757. export class LineEdgesRenderer extends EdgesRenderer {
  19758. /**
  19759. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19760. * @param source LineMesh used to generate edges
  19761. * @param epsilon not important (specified angle for edge detection)
  19762. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19763. */
  19764. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19765. /**
  19766. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19767. */
  19768. _generateEdgesLines(): void;
  19769. }
  19770. }
  19771. declare module "babylonjs/Rendering/renderingGroup" {
  19772. import { SmartArray } from "babylonjs/Misc/smartArray";
  19773. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19774. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19775. import { Nullable } from "babylonjs/types";
  19776. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19777. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  19778. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19779. import { Material } from "babylonjs/Materials/material";
  19780. import { Scene } from "babylonjs/scene";
  19781. /**
  19782. * This represents the object necessary to create a rendering group.
  19783. * This is exclusively used and created by the rendering manager.
  19784. * To modify the behavior, you use the available helpers in your scene or meshes.
  19785. * @hidden
  19786. */
  19787. export class RenderingGroup {
  19788. index: number;
  19789. private static _zeroVector;
  19790. private _scene;
  19791. private _opaqueSubMeshes;
  19792. private _transparentSubMeshes;
  19793. private _alphaTestSubMeshes;
  19794. private _depthOnlySubMeshes;
  19795. private _particleSystems;
  19796. private _spriteManagers;
  19797. private _opaqueSortCompareFn;
  19798. private _alphaTestSortCompareFn;
  19799. private _transparentSortCompareFn;
  19800. private _renderOpaque;
  19801. private _renderAlphaTest;
  19802. private _renderTransparent;
  19803. /** @hidden */
  19804. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19805. onBeforeTransparentRendering: () => void;
  19806. /**
  19807. * Set the opaque sort comparison function.
  19808. * If null the sub meshes will be render in the order they were created
  19809. */
  19810. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19811. /**
  19812. * Set the alpha test sort comparison function.
  19813. * If null the sub meshes will be render in the order they were created
  19814. */
  19815. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19816. /**
  19817. * Set the transparent sort comparison function.
  19818. * If null the sub meshes will be render in the order they were created
  19819. */
  19820. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19821. /**
  19822. * Creates a new rendering group.
  19823. * @param index The rendering group index
  19824. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19825. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19826. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19827. */
  19828. 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>);
  19829. /**
  19830. * Render all the sub meshes contained in the group.
  19831. * @param customRenderFunction Used to override the default render behaviour of the group.
  19832. * @returns true if rendered some submeshes.
  19833. */
  19834. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19835. /**
  19836. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19837. * @param subMeshes The submeshes to render
  19838. */
  19839. private renderOpaqueSorted;
  19840. /**
  19841. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19842. * @param subMeshes The submeshes to render
  19843. */
  19844. private renderAlphaTestSorted;
  19845. /**
  19846. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19847. * @param subMeshes The submeshes to render
  19848. */
  19849. private renderTransparentSorted;
  19850. /**
  19851. * Renders the submeshes in a specified order.
  19852. * @param subMeshes The submeshes to sort before render
  19853. * @param sortCompareFn The comparison function use to sort
  19854. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19855. * @param transparent Specifies to activate blending if true
  19856. */
  19857. private static renderSorted;
  19858. /**
  19859. * Renders the submeshes in the order they were dispatched (no sort applied).
  19860. * @param subMeshes The submeshes to render
  19861. */
  19862. private static renderUnsorted;
  19863. /**
  19864. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19865. * are rendered back to front if in the same alpha index.
  19866. *
  19867. * @param a The first submesh
  19868. * @param b The second submesh
  19869. * @returns The result of the comparison
  19870. */
  19871. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19872. /**
  19873. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19874. * are rendered back to front.
  19875. *
  19876. * @param a The first submesh
  19877. * @param b The second submesh
  19878. * @returns The result of the comparison
  19879. */
  19880. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19881. /**
  19882. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19883. * are rendered front to back (prevent overdraw).
  19884. *
  19885. * @param a The first submesh
  19886. * @param b The second submesh
  19887. * @returns The result of the comparison
  19888. */
  19889. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19890. /**
  19891. * Resets the different lists of submeshes to prepare a new frame.
  19892. */
  19893. prepare(): void;
  19894. dispose(): void;
  19895. /**
  19896. * Inserts the submesh in its correct queue depending on its material.
  19897. * @param subMesh The submesh to dispatch
  19898. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19899. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19900. */
  19901. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19902. dispatchSprites(spriteManager: ISpriteManager): void;
  19903. dispatchParticles(particleSystem: IParticleSystem): void;
  19904. private _renderParticles;
  19905. private _renderSprites;
  19906. }
  19907. }
  19908. declare module "babylonjs/Rendering/renderingManager" {
  19909. import { Nullable } from "babylonjs/types";
  19910. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19911. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19912. import { SmartArray } from "babylonjs/Misc/smartArray";
  19913. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19914. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19915. import { Material } from "babylonjs/Materials/material";
  19916. import { Scene } from "babylonjs/scene";
  19917. import { Camera } from "babylonjs/Cameras/camera";
  19918. /**
  19919. * Interface describing the different options available in the rendering manager
  19920. * regarding Auto Clear between groups.
  19921. */
  19922. export interface IRenderingManagerAutoClearSetup {
  19923. /**
  19924. * Defines whether or not autoclear is enable.
  19925. */
  19926. autoClear: boolean;
  19927. /**
  19928. * Defines whether or not to autoclear the depth buffer.
  19929. */
  19930. depth: boolean;
  19931. /**
  19932. * Defines whether or not to autoclear the stencil buffer.
  19933. */
  19934. stencil: boolean;
  19935. }
  19936. /**
  19937. * This class is used by the onRenderingGroupObservable
  19938. */
  19939. export class RenderingGroupInfo {
  19940. /**
  19941. * The Scene that being rendered
  19942. */
  19943. scene: Scene;
  19944. /**
  19945. * The camera currently used for the rendering pass
  19946. */
  19947. camera: Nullable<Camera>;
  19948. /**
  19949. * The ID of the renderingGroup being processed
  19950. */
  19951. renderingGroupId: number;
  19952. }
  19953. /**
  19954. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19955. * It is enable to manage the different groups as well as the different necessary sort functions.
  19956. * This should not be used directly aside of the few static configurations
  19957. */
  19958. export class RenderingManager {
  19959. /**
  19960. * The max id used for rendering groups (not included)
  19961. */
  19962. static MAX_RENDERINGGROUPS: number;
  19963. /**
  19964. * The min id used for rendering groups (included)
  19965. */
  19966. static MIN_RENDERINGGROUPS: number;
  19967. /**
  19968. * Used to globally prevent autoclearing scenes.
  19969. */
  19970. static AUTOCLEAR: boolean;
  19971. /**
  19972. * @hidden
  19973. */
  19974. _useSceneAutoClearSetup: boolean;
  19975. private _scene;
  19976. private _renderingGroups;
  19977. private _depthStencilBufferAlreadyCleaned;
  19978. private _autoClearDepthStencil;
  19979. private _customOpaqueSortCompareFn;
  19980. private _customAlphaTestSortCompareFn;
  19981. private _customTransparentSortCompareFn;
  19982. private _renderingGroupInfo;
  19983. /**
  19984. * Instantiates a new rendering group for a particular scene
  19985. * @param scene Defines the scene the groups belongs to
  19986. */
  19987. constructor(scene: Scene);
  19988. private _clearDepthStencilBuffer;
  19989. /**
  19990. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19991. * @hidden
  19992. */
  19993. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19994. /**
  19995. * Resets the different information of the group to prepare a new frame
  19996. * @hidden
  19997. */
  19998. reset(): void;
  19999. /**
  20000. * Dispose and release the group and its associated resources.
  20001. * @hidden
  20002. */
  20003. dispose(): void;
  20004. /**
  20005. * Clear the info related to rendering groups preventing retention points during dispose.
  20006. */
  20007. freeRenderingGroups(): void;
  20008. private _prepareRenderingGroup;
  20009. /**
  20010. * Add a sprite manager to the rendering manager in order to render it this frame.
  20011. * @param spriteManager Define the sprite manager to render
  20012. */
  20013. dispatchSprites(spriteManager: ISpriteManager): void;
  20014. /**
  20015. * Add a particle system to the rendering manager in order to render it this frame.
  20016. * @param particleSystem Define the particle system to render
  20017. */
  20018. dispatchParticles(particleSystem: IParticleSystem): void;
  20019. /**
  20020. * Add a submesh to the manager in order to render it this frame
  20021. * @param subMesh The submesh to dispatch
  20022. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20023. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20024. */
  20025. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20026. /**
  20027. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20028. * This allowed control for front to back rendering or reversly depending of the special needs.
  20029. *
  20030. * @param renderingGroupId The rendering group id corresponding to its index
  20031. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20032. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20033. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20034. */
  20035. 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;
  20036. /**
  20037. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20038. *
  20039. * @param renderingGroupId The rendering group id corresponding to its index
  20040. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20041. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20042. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20043. */
  20044. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20045. /**
  20046. * Gets the current auto clear configuration for one rendering group of the rendering
  20047. * manager.
  20048. * @param index the rendering group index to get the information for
  20049. * @returns The auto clear setup for the requested rendering group
  20050. */
  20051. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20052. }
  20053. }
  20054. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20055. import { Observable } from "babylonjs/Misc/observable";
  20056. import { SmartArray } from "babylonjs/Misc/smartArray";
  20057. import { Nullable } from "babylonjs/types";
  20058. import { Camera } from "babylonjs/Cameras/camera";
  20059. import { Scene } from "babylonjs/scene";
  20060. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20061. import { Color4 } from "babylonjs/Maths/math.color";
  20062. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20064. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20065. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20066. import { Texture } from "babylonjs/Materials/Textures/texture";
  20067. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20068. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20069. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20070. import { Engine } from "babylonjs/Engines/engine";
  20071. /**
  20072. * This Helps creating a texture that will be created from a camera in your scene.
  20073. * It is basically a dynamic texture that could be used to create special effects for instance.
  20074. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20075. */
  20076. export class RenderTargetTexture extends Texture {
  20077. isCube: boolean;
  20078. /**
  20079. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20080. */
  20081. static readonly REFRESHRATE_RENDER_ONCE: number;
  20082. /**
  20083. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20084. */
  20085. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20086. /**
  20087. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20088. * the central point of your effect and can save a lot of performances.
  20089. */
  20090. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20091. /**
  20092. * Use this predicate to dynamically define the list of mesh you want to render.
  20093. * If set, the renderList property will be overwritten.
  20094. */
  20095. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20096. private _renderList;
  20097. /**
  20098. * Use this list to define the list of mesh you want to render.
  20099. */
  20100. renderList: Nullable<Array<AbstractMesh>>;
  20101. private _hookArray;
  20102. /**
  20103. * Define if particles should be rendered in your texture.
  20104. */
  20105. renderParticles: boolean;
  20106. /**
  20107. * Define if sprites should be rendered in your texture.
  20108. */
  20109. renderSprites: boolean;
  20110. /**
  20111. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20112. */
  20113. coordinatesMode: number;
  20114. /**
  20115. * Define the camera used to render the texture.
  20116. */
  20117. activeCamera: Nullable<Camera>;
  20118. /**
  20119. * Override the render function of the texture with your own one.
  20120. */
  20121. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20122. /**
  20123. * Define if camera post processes should be use while rendering the texture.
  20124. */
  20125. useCameraPostProcesses: boolean;
  20126. /**
  20127. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20128. */
  20129. ignoreCameraViewport: boolean;
  20130. private _postProcessManager;
  20131. private _postProcesses;
  20132. private _resizeObserver;
  20133. /**
  20134. * An event triggered when the texture is unbind.
  20135. */
  20136. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20137. /**
  20138. * An event triggered when the texture is unbind.
  20139. */
  20140. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20141. private _onAfterUnbindObserver;
  20142. /**
  20143. * Set a after unbind callback in the texture.
  20144. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20145. */
  20146. onAfterUnbind: () => void;
  20147. /**
  20148. * An event triggered before rendering the texture
  20149. */
  20150. onBeforeRenderObservable: Observable<number>;
  20151. private _onBeforeRenderObserver;
  20152. /**
  20153. * Set a before render callback in the texture.
  20154. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20155. */
  20156. onBeforeRender: (faceIndex: number) => void;
  20157. /**
  20158. * An event triggered after rendering the texture
  20159. */
  20160. onAfterRenderObservable: Observable<number>;
  20161. private _onAfterRenderObserver;
  20162. /**
  20163. * Set a after render callback in the texture.
  20164. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20165. */
  20166. onAfterRender: (faceIndex: number) => void;
  20167. /**
  20168. * An event triggered after the texture clear
  20169. */
  20170. onClearObservable: Observable<Engine>;
  20171. private _onClearObserver;
  20172. /**
  20173. * Set a clear callback in the texture.
  20174. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20175. */
  20176. onClear: (Engine: Engine) => void;
  20177. /**
  20178. * Define the clear color of the Render Target if it should be different from the scene.
  20179. */
  20180. clearColor: Color4;
  20181. protected _size: number | {
  20182. width: number;
  20183. height: number;
  20184. };
  20185. protected _initialSizeParameter: number | {
  20186. width: number;
  20187. height: number;
  20188. } | {
  20189. ratio: number;
  20190. };
  20191. protected _sizeRatio: Nullable<number>;
  20192. /** @hidden */
  20193. _generateMipMaps: boolean;
  20194. protected _renderingManager: RenderingManager;
  20195. /** @hidden */
  20196. _waitingRenderList: string[];
  20197. protected _doNotChangeAspectRatio: boolean;
  20198. protected _currentRefreshId: number;
  20199. protected _refreshRate: number;
  20200. protected _textureMatrix: Matrix;
  20201. protected _samples: number;
  20202. protected _renderTargetOptions: RenderTargetCreationOptions;
  20203. /**
  20204. * Gets render target creation options that were used.
  20205. */
  20206. readonly renderTargetOptions: RenderTargetCreationOptions;
  20207. protected _engine: Engine;
  20208. protected _onRatioRescale(): void;
  20209. /**
  20210. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20211. * It must define where the camera used to render the texture is set
  20212. */
  20213. boundingBoxPosition: Vector3;
  20214. private _boundingBoxSize;
  20215. /**
  20216. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20217. * When defined, the cubemap will switch to local mode
  20218. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20219. * @example https://www.babylonjs-playground.com/#RNASML
  20220. */
  20221. boundingBoxSize: Vector3;
  20222. /**
  20223. * In case the RTT has been created with a depth texture, get the associated
  20224. * depth texture.
  20225. * Otherwise, return null.
  20226. */
  20227. depthStencilTexture: Nullable<InternalTexture>;
  20228. /**
  20229. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20230. * or used a shadow, depth texture...
  20231. * @param name The friendly name of the texture
  20232. * @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)
  20233. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20234. * @param generateMipMaps True if mip maps need to be generated after render.
  20235. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20236. * @param type The type of the buffer in the RTT (int, half float, float...)
  20237. * @param isCube True if a cube texture needs to be created
  20238. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20239. * @param generateDepthBuffer True to generate a depth buffer
  20240. * @param generateStencilBuffer True to generate a stencil buffer
  20241. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20242. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20243. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20244. */
  20245. constructor(name: string, size: number | {
  20246. width: number;
  20247. height: number;
  20248. } | {
  20249. ratio: number;
  20250. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20251. /**
  20252. * Creates a depth stencil texture.
  20253. * This is only available in WebGL 2 or with the depth texture extension available.
  20254. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20255. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20256. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20257. */
  20258. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20259. private _processSizeParameter;
  20260. /**
  20261. * Define the number of samples to use in case of MSAA.
  20262. * It defaults to one meaning no MSAA has been enabled.
  20263. */
  20264. samples: number;
  20265. /**
  20266. * Resets the refresh counter of the texture and start bak from scratch.
  20267. * Could be useful to regenerate the texture if it is setup to render only once.
  20268. */
  20269. resetRefreshCounter(): void;
  20270. /**
  20271. * Define the refresh rate of the texture or the rendering frequency.
  20272. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20273. */
  20274. refreshRate: number;
  20275. /**
  20276. * Adds a post process to the render target rendering passes.
  20277. * @param postProcess define the post process to add
  20278. */
  20279. addPostProcess(postProcess: PostProcess): void;
  20280. /**
  20281. * Clear all the post processes attached to the render target
  20282. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20283. */
  20284. clearPostProcesses(dispose?: boolean): void;
  20285. /**
  20286. * Remove one of the post process from the list of attached post processes to the texture
  20287. * @param postProcess define the post process to remove from the list
  20288. */
  20289. removePostProcess(postProcess: PostProcess): void;
  20290. /** @hidden */
  20291. _shouldRender(): boolean;
  20292. /**
  20293. * Gets the actual render size of the texture.
  20294. * @returns the width of the render size
  20295. */
  20296. getRenderSize(): number;
  20297. /**
  20298. * Gets the actual render width of the texture.
  20299. * @returns the width of the render size
  20300. */
  20301. getRenderWidth(): number;
  20302. /**
  20303. * Gets the actual render height of the texture.
  20304. * @returns the height of the render size
  20305. */
  20306. getRenderHeight(): number;
  20307. /**
  20308. * Get if the texture can be rescaled or not.
  20309. */
  20310. readonly canRescale: boolean;
  20311. /**
  20312. * Resize the texture using a ratio.
  20313. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20314. */
  20315. scale(ratio: number): void;
  20316. /**
  20317. * Get the texture reflection matrix used to rotate/transform the reflection.
  20318. * @returns the reflection matrix
  20319. */
  20320. getReflectionTextureMatrix(): Matrix;
  20321. /**
  20322. * Resize the texture to a new desired size.
  20323. * Be carrefull as it will recreate all the data in the new texture.
  20324. * @param size Define the new size. It can be:
  20325. * - a number for squared texture,
  20326. * - an object containing { width: number, height: number }
  20327. * - or an object containing a ratio { ratio: number }
  20328. */
  20329. resize(size: number | {
  20330. width: number;
  20331. height: number;
  20332. } | {
  20333. ratio: number;
  20334. }): void;
  20335. /**
  20336. * Renders all the objects from the render list into the texture.
  20337. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20338. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20339. */
  20340. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20341. private _bestReflectionRenderTargetDimension;
  20342. /**
  20343. * @hidden
  20344. * @param faceIndex face index to bind to if this is a cubetexture
  20345. */
  20346. _bindFrameBuffer(faceIndex?: number): void;
  20347. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20348. private renderToTarget;
  20349. /**
  20350. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20351. * This allowed control for front to back rendering or reversly depending of the special needs.
  20352. *
  20353. * @param renderingGroupId The rendering group id corresponding to its index
  20354. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20355. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20356. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20357. */
  20358. 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;
  20359. /**
  20360. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20361. *
  20362. * @param renderingGroupId The rendering group id corresponding to its index
  20363. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20364. */
  20365. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20366. /**
  20367. * Clones the texture.
  20368. * @returns the cloned texture
  20369. */
  20370. clone(): RenderTargetTexture;
  20371. /**
  20372. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20373. * @returns The JSON representation of the texture
  20374. */
  20375. serialize(): any;
  20376. /**
  20377. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20378. */
  20379. disposeFramebufferObjects(): void;
  20380. /**
  20381. * Dispose the texture and release its associated resources.
  20382. */
  20383. dispose(): void;
  20384. /** @hidden */
  20385. _rebuild(): void;
  20386. /**
  20387. * Clear the info related to rendering groups preventing retention point in material dispose.
  20388. */
  20389. freeRenderingGroups(): void;
  20390. /**
  20391. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20392. * @returns the view count
  20393. */
  20394. getViewCount(): number;
  20395. }
  20396. }
  20397. declare module "babylonjs/Materials/material" {
  20398. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20399. import { SmartArray } from "babylonjs/Misc/smartArray";
  20400. import { Observable } from "babylonjs/Misc/observable";
  20401. import { Nullable } from "babylonjs/types";
  20402. import { Scene } from "babylonjs/scene";
  20403. import { Matrix } from "babylonjs/Maths/math.vector";
  20404. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20405. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20406. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20407. import { Effect } from "babylonjs/Materials/effect";
  20408. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20409. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20410. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20411. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20412. import { Mesh } from "babylonjs/Meshes/mesh";
  20413. import { Animation } from "babylonjs/Animations/animation";
  20414. /**
  20415. * Base class for the main features of a material in Babylon.js
  20416. */
  20417. export class Material implements IAnimatable {
  20418. /**
  20419. * Returns the triangle fill mode
  20420. */
  20421. static readonly TriangleFillMode: number;
  20422. /**
  20423. * Returns the wireframe mode
  20424. */
  20425. static readonly WireFrameFillMode: number;
  20426. /**
  20427. * Returns the point fill mode
  20428. */
  20429. static readonly PointFillMode: number;
  20430. /**
  20431. * Returns the point list draw mode
  20432. */
  20433. static readonly PointListDrawMode: number;
  20434. /**
  20435. * Returns the line list draw mode
  20436. */
  20437. static readonly LineListDrawMode: number;
  20438. /**
  20439. * Returns the line loop draw mode
  20440. */
  20441. static readonly LineLoopDrawMode: number;
  20442. /**
  20443. * Returns the line strip draw mode
  20444. */
  20445. static readonly LineStripDrawMode: number;
  20446. /**
  20447. * Returns the triangle strip draw mode
  20448. */
  20449. static readonly TriangleStripDrawMode: number;
  20450. /**
  20451. * Returns the triangle fan draw mode
  20452. */
  20453. static readonly TriangleFanDrawMode: number;
  20454. /**
  20455. * Stores the clock-wise side orientation
  20456. */
  20457. static readonly ClockWiseSideOrientation: number;
  20458. /**
  20459. * Stores the counter clock-wise side orientation
  20460. */
  20461. static readonly CounterClockWiseSideOrientation: number;
  20462. /**
  20463. * The dirty texture flag value
  20464. */
  20465. static readonly TextureDirtyFlag: number;
  20466. /**
  20467. * The dirty light flag value
  20468. */
  20469. static readonly LightDirtyFlag: number;
  20470. /**
  20471. * The dirty fresnel flag value
  20472. */
  20473. static readonly FresnelDirtyFlag: number;
  20474. /**
  20475. * The dirty attribute flag value
  20476. */
  20477. static readonly AttributesDirtyFlag: number;
  20478. /**
  20479. * The dirty misc flag value
  20480. */
  20481. static readonly MiscDirtyFlag: number;
  20482. /**
  20483. * The all dirty flag value
  20484. */
  20485. static readonly AllDirtyFlag: number;
  20486. /**
  20487. * The ID of the material
  20488. */
  20489. id: string;
  20490. /**
  20491. * Gets or sets the unique id of the material
  20492. */
  20493. uniqueId: number;
  20494. /**
  20495. * The name of the material
  20496. */
  20497. name: string;
  20498. /**
  20499. * Gets or sets user defined metadata
  20500. */
  20501. metadata: any;
  20502. /**
  20503. * For internal use only. Please do not use.
  20504. */
  20505. reservedDataStore: any;
  20506. /**
  20507. * Specifies if the ready state should be checked on each call
  20508. */
  20509. checkReadyOnEveryCall: boolean;
  20510. /**
  20511. * Specifies if the ready state should be checked once
  20512. */
  20513. checkReadyOnlyOnce: boolean;
  20514. /**
  20515. * The state of the material
  20516. */
  20517. state: string;
  20518. /**
  20519. * The alpha value of the material
  20520. */
  20521. protected _alpha: number;
  20522. /**
  20523. * List of inspectable custom properties (used by the Inspector)
  20524. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20525. */
  20526. inspectableCustomProperties: IInspectable[];
  20527. /**
  20528. * Sets the alpha value of the material
  20529. */
  20530. /**
  20531. * Gets the alpha value of the material
  20532. */
  20533. alpha: number;
  20534. /**
  20535. * Specifies if back face culling is enabled
  20536. */
  20537. protected _backFaceCulling: boolean;
  20538. /**
  20539. * Sets the back-face culling state
  20540. */
  20541. /**
  20542. * Gets the back-face culling state
  20543. */
  20544. backFaceCulling: boolean;
  20545. /**
  20546. * Stores the value for side orientation
  20547. */
  20548. sideOrientation: number;
  20549. /**
  20550. * Callback triggered when the material is compiled
  20551. */
  20552. onCompiled: Nullable<(effect: Effect) => void>;
  20553. /**
  20554. * Callback triggered when an error occurs
  20555. */
  20556. onError: Nullable<(effect: Effect, errors: string) => void>;
  20557. /**
  20558. * Callback triggered to get the render target textures
  20559. */
  20560. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20561. /**
  20562. * Gets a boolean indicating that current material needs to register RTT
  20563. */
  20564. readonly hasRenderTargetTextures: boolean;
  20565. /**
  20566. * Specifies if the material should be serialized
  20567. */
  20568. doNotSerialize: boolean;
  20569. /**
  20570. * @hidden
  20571. */
  20572. _storeEffectOnSubMeshes: boolean;
  20573. /**
  20574. * Stores the animations for the material
  20575. */
  20576. animations: Nullable<Array<Animation>>;
  20577. /**
  20578. * An event triggered when the material is disposed
  20579. */
  20580. onDisposeObservable: Observable<Material>;
  20581. /**
  20582. * An observer which watches for dispose events
  20583. */
  20584. private _onDisposeObserver;
  20585. private _onUnBindObservable;
  20586. /**
  20587. * Called during a dispose event
  20588. */
  20589. onDispose: () => void;
  20590. private _onBindObservable;
  20591. /**
  20592. * An event triggered when the material is bound
  20593. */
  20594. readonly onBindObservable: Observable<AbstractMesh>;
  20595. /**
  20596. * An observer which watches for bind events
  20597. */
  20598. private _onBindObserver;
  20599. /**
  20600. * Called during a bind event
  20601. */
  20602. onBind: (Mesh: AbstractMesh) => void;
  20603. /**
  20604. * An event triggered when the material is unbound
  20605. */
  20606. readonly onUnBindObservable: Observable<Material>;
  20607. /**
  20608. * Stores the value of the alpha mode
  20609. */
  20610. private _alphaMode;
  20611. /**
  20612. * Sets the value of the alpha mode.
  20613. *
  20614. * | Value | Type | Description |
  20615. * | --- | --- | --- |
  20616. * | 0 | ALPHA_DISABLE | |
  20617. * | 1 | ALPHA_ADD | |
  20618. * | 2 | ALPHA_COMBINE | |
  20619. * | 3 | ALPHA_SUBTRACT | |
  20620. * | 4 | ALPHA_MULTIPLY | |
  20621. * | 5 | ALPHA_MAXIMIZED | |
  20622. * | 6 | ALPHA_ONEONE | |
  20623. * | 7 | ALPHA_PREMULTIPLIED | |
  20624. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20625. * | 9 | ALPHA_INTERPOLATE | |
  20626. * | 10 | ALPHA_SCREENMODE | |
  20627. *
  20628. */
  20629. /**
  20630. * Gets the value of the alpha mode
  20631. */
  20632. alphaMode: number;
  20633. /**
  20634. * Stores the state of the need depth pre-pass value
  20635. */
  20636. private _needDepthPrePass;
  20637. /**
  20638. * Sets the need depth pre-pass value
  20639. */
  20640. /**
  20641. * Gets the depth pre-pass value
  20642. */
  20643. needDepthPrePass: boolean;
  20644. /**
  20645. * Specifies if depth writing should be disabled
  20646. */
  20647. disableDepthWrite: boolean;
  20648. /**
  20649. * Specifies if depth writing should be forced
  20650. */
  20651. forceDepthWrite: boolean;
  20652. /**
  20653. * Specifies if there should be a separate pass for culling
  20654. */
  20655. separateCullingPass: boolean;
  20656. /**
  20657. * Stores the state specifing if fog should be enabled
  20658. */
  20659. private _fogEnabled;
  20660. /**
  20661. * Sets the state for enabling fog
  20662. */
  20663. /**
  20664. * Gets the value of the fog enabled state
  20665. */
  20666. fogEnabled: boolean;
  20667. /**
  20668. * Stores the size of points
  20669. */
  20670. pointSize: number;
  20671. /**
  20672. * Stores the z offset value
  20673. */
  20674. zOffset: number;
  20675. /**
  20676. * Gets a value specifying if wireframe mode is enabled
  20677. */
  20678. /**
  20679. * Sets the state of wireframe mode
  20680. */
  20681. wireframe: boolean;
  20682. /**
  20683. * Gets the value specifying if point clouds are enabled
  20684. */
  20685. /**
  20686. * Sets the state of point cloud mode
  20687. */
  20688. pointsCloud: boolean;
  20689. /**
  20690. * Gets the material fill mode
  20691. */
  20692. /**
  20693. * Sets the material fill mode
  20694. */
  20695. fillMode: number;
  20696. /**
  20697. * @hidden
  20698. * Stores the effects for the material
  20699. */
  20700. _effect: Nullable<Effect>;
  20701. /**
  20702. * @hidden
  20703. * Specifies if the material was previously ready
  20704. */
  20705. _wasPreviouslyReady: boolean;
  20706. /**
  20707. * Specifies if uniform buffers should be used
  20708. */
  20709. private _useUBO;
  20710. /**
  20711. * Stores a reference to the scene
  20712. */
  20713. private _scene;
  20714. /**
  20715. * Stores the fill mode state
  20716. */
  20717. private _fillMode;
  20718. /**
  20719. * Specifies if the depth write state should be cached
  20720. */
  20721. private _cachedDepthWriteState;
  20722. /**
  20723. * Stores the uniform buffer
  20724. */
  20725. protected _uniformBuffer: UniformBuffer;
  20726. /** @hidden */
  20727. _indexInSceneMaterialArray: number;
  20728. /** @hidden */
  20729. meshMap: Nullable<{
  20730. [id: string]: AbstractMesh | undefined;
  20731. }>;
  20732. /**
  20733. * Creates a material instance
  20734. * @param name defines the name of the material
  20735. * @param scene defines the scene to reference
  20736. * @param doNotAdd specifies if the material should be added to the scene
  20737. */
  20738. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20739. /**
  20740. * Returns a string representation of the current material
  20741. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20742. * @returns a string with material information
  20743. */
  20744. toString(fullDetails?: boolean): string;
  20745. /**
  20746. * Gets the class name of the material
  20747. * @returns a string with the class name of the material
  20748. */
  20749. getClassName(): string;
  20750. /**
  20751. * Specifies if updates for the material been locked
  20752. */
  20753. readonly isFrozen: boolean;
  20754. /**
  20755. * Locks updates for the material
  20756. */
  20757. freeze(): void;
  20758. /**
  20759. * Unlocks updates for the material
  20760. */
  20761. unfreeze(): void;
  20762. /**
  20763. * Specifies if the material is ready to be used
  20764. * @param mesh defines the mesh to check
  20765. * @param useInstances specifies if instances should be used
  20766. * @returns a boolean indicating if the material is ready to be used
  20767. */
  20768. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20769. /**
  20770. * Specifies that the submesh is ready to be used
  20771. * @param mesh defines the mesh to check
  20772. * @param subMesh defines which submesh to check
  20773. * @param useInstances specifies that instances should be used
  20774. * @returns a boolean indicating that the submesh is ready or not
  20775. */
  20776. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20777. /**
  20778. * Returns the material effect
  20779. * @returns the effect associated with the material
  20780. */
  20781. getEffect(): Nullable<Effect>;
  20782. /**
  20783. * Returns the current scene
  20784. * @returns a Scene
  20785. */
  20786. getScene(): Scene;
  20787. /**
  20788. * Specifies if the material will require alpha blending
  20789. * @returns a boolean specifying if alpha blending is needed
  20790. */
  20791. needAlphaBlending(): boolean;
  20792. /**
  20793. * Specifies if the mesh will require alpha blending
  20794. * @param mesh defines the mesh to check
  20795. * @returns a boolean specifying if alpha blending is needed for the mesh
  20796. */
  20797. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20798. /**
  20799. * Specifies if this material should be rendered in alpha test mode
  20800. * @returns a boolean specifying if an alpha test is needed.
  20801. */
  20802. needAlphaTesting(): boolean;
  20803. /**
  20804. * Gets the texture used for the alpha test
  20805. * @returns the texture to use for alpha testing
  20806. */
  20807. getAlphaTestTexture(): Nullable<BaseTexture>;
  20808. /**
  20809. * Marks the material to indicate that it needs to be re-calculated
  20810. */
  20811. markDirty(): void;
  20812. /** @hidden */
  20813. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20814. /**
  20815. * Binds the material to the mesh
  20816. * @param world defines the world transformation matrix
  20817. * @param mesh defines the mesh to bind the material to
  20818. */
  20819. bind(world: Matrix, mesh?: Mesh): void;
  20820. /**
  20821. * Binds the submesh to the material
  20822. * @param world defines the world transformation matrix
  20823. * @param mesh defines the mesh containing the submesh
  20824. * @param subMesh defines the submesh to bind the material to
  20825. */
  20826. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20827. /**
  20828. * Binds the world matrix to the material
  20829. * @param world defines the world transformation matrix
  20830. */
  20831. bindOnlyWorldMatrix(world: Matrix): void;
  20832. /**
  20833. * Binds the scene's uniform buffer to the effect.
  20834. * @param effect defines the effect to bind to the scene uniform buffer
  20835. * @param sceneUbo defines the uniform buffer storing scene data
  20836. */
  20837. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20838. /**
  20839. * Binds the view matrix to the effect
  20840. * @param effect defines the effect to bind the view matrix to
  20841. */
  20842. bindView(effect: Effect): void;
  20843. /**
  20844. * Binds the view projection matrix to the effect
  20845. * @param effect defines the effect to bind the view projection matrix to
  20846. */
  20847. bindViewProjection(effect: Effect): void;
  20848. /**
  20849. * Specifies if material alpha testing should be turned on for the mesh
  20850. * @param mesh defines the mesh to check
  20851. */
  20852. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20853. /**
  20854. * Processes to execute after binding the material to a mesh
  20855. * @param mesh defines the rendered mesh
  20856. */
  20857. protected _afterBind(mesh?: Mesh): void;
  20858. /**
  20859. * Unbinds the material from the mesh
  20860. */
  20861. unbind(): void;
  20862. /**
  20863. * Gets the active textures from the material
  20864. * @returns an array of textures
  20865. */
  20866. getActiveTextures(): BaseTexture[];
  20867. /**
  20868. * Specifies if the material uses a texture
  20869. * @param texture defines the texture to check against the material
  20870. * @returns a boolean specifying if the material uses the texture
  20871. */
  20872. hasTexture(texture: BaseTexture): boolean;
  20873. /**
  20874. * Makes a duplicate of the material, and gives it a new name
  20875. * @param name defines the new name for the duplicated material
  20876. * @returns the cloned material
  20877. */
  20878. clone(name: string): Nullable<Material>;
  20879. /**
  20880. * Gets the meshes bound to the material
  20881. * @returns an array of meshes bound to the material
  20882. */
  20883. getBindedMeshes(): AbstractMesh[];
  20884. /**
  20885. * Force shader compilation
  20886. * @param mesh defines the mesh associated with this material
  20887. * @param onCompiled defines a function to execute once the material is compiled
  20888. * @param options defines the options to configure the compilation
  20889. */
  20890. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20891. clipPlane: boolean;
  20892. }>): void;
  20893. /**
  20894. * Force shader compilation
  20895. * @param mesh defines the mesh that will use this material
  20896. * @param options defines additional options for compiling the shaders
  20897. * @returns a promise that resolves when the compilation completes
  20898. */
  20899. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20900. clipPlane: boolean;
  20901. }>): Promise<void>;
  20902. private static readonly _AllDirtyCallBack;
  20903. private static readonly _ImageProcessingDirtyCallBack;
  20904. private static readonly _TextureDirtyCallBack;
  20905. private static readonly _FresnelDirtyCallBack;
  20906. private static readonly _MiscDirtyCallBack;
  20907. private static readonly _LightsDirtyCallBack;
  20908. private static readonly _AttributeDirtyCallBack;
  20909. private static _FresnelAndMiscDirtyCallBack;
  20910. private static _TextureAndMiscDirtyCallBack;
  20911. private static readonly _DirtyCallbackArray;
  20912. private static readonly _RunDirtyCallBacks;
  20913. /**
  20914. * Marks a define in the material to indicate that it needs to be re-computed
  20915. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20916. */
  20917. markAsDirty(flag: number): void;
  20918. /**
  20919. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20920. * @param func defines a function which checks material defines against the submeshes
  20921. */
  20922. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20923. /**
  20924. * Indicates that we need to re-calculated for all submeshes
  20925. */
  20926. protected _markAllSubMeshesAsAllDirty(): void;
  20927. /**
  20928. * Indicates that image processing needs to be re-calculated for all submeshes
  20929. */
  20930. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20931. /**
  20932. * Indicates that textures need to be re-calculated for all submeshes
  20933. */
  20934. protected _markAllSubMeshesAsTexturesDirty(): void;
  20935. /**
  20936. * Indicates that fresnel needs to be re-calculated for all submeshes
  20937. */
  20938. protected _markAllSubMeshesAsFresnelDirty(): void;
  20939. /**
  20940. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20941. */
  20942. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20943. /**
  20944. * Indicates that lights need to be re-calculated for all submeshes
  20945. */
  20946. protected _markAllSubMeshesAsLightsDirty(): void;
  20947. /**
  20948. * Indicates that attributes need to be re-calculated for all submeshes
  20949. */
  20950. protected _markAllSubMeshesAsAttributesDirty(): void;
  20951. /**
  20952. * Indicates that misc needs to be re-calculated for all submeshes
  20953. */
  20954. protected _markAllSubMeshesAsMiscDirty(): void;
  20955. /**
  20956. * Indicates that textures and misc need to be re-calculated for all submeshes
  20957. */
  20958. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20959. /**
  20960. * Disposes the material
  20961. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20962. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20963. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20964. */
  20965. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20966. /** @hidden */
  20967. private releaseVertexArrayObject;
  20968. /**
  20969. * Serializes this material
  20970. * @returns the serialized material object
  20971. */
  20972. serialize(): any;
  20973. /**
  20974. * Creates a material from parsed material data
  20975. * @param parsedMaterial defines parsed material data
  20976. * @param scene defines the hosting scene
  20977. * @param rootUrl defines the root URL to use to load textures
  20978. * @returns a new material
  20979. */
  20980. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20981. }
  20982. }
  20983. declare module "babylonjs/Materials/multiMaterial" {
  20984. import { Nullable } from "babylonjs/types";
  20985. import { Scene } from "babylonjs/scene";
  20986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20987. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  20988. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20989. import { Material } from "babylonjs/Materials/material";
  20990. /**
  20991. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20992. * separate meshes. This can be use to improve performances.
  20993. * @see http://doc.babylonjs.com/how_to/multi_materials
  20994. */
  20995. export class MultiMaterial extends Material {
  20996. private _subMaterials;
  20997. /**
  20998. * Gets or Sets the list of Materials used within the multi material.
  20999. * They need to be ordered according to the submeshes order in the associated mesh
  21000. */
  21001. subMaterials: Nullable<Material>[];
  21002. /**
  21003. * Function used to align with Node.getChildren()
  21004. * @returns the list of Materials used within the multi material
  21005. */
  21006. getChildren(): Nullable<Material>[];
  21007. /**
  21008. * Instantiates a new Multi Material
  21009. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21010. * separate meshes. This can be use to improve performances.
  21011. * @see http://doc.babylonjs.com/how_to/multi_materials
  21012. * @param name Define the name in the scene
  21013. * @param scene Define the scene the material belongs to
  21014. */
  21015. constructor(name: string, scene: Scene);
  21016. private _hookArray;
  21017. /**
  21018. * Get one of the submaterial by its index in the submaterials array
  21019. * @param index The index to look the sub material at
  21020. * @returns The Material if the index has been defined
  21021. */
  21022. getSubMaterial(index: number): Nullable<Material>;
  21023. /**
  21024. * Get the list of active textures for the whole sub materials list.
  21025. * @returns All the textures that will be used during the rendering
  21026. */
  21027. getActiveTextures(): BaseTexture[];
  21028. /**
  21029. * Gets the current class name of the material e.g. "MultiMaterial"
  21030. * Mainly use in serialization.
  21031. * @returns the class name
  21032. */
  21033. getClassName(): string;
  21034. /**
  21035. * Checks if the material is ready to render the requested sub mesh
  21036. * @param mesh Define the mesh the submesh belongs to
  21037. * @param subMesh Define the sub mesh to look readyness for
  21038. * @param useInstances Define whether or not the material is used with instances
  21039. * @returns true if ready, otherwise false
  21040. */
  21041. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21042. /**
  21043. * Clones the current material and its related sub materials
  21044. * @param name Define the name of the newly cloned material
  21045. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21046. * @returns the cloned material
  21047. */
  21048. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21049. /**
  21050. * Serializes the materials into a JSON representation.
  21051. * @returns the JSON representation
  21052. */
  21053. serialize(): any;
  21054. /**
  21055. * Dispose the material and release its associated resources
  21056. * @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)
  21057. * @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)
  21058. * @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)
  21059. */
  21060. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21061. /**
  21062. * Creates a MultiMaterial from parsed MultiMaterial data.
  21063. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21064. * @param scene defines the hosting scene
  21065. * @returns a new MultiMaterial
  21066. */
  21067. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21068. }
  21069. }
  21070. declare module "babylonjs/Meshes/subMesh" {
  21071. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21072. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21073. import { Engine } from "babylonjs/Engines/engine";
  21074. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21075. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21076. import { Effect } from "babylonjs/Materials/effect";
  21077. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21078. import { Plane } from "babylonjs/Maths/math.plane";
  21079. import { Collider } from "babylonjs/Collisions/collider";
  21080. import { Material } from "babylonjs/Materials/material";
  21081. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21082. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21083. import { Mesh } from "babylonjs/Meshes/mesh";
  21084. import { Ray } from "babylonjs/Culling/ray";
  21085. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21086. /**
  21087. * Base class for submeshes
  21088. */
  21089. export class BaseSubMesh {
  21090. /** @hidden */
  21091. _materialDefines: Nullable<MaterialDefines>;
  21092. /** @hidden */
  21093. _materialEffect: Nullable<Effect>;
  21094. /**
  21095. * Gets associated effect
  21096. */
  21097. readonly effect: Nullable<Effect>;
  21098. /**
  21099. * Sets associated effect (effect used to render this submesh)
  21100. * @param effect defines the effect to associate with
  21101. * @param defines defines the set of defines used to compile this effect
  21102. */
  21103. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21104. }
  21105. /**
  21106. * Defines a subdivision inside a mesh
  21107. */
  21108. export class SubMesh extends BaseSubMesh implements ICullable {
  21109. /** the material index to use */
  21110. materialIndex: number;
  21111. /** vertex index start */
  21112. verticesStart: number;
  21113. /** vertices count */
  21114. verticesCount: number;
  21115. /** index start */
  21116. indexStart: number;
  21117. /** indices count */
  21118. indexCount: number;
  21119. /** @hidden */
  21120. _linesIndexCount: number;
  21121. private _mesh;
  21122. private _renderingMesh;
  21123. private _boundingInfo;
  21124. private _linesIndexBuffer;
  21125. /** @hidden */
  21126. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21127. /** @hidden */
  21128. _trianglePlanes: Plane[];
  21129. /** @hidden */
  21130. _lastColliderTransformMatrix: Nullable<Matrix>;
  21131. /** @hidden */
  21132. _renderId: number;
  21133. /** @hidden */
  21134. _alphaIndex: number;
  21135. /** @hidden */
  21136. _distanceToCamera: number;
  21137. /** @hidden */
  21138. _id: number;
  21139. private _currentMaterial;
  21140. /**
  21141. * Add a new submesh to a mesh
  21142. * @param materialIndex defines the material index to use
  21143. * @param verticesStart defines vertex index start
  21144. * @param verticesCount defines vertices count
  21145. * @param indexStart defines index start
  21146. * @param indexCount defines indices count
  21147. * @param mesh defines the parent mesh
  21148. * @param renderingMesh defines an optional rendering mesh
  21149. * @param createBoundingBox defines if bounding box should be created for this submesh
  21150. * @returns the new submesh
  21151. */
  21152. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21153. /**
  21154. * Creates a new submesh
  21155. * @param materialIndex defines the material index to use
  21156. * @param verticesStart defines vertex index start
  21157. * @param verticesCount defines vertices count
  21158. * @param indexStart defines index start
  21159. * @param indexCount defines indices count
  21160. * @param mesh defines the parent mesh
  21161. * @param renderingMesh defines an optional rendering mesh
  21162. * @param createBoundingBox defines if bounding box should be created for this submesh
  21163. */
  21164. constructor(
  21165. /** the material index to use */
  21166. materialIndex: number,
  21167. /** vertex index start */
  21168. verticesStart: number,
  21169. /** vertices count */
  21170. verticesCount: number,
  21171. /** index start */
  21172. indexStart: number,
  21173. /** indices count */
  21174. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21175. /**
  21176. * Returns true if this submesh covers the entire parent mesh
  21177. * @ignorenaming
  21178. */
  21179. readonly IsGlobal: boolean;
  21180. /**
  21181. * Returns the submesh BoudingInfo object
  21182. * @returns current bounding info (or mesh's one if the submesh is global)
  21183. */
  21184. getBoundingInfo(): BoundingInfo;
  21185. /**
  21186. * Sets the submesh BoundingInfo
  21187. * @param boundingInfo defines the new bounding info to use
  21188. * @returns the SubMesh
  21189. */
  21190. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21191. /**
  21192. * Returns the mesh of the current submesh
  21193. * @return the parent mesh
  21194. */
  21195. getMesh(): AbstractMesh;
  21196. /**
  21197. * Returns the rendering mesh of the submesh
  21198. * @returns the rendering mesh (could be different from parent mesh)
  21199. */
  21200. getRenderingMesh(): Mesh;
  21201. /**
  21202. * Returns the submesh material
  21203. * @returns null or the current material
  21204. */
  21205. getMaterial(): Nullable<Material>;
  21206. /**
  21207. * Sets a new updated BoundingInfo object to the submesh
  21208. * @param data defines an optional position array to use to determine the bounding info
  21209. * @returns the SubMesh
  21210. */
  21211. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21212. /** @hidden */
  21213. _checkCollision(collider: Collider): boolean;
  21214. /**
  21215. * Updates the submesh BoundingInfo
  21216. * @param world defines the world matrix to use to update the bounding info
  21217. * @returns the submesh
  21218. */
  21219. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21220. /**
  21221. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21222. * @param frustumPlanes defines the frustum planes
  21223. * @returns true if the submesh is intersecting with the frustum
  21224. */
  21225. isInFrustum(frustumPlanes: Plane[]): boolean;
  21226. /**
  21227. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21228. * @param frustumPlanes defines the frustum planes
  21229. * @returns true if the submesh is inside the frustum
  21230. */
  21231. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21232. /**
  21233. * Renders the submesh
  21234. * @param enableAlphaMode defines if alpha needs to be used
  21235. * @returns the submesh
  21236. */
  21237. render(enableAlphaMode: boolean): SubMesh;
  21238. /**
  21239. * @hidden
  21240. */
  21241. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21242. /**
  21243. * Checks if the submesh intersects with a ray
  21244. * @param ray defines the ray to test
  21245. * @returns true is the passed ray intersects the submesh bounding box
  21246. */
  21247. canIntersects(ray: Ray): boolean;
  21248. /**
  21249. * Intersects current submesh with a ray
  21250. * @param ray defines the ray to test
  21251. * @param positions defines mesh's positions array
  21252. * @param indices defines mesh's indices array
  21253. * @param fastCheck defines if only bounding info should be used
  21254. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21255. * @returns intersection info or null if no intersection
  21256. */
  21257. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21258. /** @hidden */
  21259. private _intersectLines;
  21260. /** @hidden */
  21261. private _intersectUnIndexedLines;
  21262. /** @hidden */
  21263. private _intersectTriangles;
  21264. /** @hidden */
  21265. private _intersectUnIndexedTriangles;
  21266. /** @hidden */
  21267. _rebuild(): void;
  21268. /**
  21269. * Creates a new submesh from the passed mesh
  21270. * @param newMesh defines the new hosting mesh
  21271. * @param newRenderingMesh defines an optional rendering mesh
  21272. * @returns the new submesh
  21273. */
  21274. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21275. /**
  21276. * Release associated resources
  21277. */
  21278. dispose(): void;
  21279. /**
  21280. * Gets the class name
  21281. * @returns the string "SubMesh".
  21282. */
  21283. getClassName(): string;
  21284. /**
  21285. * Creates a new submesh from indices data
  21286. * @param materialIndex the index of the main mesh material
  21287. * @param startIndex the index where to start the copy in the mesh indices array
  21288. * @param indexCount the number of indices to copy then from the startIndex
  21289. * @param mesh the main mesh to create the submesh from
  21290. * @param renderingMesh the optional rendering mesh
  21291. * @returns a new submesh
  21292. */
  21293. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21294. }
  21295. }
  21296. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21297. /**
  21298. * Class used to represent data loading progression
  21299. */
  21300. export class SceneLoaderFlags {
  21301. private static _ForceFullSceneLoadingForIncremental;
  21302. private static _ShowLoadingScreen;
  21303. private static _CleanBoneMatrixWeights;
  21304. private static _loggingLevel;
  21305. /**
  21306. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21307. */
  21308. static ForceFullSceneLoadingForIncremental: boolean;
  21309. /**
  21310. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21311. */
  21312. static ShowLoadingScreen: boolean;
  21313. /**
  21314. * Defines the current logging level (while loading the scene)
  21315. * @ignorenaming
  21316. */
  21317. static loggingLevel: number;
  21318. /**
  21319. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21320. */
  21321. static CleanBoneMatrixWeights: boolean;
  21322. }
  21323. }
  21324. declare module "babylonjs/Meshes/geometry" {
  21325. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21326. import { Scene } from "babylonjs/scene";
  21327. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21328. import { Engine } from "babylonjs/Engines/engine";
  21329. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21330. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21331. import { Effect } from "babylonjs/Materials/effect";
  21332. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21333. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21334. import { Mesh } from "babylonjs/Meshes/mesh";
  21335. /**
  21336. * Class used to store geometry data (vertex buffers + index buffer)
  21337. */
  21338. export class Geometry implements IGetSetVerticesData {
  21339. /**
  21340. * Gets or sets the ID of the geometry
  21341. */
  21342. id: string;
  21343. /**
  21344. * Gets or sets the unique ID of the geometry
  21345. */
  21346. uniqueId: number;
  21347. /**
  21348. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21349. */
  21350. delayLoadState: number;
  21351. /**
  21352. * Gets the file containing the data to load when running in delay load state
  21353. */
  21354. delayLoadingFile: Nullable<string>;
  21355. /**
  21356. * Callback called when the geometry is updated
  21357. */
  21358. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21359. private _scene;
  21360. private _engine;
  21361. private _meshes;
  21362. private _totalVertices;
  21363. /** @hidden */
  21364. _indices: IndicesArray;
  21365. /** @hidden */
  21366. _vertexBuffers: {
  21367. [key: string]: VertexBuffer;
  21368. };
  21369. private _isDisposed;
  21370. private _extend;
  21371. private _boundingBias;
  21372. /** @hidden */
  21373. _delayInfo: Array<string>;
  21374. private _indexBuffer;
  21375. private _indexBufferIsUpdatable;
  21376. /** @hidden */
  21377. _boundingInfo: Nullable<BoundingInfo>;
  21378. /** @hidden */
  21379. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21380. /** @hidden */
  21381. _softwareSkinningFrameId: number;
  21382. private _vertexArrayObjects;
  21383. private _updatable;
  21384. /** @hidden */
  21385. _positions: Nullable<Vector3[]>;
  21386. /**
  21387. * 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
  21388. */
  21389. /**
  21390. * 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
  21391. */
  21392. boundingBias: Vector2;
  21393. /**
  21394. * Static function used to attach a new empty geometry to a mesh
  21395. * @param mesh defines the mesh to attach the geometry to
  21396. * @returns the new Geometry
  21397. */
  21398. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21399. /**
  21400. * Creates a new geometry
  21401. * @param id defines the unique ID
  21402. * @param scene defines the hosting scene
  21403. * @param vertexData defines the VertexData used to get geometry data
  21404. * @param updatable defines if geometry must be updatable (false by default)
  21405. * @param mesh defines the mesh that will be associated with the geometry
  21406. */
  21407. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21408. /**
  21409. * Gets the current extend of the geometry
  21410. */
  21411. readonly extend: {
  21412. minimum: Vector3;
  21413. maximum: Vector3;
  21414. };
  21415. /**
  21416. * Gets the hosting scene
  21417. * @returns the hosting Scene
  21418. */
  21419. getScene(): Scene;
  21420. /**
  21421. * Gets the hosting engine
  21422. * @returns the hosting Engine
  21423. */
  21424. getEngine(): Engine;
  21425. /**
  21426. * Defines if the geometry is ready to use
  21427. * @returns true if the geometry is ready to be used
  21428. */
  21429. isReady(): boolean;
  21430. /**
  21431. * Gets a value indicating that the geometry should not be serialized
  21432. */
  21433. readonly doNotSerialize: boolean;
  21434. /** @hidden */
  21435. _rebuild(): void;
  21436. /**
  21437. * Affects all geometry data in one call
  21438. * @param vertexData defines the geometry data
  21439. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21440. */
  21441. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21442. /**
  21443. * Set specific vertex data
  21444. * @param kind defines the data kind (Position, normal, etc...)
  21445. * @param data defines the vertex data to use
  21446. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21447. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21448. */
  21449. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21450. /**
  21451. * Removes a specific vertex data
  21452. * @param kind defines the data kind (Position, normal, etc...)
  21453. */
  21454. removeVerticesData(kind: string): void;
  21455. /**
  21456. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21457. * @param buffer defines the vertex buffer to use
  21458. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21459. */
  21460. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21461. /**
  21462. * Update a specific vertex buffer
  21463. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21464. * It will do nothing if the buffer is not updatable
  21465. * @param kind defines the data kind (Position, normal, etc...)
  21466. * @param data defines the data to use
  21467. * @param offset defines the offset in the target buffer where to store the data
  21468. * @param useBytes set to true if the offset is in bytes
  21469. */
  21470. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21471. /**
  21472. * Update a specific vertex buffer
  21473. * This function will create a new buffer if the current one is not updatable
  21474. * @param kind defines the data kind (Position, normal, etc...)
  21475. * @param data defines the data to use
  21476. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21477. */
  21478. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21479. private _updateBoundingInfo;
  21480. /** @hidden */
  21481. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21482. /**
  21483. * Gets total number of vertices
  21484. * @returns the total number of vertices
  21485. */
  21486. getTotalVertices(): number;
  21487. /**
  21488. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21489. * @param kind defines the data kind (Position, normal, etc...)
  21490. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21491. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21492. * @returns a float array containing vertex data
  21493. */
  21494. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21495. /**
  21496. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21497. * @param kind defines the data kind (Position, normal, etc...)
  21498. * @returns true if the vertex buffer with the specified kind is updatable
  21499. */
  21500. isVertexBufferUpdatable(kind: string): boolean;
  21501. /**
  21502. * Gets a specific vertex buffer
  21503. * @param kind defines the data kind (Position, normal, etc...)
  21504. * @returns a VertexBuffer
  21505. */
  21506. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21507. /**
  21508. * Returns all vertex buffers
  21509. * @return an object holding all vertex buffers indexed by kind
  21510. */
  21511. getVertexBuffers(): Nullable<{
  21512. [key: string]: VertexBuffer;
  21513. }>;
  21514. /**
  21515. * Gets a boolean indicating if specific vertex buffer is present
  21516. * @param kind defines the data kind (Position, normal, etc...)
  21517. * @returns true if data is present
  21518. */
  21519. isVerticesDataPresent(kind: string): boolean;
  21520. /**
  21521. * Gets a list of all attached data kinds (Position, normal, etc...)
  21522. * @returns a list of string containing all kinds
  21523. */
  21524. getVerticesDataKinds(): string[];
  21525. /**
  21526. * Update index buffer
  21527. * @param indices defines the indices to store in the index buffer
  21528. * @param offset defines the offset in the target buffer where to store the data
  21529. * @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)
  21530. */
  21531. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21532. /**
  21533. * Creates a new index buffer
  21534. * @param indices defines the indices to store in the index buffer
  21535. * @param totalVertices defines the total number of vertices (could be null)
  21536. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21537. */
  21538. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21539. /**
  21540. * Return the total number of indices
  21541. * @returns the total number of indices
  21542. */
  21543. getTotalIndices(): number;
  21544. /**
  21545. * Gets the index buffer array
  21546. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21547. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21548. * @returns the index buffer array
  21549. */
  21550. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21551. /**
  21552. * Gets the index buffer
  21553. * @return the index buffer
  21554. */
  21555. getIndexBuffer(): Nullable<DataBuffer>;
  21556. /** @hidden */
  21557. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21558. /**
  21559. * Release the associated resources for a specific mesh
  21560. * @param mesh defines the source mesh
  21561. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21562. */
  21563. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21564. /**
  21565. * Apply current geometry to a given mesh
  21566. * @param mesh defines the mesh to apply geometry to
  21567. */
  21568. applyToMesh(mesh: Mesh): void;
  21569. private _updateExtend;
  21570. private _applyToMesh;
  21571. private notifyUpdate;
  21572. /**
  21573. * Load the geometry if it was flagged as delay loaded
  21574. * @param scene defines the hosting scene
  21575. * @param onLoaded defines a callback called when the geometry is loaded
  21576. */
  21577. load(scene: Scene, onLoaded?: () => void): void;
  21578. private _queueLoad;
  21579. /**
  21580. * Invert the geometry to move from a right handed system to a left handed one.
  21581. */
  21582. toLeftHanded(): void;
  21583. /** @hidden */
  21584. _resetPointsArrayCache(): void;
  21585. /** @hidden */
  21586. _generatePointsArray(): boolean;
  21587. /**
  21588. * Gets a value indicating if the geometry is disposed
  21589. * @returns true if the geometry was disposed
  21590. */
  21591. isDisposed(): boolean;
  21592. private _disposeVertexArrayObjects;
  21593. /**
  21594. * Free all associated resources
  21595. */
  21596. dispose(): void;
  21597. /**
  21598. * Clone the current geometry into a new geometry
  21599. * @param id defines the unique ID of the new geometry
  21600. * @returns a new geometry object
  21601. */
  21602. copy(id: string): Geometry;
  21603. /**
  21604. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21605. * @return a JSON representation of the current geometry data (without the vertices data)
  21606. */
  21607. serialize(): any;
  21608. private toNumberArray;
  21609. /**
  21610. * Serialize all vertices data into a JSON oject
  21611. * @returns a JSON representation of the current geometry data
  21612. */
  21613. serializeVerticeData(): any;
  21614. /**
  21615. * Extracts a clone of a mesh geometry
  21616. * @param mesh defines the source mesh
  21617. * @param id defines the unique ID of the new geometry object
  21618. * @returns the new geometry object
  21619. */
  21620. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21621. /**
  21622. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21623. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21624. * Be aware Math.random() could cause collisions, but:
  21625. * "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"
  21626. * @returns a string containing a new GUID
  21627. */
  21628. static RandomId(): string;
  21629. /** @hidden */
  21630. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21631. private static _CleanMatricesWeights;
  21632. /**
  21633. * Create a new geometry from persisted data (Using .babylon file format)
  21634. * @param parsedVertexData defines the persisted data
  21635. * @param scene defines the hosting scene
  21636. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21637. * @returns the new geometry object
  21638. */
  21639. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21640. }
  21641. }
  21642. declare module "babylonjs/Meshes/mesh.vertexData" {
  21643. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21644. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21645. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21646. import { Geometry } from "babylonjs/Meshes/geometry";
  21647. import { Mesh } from "babylonjs/Meshes/mesh";
  21648. /**
  21649. * Define an interface for all classes that will get and set the data on vertices
  21650. */
  21651. export interface IGetSetVerticesData {
  21652. /**
  21653. * Gets a boolean indicating if specific vertex data is present
  21654. * @param kind defines the vertex data kind to use
  21655. * @returns true is data kind is present
  21656. */
  21657. isVerticesDataPresent(kind: string): boolean;
  21658. /**
  21659. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21660. * @param kind defines the data kind (Position, normal, etc...)
  21661. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21662. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21663. * @returns a float array containing vertex data
  21664. */
  21665. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21666. /**
  21667. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21668. * @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.
  21669. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21670. * @returns the indices array or an empty array if the mesh has no geometry
  21671. */
  21672. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21673. /**
  21674. * Set specific vertex data
  21675. * @param kind defines the data kind (Position, normal, etc...)
  21676. * @param data defines the vertex data to use
  21677. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21678. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21679. */
  21680. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21681. /**
  21682. * Update a specific associated vertex buffer
  21683. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21684. * - VertexBuffer.PositionKind
  21685. * - VertexBuffer.UVKind
  21686. * - VertexBuffer.UV2Kind
  21687. * - VertexBuffer.UV3Kind
  21688. * - VertexBuffer.UV4Kind
  21689. * - VertexBuffer.UV5Kind
  21690. * - VertexBuffer.UV6Kind
  21691. * - VertexBuffer.ColorKind
  21692. * - VertexBuffer.MatricesIndicesKind
  21693. * - VertexBuffer.MatricesIndicesExtraKind
  21694. * - VertexBuffer.MatricesWeightsKind
  21695. * - VertexBuffer.MatricesWeightsExtraKind
  21696. * @param data defines the data source
  21697. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21698. * @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)
  21699. */
  21700. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21701. /**
  21702. * Creates a new index buffer
  21703. * @param indices defines the indices to store in the index buffer
  21704. * @param totalVertices defines the total number of vertices (could be null)
  21705. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21706. */
  21707. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21708. }
  21709. /**
  21710. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21711. */
  21712. export class VertexData {
  21713. /**
  21714. * Mesh side orientation : usually the external or front surface
  21715. */
  21716. static readonly FRONTSIDE: number;
  21717. /**
  21718. * Mesh side orientation : usually the internal or back surface
  21719. */
  21720. static readonly BACKSIDE: number;
  21721. /**
  21722. * Mesh side orientation : both internal and external or front and back surfaces
  21723. */
  21724. static readonly DOUBLESIDE: number;
  21725. /**
  21726. * Mesh side orientation : by default, `FRONTSIDE`
  21727. */
  21728. static readonly DEFAULTSIDE: number;
  21729. /**
  21730. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21731. */
  21732. positions: Nullable<FloatArray>;
  21733. /**
  21734. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21735. */
  21736. normals: Nullable<FloatArray>;
  21737. /**
  21738. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21739. */
  21740. tangents: Nullable<FloatArray>;
  21741. /**
  21742. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21743. */
  21744. uvs: Nullable<FloatArray>;
  21745. /**
  21746. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21747. */
  21748. uvs2: Nullable<FloatArray>;
  21749. /**
  21750. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21751. */
  21752. uvs3: Nullable<FloatArray>;
  21753. /**
  21754. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21755. */
  21756. uvs4: Nullable<FloatArray>;
  21757. /**
  21758. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21759. */
  21760. uvs5: Nullable<FloatArray>;
  21761. /**
  21762. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21763. */
  21764. uvs6: Nullable<FloatArray>;
  21765. /**
  21766. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21767. */
  21768. colors: Nullable<FloatArray>;
  21769. /**
  21770. * 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).
  21771. */
  21772. matricesIndices: Nullable<FloatArray>;
  21773. /**
  21774. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21775. */
  21776. matricesWeights: Nullable<FloatArray>;
  21777. /**
  21778. * An array extending the number of possible indices
  21779. */
  21780. matricesIndicesExtra: Nullable<FloatArray>;
  21781. /**
  21782. * An array extending the number of possible weights when the number of indices is extended
  21783. */
  21784. matricesWeightsExtra: Nullable<FloatArray>;
  21785. /**
  21786. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21787. */
  21788. indices: Nullable<IndicesArray>;
  21789. /**
  21790. * Uses the passed data array to set the set the values for the specified kind of data
  21791. * @param data a linear array of floating numbers
  21792. * @param kind the type of data that is being set, eg positions, colors etc
  21793. */
  21794. set(data: FloatArray, kind: string): void;
  21795. /**
  21796. * Associates the vertexData to the passed Mesh.
  21797. * Sets it as updatable or not (default `false`)
  21798. * @param mesh the mesh the vertexData is applied to
  21799. * @param updatable when used and having the value true allows new data to update the vertexData
  21800. * @returns the VertexData
  21801. */
  21802. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21803. /**
  21804. * Associates the vertexData to the passed Geometry.
  21805. * Sets it as updatable or not (default `false`)
  21806. * @param geometry the geometry the vertexData is applied to
  21807. * @param updatable when used and having the value true allows new data to update the vertexData
  21808. * @returns VertexData
  21809. */
  21810. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21811. /**
  21812. * Updates the associated mesh
  21813. * @param mesh the mesh to be updated
  21814. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21815. * @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
  21816. * @returns VertexData
  21817. */
  21818. updateMesh(mesh: Mesh): VertexData;
  21819. /**
  21820. * Updates the associated geometry
  21821. * @param geometry the geometry to be updated
  21822. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21823. * @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
  21824. * @returns VertexData.
  21825. */
  21826. updateGeometry(geometry: Geometry): VertexData;
  21827. private _applyTo;
  21828. private _update;
  21829. /**
  21830. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21831. * @param matrix the transforming matrix
  21832. * @returns the VertexData
  21833. */
  21834. transform(matrix: Matrix): VertexData;
  21835. /**
  21836. * Merges the passed VertexData into the current one
  21837. * @param other the VertexData to be merged into the current one
  21838. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21839. * @returns the modified VertexData
  21840. */
  21841. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21842. private _mergeElement;
  21843. private _validate;
  21844. /**
  21845. * Serializes the VertexData
  21846. * @returns a serialized object
  21847. */
  21848. serialize(): any;
  21849. /**
  21850. * Extracts the vertexData from a mesh
  21851. * @param mesh the mesh from which to extract the VertexData
  21852. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21853. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21854. * @returns the object VertexData associated to the passed mesh
  21855. */
  21856. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21857. /**
  21858. * Extracts the vertexData from the geometry
  21859. * @param geometry the geometry from which to extract the VertexData
  21860. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21861. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21862. * @returns the object VertexData associated to the passed mesh
  21863. */
  21864. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21865. private static _ExtractFrom;
  21866. /**
  21867. * Creates the VertexData for a Ribbon
  21868. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21869. * * pathArray array of paths, each of which an array of successive Vector3
  21870. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21871. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21872. * * 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
  21873. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21874. * * 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)
  21875. * * 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)
  21876. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21877. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21878. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21879. * @returns the VertexData of the ribbon
  21880. */
  21881. static CreateRibbon(options: {
  21882. pathArray: Vector3[][];
  21883. closeArray?: boolean;
  21884. closePath?: boolean;
  21885. offset?: number;
  21886. sideOrientation?: number;
  21887. frontUVs?: Vector4;
  21888. backUVs?: Vector4;
  21889. invertUV?: boolean;
  21890. uvs?: Vector2[];
  21891. colors?: Color4[];
  21892. }): VertexData;
  21893. /**
  21894. * Creates the VertexData for a box
  21895. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21896. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21897. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21898. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21899. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21900. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21901. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21902. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21903. * * 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)
  21904. * * 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)
  21905. * @returns the VertexData of the box
  21906. */
  21907. static CreateBox(options: {
  21908. size?: number;
  21909. width?: number;
  21910. height?: number;
  21911. depth?: number;
  21912. faceUV?: Vector4[];
  21913. faceColors?: Color4[];
  21914. sideOrientation?: number;
  21915. frontUVs?: Vector4;
  21916. backUVs?: Vector4;
  21917. }): VertexData;
  21918. /**
  21919. * Creates the VertexData for a tiled box
  21920. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21921. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21922. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21923. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21924. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21925. * @returns the VertexData of the box
  21926. */
  21927. static CreateTiledBox(options: {
  21928. pattern?: number;
  21929. width?: number;
  21930. height?: number;
  21931. depth?: number;
  21932. tileSize?: number;
  21933. tileWidth?: number;
  21934. tileHeight?: number;
  21935. alignHorizontal?: number;
  21936. alignVertical?: number;
  21937. faceUV?: Vector4[];
  21938. faceColors?: Color4[];
  21939. sideOrientation?: number;
  21940. }): VertexData;
  21941. /**
  21942. * Creates the VertexData for a tiled plane
  21943. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21944. * * pattern a limited pattern arrangement depending on the number
  21945. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21946. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21947. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21948. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21949. * * 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)
  21950. * * 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)
  21951. * @returns the VertexData of the tiled plane
  21952. */
  21953. static CreateTiledPlane(options: {
  21954. pattern?: number;
  21955. tileSize?: number;
  21956. tileWidth?: number;
  21957. tileHeight?: number;
  21958. size?: number;
  21959. width?: number;
  21960. height?: number;
  21961. alignHorizontal?: number;
  21962. alignVertical?: number;
  21963. sideOrientation?: number;
  21964. frontUVs?: Vector4;
  21965. backUVs?: Vector4;
  21966. }): VertexData;
  21967. /**
  21968. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21969. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21970. * * segments sets the number of horizontal strips optional, default 32
  21971. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21972. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21973. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21974. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21975. * * 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
  21976. * * 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
  21977. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21978. * * 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)
  21979. * * 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)
  21980. * @returns the VertexData of the ellipsoid
  21981. */
  21982. static CreateSphere(options: {
  21983. segments?: number;
  21984. diameter?: number;
  21985. diameterX?: number;
  21986. diameterY?: number;
  21987. diameterZ?: number;
  21988. arc?: number;
  21989. slice?: number;
  21990. sideOrientation?: number;
  21991. frontUVs?: Vector4;
  21992. backUVs?: Vector4;
  21993. }): VertexData;
  21994. /**
  21995. * Creates the VertexData for a cylinder, cone or prism
  21996. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21997. * * height sets the height (y direction) of the cylinder, optional, default 2
  21998. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21999. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22000. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22001. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22002. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22003. * * 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
  22004. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22005. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22006. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22007. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22008. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22009. * * 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)
  22010. * * 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)
  22011. * @returns the VertexData of the cylinder, cone or prism
  22012. */
  22013. static CreateCylinder(options: {
  22014. height?: number;
  22015. diameterTop?: number;
  22016. diameterBottom?: number;
  22017. diameter?: number;
  22018. tessellation?: number;
  22019. subdivisions?: number;
  22020. arc?: number;
  22021. faceColors?: Color4[];
  22022. faceUV?: Vector4[];
  22023. hasRings?: boolean;
  22024. enclose?: boolean;
  22025. sideOrientation?: number;
  22026. frontUVs?: Vector4;
  22027. backUVs?: Vector4;
  22028. }): VertexData;
  22029. /**
  22030. * Creates the VertexData for a torus
  22031. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22032. * * diameter the diameter of the torus, optional default 1
  22033. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22034. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22035. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22036. * * 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)
  22037. * * 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)
  22038. * @returns the VertexData of the torus
  22039. */
  22040. static CreateTorus(options: {
  22041. diameter?: number;
  22042. thickness?: number;
  22043. tessellation?: number;
  22044. sideOrientation?: number;
  22045. frontUVs?: Vector4;
  22046. backUVs?: Vector4;
  22047. }): VertexData;
  22048. /**
  22049. * Creates the VertexData of the LineSystem
  22050. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22051. * - lines an array of lines, each line being an array of successive Vector3
  22052. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22053. * @returns the VertexData of the LineSystem
  22054. */
  22055. static CreateLineSystem(options: {
  22056. lines: Vector3[][];
  22057. colors?: Nullable<Color4[][]>;
  22058. }): VertexData;
  22059. /**
  22060. * Create the VertexData for a DashedLines
  22061. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22062. * - points an array successive Vector3
  22063. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22064. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22065. * - dashNb the intended total number of dashes, optional, default 200
  22066. * @returns the VertexData for the DashedLines
  22067. */
  22068. static CreateDashedLines(options: {
  22069. points: Vector3[];
  22070. dashSize?: number;
  22071. gapSize?: number;
  22072. dashNb?: number;
  22073. }): VertexData;
  22074. /**
  22075. * Creates the VertexData for a Ground
  22076. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22077. * - width the width (x direction) of the ground, optional, default 1
  22078. * - height the height (z direction) of the ground, optional, default 1
  22079. * - subdivisions the number of subdivisions per side, optional, default 1
  22080. * @returns the VertexData of the Ground
  22081. */
  22082. static CreateGround(options: {
  22083. width?: number;
  22084. height?: number;
  22085. subdivisions?: number;
  22086. subdivisionsX?: number;
  22087. subdivisionsY?: number;
  22088. }): VertexData;
  22089. /**
  22090. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22091. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22092. * * xmin the ground minimum X coordinate, optional, default -1
  22093. * * zmin the ground minimum Z coordinate, optional, default -1
  22094. * * xmax the ground maximum X coordinate, optional, default 1
  22095. * * zmax the ground maximum Z coordinate, optional, default 1
  22096. * * 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}
  22097. * * 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}
  22098. * @returns the VertexData of the TiledGround
  22099. */
  22100. static CreateTiledGround(options: {
  22101. xmin: number;
  22102. zmin: number;
  22103. xmax: number;
  22104. zmax: number;
  22105. subdivisions?: {
  22106. w: number;
  22107. h: number;
  22108. };
  22109. precision?: {
  22110. w: number;
  22111. h: number;
  22112. };
  22113. }): VertexData;
  22114. /**
  22115. * Creates the VertexData of the Ground designed from a heightmap
  22116. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22117. * * width the width (x direction) of the ground
  22118. * * height the height (z direction) of the ground
  22119. * * subdivisions the number of subdivisions per side
  22120. * * minHeight the minimum altitude on the ground, optional, default 0
  22121. * * maxHeight the maximum altitude on the ground, optional default 1
  22122. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22123. * * buffer the array holding the image color data
  22124. * * bufferWidth the width of image
  22125. * * bufferHeight the height of image
  22126. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22127. * @returns the VertexData of the Ground designed from a heightmap
  22128. */
  22129. static CreateGroundFromHeightMap(options: {
  22130. width: number;
  22131. height: number;
  22132. subdivisions: number;
  22133. minHeight: number;
  22134. maxHeight: number;
  22135. colorFilter: Color3;
  22136. buffer: Uint8Array;
  22137. bufferWidth: number;
  22138. bufferHeight: number;
  22139. alphaFilter: number;
  22140. }): VertexData;
  22141. /**
  22142. * Creates the VertexData for a Plane
  22143. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22144. * * size sets the width and height of the plane to the value of size, optional default 1
  22145. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22146. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22147. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22148. * * 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)
  22149. * * 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)
  22150. * @returns the VertexData of the box
  22151. */
  22152. static CreatePlane(options: {
  22153. size?: number;
  22154. width?: number;
  22155. height?: number;
  22156. sideOrientation?: number;
  22157. frontUVs?: Vector4;
  22158. backUVs?: Vector4;
  22159. }): VertexData;
  22160. /**
  22161. * Creates the VertexData of the Disc or regular Polygon
  22162. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22163. * * radius the radius of the disc, optional default 0.5
  22164. * * tessellation the number of polygon sides, optional, default 64
  22165. * * 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
  22166. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22167. * * 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)
  22168. * * 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)
  22169. * @returns the VertexData of the box
  22170. */
  22171. static CreateDisc(options: {
  22172. radius?: number;
  22173. tessellation?: number;
  22174. arc?: number;
  22175. sideOrientation?: number;
  22176. frontUVs?: Vector4;
  22177. backUVs?: Vector4;
  22178. }): VertexData;
  22179. /**
  22180. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22181. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22182. * @param polygon a mesh built from polygonTriangulation.build()
  22183. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22184. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22185. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22186. * @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)
  22187. * @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)
  22188. * @returns the VertexData of the Polygon
  22189. */
  22190. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22191. /**
  22192. * Creates the VertexData of the IcoSphere
  22193. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22194. * * radius the radius of the IcoSphere, optional default 1
  22195. * * radiusX allows stretching in the x direction, optional, default radius
  22196. * * radiusY allows stretching in the y direction, optional, default radius
  22197. * * radiusZ allows stretching in the z direction, optional, default radius
  22198. * * flat when true creates a flat shaded mesh, optional, default true
  22199. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22200. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22201. * * 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)
  22202. * * 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)
  22203. * @returns the VertexData of the IcoSphere
  22204. */
  22205. static CreateIcoSphere(options: {
  22206. radius?: number;
  22207. radiusX?: number;
  22208. radiusY?: number;
  22209. radiusZ?: number;
  22210. flat?: boolean;
  22211. subdivisions?: number;
  22212. sideOrientation?: number;
  22213. frontUVs?: Vector4;
  22214. backUVs?: Vector4;
  22215. }): VertexData;
  22216. /**
  22217. * Creates the VertexData for a Polyhedron
  22218. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22219. * * type provided types are:
  22220. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22221. * * 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)
  22222. * * size the size of the IcoSphere, optional default 1
  22223. * * sizeX allows stretching in the x direction, optional, default size
  22224. * * sizeY allows stretching in the y direction, optional, default size
  22225. * * sizeZ allows stretching in the z direction, optional, default size
  22226. * * 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
  22227. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22228. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22229. * * flat when true creates a flat shaded mesh, optional, default true
  22230. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22231. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22232. * * 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)
  22233. * * 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)
  22234. * @returns the VertexData of the Polyhedron
  22235. */
  22236. static CreatePolyhedron(options: {
  22237. type?: number;
  22238. size?: number;
  22239. sizeX?: number;
  22240. sizeY?: number;
  22241. sizeZ?: number;
  22242. custom?: any;
  22243. faceUV?: Vector4[];
  22244. faceColors?: Color4[];
  22245. flat?: boolean;
  22246. sideOrientation?: number;
  22247. frontUVs?: Vector4;
  22248. backUVs?: Vector4;
  22249. }): VertexData;
  22250. /**
  22251. * Creates the VertexData for a TorusKnot
  22252. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22253. * * radius the radius of the torus knot, optional, default 2
  22254. * * tube the thickness of the tube, optional, default 0.5
  22255. * * radialSegments the number of sides on each tube segments, optional, default 32
  22256. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22257. * * p the number of windings around the z axis, optional, default 2
  22258. * * q the number of windings around the x axis, optional, default 3
  22259. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22260. * * 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)
  22261. * * 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)
  22262. * @returns the VertexData of the Torus Knot
  22263. */
  22264. static CreateTorusKnot(options: {
  22265. radius?: number;
  22266. tube?: number;
  22267. radialSegments?: number;
  22268. tubularSegments?: number;
  22269. p?: number;
  22270. q?: number;
  22271. sideOrientation?: number;
  22272. frontUVs?: Vector4;
  22273. backUVs?: Vector4;
  22274. }): VertexData;
  22275. /**
  22276. * Compute normals for given positions and indices
  22277. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22278. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22279. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22280. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22281. * * facetNormals : optional array of facet normals (vector3)
  22282. * * facetPositions : optional array of facet positions (vector3)
  22283. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22284. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22285. * * bInfo : optional bounding info, required for facetPartitioning computation
  22286. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22287. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22288. * * useRightHandedSystem: optional boolean to for right handed system computation
  22289. * * depthSort : optional boolean to enable the facet depth sort computation
  22290. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22291. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22292. */
  22293. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22294. facetNormals?: any;
  22295. facetPositions?: any;
  22296. facetPartitioning?: any;
  22297. ratio?: number;
  22298. bInfo?: any;
  22299. bbSize?: Vector3;
  22300. subDiv?: any;
  22301. useRightHandedSystem?: boolean;
  22302. depthSort?: boolean;
  22303. distanceTo?: Vector3;
  22304. depthSortedFacets?: any;
  22305. }): void;
  22306. /** @hidden */
  22307. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22308. /**
  22309. * Applies VertexData created from the imported parameters to the geometry
  22310. * @param parsedVertexData the parsed data from an imported file
  22311. * @param geometry the geometry to apply the VertexData to
  22312. */
  22313. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22314. }
  22315. }
  22316. declare module "babylonjs/Morph/morphTarget" {
  22317. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22318. import { Observable } from "babylonjs/Misc/observable";
  22319. import { Nullable, FloatArray } from "babylonjs/types";
  22320. import { Scene } from "babylonjs/scene";
  22321. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22322. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22323. /**
  22324. * Defines a target to use with MorphTargetManager
  22325. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22326. */
  22327. export class MorphTarget implements IAnimatable {
  22328. /** defines the name of the target */
  22329. name: string;
  22330. /**
  22331. * Gets or sets the list of animations
  22332. */
  22333. animations: import("babylonjs/Animations/animation").Animation[];
  22334. private _scene;
  22335. private _positions;
  22336. private _normals;
  22337. private _tangents;
  22338. private _uvs;
  22339. private _influence;
  22340. /**
  22341. * Observable raised when the influence changes
  22342. */
  22343. onInfluenceChanged: Observable<boolean>;
  22344. /** @hidden */
  22345. _onDataLayoutChanged: Observable<void>;
  22346. /**
  22347. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22348. */
  22349. influence: number;
  22350. /**
  22351. * Gets or sets the id of the morph Target
  22352. */
  22353. id: string;
  22354. private _animationPropertiesOverride;
  22355. /**
  22356. * Gets or sets the animation properties override
  22357. */
  22358. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22359. /**
  22360. * Creates a new MorphTarget
  22361. * @param name defines the name of the target
  22362. * @param influence defines the influence to use
  22363. * @param scene defines the scene the morphtarget belongs to
  22364. */
  22365. constructor(
  22366. /** defines the name of the target */
  22367. name: string, influence?: number, scene?: Nullable<Scene>);
  22368. /**
  22369. * Gets a boolean defining if the target contains position data
  22370. */
  22371. readonly hasPositions: boolean;
  22372. /**
  22373. * Gets a boolean defining if the target contains normal data
  22374. */
  22375. readonly hasNormals: boolean;
  22376. /**
  22377. * Gets a boolean defining if the target contains tangent data
  22378. */
  22379. readonly hasTangents: boolean;
  22380. /**
  22381. * Gets a boolean defining if the target contains texture coordinates data
  22382. */
  22383. readonly hasUVs: boolean;
  22384. /**
  22385. * Affects position data to this target
  22386. * @param data defines the position data to use
  22387. */
  22388. setPositions(data: Nullable<FloatArray>): void;
  22389. /**
  22390. * Gets the position data stored in this target
  22391. * @returns a FloatArray containing the position data (or null if not present)
  22392. */
  22393. getPositions(): Nullable<FloatArray>;
  22394. /**
  22395. * Affects normal data to this target
  22396. * @param data defines the normal data to use
  22397. */
  22398. setNormals(data: Nullable<FloatArray>): void;
  22399. /**
  22400. * Gets the normal data stored in this target
  22401. * @returns a FloatArray containing the normal data (or null if not present)
  22402. */
  22403. getNormals(): Nullable<FloatArray>;
  22404. /**
  22405. * Affects tangent data to this target
  22406. * @param data defines the tangent data to use
  22407. */
  22408. setTangents(data: Nullable<FloatArray>): void;
  22409. /**
  22410. * Gets the tangent data stored in this target
  22411. * @returns a FloatArray containing the tangent data (or null if not present)
  22412. */
  22413. getTangents(): Nullable<FloatArray>;
  22414. /**
  22415. * Affects texture coordinates data to this target
  22416. * @param data defines the texture coordinates data to use
  22417. */
  22418. setUVs(data: Nullable<FloatArray>): void;
  22419. /**
  22420. * Gets the texture coordinates data stored in this target
  22421. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22422. */
  22423. getUVs(): Nullable<FloatArray>;
  22424. /**
  22425. * Serializes the current target into a Serialization object
  22426. * @returns the serialized object
  22427. */
  22428. serialize(): any;
  22429. /**
  22430. * Returns the string "MorphTarget"
  22431. * @returns "MorphTarget"
  22432. */
  22433. getClassName(): string;
  22434. /**
  22435. * Creates a new target from serialized data
  22436. * @param serializationObject defines the serialized data to use
  22437. * @returns a new MorphTarget
  22438. */
  22439. static Parse(serializationObject: any): MorphTarget;
  22440. /**
  22441. * Creates a MorphTarget from mesh data
  22442. * @param mesh defines the source mesh
  22443. * @param name defines the name to use for the new target
  22444. * @param influence defines the influence to attach to the target
  22445. * @returns a new MorphTarget
  22446. */
  22447. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22448. }
  22449. }
  22450. declare module "babylonjs/Morph/morphTargetManager" {
  22451. import { Nullable } from "babylonjs/types";
  22452. import { Scene } from "babylonjs/scene";
  22453. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22454. /**
  22455. * This class is used to deform meshes using morphing between different targets
  22456. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22457. */
  22458. export class MorphTargetManager {
  22459. private _targets;
  22460. private _targetInfluenceChangedObservers;
  22461. private _targetDataLayoutChangedObservers;
  22462. private _activeTargets;
  22463. private _scene;
  22464. private _influences;
  22465. private _supportsNormals;
  22466. private _supportsTangents;
  22467. private _supportsUVs;
  22468. private _vertexCount;
  22469. private _uniqueId;
  22470. private _tempInfluences;
  22471. /**
  22472. * Gets or sets a boolean indicating if normals must be morphed
  22473. */
  22474. enableNormalMorphing: boolean;
  22475. /**
  22476. * Gets or sets a boolean indicating if tangents must be morphed
  22477. */
  22478. enableTangentMorphing: boolean;
  22479. /**
  22480. * Gets or sets a boolean indicating if UV must be morphed
  22481. */
  22482. enableUVMorphing: boolean;
  22483. /**
  22484. * Creates a new MorphTargetManager
  22485. * @param scene defines the current scene
  22486. */
  22487. constructor(scene?: Nullable<Scene>);
  22488. /**
  22489. * Gets the unique ID of this manager
  22490. */
  22491. readonly uniqueId: number;
  22492. /**
  22493. * Gets the number of vertices handled by this manager
  22494. */
  22495. readonly vertexCount: number;
  22496. /**
  22497. * Gets a boolean indicating if this manager supports morphing of normals
  22498. */
  22499. readonly supportsNormals: boolean;
  22500. /**
  22501. * Gets a boolean indicating if this manager supports morphing of tangents
  22502. */
  22503. readonly supportsTangents: boolean;
  22504. /**
  22505. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22506. */
  22507. readonly supportsUVs: boolean;
  22508. /**
  22509. * Gets the number of targets stored in this manager
  22510. */
  22511. readonly numTargets: number;
  22512. /**
  22513. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22514. */
  22515. readonly numInfluencers: number;
  22516. /**
  22517. * Gets the list of influences (one per target)
  22518. */
  22519. readonly influences: Float32Array;
  22520. /**
  22521. * Gets the active target at specified index. An active target is a target with an influence > 0
  22522. * @param index defines the index to check
  22523. * @returns the requested target
  22524. */
  22525. getActiveTarget(index: number): MorphTarget;
  22526. /**
  22527. * Gets the target at specified index
  22528. * @param index defines the index to check
  22529. * @returns the requested target
  22530. */
  22531. getTarget(index: number): MorphTarget;
  22532. /**
  22533. * Add a new target to this manager
  22534. * @param target defines the target to add
  22535. */
  22536. addTarget(target: MorphTarget): void;
  22537. /**
  22538. * Removes a target from the manager
  22539. * @param target defines the target to remove
  22540. */
  22541. removeTarget(target: MorphTarget): void;
  22542. /**
  22543. * Serializes the current manager into a Serialization object
  22544. * @returns the serialized object
  22545. */
  22546. serialize(): any;
  22547. private _syncActiveTargets;
  22548. /**
  22549. * Syncrhonize the targets with all the meshes using this morph target manager
  22550. */
  22551. synchronize(): void;
  22552. /**
  22553. * Creates a new MorphTargetManager from serialized data
  22554. * @param serializationObject defines the serialized data
  22555. * @param scene defines the hosting scene
  22556. * @returns the new MorphTargetManager
  22557. */
  22558. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22559. }
  22560. }
  22561. declare module "babylonjs/Meshes/meshLODLevel" {
  22562. import { Mesh } from "babylonjs/Meshes/mesh";
  22563. import { Nullable } from "babylonjs/types";
  22564. /**
  22565. * Class used to represent a specific level of detail of a mesh
  22566. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22567. */
  22568. export class MeshLODLevel {
  22569. /** Defines the distance where this level should star being displayed */
  22570. distance: number;
  22571. /** Defines the mesh to use to render this level */
  22572. mesh: Nullable<Mesh>;
  22573. /**
  22574. * Creates a new LOD level
  22575. * @param distance defines the distance where this level should star being displayed
  22576. * @param mesh defines the mesh to use to render this level
  22577. */
  22578. constructor(
  22579. /** Defines the distance where this level should star being displayed */
  22580. distance: number,
  22581. /** Defines the mesh to use to render this level */
  22582. mesh: Nullable<Mesh>);
  22583. }
  22584. }
  22585. declare module "babylonjs/Meshes/groundMesh" {
  22586. import { Scene } from "babylonjs/scene";
  22587. import { Vector3 } from "babylonjs/Maths/math.vector";
  22588. import { Mesh } from "babylonjs/Meshes/mesh";
  22589. /**
  22590. * Mesh representing the gorund
  22591. */
  22592. export class GroundMesh extends Mesh {
  22593. /** If octree should be generated */
  22594. generateOctree: boolean;
  22595. private _heightQuads;
  22596. /** @hidden */
  22597. _subdivisionsX: number;
  22598. /** @hidden */
  22599. _subdivisionsY: number;
  22600. /** @hidden */
  22601. _width: number;
  22602. /** @hidden */
  22603. _height: number;
  22604. /** @hidden */
  22605. _minX: number;
  22606. /** @hidden */
  22607. _maxX: number;
  22608. /** @hidden */
  22609. _minZ: number;
  22610. /** @hidden */
  22611. _maxZ: number;
  22612. constructor(name: string, scene: Scene);
  22613. /**
  22614. * "GroundMesh"
  22615. * @returns "GroundMesh"
  22616. */
  22617. getClassName(): string;
  22618. /**
  22619. * The minimum of x and y subdivisions
  22620. */
  22621. readonly subdivisions: number;
  22622. /**
  22623. * X subdivisions
  22624. */
  22625. readonly subdivisionsX: number;
  22626. /**
  22627. * Y subdivisions
  22628. */
  22629. readonly subdivisionsY: number;
  22630. /**
  22631. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22632. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22633. * @param chunksCount the number of subdivisions for x and y
  22634. * @param octreeBlocksSize (Default: 32)
  22635. */
  22636. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22637. /**
  22638. * Returns a height (y) value in the Worl system :
  22639. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22640. * @param x x coordinate
  22641. * @param z z coordinate
  22642. * @returns the ground y position if (x, z) are outside the ground surface.
  22643. */
  22644. getHeightAtCoordinates(x: number, z: number): number;
  22645. /**
  22646. * Returns a normalized vector (Vector3) orthogonal to the ground
  22647. * at the ground coordinates (x, z) expressed in the World system.
  22648. * @param x x coordinate
  22649. * @param z z coordinate
  22650. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22651. */
  22652. getNormalAtCoordinates(x: number, z: number): Vector3;
  22653. /**
  22654. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22655. * at the ground coordinates (x, z) expressed in the World system.
  22656. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22657. * @param x x coordinate
  22658. * @param z z coordinate
  22659. * @param ref vector to store the result
  22660. * @returns the GroundMesh.
  22661. */
  22662. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22663. /**
  22664. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22665. * if the ground has been updated.
  22666. * This can be used in the render loop.
  22667. * @returns the GroundMesh.
  22668. */
  22669. updateCoordinateHeights(): GroundMesh;
  22670. private _getFacetAt;
  22671. private _initHeightQuads;
  22672. private _computeHeightQuads;
  22673. /**
  22674. * Serializes this ground mesh
  22675. * @param serializationObject object to write serialization to
  22676. */
  22677. serialize(serializationObject: any): void;
  22678. /**
  22679. * Parses a serialized ground mesh
  22680. * @param parsedMesh the serialized mesh
  22681. * @param scene the scene to create the ground mesh in
  22682. * @returns the created ground mesh
  22683. */
  22684. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22685. }
  22686. }
  22687. declare module "babylonjs/Physics/physicsJoint" {
  22688. import { Vector3 } from "babylonjs/Maths/math.vector";
  22689. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  22690. /**
  22691. * Interface for Physics-Joint data
  22692. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22693. */
  22694. export interface PhysicsJointData {
  22695. /**
  22696. * The main pivot of the joint
  22697. */
  22698. mainPivot?: Vector3;
  22699. /**
  22700. * The connected pivot of the joint
  22701. */
  22702. connectedPivot?: Vector3;
  22703. /**
  22704. * The main axis of the joint
  22705. */
  22706. mainAxis?: Vector3;
  22707. /**
  22708. * The connected axis of the joint
  22709. */
  22710. connectedAxis?: Vector3;
  22711. /**
  22712. * The collision of the joint
  22713. */
  22714. collision?: boolean;
  22715. /**
  22716. * Native Oimo/Cannon/Energy data
  22717. */
  22718. nativeParams?: any;
  22719. }
  22720. /**
  22721. * This is a holder class for the physics joint created by the physics plugin
  22722. * It holds a set of functions to control the underlying joint
  22723. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22724. */
  22725. export class PhysicsJoint {
  22726. /**
  22727. * The type of the physics joint
  22728. */
  22729. type: number;
  22730. /**
  22731. * The data for the physics joint
  22732. */
  22733. jointData: PhysicsJointData;
  22734. private _physicsJoint;
  22735. protected _physicsPlugin: IPhysicsEnginePlugin;
  22736. /**
  22737. * Initializes the physics joint
  22738. * @param type The type of the physics joint
  22739. * @param jointData The data for the physics joint
  22740. */
  22741. constructor(
  22742. /**
  22743. * The type of the physics joint
  22744. */
  22745. type: number,
  22746. /**
  22747. * The data for the physics joint
  22748. */
  22749. jointData: PhysicsJointData);
  22750. /**
  22751. * Gets the physics joint
  22752. */
  22753. /**
  22754. * Sets the physics joint
  22755. */
  22756. physicsJoint: any;
  22757. /**
  22758. * Sets the physics plugin
  22759. */
  22760. physicsPlugin: IPhysicsEnginePlugin;
  22761. /**
  22762. * Execute a function that is physics-plugin specific.
  22763. * @param {Function} func the function that will be executed.
  22764. * It accepts two parameters: the physics world and the physics joint
  22765. */
  22766. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22767. /**
  22768. * Distance-Joint type
  22769. */
  22770. static DistanceJoint: number;
  22771. /**
  22772. * Hinge-Joint type
  22773. */
  22774. static HingeJoint: number;
  22775. /**
  22776. * Ball-and-Socket joint type
  22777. */
  22778. static BallAndSocketJoint: number;
  22779. /**
  22780. * Wheel-Joint type
  22781. */
  22782. static WheelJoint: number;
  22783. /**
  22784. * Slider-Joint type
  22785. */
  22786. static SliderJoint: number;
  22787. /**
  22788. * Prismatic-Joint type
  22789. */
  22790. static PrismaticJoint: number;
  22791. /**
  22792. * Universal-Joint type
  22793. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22794. */
  22795. static UniversalJoint: number;
  22796. /**
  22797. * Hinge-Joint 2 type
  22798. */
  22799. static Hinge2Joint: number;
  22800. /**
  22801. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22802. */
  22803. static PointToPointJoint: number;
  22804. /**
  22805. * Spring-Joint type
  22806. */
  22807. static SpringJoint: number;
  22808. /**
  22809. * Lock-Joint type
  22810. */
  22811. static LockJoint: number;
  22812. }
  22813. /**
  22814. * A class representing a physics distance joint
  22815. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22816. */
  22817. export class DistanceJoint extends PhysicsJoint {
  22818. /**
  22819. *
  22820. * @param jointData The data for the Distance-Joint
  22821. */
  22822. constructor(jointData: DistanceJointData);
  22823. /**
  22824. * Update the predefined distance.
  22825. * @param maxDistance The maximum preferred distance
  22826. * @param minDistance The minimum preferred distance
  22827. */
  22828. updateDistance(maxDistance: number, minDistance?: number): void;
  22829. }
  22830. /**
  22831. * Represents a Motor-Enabled Joint
  22832. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22833. */
  22834. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22835. /**
  22836. * Initializes the Motor-Enabled Joint
  22837. * @param type The type of the joint
  22838. * @param jointData The physica joint data for the joint
  22839. */
  22840. constructor(type: number, jointData: PhysicsJointData);
  22841. /**
  22842. * Set the motor values.
  22843. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22844. * @param force the force to apply
  22845. * @param maxForce max force for this motor.
  22846. */
  22847. setMotor(force?: number, maxForce?: number): void;
  22848. /**
  22849. * Set the motor's limits.
  22850. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22851. * @param upperLimit The upper limit of the motor
  22852. * @param lowerLimit The lower limit of the motor
  22853. */
  22854. setLimit(upperLimit: number, lowerLimit?: number): void;
  22855. }
  22856. /**
  22857. * This class represents a single physics Hinge-Joint
  22858. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22859. */
  22860. export class HingeJoint extends MotorEnabledJoint {
  22861. /**
  22862. * Initializes the Hinge-Joint
  22863. * @param jointData The joint data for the Hinge-Joint
  22864. */
  22865. constructor(jointData: PhysicsJointData);
  22866. /**
  22867. * Set the motor values.
  22868. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22869. * @param {number} force the force to apply
  22870. * @param {number} maxForce max force for this motor.
  22871. */
  22872. setMotor(force?: number, maxForce?: number): void;
  22873. /**
  22874. * Set the motor's limits.
  22875. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22876. * @param upperLimit The upper limit of the motor
  22877. * @param lowerLimit The lower limit of the motor
  22878. */
  22879. setLimit(upperLimit: number, lowerLimit?: number): void;
  22880. }
  22881. /**
  22882. * This class represents a dual hinge physics joint (same as wheel joint)
  22883. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22884. */
  22885. export class Hinge2Joint extends MotorEnabledJoint {
  22886. /**
  22887. * Initializes the Hinge2-Joint
  22888. * @param jointData The joint data for the Hinge2-Joint
  22889. */
  22890. constructor(jointData: PhysicsJointData);
  22891. /**
  22892. * Set the motor values.
  22893. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22894. * @param {number} targetSpeed the speed the motor is to reach
  22895. * @param {number} maxForce max force for this motor.
  22896. * @param {motorIndex} the motor's index, 0 or 1.
  22897. */
  22898. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22899. /**
  22900. * Set the motor limits.
  22901. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22902. * @param {number} upperLimit the upper limit
  22903. * @param {number} lowerLimit lower limit
  22904. * @param {motorIndex} the motor's index, 0 or 1.
  22905. */
  22906. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22907. }
  22908. /**
  22909. * Interface for a motor enabled joint
  22910. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22911. */
  22912. export interface IMotorEnabledJoint {
  22913. /**
  22914. * Physics joint
  22915. */
  22916. physicsJoint: any;
  22917. /**
  22918. * Sets the motor of the motor-enabled joint
  22919. * @param force The force of the motor
  22920. * @param maxForce The maximum force of the motor
  22921. * @param motorIndex The index of the motor
  22922. */
  22923. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22924. /**
  22925. * Sets the limit of the motor
  22926. * @param upperLimit The upper limit of the motor
  22927. * @param lowerLimit The lower limit of the motor
  22928. * @param motorIndex The index of the motor
  22929. */
  22930. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22931. }
  22932. /**
  22933. * Joint data for a Distance-Joint
  22934. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22935. */
  22936. export interface DistanceJointData extends PhysicsJointData {
  22937. /**
  22938. * Max distance the 2 joint objects can be apart
  22939. */
  22940. maxDistance: number;
  22941. }
  22942. /**
  22943. * Joint data from a spring joint
  22944. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22945. */
  22946. export interface SpringJointData extends PhysicsJointData {
  22947. /**
  22948. * Length of the spring
  22949. */
  22950. length: number;
  22951. /**
  22952. * Stiffness of the spring
  22953. */
  22954. stiffness: number;
  22955. /**
  22956. * Damping of the spring
  22957. */
  22958. damping: number;
  22959. /** this callback will be called when applying the force to the impostors. */
  22960. forceApplicationCallback: () => void;
  22961. }
  22962. }
  22963. declare module "babylonjs/Physics/physicsRaycastResult" {
  22964. import { Vector3 } from "babylonjs/Maths/math.vector";
  22965. /**
  22966. * Holds the data for the raycast result
  22967. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22968. */
  22969. export class PhysicsRaycastResult {
  22970. private _hasHit;
  22971. private _hitDistance;
  22972. private _hitNormalWorld;
  22973. private _hitPointWorld;
  22974. private _rayFromWorld;
  22975. private _rayToWorld;
  22976. /**
  22977. * Gets if there was a hit
  22978. */
  22979. readonly hasHit: boolean;
  22980. /**
  22981. * Gets the distance from the hit
  22982. */
  22983. readonly hitDistance: number;
  22984. /**
  22985. * Gets the hit normal/direction in the world
  22986. */
  22987. readonly hitNormalWorld: Vector3;
  22988. /**
  22989. * Gets the hit point in the world
  22990. */
  22991. readonly hitPointWorld: Vector3;
  22992. /**
  22993. * Gets the ray "start point" of the ray in the world
  22994. */
  22995. readonly rayFromWorld: Vector3;
  22996. /**
  22997. * Gets the ray "end point" of the ray in the world
  22998. */
  22999. readonly rayToWorld: Vector3;
  23000. /**
  23001. * Sets the hit data (normal & point in world space)
  23002. * @param hitNormalWorld defines the normal in world space
  23003. * @param hitPointWorld defines the point in world space
  23004. */
  23005. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23006. /**
  23007. * Sets the distance from the start point to the hit point
  23008. * @param distance
  23009. */
  23010. setHitDistance(distance: number): void;
  23011. /**
  23012. * Calculates the distance manually
  23013. */
  23014. calculateHitDistance(): void;
  23015. /**
  23016. * Resets all the values to default
  23017. * @param from The from point on world space
  23018. * @param to The to point on world space
  23019. */
  23020. reset(from?: Vector3, to?: Vector3): void;
  23021. }
  23022. /**
  23023. * Interface for the size containing width and height
  23024. */
  23025. interface IXYZ {
  23026. /**
  23027. * X
  23028. */
  23029. x: number;
  23030. /**
  23031. * Y
  23032. */
  23033. y: number;
  23034. /**
  23035. * Z
  23036. */
  23037. z: number;
  23038. }
  23039. }
  23040. declare module "babylonjs/Physics/IPhysicsEngine" {
  23041. import { Nullable } from "babylonjs/types";
  23042. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23043. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23044. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23045. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23046. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23047. /**
  23048. * Interface used to describe a physics joint
  23049. */
  23050. export interface PhysicsImpostorJoint {
  23051. /** Defines the main impostor to which the joint is linked */
  23052. mainImpostor: PhysicsImpostor;
  23053. /** Defines the impostor that is connected to the main impostor using this joint */
  23054. connectedImpostor: PhysicsImpostor;
  23055. /** Defines the joint itself */
  23056. joint: PhysicsJoint;
  23057. }
  23058. /** @hidden */
  23059. export interface IPhysicsEnginePlugin {
  23060. world: any;
  23061. name: string;
  23062. setGravity(gravity: Vector3): void;
  23063. setTimeStep(timeStep: number): void;
  23064. getTimeStep(): number;
  23065. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23066. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23067. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23068. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23069. removePhysicsBody(impostor: PhysicsImpostor): void;
  23070. generateJoint(joint: PhysicsImpostorJoint): void;
  23071. removeJoint(joint: PhysicsImpostorJoint): void;
  23072. isSupported(): boolean;
  23073. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23074. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23075. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23076. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23077. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23078. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23079. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23080. getBodyMass(impostor: PhysicsImpostor): number;
  23081. getBodyFriction(impostor: PhysicsImpostor): number;
  23082. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23083. getBodyRestitution(impostor: PhysicsImpostor): number;
  23084. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23085. getBodyPressure?(impostor: PhysicsImpostor): number;
  23086. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23087. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23088. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23089. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23090. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23091. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23092. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23093. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23094. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23095. sleepBody(impostor: PhysicsImpostor): void;
  23096. wakeUpBody(impostor: PhysicsImpostor): void;
  23097. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23098. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23099. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23100. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23101. getRadius(impostor: PhysicsImpostor): number;
  23102. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23103. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23104. dispose(): void;
  23105. }
  23106. /**
  23107. * Interface used to define a physics engine
  23108. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23109. */
  23110. export interface IPhysicsEngine {
  23111. /**
  23112. * Gets the gravity vector used by the simulation
  23113. */
  23114. gravity: Vector3;
  23115. /**
  23116. * Sets the gravity vector used by the simulation
  23117. * @param gravity defines the gravity vector to use
  23118. */
  23119. setGravity(gravity: Vector3): void;
  23120. /**
  23121. * Set the time step of the physics engine.
  23122. * Default is 1/60.
  23123. * To slow it down, enter 1/600 for example.
  23124. * To speed it up, 1/30
  23125. * @param newTimeStep the new timestep to apply to this world.
  23126. */
  23127. setTimeStep(newTimeStep: number): void;
  23128. /**
  23129. * Get the time step of the physics engine.
  23130. * @returns the current time step
  23131. */
  23132. getTimeStep(): number;
  23133. /**
  23134. * Release all resources
  23135. */
  23136. dispose(): void;
  23137. /**
  23138. * Gets the name of the current physics plugin
  23139. * @returns the name of the plugin
  23140. */
  23141. getPhysicsPluginName(): string;
  23142. /**
  23143. * Adding a new impostor for the impostor tracking.
  23144. * This will be done by the impostor itself.
  23145. * @param impostor the impostor to add
  23146. */
  23147. addImpostor(impostor: PhysicsImpostor): void;
  23148. /**
  23149. * Remove an impostor from the engine.
  23150. * This impostor and its mesh will not longer be updated by the physics engine.
  23151. * @param impostor the impostor to remove
  23152. */
  23153. removeImpostor(impostor: PhysicsImpostor): void;
  23154. /**
  23155. * Add a joint to the physics engine
  23156. * @param mainImpostor defines the main impostor to which the joint is added.
  23157. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23158. * @param joint defines the joint that will connect both impostors.
  23159. */
  23160. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23161. /**
  23162. * Removes a joint from the simulation
  23163. * @param mainImpostor defines the impostor used with the joint
  23164. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23165. * @param joint defines the joint to remove
  23166. */
  23167. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23168. /**
  23169. * Gets the current plugin used to run the simulation
  23170. * @returns current plugin
  23171. */
  23172. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23173. /**
  23174. * Gets the list of physic impostors
  23175. * @returns an array of PhysicsImpostor
  23176. */
  23177. getImpostors(): Array<PhysicsImpostor>;
  23178. /**
  23179. * Gets the impostor for a physics enabled object
  23180. * @param object defines the object impersonated by the impostor
  23181. * @returns the PhysicsImpostor or null if not found
  23182. */
  23183. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23184. /**
  23185. * Gets the impostor for a physics body object
  23186. * @param body defines physics body used by the impostor
  23187. * @returns the PhysicsImpostor or null if not found
  23188. */
  23189. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23190. /**
  23191. * Does a raycast in the physics world
  23192. * @param from when should the ray start?
  23193. * @param to when should the ray end?
  23194. * @returns PhysicsRaycastResult
  23195. */
  23196. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23197. /**
  23198. * Called by the scene. No need to call it.
  23199. * @param delta defines the timespam between frames
  23200. */
  23201. _step(delta: number): void;
  23202. }
  23203. }
  23204. declare module "babylonjs/Physics/physicsImpostor" {
  23205. import { Nullable, IndicesArray } from "babylonjs/types";
  23206. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23207. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23208. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23209. import { Scene } from "babylonjs/scene";
  23210. import { Bone } from "babylonjs/Bones/bone";
  23211. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23212. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23213. import { Space } from "babylonjs/Maths/math.axis";
  23214. /**
  23215. * The interface for the physics imposter parameters
  23216. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23217. */
  23218. export interface PhysicsImpostorParameters {
  23219. /**
  23220. * The mass of the physics imposter
  23221. */
  23222. mass: number;
  23223. /**
  23224. * The friction of the physics imposter
  23225. */
  23226. friction?: number;
  23227. /**
  23228. * The coefficient of restitution of the physics imposter
  23229. */
  23230. restitution?: number;
  23231. /**
  23232. * The native options of the physics imposter
  23233. */
  23234. nativeOptions?: any;
  23235. /**
  23236. * Specifies if the parent should be ignored
  23237. */
  23238. ignoreParent?: boolean;
  23239. /**
  23240. * Specifies if bi-directional transformations should be disabled
  23241. */
  23242. disableBidirectionalTransformation?: boolean;
  23243. /**
  23244. * The pressure inside the physics imposter, soft object only
  23245. */
  23246. pressure?: number;
  23247. /**
  23248. * The stiffness the physics imposter, soft object only
  23249. */
  23250. stiffness?: number;
  23251. /**
  23252. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23253. */
  23254. velocityIterations?: number;
  23255. /**
  23256. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23257. */
  23258. positionIterations?: number;
  23259. /**
  23260. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23261. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23262. * Add to fix multiple points
  23263. */
  23264. fixedPoints?: number;
  23265. /**
  23266. * The collision margin around a soft object
  23267. */
  23268. margin?: number;
  23269. /**
  23270. * The collision margin around a soft object
  23271. */
  23272. damping?: number;
  23273. /**
  23274. * The path for a rope based on an extrusion
  23275. */
  23276. path?: any;
  23277. /**
  23278. * The shape of an extrusion used for a rope based on an extrusion
  23279. */
  23280. shape?: any;
  23281. }
  23282. /**
  23283. * Interface for a physics-enabled object
  23284. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23285. */
  23286. export interface IPhysicsEnabledObject {
  23287. /**
  23288. * The position of the physics-enabled object
  23289. */
  23290. position: Vector3;
  23291. /**
  23292. * The rotation of the physics-enabled object
  23293. */
  23294. rotationQuaternion: Nullable<Quaternion>;
  23295. /**
  23296. * The scale of the physics-enabled object
  23297. */
  23298. scaling: Vector3;
  23299. /**
  23300. * The rotation of the physics-enabled object
  23301. */
  23302. rotation?: Vector3;
  23303. /**
  23304. * The parent of the physics-enabled object
  23305. */
  23306. parent?: any;
  23307. /**
  23308. * The bounding info of the physics-enabled object
  23309. * @returns The bounding info of the physics-enabled object
  23310. */
  23311. getBoundingInfo(): BoundingInfo;
  23312. /**
  23313. * Computes the world matrix
  23314. * @param force Specifies if the world matrix should be computed by force
  23315. * @returns A world matrix
  23316. */
  23317. computeWorldMatrix(force: boolean): Matrix;
  23318. /**
  23319. * Gets the world matrix
  23320. * @returns A world matrix
  23321. */
  23322. getWorldMatrix?(): Matrix;
  23323. /**
  23324. * Gets the child meshes
  23325. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23326. * @returns An array of abstract meshes
  23327. */
  23328. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23329. /**
  23330. * Gets the vertex data
  23331. * @param kind The type of vertex data
  23332. * @returns A nullable array of numbers, or a float32 array
  23333. */
  23334. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23335. /**
  23336. * Gets the indices from the mesh
  23337. * @returns A nullable array of index arrays
  23338. */
  23339. getIndices?(): Nullable<IndicesArray>;
  23340. /**
  23341. * Gets the scene from the mesh
  23342. * @returns the indices array or null
  23343. */
  23344. getScene?(): Scene;
  23345. /**
  23346. * Gets the absolute position from the mesh
  23347. * @returns the absolute position
  23348. */
  23349. getAbsolutePosition(): Vector3;
  23350. /**
  23351. * Gets the absolute pivot point from the mesh
  23352. * @returns the absolute pivot point
  23353. */
  23354. getAbsolutePivotPoint(): Vector3;
  23355. /**
  23356. * Rotates the mesh
  23357. * @param axis The axis of rotation
  23358. * @param amount The amount of rotation
  23359. * @param space The space of the rotation
  23360. * @returns The rotation transform node
  23361. */
  23362. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23363. /**
  23364. * Translates the mesh
  23365. * @param axis The axis of translation
  23366. * @param distance The distance of translation
  23367. * @param space The space of the translation
  23368. * @returns The transform node
  23369. */
  23370. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23371. /**
  23372. * Sets the absolute position of the mesh
  23373. * @param absolutePosition The absolute position of the mesh
  23374. * @returns The transform node
  23375. */
  23376. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23377. /**
  23378. * Gets the class name of the mesh
  23379. * @returns The class name
  23380. */
  23381. getClassName(): string;
  23382. }
  23383. /**
  23384. * Represents a physics imposter
  23385. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23386. */
  23387. export class PhysicsImpostor {
  23388. /**
  23389. * The physics-enabled object used as the physics imposter
  23390. */
  23391. object: IPhysicsEnabledObject;
  23392. /**
  23393. * The type of the physics imposter
  23394. */
  23395. type: number;
  23396. private _options;
  23397. private _scene?;
  23398. /**
  23399. * The default object size of the imposter
  23400. */
  23401. static DEFAULT_OBJECT_SIZE: Vector3;
  23402. /**
  23403. * The identity quaternion of the imposter
  23404. */
  23405. static IDENTITY_QUATERNION: Quaternion;
  23406. /** @hidden */
  23407. _pluginData: any;
  23408. private _physicsEngine;
  23409. private _physicsBody;
  23410. private _bodyUpdateRequired;
  23411. private _onBeforePhysicsStepCallbacks;
  23412. private _onAfterPhysicsStepCallbacks;
  23413. /** @hidden */
  23414. _onPhysicsCollideCallbacks: Array<{
  23415. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23416. otherImpostors: Array<PhysicsImpostor>;
  23417. }>;
  23418. private _deltaPosition;
  23419. private _deltaRotation;
  23420. private _deltaRotationConjugated;
  23421. /** @hidden */
  23422. _isFromLine: boolean;
  23423. private _parent;
  23424. private _isDisposed;
  23425. private static _tmpVecs;
  23426. private static _tmpQuat;
  23427. /**
  23428. * Specifies if the physics imposter is disposed
  23429. */
  23430. readonly isDisposed: boolean;
  23431. /**
  23432. * Gets the mass of the physics imposter
  23433. */
  23434. mass: number;
  23435. /**
  23436. * Gets the coefficient of friction
  23437. */
  23438. /**
  23439. * Sets the coefficient of friction
  23440. */
  23441. friction: number;
  23442. /**
  23443. * Gets the coefficient of restitution
  23444. */
  23445. /**
  23446. * Sets the coefficient of restitution
  23447. */
  23448. restitution: number;
  23449. /**
  23450. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23451. */
  23452. /**
  23453. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23454. */
  23455. pressure: number;
  23456. /**
  23457. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23458. */
  23459. /**
  23460. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23461. */
  23462. stiffness: number;
  23463. /**
  23464. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23465. */
  23466. /**
  23467. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23468. */
  23469. velocityIterations: number;
  23470. /**
  23471. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23472. */
  23473. /**
  23474. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23475. */
  23476. positionIterations: number;
  23477. /**
  23478. * The unique id of the physics imposter
  23479. * set by the physics engine when adding this impostor to the array
  23480. */
  23481. uniqueId: number;
  23482. /**
  23483. * @hidden
  23484. */
  23485. soft: boolean;
  23486. /**
  23487. * @hidden
  23488. */
  23489. segments: number;
  23490. private _joints;
  23491. /**
  23492. * Initializes the physics imposter
  23493. * @param object The physics-enabled object used as the physics imposter
  23494. * @param type The type of the physics imposter
  23495. * @param _options The options for the physics imposter
  23496. * @param _scene The Babylon scene
  23497. */
  23498. constructor(
  23499. /**
  23500. * The physics-enabled object used as the physics imposter
  23501. */
  23502. object: IPhysicsEnabledObject,
  23503. /**
  23504. * The type of the physics imposter
  23505. */
  23506. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23507. /**
  23508. * This function will completly initialize this impostor.
  23509. * It will create a new body - but only if this mesh has no parent.
  23510. * If it has, this impostor will not be used other than to define the impostor
  23511. * of the child mesh.
  23512. * @hidden
  23513. */
  23514. _init(): void;
  23515. private _getPhysicsParent;
  23516. /**
  23517. * Should a new body be generated.
  23518. * @returns boolean specifying if body initialization is required
  23519. */
  23520. isBodyInitRequired(): boolean;
  23521. /**
  23522. * Sets the updated scaling
  23523. * @param updated Specifies if the scaling is updated
  23524. */
  23525. setScalingUpdated(): void;
  23526. /**
  23527. * Force a regeneration of this or the parent's impostor's body.
  23528. * Use under cautious - This will remove all joints already implemented.
  23529. */
  23530. forceUpdate(): void;
  23531. /**
  23532. * Gets the body that holds this impostor. Either its own, or its parent.
  23533. */
  23534. /**
  23535. * Set the physics body. Used mainly by the physics engine/plugin
  23536. */
  23537. physicsBody: any;
  23538. /**
  23539. * Get the parent of the physics imposter
  23540. * @returns Physics imposter or null
  23541. */
  23542. /**
  23543. * Sets the parent of the physics imposter
  23544. */
  23545. parent: Nullable<PhysicsImpostor>;
  23546. /**
  23547. * Resets the update flags
  23548. */
  23549. resetUpdateFlags(): void;
  23550. /**
  23551. * Gets the object extend size
  23552. * @returns the object extend size
  23553. */
  23554. getObjectExtendSize(): Vector3;
  23555. /**
  23556. * Gets the object center
  23557. * @returns The object center
  23558. */
  23559. getObjectCenter(): Vector3;
  23560. /**
  23561. * Get a specific parametes from the options parameter
  23562. * @param paramName The object parameter name
  23563. * @returns The object parameter
  23564. */
  23565. getParam(paramName: string): any;
  23566. /**
  23567. * Sets a specific parameter in the options given to the physics plugin
  23568. * @param paramName The parameter name
  23569. * @param value The value of the parameter
  23570. */
  23571. setParam(paramName: string, value: number): void;
  23572. /**
  23573. * Specifically change the body's mass option. Won't recreate the physics body object
  23574. * @param mass The mass of the physics imposter
  23575. */
  23576. setMass(mass: number): void;
  23577. /**
  23578. * Gets the linear velocity
  23579. * @returns linear velocity or null
  23580. */
  23581. getLinearVelocity(): Nullable<Vector3>;
  23582. /**
  23583. * Sets the linear velocity
  23584. * @param velocity linear velocity or null
  23585. */
  23586. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23587. /**
  23588. * Gets the angular velocity
  23589. * @returns angular velocity or null
  23590. */
  23591. getAngularVelocity(): Nullable<Vector3>;
  23592. /**
  23593. * Sets the angular velocity
  23594. * @param velocity The velocity or null
  23595. */
  23596. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23597. /**
  23598. * Execute a function with the physics plugin native code
  23599. * Provide a function the will have two variables - the world object and the physics body object
  23600. * @param func The function to execute with the physics plugin native code
  23601. */
  23602. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23603. /**
  23604. * Register a function that will be executed before the physics world is stepping forward
  23605. * @param func The function to execute before the physics world is stepped forward
  23606. */
  23607. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23608. /**
  23609. * Unregister a function that will be executed before the physics world is stepping forward
  23610. * @param func The function to execute before the physics world is stepped forward
  23611. */
  23612. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23613. /**
  23614. * Register a function that will be executed after the physics step
  23615. * @param func The function to execute after physics step
  23616. */
  23617. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23618. /**
  23619. * Unregisters a function that will be executed after the physics step
  23620. * @param func The function to execute after physics step
  23621. */
  23622. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23623. /**
  23624. * register a function that will be executed when this impostor collides against a different body
  23625. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23626. * @param func Callback that is executed on collision
  23627. */
  23628. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23629. /**
  23630. * Unregisters the physics imposter on contact
  23631. * @param collideAgainst The physics object to collide against
  23632. * @param func Callback to execute on collision
  23633. */
  23634. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23635. private _tmpQuat;
  23636. private _tmpQuat2;
  23637. /**
  23638. * Get the parent rotation
  23639. * @returns The parent rotation
  23640. */
  23641. getParentsRotation(): Quaternion;
  23642. /**
  23643. * this function is executed by the physics engine.
  23644. */
  23645. beforeStep: () => void;
  23646. /**
  23647. * this function is executed by the physics engine
  23648. */
  23649. afterStep: () => void;
  23650. /**
  23651. * Legacy collision detection event support
  23652. */
  23653. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23654. /**
  23655. * event and body object due to cannon's event-based architecture.
  23656. */
  23657. onCollide: (e: {
  23658. body: any;
  23659. }) => void;
  23660. /**
  23661. * Apply a force
  23662. * @param force The force to apply
  23663. * @param contactPoint The contact point for the force
  23664. * @returns The physics imposter
  23665. */
  23666. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23667. /**
  23668. * Apply an impulse
  23669. * @param force The impulse force
  23670. * @param contactPoint The contact point for the impulse force
  23671. * @returns The physics imposter
  23672. */
  23673. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23674. /**
  23675. * A help function to create a joint
  23676. * @param otherImpostor A physics imposter used to create a joint
  23677. * @param jointType The type of joint
  23678. * @param jointData The data for the joint
  23679. * @returns The physics imposter
  23680. */
  23681. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23682. /**
  23683. * Add a joint to this impostor with a different impostor
  23684. * @param otherImpostor A physics imposter used to add a joint
  23685. * @param joint The joint to add
  23686. * @returns The physics imposter
  23687. */
  23688. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23689. /**
  23690. * Add an anchor to a cloth impostor
  23691. * @param otherImpostor rigid impostor to anchor to
  23692. * @param width ratio across width from 0 to 1
  23693. * @param height ratio up height from 0 to 1
  23694. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23695. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23696. * @returns impostor the soft imposter
  23697. */
  23698. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23699. /**
  23700. * Add a hook to a rope impostor
  23701. * @param otherImpostor rigid impostor to anchor to
  23702. * @param length ratio across rope from 0 to 1
  23703. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23704. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23705. * @returns impostor the rope imposter
  23706. */
  23707. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23708. /**
  23709. * Will keep this body still, in a sleep mode.
  23710. * @returns the physics imposter
  23711. */
  23712. sleep(): PhysicsImpostor;
  23713. /**
  23714. * Wake the body up.
  23715. * @returns The physics imposter
  23716. */
  23717. wakeUp(): PhysicsImpostor;
  23718. /**
  23719. * Clones the physics imposter
  23720. * @param newObject The physics imposter clones to this physics-enabled object
  23721. * @returns A nullable physics imposter
  23722. */
  23723. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23724. /**
  23725. * Disposes the physics imposter
  23726. */
  23727. dispose(): void;
  23728. /**
  23729. * Sets the delta position
  23730. * @param position The delta position amount
  23731. */
  23732. setDeltaPosition(position: Vector3): void;
  23733. /**
  23734. * Sets the delta rotation
  23735. * @param rotation The delta rotation amount
  23736. */
  23737. setDeltaRotation(rotation: Quaternion): void;
  23738. /**
  23739. * Gets the box size of the physics imposter and stores the result in the input parameter
  23740. * @param result Stores the box size
  23741. * @returns The physics imposter
  23742. */
  23743. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23744. /**
  23745. * Gets the radius of the physics imposter
  23746. * @returns Radius of the physics imposter
  23747. */
  23748. getRadius(): number;
  23749. /**
  23750. * Sync a bone with this impostor
  23751. * @param bone The bone to sync to the impostor.
  23752. * @param boneMesh The mesh that the bone is influencing.
  23753. * @param jointPivot The pivot of the joint / bone in local space.
  23754. * @param distToJoint Optional distance from the impostor to the joint.
  23755. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23756. */
  23757. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23758. /**
  23759. * Sync impostor to a bone
  23760. * @param bone The bone that the impostor will be synced to.
  23761. * @param boneMesh The mesh that the bone is influencing.
  23762. * @param jointPivot The pivot of the joint / bone in local space.
  23763. * @param distToJoint Optional distance from the impostor to the joint.
  23764. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23765. * @param boneAxis Optional vector3 axis the bone is aligned with
  23766. */
  23767. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23768. /**
  23769. * No-Imposter type
  23770. */
  23771. static NoImpostor: number;
  23772. /**
  23773. * Sphere-Imposter type
  23774. */
  23775. static SphereImpostor: number;
  23776. /**
  23777. * Box-Imposter type
  23778. */
  23779. static BoxImpostor: number;
  23780. /**
  23781. * Plane-Imposter type
  23782. */
  23783. static PlaneImpostor: number;
  23784. /**
  23785. * Mesh-imposter type
  23786. */
  23787. static MeshImpostor: number;
  23788. /**
  23789. * Capsule-Impostor type (Ammo.js plugin only)
  23790. */
  23791. static CapsuleImpostor: number;
  23792. /**
  23793. * Cylinder-Imposter type
  23794. */
  23795. static CylinderImpostor: number;
  23796. /**
  23797. * Particle-Imposter type
  23798. */
  23799. static ParticleImpostor: number;
  23800. /**
  23801. * Heightmap-Imposter type
  23802. */
  23803. static HeightmapImpostor: number;
  23804. /**
  23805. * ConvexHull-Impostor type (Ammo.js plugin only)
  23806. */
  23807. static ConvexHullImpostor: number;
  23808. /**
  23809. * Rope-Imposter type
  23810. */
  23811. static RopeImpostor: number;
  23812. /**
  23813. * Cloth-Imposter type
  23814. */
  23815. static ClothImpostor: number;
  23816. /**
  23817. * Softbody-Imposter type
  23818. */
  23819. static SoftbodyImpostor: number;
  23820. }
  23821. }
  23822. declare module "babylonjs/Meshes/mesh" {
  23823. import { Observable } from "babylonjs/Misc/observable";
  23824. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23825. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23826. import { Camera } from "babylonjs/Cameras/camera";
  23827. import { Scene } from "babylonjs/scene";
  23828. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  23829. import { Color4 } from "babylonjs/Maths/math.color";
  23830. import { Engine } from "babylonjs/Engines/engine";
  23831. import { Node } from "babylonjs/node";
  23832. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23833. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23834. import { Buffer } from "babylonjs/Meshes/buffer";
  23835. import { Geometry } from "babylonjs/Meshes/geometry";
  23836. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23837. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23838. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  23839. import { Effect } from "babylonjs/Materials/effect";
  23840. import { Material } from "babylonjs/Materials/material";
  23841. import { Skeleton } from "babylonjs/Bones/skeleton";
  23842. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  23843. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  23844. import { Path3D } from "babylonjs/Maths/math.path";
  23845. import { Plane } from "babylonjs/Maths/math.plane";
  23846. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  23847. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  23848. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  23849. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23850. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  23851. /**
  23852. * @hidden
  23853. **/
  23854. export class _CreationDataStorage {
  23855. closePath?: boolean;
  23856. closeArray?: boolean;
  23857. idx: number[];
  23858. dashSize: number;
  23859. gapSize: number;
  23860. path3D: Path3D;
  23861. pathArray: Vector3[][];
  23862. arc: number;
  23863. radius: number;
  23864. cap: number;
  23865. tessellation: number;
  23866. }
  23867. /**
  23868. * @hidden
  23869. **/
  23870. class _InstanceDataStorage {
  23871. visibleInstances: any;
  23872. batchCache: _InstancesBatch;
  23873. instancesBufferSize: number;
  23874. instancesBuffer: Nullable<Buffer>;
  23875. instancesData: Float32Array;
  23876. overridenInstanceCount: number;
  23877. isFrozen: boolean;
  23878. previousBatch: Nullable<_InstancesBatch>;
  23879. hardwareInstancedRendering: boolean;
  23880. sideOrientation: number;
  23881. }
  23882. /**
  23883. * @hidden
  23884. **/
  23885. export class _InstancesBatch {
  23886. mustReturn: boolean;
  23887. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  23888. renderSelf: boolean[];
  23889. hardwareInstancedRendering: boolean[];
  23890. }
  23891. /**
  23892. * Class used to represent renderable models
  23893. */
  23894. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23895. /**
  23896. * Mesh side orientation : usually the external or front surface
  23897. */
  23898. static readonly FRONTSIDE: number;
  23899. /**
  23900. * Mesh side orientation : usually the internal or back surface
  23901. */
  23902. static readonly BACKSIDE: number;
  23903. /**
  23904. * Mesh side orientation : both internal and external or front and back surfaces
  23905. */
  23906. static readonly DOUBLESIDE: number;
  23907. /**
  23908. * Mesh side orientation : by default, `FRONTSIDE`
  23909. */
  23910. static readonly DEFAULTSIDE: number;
  23911. /**
  23912. * Mesh cap setting : no cap
  23913. */
  23914. static readonly NO_CAP: number;
  23915. /**
  23916. * Mesh cap setting : one cap at the beginning of the mesh
  23917. */
  23918. static readonly CAP_START: number;
  23919. /**
  23920. * Mesh cap setting : one cap at the end of the mesh
  23921. */
  23922. static readonly CAP_END: number;
  23923. /**
  23924. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23925. */
  23926. static readonly CAP_ALL: number;
  23927. /**
  23928. * Mesh pattern setting : no flip or rotate
  23929. */
  23930. static readonly NO_FLIP: number;
  23931. /**
  23932. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23933. */
  23934. static readonly FLIP_TILE: number;
  23935. /**
  23936. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23937. */
  23938. static readonly ROTATE_TILE: number;
  23939. /**
  23940. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23941. */
  23942. static readonly FLIP_ROW: number;
  23943. /**
  23944. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23945. */
  23946. static readonly ROTATE_ROW: number;
  23947. /**
  23948. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23949. */
  23950. static readonly FLIP_N_ROTATE_TILE: number;
  23951. /**
  23952. * Mesh pattern setting : rotate pattern and rotate
  23953. */
  23954. static readonly FLIP_N_ROTATE_ROW: number;
  23955. /**
  23956. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23957. */
  23958. static readonly CENTER: number;
  23959. /**
  23960. * Mesh tile positioning : part tiles on left
  23961. */
  23962. static readonly LEFT: number;
  23963. /**
  23964. * Mesh tile positioning : part tiles on right
  23965. */
  23966. static readonly RIGHT: number;
  23967. /**
  23968. * Mesh tile positioning : part tiles on top
  23969. */
  23970. static readonly TOP: number;
  23971. /**
  23972. * Mesh tile positioning : part tiles on bottom
  23973. */
  23974. static readonly BOTTOM: number;
  23975. /**
  23976. * Gets the default side orientation.
  23977. * @param orientation the orientation to value to attempt to get
  23978. * @returns the default orientation
  23979. * @hidden
  23980. */
  23981. static _GetDefaultSideOrientation(orientation?: number): number;
  23982. private _internalMeshDataInfo;
  23983. /**
  23984. * An event triggered before rendering the mesh
  23985. */
  23986. readonly onBeforeRenderObservable: Observable<Mesh>;
  23987. /**
  23988. * An event triggered before binding the mesh
  23989. */
  23990. readonly onBeforeBindObservable: Observable<Mesh>;
  23991. /**
  23992. * An event triggered after rendering the mesh
  23993. */
  23994. readonly onAfterRenderObservable: Observable<Mesh>;
  23995. /**
  23996. * An event triggered before drawing the mesh
  23997. */
  23998. readonly onBeforeDrawObservable: Observable<Mesh>;
  23999. private _onBeforeDrawObserver;
  24000. /**
  24001. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24002. */
  24003. onBeforeDraw: () => void;
  24004. /**
  24005. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24006. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24007. */
  24008. delayLoadState: number;
  24009. /**
  24010. * Gets the list of instances created from this mesh
  24011. * it is not supposed to be modified manually.
  24012. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24013. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24014. */
  24015. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24016. /**
  24017. * Gets the file containing delay loading data for this mesh
  24018. */
  24019. delayLoadingFile: string;
  24020. /** @hidden */
  24021. _binaryInfo: any;
  24022. /**
  24023. * User defined function used to change how LOD level selection is done
  24024. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24025. */
  24026. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24027. /**
  24028. * Gets or sets the morph target manager
  24029. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24030. */
  24031. morphTargetManager: Nullable<MorphTargetManager>;
  24032. /** @hidden */
  24033. _creationDataStorage: Nullable<_CreationDataStorage>;
  24034. /** @hidden */
  24035. _geometry: Nullable<Geometry>;
  24036. /** @hidden */
  24037. _delayInfo: Array<string>;
  24038. /** @hidden */
  24039. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24040. /** @hidden */
  24041. _instanceDataStorage: _InstanceDataStorage;
  24042. private _effectiveMaterial;
  24043. /** @hidden */
  24044. _shouldGenerateFlatShading: boolean;
  24045. /** @hidden */
  24046. _originalBuilderSideOrientation: number;
  24047. /**
  24048. * Use this property to change the original side orientation defined at construction time
  24049. */
  24050. overrideMaterialSideOrientation: Nullable<number>;
  24051. /**
  24052. * Gets the source mesh (the one used to clone this one from)
  24053. */
  24054. readonly source: Nullable<Mesh>;
  24055. /**
  24056. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24057. */
  24058. isUnIndexed: boolean;
  24059. /**
  24060. * @constructor
  24061. * @param name The value used by scene.getMeshByName() to do a lookup.
  24062. * @param scene The scene to add this mesh to.
  24063. * @param parent The parent of this mesh, if it has one
  24064. * @param source An optional Mesh from which geometry is shared, cloned.
  24065. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24066. * When false, achieved by calling a clone(), also passing False.
  24067. * This will make creation of children, recursive.
  24068. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24069. */
  24070. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24071. /**
  24072. * Gets the class name
  24073. * @returns the string "Mesh".
  24074. */
  24075. getClassName(): string;
  24076. /** @hidden */
  24077. readonly _isMesh: boolean;
  24078. /**
  24079. * Returns a description of this mesh
  24080. * @param fullDetails define if full details about this mesh must be used
  24081. * @returns a descriptive string representing this mesh
  24082. */
  24083. toString(fullDetails?: boolean): string;
  24084. /** @hidden */
  24085. _unBindEffect(): void;
  24086. /**
  24087. * Gets a boolean indicating if this mesh has LOD
  24088. */
  24089. readonly hasLODLevels: boolean;
  24090. /**
  24091. * Gets the list of MeshLODLevel associated with the current mesh
  24092. * @returns an array of MeshLODLevel
  24093. */
  24094. getLODLevels(): MeshLODLevel[];
  24095. private _sortLODLevels;
  24096. /**
  24097. * Add a mesh as LOD level triggered at the given distance.
  24098. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24099. * @param distance The distance from the center of the object to show this level
  24100. * @param mesh The mesh to be added as LOD level (can be null)
  24101. * @return This mesh (for chaining)
  24102. */
  24103. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24104. /**
  24105. * Returns the LOD level mesh at the passed distance or null if not found.
  24106. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24107. * @param distance The distance from the center of the object to show this level
  24108. * @returns a Mesh or `null`
  24109. */
  24110. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24111. /**
  24112. * Remove a mesh from the LOD array
  24113. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24114. * @param mesh defines the mesh to be removed
  24115. * @return This mesh (for chaining)
  24116. */
  24117. removeLODLevel(mesh: Mesh): Mesh;
  24118. /**
  24119. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24120. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24121. * @param camera defines the camera to use to compute distance
  24122. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24123. * @return This mesh (for chaining)
  24124. */
  24125. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24126. /**
  24127. * Gets the mesh internal Geometry object
  24128. */
  24129. readonly geometry: Nullable<Geometry>;
  24130. /**
  24131. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24132. * @returns the total number of vertices
  24133. */
  24134. getTotalVertices(): number;
  24135. /**
  24136. * Returns the content of an associated vertex buffer
  24137. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24138. * - VertexBuffer.PositionKind
  24139. * - VertexBuffer.UVKind
  24140. * - VertexBuffer.UV2Kind
  24141. * - VertexBuffer.UV3Kind
  24142. * - VertexBuffer.UV4Kind
  24143. * - VertexBuffer.UV5Kind
  24144. * - VertexBuffer.UV6Kind
  24145. * - VertexBuffer.ColorKind
  24146. * - VertexBuffer.MatricesIndicesKind
  24147. * - VertexBuffer.MatricesIndicesExtraKind
  24148. * - VertexBuffer.MatricesWeightsKind
  24149. * - VertexBuffer.MatricesWeightsExtraKind
  24150. * @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
  24151. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24152. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24153. */
  24154. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24155. /**
  24156. * Returns the mesh VertexBuffer object from the requested `kind`
  24157. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24158. * - VertexBuffer.PositionKind
  24159. * - VertexBuffer.NormalKind
  24160. * - VertexBuffer.UVKind
  24161. * - VertexBuffer.UV2Kind
  24162. * - VertexBuffer.UV3Kind
  24163. * - VertexBuffer.UV4Kind
  24164. * - VertexBuffer.UV5Kind
  24165. * - VertexBuffer.UV6Kind
  24166. * - VertexBuffer.ColorKind
  24167. * - VertexBuffer.MatricesIndicesKind
  24168. * - VertexBuffer.MatricesIndicesExtraKind
  24169. * - VertexBuffer.MatricesWeightsKind
  24170. * - VertexBuffer.MatricesWeightsExtraKind
  24171. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24172. */
  24173. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24174. /**
  24175. * Tests if a specific vertex buffer is associated with this mesh
  24176. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24177. * - VertexBuffer.PositionKind
  24178. * - VertexBuffer.NormalKind
  24179. * - VertexBuffer.UVKind
  24180. * - VertexBuffer.UV2Kind
  24181. * - VertexBuffer.UV3Kind
  24182. * - VertexBuffer.UV4Kind
  24183. * - VertexBuffer.UV5Kind
  24184. * - VertexBuffer.UV6Kind
  24185. * - VertexBuffer.ColorKind
  24186. * - VertexBuffer.MatricesIndicesKind
  24187. * - VertexBuffer.MatricesIndicesExtraKind
  24188. * - VertexBuffer.MatricesWeightsKind
  24189. * - VertexBuffer.MatricesWeightsExtraKind
  24190. * @returns a boolean
  24191. */
  24192. isVerticesDataPresent(kind: string): boolean;
  24193. /**
  24194. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24195. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24196. * - VertexBuffer.PositionKind
  24197. * - VertexBuffer.UVKind
  24198. * - VertexBuffer.UV2Kind
  24199. * - VertexBuffer.UV3Kind
  24200. * - VertexBuffer.UV4Kind
  24201. * - VertexBuffer.UV5Kind
  24202. * - VertexBuffer.UV6Kind
  24203. * - VertexBuffer.ColorKind
  24204. * - VertexBuffer.MatricesIndicesKind
  24205. * - VertexBuffer.MatricesIndicesExtraKind
  24206. * - VertexBuffer.MatricesWeightsKind
  24207. * - VertexBuffer.MatricesWeightsExtraKind
  24208. * @returns a boolean
  24209. */
  24210. isVertexBufferUpdatable(kind: string): boolean;
  24211. /**
  24212. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24213. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24214. * - VertexBuffer.PositionKind
  24215. * - VertexBuffer.NormalKind
  24216. * - VertexBuffer.UVKind
  24217. * - VertexBuffer.UV2Kind
  24218. * - VertexBuffer.UV3Kind
  24219. * - VertexBuffer.UV4Kind
  24220. * - VertexBuffer.UV5Kind
  24221. * - VertexBuffer.UV6Kind
  24222. * - VertexBuffer.ColorKind
  24223. * - VertexBuffer.MatricesIndicesKind
  24224. * - VertexBuffer.MatricesIndicesExtraKind
  24225. * - VertexBuffer.MatricesWeightsKind
  24226. * - VertexBuffer.MatricesWeightsExtraKind
  24227. * @returns an array of strings
  24228. */
  24229. getVerticesDataKinds(): string[];
  24230. /**
  24231. * Returns a positive integer : the total number of indices in this mesh geometry.
  24232. * @returns the numner of indices or zero if the mesh has no geometry.
  24233. */
  24234. getTotalIndices(): number;
  24235. /**
  24236. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24237. * @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.
  24238. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24239. * @returns the indices array or an empty array if the mesh has no geometry
  24240. */
  24241. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24242. readonly isBlocked: boolean;
  24243. /**
  24244. * Determine if the current mesh is ready to be rendered
  24245. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24246. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24247. * @returns true if all associated assets are ready (material, textures, shaders)
  24248. */
  24249. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24250. /**
  24251. * 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.
  24252. */
  24253. readonly areNormalsFrozen: boolean;
  24254. /**
  24255. * 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.
  24256. * @returns the current mesh
  24257. */
  24258. freezeNormals(): Mesh;
  24259. /**
  24260. * 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
  24261. * @returns the current mesh
  24262. */
  24263. unfreezeNormals(): Mesh;
  24264. /**
  24265. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24266. */
  24267. overridenInstanceCount: number;
  24268. /** @hidden */
  24269. _preActivate(): Mesh;
  24270. /** @hidden */
  24271. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24272. /** @hidden */
  24273. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24274. /**
  24275. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24276. * This means the mesh underlying bounding box and sphere are recomputed.
  24277. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24278. * @returns the current mesh
  24279. */
  24280. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24281. /** @hidden */
  24282. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24283. /**
  24284. * This function will subdivide the mesh into multiple submeshes
  24285. * @param count defines the expected number of submeshes
  24286. */
  24287. subdivide(count: number): void;
  24288. /**
  24289. * Copy a FloatArray into a specific associated vertex buffer
  24290. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24291. * - VertexBuffer.PositionKind
  24292. * - VertexBuffer.UVKind
  24293. * - VertexBuffer.UV2Kind
  24294. * - VertexBuffer.UV3Kind
  24295. * - VertexBuffer.UV4Kind
  24296. * - VertexBuffer.UV5Kind
  24297. * - VertexBuffer.UV6Kind
  24298. * - VertexBuffer.ColorKind
  24299. * - VertexBuffer.MatricesIndicesKind
  24300. * - VertexBuffer.MatricesIndicesExtraKind
  24301. * - VertexBuffer.MatricesWeightsKind
  24302. * - VertexBuffer.MatricesWeightsExtraKind
  24303. * @param data defines the data source
  24304. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24305. * @param stride defines the data stride size (can be null)
  24306. * @returns the current mesh
  24307. */
  24308. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  24309. /**
  24310. * Flags an associated vertex buffer as updatable
  24311. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24312. * - VertexBuffer.PositionKind
  24313. * - VertexBuffer.UVKind
  24314. * - VertexBuffer.UV2Kind
  24315. * - VertexBuffer.UV3Kind
  24316. * - VertexBuffer.UV4Kind
  24317. * - VertexBuffer.UV5Kind
  24318. * - VertexBuffer.UV6Kind
  24319. * - VertexBuffer.ColorKind
  24320. * - VertexBuffer.MatricesIndicesKind
  24321. * - VertexBuffer.MatricesIndicesExtraKind
  24322. * - VertexBuffer.MatricesWeightsKind
  24323. * - VertexBuffer.MatricesWeightsExtraKind
  24324. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24325. */
  24326. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24327. /**
  24328. * Sets the mesh global Vertex Buffer
  24329. * @param buffer defines the buffer to use
  24330. * @returns the current mesh
  24331. */
  24332. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24333. /**
  24334. * Update a specific associated vertex buffer
  24335. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24336. * - VertexBuffer.PositionKind
  24337. * - VertexBuffer.UVKind
  24338. * - VertexBuffer.UV2Kind
  24339. * - VertexBuffer.UV3Kind
  24340. * - VertexBuffer.UV4Kind
  24341. * - VertexBuffer.UV5Kind
  24342. * - VertexBuffer.UV6Kind
  24343. * - VertexBuffer.ColorKind
  24344. * - VertexBuffer.MatricesIndicesKind
  24345. * - VertexBuffer.MatricesIndicesExtraKind
  24346. * - VertexBuffer.MatricesWeightsKind
  24347. * - VertexBuffer.MatricesWeightsExtraKind
  24348. * @param data defines the data source
  24349. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24350. * @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)
  24351. * @returns the current mesh
  24352. */
  24353. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  24354. /**
  24355. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24356. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24357. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24358. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24359. * @returns the current mesh
  24360. */
  24361. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24362. /**
  24363. * Creates a un-shared specific occurence of the geometry for the mesh.
  24364. * @returns the current mesh
  24365. */
  24366. makeGeometryUnique(): Mesh;
  24367. /**
  24368. * Set the index buffer of this mesh
  24369. * @param indices defines the source data
  24370. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24371. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24372. * @returns the current mesh
  24373. */
  24374. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  24375. /**
  24376. * Update the current index buffer
  24377. * @param indices defines the source data
  24378. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24379. * @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)
  24380. * @returns the current mesh
  24381. */
  24382. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  24383. /**
  24384. * Invert the geometry to move from a right handed system to a left handed one.
  24385. * @returns the current mesh
  24386. */
  24387. toLeftHanded(): Mesh;
  24388. /** @hidden */
  24389. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24390. /** @hidden */
  24391. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24392. /**
  24393. * Registers for this mesh a javascript function called just before the rendering process
  24394. * @param func defines the function to call before rendering this mesh
  24395. * @returns the current mesh
  24396. */
  24397. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24398. /**
  24399. * Disposes a previously registered javascript function called before the rendering
  24400. * @param func defines the function to remove
  24401. * @returns the current mesh
  24402. */
  24403. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24404. /**
  24405. * Registers for this mesh a javascript function called just after the rendering is complete
  24406. * @param func defines the function to call after rendering this mesh
  24407. * @returns the current mesh
  24408. */
  24409. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24410. /**
  24411. * Disposes a previously registered javascript function called after the rendering.
  24412. * @param func defines the function to remove
  24413. * @returns the current mesh
  24414. */
  24415. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24416. /** @hidden */
  24417. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24418. /** @hidden */
  24419. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24420. /** @hidden */
  24421. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24422. /** @hidden */
  24423. _rebuild(): void;
  24424. /** @hidden */
  24425. _freeze(): void;
  24426. /** @hidden */
  24427. _unFreeze(): void;
  24428. /**
  24429. * 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
  24430. * @param subMesh defines the subMesh to render
  24431. * @param enableAlphaMode defines if alpha mode can be changed
  24432. * @returns the current mesh
  24433. */
  24434. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24435. private _onBeforeDraw;
  24436. /**
  24437. * Renormalize the mesh and patch it up if there are no weights
  24438. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24439. * However in the case of zero weights then we set just a single influence to 1.
  24440. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24441. */
  24442. cleanMatrixWeights(): void;
  24443. private normalizeSkinFourWeights;
  24444. private normalizeSkinWeightsAndExtra;
  24445. /**
  24446. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24447. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24448. * the user know there was an issue with importing the mesh
  24449. * @returns a validation object with skinned, valid and report string
  24450. */
  24451. validateSkinning(): {
  24452. skinned: boolean;
  24453. valid: boolean;
  24454. report: string;
  24455. };
  24456. /** @hidden */
  24457. _checkDelayState(): Mesh;
  24458. private _queueLoad;
  24459. /**
  24460. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24461. * A mesh is in the frustum if its bounding box intersects the frustum
  24462. * @param frustumPlanes defines the frustum to test
  24463. * @returns true if the mesh is in the frustum planes
  24464. */
  24465. isInFrustum(frustumPlanes: Plane[]): boolean;
  24466. /**
  24467. * Sets the mesh material by the material or multiMaterial `id` property
  24468. * @param id is a string identifying the material or the multiMaterial
  24469. * @returns the current mesh
  24470. */
  24471. setMaterialByID(id: string): Mesh;
  24472. /**
  24473. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24474. * @returns an array of IAnimatable
  24475. */
  24476. getAnimatables(): IAnimatable[];
  24477. /**
  24478. * Modifies the mesh geometry according to the passed transformation matrix.
  24479. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24480. * The mesh normals are modified using the same transformation.
  24481. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24482. * @param transform defines the transform matrix to use
  24483. * @see http://doc.babylonjs.com/resources/baking_transformations
  24484. * @returns the current mesh
  24485. */
  24486. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24487. /**
  24488. * Modifies the mesh geometry according to its own current World Matrix.
  24489. * The mesh World Matrix is then reset.
  24490. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24491. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24492. * @see http://doc.babylonjs.com/resources/baking_transformations
  24493. * @returns the current mesh
  24494. */
  24495. bakeCurrentTransformIntoVertices(): Mesh;
  24496. /** @hidden */
  24497. readonly _positions: Nullable<Vector3[]>;
  24498. /** @hidden */
  24499. _resetPointsArrayCache(): Mesh;
  24500. /** @hidden */
  24501. _generatePointsArray(): boolean;
  24502. /**
  24503. * Returns a new Mesh object generated from the current mesh properties.
  24504. * This method must not get confused with createInstance()
  24505. * @param name is a string, the name given to the new mesh
  24506. * @param newParent can be any Node object (default `null`)
  24507. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24508. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24509. * @returns a new mesh
  24510. */
  24511. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  24512. /**
  24513. * Releases resources associated with this mesh.
  24514. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24515. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24516. */
  24517. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24518. /**
  24519. * Modifies the mesh geometry according to a displacement map.
  24520. * 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.
  24521. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24522. * @param url is a string, the URL from the image file is to be downloaded.
  24523. * @param minHeight is the lower limit of the displacement.
  24524. * @param maxHeight is the upper limit of the displacement.
  24525. * @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.
  24526. * @param uvOffset is an optional vector2 used to offset UV.
  24527. * @param uvScale is an optional vector2 used to scale UV.
  24528. * @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.
  24529. * @returns the Mesh.
  24530. */
  24531. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24532. /**
  24533. * Modifies the mesh geometry according to a displacementMap buffer.
  24534. * 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.
  24535. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24536. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24537. * @param heightMapWidth is the width of the buffer image.
  24538. * @param heightMapHeight is the height of the buffer image.
  24539. * @param minHeight is the lower limit of the displacement.
  24540. * @param maxHeight is the upper limit of the displacement.
  24541. * @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.
  24542. * @param uvOffset is an optional vector2 used to offset UV.
  24543. * @param uvScale is an optional vector2 used to scale UV.
  24544. * @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.
  24545. * @returns the Mesh.
  24546. */
  24547. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24548. /**
  24549. * Modify the mesh to get a flat shading rendering.
  24550. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24551. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24552. * @returns current mesh
  24553. */
  24554. convertToFlatShadedMesh(): Mesh;
  24555. /**
  24556. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24557. * In other words, more vertices, no more indices and a single bigger VBO.
  24558. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24559. * @returns current mesh
  24560. */
  24561. convertToUnIndexedMesh(): Mesh;
  24562. /**
  24563. * Inverses facet orientations.
  24564. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24565. * @param flipNormals will also inverts the normals
  24566. * @returns current mesh
  24567. */
  24568. flipFaces(flipNormals?: boolean): Mesh;
  24569. /**
  24570. * Increase the number of facets and hence vertices in a mesh
  24571. * Vertex normals are interpolated from existing vertex normals
  24572. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24573. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24574. */
  24575. increaseVertices(numberPerEdge: number): void;
  24576. /**
  24577. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24578. * This will undo any application of covertToFlatShadedMesh
  24579. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24580. */
  24581. forceSharedVertices(): void;
  24582. /** @hidden */
  24583. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24584. /** @hidden */
  24585. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24586. /**
  24587. * Creates a new InstancedMesh object from the mesh model.
  24588. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24589. * @param name defines the name of the new instance
  24590. * @returns a new InstancedMesh
  24591. */
  24592. createInstance(name: string): InstancedMesh;
  24593. /**
  24594. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24595. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24596. * @returns the current mesh
  24597. */
  24598. synchronizeInstances(): Mesh;
  24599. /**
  24600. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24601. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24602. * This should be used together with the simplification to avoid disappearing triangles.
  24603. * @param successCallback an optional success callback to be called after the optimization finished.
  24604. * @returns the current mesh
  24605. */
  24606. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24607. /**
  24608. * Serialize current mesh
  24609. * @param serializationObject defines the object which will receive the serialization data
  24610. */
  24611. serialize(serializationObject: any): void;
  24612. /** @hidden */
  24613. _syncGeometryWithMorphTargetManager(): void;
  24614. /** @hidden */
  24615. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24616. /**
  24617. * Returns a new Mesh object parsed from the source provided.
  24618. * @param parsedMesh is the source
  24619. * @param scene defines the hosting scene
  24620. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24621. * @returns a new Mesh
  24622. */
  24623. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24624. /**
  24625. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24626. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24627. * @param name defines the name of the mesh to create
  24628. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24629. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24630. * @param closePath creates a seam between the first and the last points of each path of the path array
  24631. * @param offset is taken in account only if the `pathArray` is containing a single path
  24632. * @param scene defines the hosting scene
  24633. * @param updatable defines if the mesh must be flagged as updatable
  24634. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24635. * @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)
  24636. * @returns a new Mesh
  24637. */
  24638. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24639. /**
  24640. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24641. * @param name defines the name of the mesh to create
  24642. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24643. * @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
  24644. * @param scene defines the hosting scene
  24645. * @param updatable defines if the mesh must be flagged as updatable
  24646. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24647. * @returns a new Mesh
  24648. */
  24649. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24650. /**
  24651. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24652. * @param name defines the name of the mesh to create
  24653. * @param size sets the size (float) of each box side (default 1)
  24654. * @param scene defines the hosting scene
  24655. * @param updatable defines if the mesh must be flagged as updatable
  24656. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24657. * @returns a new Mesh
  24658. */
  24659. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24660. /**
  24661. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24662. * @param name defines the name of the mesh to create
  24663. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24664. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24665. * @param scene defines the hosting scene
  24666. * @param updatable defines if the mesh must be flagged as updatable
  24667. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24668. * @returns a new Mesh
  24669. */
  24670. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24671. /**
  24672. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24673. * @param name defines the name of the mesh to create
  24674. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24675. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24676. * @param scene defines the hosting scene
  24677. * @returns a new Mesh
  24678. */
  24679. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24680. /**
  24681. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24682. * @param name defines the name of the mesh to create
  24683. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24684. * @param diameterTop set the top cap diameter (floats, default 1)
  24685. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24686. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24687. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24688. * @param scene defines the hosting scene
  24689. * @param updatable defines if the mesh must be flagged as updatable
  24690. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24691. * @returns a new Mesh
  24692. */
  24693. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24694. /**
  24695. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24696. * @param name defines the name of the mesh to create
  24697. * @param diameter sets the diameter size (float) of the torus (default 1)
  24698. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24699. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24700. * @param scene defines the hosting scene
  24701. * @param updatable defines if the mesh must be flagged as updatable
  24702. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24703. * @returns a new Mesh
  24704. */
  24705. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24706. /**
  24707. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24708. * @param name defines the name of the mesh to create
  24709. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24710. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24711. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24712. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24713. * @param p the number of windings on X axis (positive integers, default 2)
  24714. * @param q the number of windings on Y axis (positive integers, default 3)
  24715. * @param scene defines the hosting scene
  24716. * @param updatable defines if the mesh must be flagged as updatable
  24717. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24718. * @returns a new Mesh
  24719. */
  24720. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24721. /**
  24722. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24723. * @param name defines the name of the mesh to create
  24724. * @param points is an array successive Vector3
  24725. * @param scene defines the hosting scene
  24726. * @param updatable defines if the mesh must be flagged as updatable
  24727. * @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).
  24728. * @returns a new Mesh
  24729. */
  24730. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24731. /**
  24732. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24733. * @param name defines the name of the mesh to create
  24734. * @param points is an array successive Vector3
  24735. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24736. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24737. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24738. * @param scene defines the hosting scene
  24739. * @param updatable defines if the mesh must be flagged as updatable
  24740. * @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)
  24741. * @returns a new Mesh
  24742. */
  24743. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24744. /**
  24745. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24746. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24747. * 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.
  24748. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24749. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24750. * Remember you can only change the shape positions, not their number when updating a polygon.
  24751. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24752. * @param name defines the name of the mesh to create
  24753. * @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
  24754. * @param scene defines the hosting scene
  24755. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24756. * @param updatable defines if the mesh must be flagged as updatable
  24757. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24758. * @param earcutInjection can be used to inject your own earcut reference
  24759. * @returns a new Mesh
  24760. */
  24761. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24762. /**
  24763. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24764. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24765. * @param name defines the name of the mesh to create
  24766. * @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
  24767. * @param depth defines the height of extrusion
  24768. * @param scene defines the hosting scene
  24769. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24770. * @param updatable defines if the mesh must be flagged as updatable
  24771. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24772. * @param earcutInjection can be used to inject your own earcut reference
  24773. * @returns a new Mesh
  24774. */
  24775. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24776. /**
  24777. * Creates an extruded shape mesh.
  24778. * 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
  24779. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24780. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24781. * @param name defines the name of the mesh to create
  24782. * @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
  24783. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24784. * @param scale is the value to scale the shape
  24785. * @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
  24786. * @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
  24787. * @param scene defines the hosting scene
  24788. * @param updatable defines if the mesh must be flagged as updatable
  24789. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24790. * @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)
  24791. * @returns a new Mesh
  24792. */
  24793. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24794. /**
  24795. * Creates an custom extruded shape mesh.
  24796. * The custom extrusion is a parametric shape.
  24797. * It has no predefined shape. Its final shape will depend on the input parameters.
  24798. * Please consider using the same method from the MeshBuilder class instead
  24799. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24800. * @param name defines the name of the mesh to create
  24801. * @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
  24802. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24803. * @param scaleFunction is a custom Javascript function called on each path point
  24804. * @param rotationFunction is a custom Javascript function called on each path point
  24805. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24806. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24807. * @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
  24808. * @param scene defines the hosting scene
  24809. * @param updatable defines if the mesh must be flagged as updatable
  24810. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24811. * @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)
  24812. * @returns a new Mesh
  24813. */
  24814. 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;
  24815. /**
  24816. * Creates lathe mesh.
  24817. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24818. * Please consider using the same method from the MeshBuilder class instead
  24819. * @param name defines the name of the mesh to create
  24820. * @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
  24821. * @param radius is the radius value of the lathe
  24822. * @param tessellation is the side number of the lathe.
  24823. * @param scene defines the hosting scene
  24824. * @param updatable defines if the mesh must be flagged as updatable
  24825. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24826. * @returns a new Mesh
  24827. */
  24828. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24829. /**
  24830. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24831. * @param name defines the name of the mesh to create
  24832. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24833. * @param scene defines the hosting scene
  24834. * @param updatable defines if the mesh must be flagged as updatable
  24835. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24836. * @returns a new Mesh
  24837. */
  24838. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24839. /**
  24840. * Creates a ground mesh.
  24841. * Please consider using the same method from the MeshBuilder class instead
  24842. * @param name defines the name of the mesh to create
  24843. * @param width set the width of the ground
  24844. * @param height set the height of the ground
  24845. * @param subdivisions sets the number of subdivisions per side
  24846. * @param scene defines the hosting scene
  24847. * @param updatable defines if the mesh must be flagged as updatable
  24848. * @returns a new Mesh
  24849. */
  24850. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24851. /**
  24852. * Creates a tiled ground mesh.
  24853. * Please consider using the same method from the MeshBuilder class instead
  24854. * @param name defines the name of the mesh to create
  24855. * @param xmin set the ground minimum X coordinate
  24856. * @param zmin set the ground minimum Y coordinate
  24857. * @param xmax set the ground maximum X coordinate
  24858. * @param zmax set the ground maximum Z coordinate
  24859. * @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
  24860. * @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
  24861. * @param scene defines the hosting scene
  24862. * @param updatable defines if the mesh must be flagged as updatable
  24863. * @returns a new Mesh
  24864. */
  24865. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24866. w: number;
  24867. h: number;
  24868. }, precision: {
  24869. w: number;
  24870. h: number;
  24871. }, scene: Scene, updatable?: boolean): Mesh;
  24872. /**
  24873. * Creates a ground mesh from a height map.
  24874. * Please consider using the same method from the MeshBuilder class instead
  24875. * @see http://doc.babylonjs.com/babylon101/height_map
  24876. * @param name defines the name of the mesh to create
  24877. * @param url sets the URL of the height map image resource
  24878. * @param width set the ground width size
  24879. * @param height set the ground height size
  24880. * @param subdivisions sets the number of subdivision per side
  24881. * @param minHeight is the minimum altitude on the ground
  24882. * @param maxHeight is the maximum altitude on the ground
  24883. * @param scene defines the hosting scene
  24884. * @param updatable defines if the mesh must be flagged as updatable
  24885. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24886. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24887. * @returns a new Mesh
  24888. */
  24889. 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;
  24890. /**
  24891. * Creates a tube mesh.
  24892. * The tube is a parametric shape.
  24893. * It has no predefined shape. Its final shape will depend on the input parameters.
  24894. * Please consider using the same method from the MeshBuilder class instead
  24895. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24896. * @param name defines the name of the mesh to create
  24897. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24898. * @param radius sets the tube radius size
  24899. * @param tessellation is the number of sides on the tubular surface
  24900. * @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
  24901. * @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
  24902. * @param scene defines the hosting scene
  24903. * @param updatable defines if the mesh must be flagged as updatable
  24904. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24905. * @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)
  24906. * @returns a new Mesh
  24907. */
  24908. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24909. (i: number, distance: number): number;
  24910. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24911. /**
  24912. * Creates a polyhedron mesh.
  24913. * Please consider using the same method from the MeshBuilder class instead.
  24914. * * 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
  24915. * * The parameter `size` (positive float, default 1) sets the polygon size
  24916. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24917. * * 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`
  24918. * * 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
  24919. * * 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)`)
  24920. * * 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
  24921. * * 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
  24922. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24923. * * If you create a double-sided mesh, you can choose what parts of 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
  24924. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24925. * @param name defines the name of the mesh to create
  24926. * @param options defines the options used to create the mesh
  24927. * @param scene defines the hosting scene
  24928. * @returns a new Mesh
  24929. */
  24930. static CreatePolyhedron(name: string, options: {
  24931. type?: number;
  24932. size?: number;
  24933. sizeX?: number;
  24934. sizeY?: number;
  24935. sizeZ?: number;
  24936. custom?: any;
  24937. faceUV?: Vector4[];
  24938. faceColors?: Color4[];
  24939. updatable?: boolean;
  24940. sideOrientation?: number;
  24941. }, scene: Scene): Mesh;
  24942. /**
  24943. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24944. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24945. * * 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`)
  24946. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24947. * * 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
  24948. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24949. * * If you create a double-sided mesh, you can choose what parts of 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
  24950. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24951. * @param name defines the name of the mesh
  24952. * @param options defines the options used to create the mesh
  24953. * @param scene defines the hosting scene
  24954. * @returns a new Mesh
  24955. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24956. */
  24957. static CreateIcoSphere(name: string, options: {
  24958. radius?: number;
  24959. flat?: boolean;
  24960. subdivisions?: number;
  24961. sideOrientation?: number;
  24962. updatable?: boolean;
  24963. }, scene: Scene): Mesh;
  24964. /**
  24965. * Creates a decal mesh.
  24966. * Please consider using the same method from the MeshBuilder class instead.
  24967. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24968. * @param name defines the name of the mesh
  24969. * @param sourceMesh defines the mesh receiving the decal
  24970. * @param position sets the position of the decal in world coordinates
  24971. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24972. * @param size sets the decal scaling
  24973. * @param angle sets the angle to rotate the decal
  24974. * @returns a new Mesh
  24975. */
  24976. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24977. /**
  24978. * Prepare internal position array for software CPU skinning
  24979. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24980. */
  24981. setPositionsForCPUSkinning(): Float32Array;
  24982. /**
  24983. * Prepare internal normal array for software CPU skinning
  24984. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24985. */
  24986. setNormalsForCPUSkinning(): Float32Array;
  24987. /**
  24988. * Updates the vertex buffer by applying transformation from the bones
  24989. * @param skeleton defines the skeleton to apply to current mesh
  24990. * @returns the current mesh
  24991. */
  24992. applySkeleton(skeleton: Skeleton): Mesh;
  24993. /**
  24994. * 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
  24995. * @param meshes defines the list of meshes to scan
  24996. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24997. */
  24998. static MinMax(meshes: AbstractMesh[]): {
  24999. min: Vector3;
  25000. max: Vector3;
  25001. };
  25002. /**
  25003. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25004. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25005. * @returns a vector3
  25006. */
  25007. static Center(meshesOrMinMaxVector: {
  25008. min: Vector3;
  25009. max: Vector3;
  25010. } | AbstractMesh[]): Vector3;
  25011. /**
  25012. * Merge the array of meshes into a single mesh for performance reasons.
  25013. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25014. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25015. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25016. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25017. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25018. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25019. * @returns a new mesh
  25020. */
  25021. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25022. /** @hidden */
  25023. addInstance(instance: InstancedMesh): void;
  25024. /** @hidden */
  25025. removeInstance(instance: InstancedMesh): void;
  25026. }
  25027. }
  25028. declare module "babylonjs/Cameras/camera" {
  25029. import { SmartArray } from "babylonjs/Misc/smartArray";
  25030. import { Observable } from "babylonjs/Misc/observable";
  25031. import { Nullable } from "babylonjs/types";
  25032. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25033. import { Scene } from "babylonjs/scene";
  25034. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25035. import { Node } from "babylonjs/node";
  25036. import { Mesh } from "babylonjs/Meshes/mesh";
  25037. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25038. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25039. import { Viewport } from "babylonjs/Maths/math.viewport";
  25040. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25041. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25042. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25043. import { Ray } from "babylonjs/Culling/ray";
  25044. /**
  25045. * This is the base class of all the camera used in the application.
  25046. * @see http://doc.babylonjs.com/features/cameras
  25047. */
  25048. export class Camera extends Node {
  25049. /** @hidden */
  25050. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25051. /**
  25052. * This is the default projection mode used by the cameras.
  25053. * It helps recreating a feeling of perspective and better appreciate depth.
  25054. * This is the best way to simulate real life cameras.
  25055. */
  25056. static readonly PERSPECTIVE_CAMERA: number;
  25057. /**
  25058. * This helps creating camera with an orthographic mode.
  25059. * 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.
  25060. */
  25061. static readonly ORTHOGRAPHIC_CAMERA: number;
  25062. /**
  25063. * This is the default FOV mode for perspective cameras.
  25064. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25065. */
  25066. static readonly FOVMODE_VERTICAL_FIXED: number;
  25067. /**
  25068. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25069. */
  25070. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25071. /**
  25072. * This specifies ther is no need for a camera rig.
  25073. * Basically only one eye is rendered corresponding to the camera.
  25074. */
  25075. static readonly RIG_MODE_NONE: number;
  25076. /**
  25077. * Simulates a camera Rig with one blue eye and one red eye.
  25078. * This can be use with 3d blue and red glasses.
  25079. */
  25080. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25081. /**
  25082. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25083. */
  25084. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25085. /**
  25086. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25087. */
  25088. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25089. /**
  25090. * Defines that both eyes of the camera will be rendered over under each other.
  25091. */
  25092. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25093. /**
  25094. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25095. */
  25096. static readonly RIG_MODE_VR: number;
  25097. /**
  25098. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25099. */
  25100. static readonly RIG_MODE_WEBVR: number;
  25101. /**
  25102. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25103. */
  25104. static readonly RIG_MODE_CUSTOM: number;
  25105. /**
  25106. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25107. */
  25108. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25109. /**
  25110. * Define the input manager associated with the camera.
  25111. */
  25112. inputs: CameraInputsManager<Camera>;
  25113. /** @hidden */
  25114. _position: Vector3;
  25115. /**
  25116. * Define the current local position of the camera in the scene
  25117. */
  25118. position: Vector3;
  25119. /**
  25120. * The vector the camera should consider as up.
  25121. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25122. */
  25123. upVector: Vector3;
  25124. /**
  25125. * Define the current limit on the left side for an orthographic camera
  25126. * In scene unit
  25127. */
  25128. orthoLeft: Nullable<number>;
  25129. /**
  25130. * Define the current limit on the right side for an orthographic camera
  25131. * In scene unit
  25132. */
  25133. orthoRight: Nullable<number>;
  25134. /**
  25135. * Define the current limit on the bottom side for an orthographic camera
  25136. * In scene unit
  25137. */
  25138. orthoBottom: Nullable<number>;
  25139. /**
  25140. * Define the current limit on the top side for an orthographic camera
  25141. * In scene unit
  25142. */
  25143. orthoTop: Nullable<number>;
  25144. /**
  25145. * Field Of View is set in Radians. (default is 0.8)
  25146. */
  25147. fov: number;
  25148. /**
  25149. * Define the minimum distance the camera can see from.
  25150. * This is important to note that the depth buffer are not infinite and the closer it starts
  25151. * the more your scene might encounter depth fighting issue.
  25152. */
  25153. minZ: number;
  25154. /**
  25155. * Define the maximum distance the camera can see to.
  25156. * This is important to note that the depth buffer are not infinite and the further it end
  25157. * the more your scene might encounter depth fighting issue.
  25158. */
  25159. maxZ: number;
  25160. /**
  25161. * Define the default inertia of the camera.
  25162. * This helps giving a smooth feeling to the camera movement.
  25163. */
  25164. inertia: number;
  25165. /**
  25166. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25167. */
  25168. mode: number;
  25169. /**
  25170. * Define wether the camera is intermediate.
  25171. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25172. */
  25173. isIntermediate: boolean;
  25174. /**
  25175. * Define the viewport of the camera.
  25176. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25177. */
  25178. viewport: Viewport;
  25179. /**
  25180. * Restricts the camera to viewing objects with the same layerMask.
  25181. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25182. */
  25183. layerMask: number;
  25184. /**
  25185. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25186. */
  25187. fovMode: number;
  25188. /**
  25189. * Rig mode of the camera.
  25190. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25191. * This is normally controlled byt the camera themselves as internal use.
  25192. */
  25193. cameraRigMode: number;
  25194. /**
  25195. * Defines the distance between both "eyes" in case of a RIG
  25196. */
  25197. interaxialDistance: number;
  25198. /**
  25199. * Defines if stereoscopic rendering is done side by side or over under.
  25200. */
  25201. isStereoscopicSideBySide: boolean;
  25202. /**
  25203. * 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
  25204. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25205. * else in the scene. (Eg. security camera)
  25206. *
  25207. * 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)
  25208. */
  25209. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25210. /**
  25211. * When set, the camera will render to this render target instead of the default canvas
  25212. *
  25213. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25214. */
  25215. outputRenderTarget: Nullable<RenderTargetTexture>;
  25216. /**
  25217. * Observable triggered when the camera view matrix has changed.
  25218. */
  25219. onViewMatrixChangedObservable: Observable<Camera>;
  25220. /**
  25221. * Observable triggered when the camera Projection matrix has changed.
  25222. */
  25223. onProjectionMatrixChangedObservable: Observable<Camera>;
  25224. /**
  25225. * Observable triggered when the inputs have been processed.
  25226. */
  25227. onAfterCheckInputsObservable: Observable<Camera>;
  25228. /**
  25229. * Observable triggered when reset has been called and applied to the camera.
  25230. */
  25231. onRestoreStateObservable: Observable<Camera>;
  25232. /** @hidden */
  25233. _cameraRigParams: any;
  25234. /** @hidden */
  25235. _rigCameras: Camera[];
  25236. /** @hidden */
  25237. _rigPostProcess: Nullable<PostProcess>;
  25238. protected _webvrViewMatrix: Matrix;
  25239. /** @hidden */
  25240. _skipRendering: boolean;
  25241. /** @hidden */
  25242. _projectionMatrix: Matrix;
  25243. /** @hidden */
  25244. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25245. /** @hidden */
  25246. _activeMeshes: SmartArray<AbstractMesh>;
  25247. protected _globalPosition: Vector3;
  25248. /** @hidden */
  25249. _computedViewMatrix: Matrix;
  25250. private _doNotComputeProjectionMatrix;
  25251. private _transformMatrix;
  25252. private _frustumPlanes;
  25253. private _refreshFrustumPlanes;
  25254. private _storedFov;
  25255. private _stateStored;
  25256. /**
  25257. * Instantiates a new camera object.
  25258. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25259. * @see http://doc.babylonjs.com/features/cameras
  25260. * @param name Defines the name of the camera in the scene
  25261. * @param position Defines the position of the camera
  25262. * @param scene Defines the scene the camera belongs too
  25263. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25264. */
  25265. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25266. /**
  25267. * Store current camera state (fov, position, etc..)
  25268. * @returns the camera
  25269. */
  25270. storeState(): Camera;
  25271. /**
  25272. * Restores the camera state values if it has been stored. You must call storeState() first
  25273. */
  25274. protected _restoreStateValues(): boolean;
  25275. /**
  25276. * Restored camera state. You must call storeState() first.
  25277. * @returns true if restored and false otherwise
  25278. */
  25279. restoreState(): boolean;
  25280. /**
  25281. * Gets the class name of the camera.
  25282. * @returns the class name
  25283. */
  25284. getClassName(): string;
  25285. /** @hidden */
  25286. readonly _isCamera: boolean;
  25287. /**
  25288. * Gets a string representation of the camera useful for debug purpose.
  25289. * @param fullDetails Defines that a more verboe level of logging is required
  25290. * @returns the string representation
  25291. */
  25292. toString(fullDetails?: boolean): string;
  25293. /**
  25294. * Gets the current world space position of the camera.
  25295. */
  25296. readonly globalPosition: Vector3;
  25297. /**
  25298. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25299. * @returns the active meshe list
  25300. */
  25301. getActiveMeshes(): SmartArray<AbstractMesh>;
  25302. /**
  25303. * Check wether a mesh is part of the current active mesh list of the camera
  25304. * @param mesh Defines the mesh to check
  25305. * @returns true if active, false otherwise
  25306. */
  25307. isActiveMesh(mesh: Mesh): boolean;
  25308. /**
  25309. * Is this camera ready to be used/rendered
  25310. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25311. * @return true if the camera is ready
  25312. */
  25313. isReady(completeCheck?: boolean): boolean;
  25314. /** @hidden */
  25315. _initCache(): void;
  25316. /** @hidden */
  25317. _updateCache(ignoreParentClass?: boolean): void;
  25318. /** @hidden */
  25319. _isSynchronized(): boolean;
  25320. /** @hidden */
  25321. _isSynchronizedViewMatrix(): boolean;
  25322. /** @hidden */
  25323. _isSynchronizedProjectionMatrix(): boolean;
  25324. /**
  25325. * Attach the input controls to a specific dom element to get the input from.
  25326. * @param element Defines the element the controls should be listened from
  25327. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25328. */
  25329. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25330. /**
  25331. * Detach the current controls from the specified dom element.
  25332. * @param element Defines the element to stop listening the inputs from
  25333. */
  25334. detachControl(element: HTMLElement): void;
  25335. /**
  25336. * Update the camera state according to the different inputs gathered during the frame.
  25337. */
  25338. update(): void;
  25339. /** @hidden */
  25340. _checkInputs(): void;
  25341. /** @hidden */
  25342. readonly rigCameras: Camera[];
  25343. /**
  25344. * Gets the post process used by the rig cameras
  25345. */
  25346. readonly rigPostProcess: Nullable<PostProcess>;
  25347. /**
  25348. * Internal, gets the first post proces.
  25349. * @returns the first post process to be run on this camera.
  25350. */
  25351. _getFirstPostProcess(): Nullable<PostProcess>;
  25352. private _cascadePostProcessesToRigCams;
  25353. /**
  25354. * Attach a post process to the camera.
  25355. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25356. * @param postProcess The post process to attach to the camera
  25357. * @param insertAt The position of the post process in case several of them are in use in the scene
  25358. * @returns the position the post process has been inserted at
  25359. */
  25360. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25361. /**
  25362. * Detach a post process to the camera.
  25363. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25364. * @param postProcess The post process to detach from the camera
  25365. */
  25366. detachPostProcess(postProcess: PostProcess): void;
  25367. /**
  25368. * Gets the current world matrix of the camera
  25369. */
  25370. getWorldMatrix(): Matrix;
  25371. /** @hidden */
  25372. _getViewMatrix(): Matrix;
  25373. /**
  25374. * Gets the current view matrix of the camera.
  25375. * @param force forces the camera to recompute the matrix without looking at the cached state
  25376. * @returns the view matrix
  25377. */
  25378. getViewMatrix(force?: boolean): Matrix;
  25379. /**
  25380. * Freeze the projection matrix.
  25381. * It will prevent the cache check of the camera projection compute and can speed up perf
  25382. * if no parameter of the camera are meant to change
  25383. * @param projection Defines manually a projection if necessary
  25384. */
  25385. freezeProjectionMatrix(projection?: Matrix): void;
  25386. /**
  25387. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25388. */
  25389. unfreezeProjectionMatrix(): void;
  25390. /**
  25391. * Gets the current projection matrix of the camera.
  25392. * @param force forces the camera to recompute the matrix without looking at the cached state
  25393. * @returns the projection matrix
  25394. */
  25395. getProjectionMatrix(force?: boolean): Matrix;
  25396. /**
  25397. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25398. * @returns a Matrix
  25399. */
  25400. getTransformationMatrix(): Matrix;
  25401. private _updateFrustumPlanes;
  25402. /**
  25403. * Checks if a cullable object (mesh...) is in the camera frustum
  25404. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25405. * @param target The object to check
  25406. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25407. * @returns true if the object is in frustum otherwise false
  25408. */
  25409. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25410. /**
  25411. * Checks if a cullable object (mesh...) is in the camera frustum
  25412. * Unlike isInFrustum this cheks the full bounding box
  25413. * @param target The object to check
  25414. * @returns true if the object is in frustum otherwise false
  25415. */
  25416. isCompletelyInFrustum(target: ICullable): boolean;
  25417. /**
  25418. * Gets a ray in the forward direction from the camera.
  25419. * @param length Defines the length of the ray to create
  25420. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25421. * @param origin Defines the start point of the ray which defaults to the camera position
  25422. * @returns the forward ray
  25423. */
  25424. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25425. /**
  25426. * Releases resources associated with this node.
  25427. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25428. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25429. */
  25430. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25431. /** @hidden */
  25432. _isLeftCamera: boolean;
  25433. /**
  25434. * Gets the left camera of a rig setup in case of Rigged Camera
  25435. */
  25436. readonly isLeftCamera: boolean;
  25437. /** @hidden */
  25438. _isRightCamera: boolean;
  25439. /**
  25440. * Gets the right camera of a rig setup in case of Rigged Camera
  25441. */
  25442. readonly isRightCamera: boolean;
  25443. /**
  25444. * Gets the left camera of a rig setup in case of Rigged Camera
  25445. */
  25446. readonly leftCamera: Nullable<FreeCamera>;
  25447. /**
  25448. * Gets the right camera of a rig setup in case of Rigged Camera
  25449. */
  25450. readonly rightCamera: Nullable<FreeCamera>;
  25451. /**
  25452. * Gets the left camera target of a rig setup in case of Rigged Camera
  25453. * @returns the target position
  25454. */
  25455. getLeftTarget(): Nullable<Vector3>;
  25456. /**
  25457. * Gets the right camera target of a rig setup in case of Rigged Camera
  25458. * @returns the target position
  25459. */
  25460. getRightTarget(): Nullable<Vector3>;
  25461. /**
  25462. * @hidden
  25463. */
  25464. setCameraRigMode(mode: number, rigParams: any): void;
  25465. /** @hidden */
  25466. static _setStereoscopicRigMode(camera: Camera): void;
  25467. /** @hidden */
  25468. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25469. /** @hidden */
  25470. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25471. /** @hidden */
  25472. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25473. /** @hidden */
  25474. _getVRProjectionMatrix(): Matrix;
  25475. protected _updateCameraRotationMatrix(): void;
  25476. protected _updateWebVRCameraRotationMatrix(): void;
  25477. /**
  25478. * This function MUST be overwritten by the different WebVR cameras available.
  25479. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25480. * @hidden
  25481. */
  25482. _getWebVRProjectionMatrix(): Matrix;
  25483. /**
  25484. * This function MUST be overwritten by the different WebVR cameras available.
  25485. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25486. * @hidden
  25487. */
  25488. _getWebVRViewMatrix(): Matrix;
  25489. /** @hidden */
  25490. setCameraRigParameter(name: string, value: any): void;
  25491. /**
  25492. * needs to be overridden by children so sub has required properties to be copied
  25493. * @hidden
  25494. */
  25495. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25496. /**
  25497. * May need to be overridden by children
  25498. * @hidden
  25499. */
  25500. _updateRigCameras(): void;
  25501. /** @hidden */
  25502. _setupInputs(): void;
  25503. /**
  25504. * Serialiaze the camera setup to a json represention
  25505. * @returns the JSON representation
  25506. */
  25507. serialize(): any;
  25508. /**
  25509. * Clones the current camera.
  25510. * @param name The cloned camera name
  25511. * @returns the cloned camera
  25512. */
  25513. clone(name: string): Camera;
  25514. /**
  25515. * Gets the direction of the camera relative to a given local axis.
  25516. * @param localAxis Defines the reference axis to provide a relative direction.
  25517. * @return the direction
  25518. */
  25519. getDirection(localAxis: Vector3): Vector3;
  25520. /**
  25521. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25522. * @param localAxis Defines the reference axis to provide a relative direction.
  25523. * @param result Defines the vector to store the result in
  25524. */
  25525. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25526. /**
  25527. * Gets a camera constructor for a given camera type
  25528. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25529. * @param name The name of the camera the result will be able to instantiate
  25530. * @param scene The scene the result will construct the camera in
  25531. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25532. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25533. * @returns a factory method to construc the camera
  25534. */
  25535. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25536. /**
  25537. * Compute the world matrix of the camera.
  25538. * @returns the camera workd matrix
  25539. */
  25540. computeWorldMatrix(): Matrix;
  25541. /**
  25542. * Parse a JSON and creates the camera from the parsed information
  25543. * @param parsedCamera The JSON to parse
  25544. * @param scene The scene to instantiate the camera in
  25545. * @returns the newly constructed camera
  25546. */
  25547. static Parse(parsedCamera: any, scene: Scene): Camera;
  25548. }
  25549. }
  25550. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25551. import { Nullable } from "babylonjs/types";
  25552. import { Scene } from "babylonjs/scene";
  25553. import { Vector4 } from "babylonjs/Maths/math.vector";
  25554. import { Mesh } from "babylonjs/Meshes/mesh";
  25555. /**
  25556. * Class containing static functions to help procedurally build meshes
  25557. */
  25558. export class DiscBuilder {
  25559. /**
  25560. * Creates a plane polygonal mesh. By default, this is a disc
  25561. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25562. * * 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
  25563. * * 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
  25564. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25565. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25567. * @param name defines the name of the mesh
  25568. * @param options defines the options used to create the mesh
  25569. * @param scene defines the hosting scene
  25570. * @returns the plane polygonal mesh
  25571. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25572. */
  25573. static CreateDisc(name: string, options: {
  25574. radius?: number;
  25575. tessellation?: number;
  25576. arc?: number;
  25577. updatable?: boolean;
  25578. sideOrientation?: number;
  25579. frontUVs?: Vector4;
  25580. backUVs?: Vector4;
  25581. }, scene?: Nullable<Scene>): Mesh;
  25582. }
  25583. }
  25584. declare module "babylonjs/Particles/solidParticleSystem" {
  25585. import { Vector3 } from "babylonjs/Maths/math.vector";
  25586. import { Mesh } from "babylonjs/Meshes/mesh";
  25587. import { Scene, IDisposable } from "babylonjs/scene";
  25588. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25589. /**
  25590. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25591. *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.
  25592. * The SPS is also a particle system. It provides some methods to manage the particles.
  25593. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25594. *
  25595. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  25596. */
  25597. export class SolidParticleSystem implements IDisposable {
  25598. /**
  25599. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25600. * Example : var p = SPS.particles[i];
  25601. */
  25602. particles: SolidParticle[];
  25603. /**
  25604. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25605. */
  25606. nbParticles: number;
  25607. /**
  25608. * If the particles must ever face the camera (default false). Useful for planar particles.
  25609. */
  25610. billboard: boolean;
  25611. /**
  25612. * Recompute normals when adding a shape
  25613. */
  25614. recomputeNormals: boolean;
  25615. /**
  25616. * This a counter ofr your own usage. It's not set by any SPS functions.
  25617. */
  25618. counter: number;
  25619. /**
  25620. * The SPS name. This name is also given to the underlying mesh.
  25621. */
  25622. name: string;
  25623. /**
  25624. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25625. */
  25626. mesh: Mesh;
  25627. /**
  25628. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25629. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  25630. */
  25631. vars: any;
  25632. /**
  25633. * This array is populated when the SPS is set as 'pickable'.
  25634. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25635. * Each element of this array is an object `{idx: int, faceId: int}`.
  25636. * `idx` is the picked particle index in the `SPS.particles` array
  25637. * `faceId` is the picked face index counted within this particle.
  25638. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  25639. */
  25640. pickedParticles: {
  25641. idx: number;
  25642. faceId: number;
  25643. }[];
  25644. /**
  25645. * This array is populated when `enableDepthSort` is set to true.
  25646. * Each element of this array is an instance of the class DepthSortedParticle.
  25647. */
  25648. depthSortedParticles: DepthSortedParticle[];
  25649. /**
  25650. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25651. * @hidden
  25652. */
  25653. _bSphereOnly: boolean;
  25654. /**
  25655. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25656. * @hidden
  25657. */
  25658. _bSphereRadiusFactor: number;
  25659. private _scene;
  25660. private _positions;
  25661. private _indices;
  25662. private _normals;
  25663. private _colors;
  25664. private _uvs;
  25665. private _indices32;
  25666. private _positions32;
  25667. private _normals32;
  25668. private _fixedNormal32;
  25669. private _colors32;
  25670. private _uvs32;
  25671. private _index;
  25672. private _updatable;
  25673. private _pickable;
  25674. private _isVisibilityBoxLocked;
  25675. private _alwaysVisible;
  25676. private _depthSort;
  25677. private _shapeCounter;
  25678. private _copy;
  25679. private _color;
  25680. private _computeParticleColor;
  25681. private _computeParticleTexture;
  25682. private _computeParticleRotation;
  25683. private _computeParticleVertex;
  25684. private _computeBoundingBox;
  25685. private _depthSortParticles;
  25686. private _camera;
  25687. private _mustUnrotateFixedNormals;
  25688. private _particlesIntersect;
  25689. private _needs32Bits;
  25690. /**
  25691. * Creates a SPS (Solid Particle System) object.
  25692. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25693. * @param scene (Scene) is the scene in which the SPS is added.
  25694. * @param options defines the options of the sps e.g.
  25695. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25696. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25697. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25698. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25699. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25700. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25701. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25702. */
  25703. constructor(name: string, scene: Scene, options?: {
  25704. updatable?: boolean;
  25705. isPickable?: boolean;
  25706. enableDepthSort?: boolean;
  25707. particleIntersection?: boolean;
  25708. boundingSphereOnly?: boolean;
  25709. bSphereRadiusFactor?: number;
  25710. });
  25711. /**
  25712. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25713. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25714. * @returns the created mesh
  25715. */
  25716. buildMesh(): Mesh;
  25717. /**
  25718. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25719. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25720. * Thus the particles generated from `digest()` have their property `position` set yet.
  25721. * @param mesh ( Mesh ) is the mesh to be digested
  25722. * @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
  25723. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25724. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25725. * @returns the current SPS
  25726. */
  25727. digest(mesh: Mesh, options?: {
  25728. facetNb?: number;
  25729. number?: number;
  25730. delta?: number;
  25731. }): SolidParticleSystem;
  25732. private _unrotateFixedNormals;
  25733. private _resetCopy;
  25734. private _meshBuilder;
  25735. private _posToShape;
  25736. private _uvsToShapeUV;
  25737. private _addParticle;
  25738. /**
  25739. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25740. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  25741. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25742. * @param nb (positive integer) the number of particles to be created from this model
  25743. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25744. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25745. * @returns the number of shapes in the system
  25746. */
  25747. addShape(mesh: Mesh, nb: number, options?: {
  25748. positionFunction?: any;
  25749. vertexFunction?: any;
  25750. }): number;
  25751. private _rebuildParticle;
  25752. /**
  25753. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25754. * @returns the SPS.
  25755. */
  25756. rebuildMesh(): SolidParticleSystem;
  25757. /**
  25758. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25759. * This method calls `updateParticle()` for each particle of the SPS.
  25760. * For an animated SPS, it is usually called within the render loop.
  25761. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25762. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25763. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25764. * @returns the SPS.
  25765. */
  25766. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25767. /**
  25768. * Disposes the SPS.
  25769. */
  25770. dispose(): void;
  25771. /**
  25772. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25773. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25774. * @returns the SPS.
  25775. */
  25776. refreshVisibleSize(): SolidParticleSystem;
  25777. /**
  25778. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25779. * @param size the size (float) of the visibility box
  25780. * note : this doesn't lock the SPS mesh bounding box.
  25781. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25782. */
  25783. setVisibilityBox(size: number): void;
  25784. /**
  25785. * Gets whether the SPS as always visible or not
  25786. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25787. */
  25788. /**
  25789. * Sets the SPS as always visible or not
  25790. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25791. */
  25792. isAlwaysVisible: boolean;
  25793. /**
  25794. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25795. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25796. */
  25797. /**
  25798. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25799. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  25800. */
  25801. isVisibilityBoxLocked: boolean;
  25802. /**
  25803. * Tells to `setParticles()` to compute the particle rotations or not.
  25804. * Default value : true. The SPS is faster when it's set to false.
  25805. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25806. */
  25807. /**
  25808. * Gets if `setParticles()` computes the particle rotations or not.
  25809. * Default value : true. The SPS is faster when it's set to false.
  25810. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25811. */
  25812. computeParticleRotation: boolean;
  25813. /**
  25814. * Tells to `setParticles()` to compute the particle colors or not.
  25815. * Default value : true. The SPS is faster when it's set to false.
  25816. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25817. */
  25818. /**
  25819. * Gets if `setParticles()` computes the particle colors or not.
  25820. * Default value : true. The SPS is faster when it's set to false.
  25821. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25822. */
  25823. computeParticleColor: boolean;
  25824. /**
  25825. * Gets if `setParticles()` computes the particle textures or not.
  25826. * Default value : true. The SPS is faster when it's set to false.
  25827. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25828. */
  25829. computeParticleTexture: boolean;
  25830. /**
  25831. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25832. * Default value : false. The SPS is faster when it's set to false.
  25833. * Note : the particle custom vertex positions aren't stored values.
  25834. */
  25835. /**
  25836. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25837. * Default value : false. The SPS is faster when it's set to false.
  25838. * Note : the particle custom vertex positions aren't stored values.
  25839. */
  25840. computeParticleVertex: boolean;
  25841. /**
  25842. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25843. */
  25844. /**
  25845. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25846. */
  25847. computeBoundingBox: boolean;
  25848. /**
  25849. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25850. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25851. * Default : `true`
  25852. */
  25853. /**
  25854. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25855. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25856. * Default : `true`
  25857. */
  25858. depthSortParticles: boolean;
  25859. /**
  25860. * This function does nothing. It may be overwritten to set all the particle first values.
  25861. * The SPS doesn't call this function, you may have to call it by your own.
  25862. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  25863. */
  25864. initParticles(): void;
  25865. /**
  25866. * This function does nothing. It may be overwritten to recycle a particle.
  25867. * The SPS doesn't call this function, you may have to call it by your own.
  25868. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  25869. * @param particle The particle to recycle
  25870. * @returns the recycled particle
  25871. */
  25872. recycleParticle(particle: SolidParticle): SolidParticle;
  25873. /**
  25874. * Updates a particle : this function should be overwritten by the user.
  25875. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25876. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  25877. * @example : just set a particle position or velocity and recycle conditions
  25878. * @param particle The particle to update
  25879. * @returns the updated particle
  25880. */
  25881. updateParticle(particle: SolidParticle): SolidParticle;
  25882. /**
  25883. * Updates a vertex of a particle : it can be overwritten by the user.
  25884. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25885. * @param particle the current particle
  25886. * @param vertex the current index of the current particle
  25887. * @param pt the index of the current vertex in the particle shape
  25888. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  25889. * @example : just set a vertex particle position
  25890. * @returns the updated vertex
  25891. */
  25892. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25893. /**
  25894. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25895. * This does nothing and may be overwritten by the user.
  25896. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25897. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25898. * @param update the boolean update value actually passed to setParticles()
  25899. */
  25900. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25901. /**
  25902. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25903. * This will be passed three parameters.
  25904. * This does nothing and may be overwritten by the user.
  25905. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25906. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25907. * @param update the boolean update value actually passed to setParticles()
  25908. */
  25909. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25910. }
  25911. }
  25912. declare module "babylonjs/Particles/solidParticle" {
  25913. import { Nullable } from "babylonjs/types";
  25914. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  25915. import { Color4 } from "babylonjs/Maths/math.color";
  25916. import { Mesh } from "babylonjs/Meshes/mesh";
  25917. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25918. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  25919. import { Plane } from "babylonjs/Maths/math.plane";
  25920. /**
  25921. * Represents one particle of a solid particle system.
  25922. */
  25923. export class SolidParticle {
  25924. /**
  25925. * particle global index
  25926. */
  25927. idx: number;
  25928. /**
  25929. * The color of the particle
  25930. */
  25931. color: Nullable<Color4>;
  25932. /**
  25933. * The world space position of the particle.
  25934. */
  25935. position: Vector3;
  25936. /**
  25937. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25938. */
  25939. rotation: Vector3;
  25940. /**
  25941. * The world space rotation quaternion of the particle.
  25942. */
  25943. rotationQuaternion: Nullable<Quaternion>;
  25944. /**
  25945. * The scaling of the particle.
  25946. */
  25947. scaling: Vector3;
  25948. /**
  25949. * The uvs of the particle.
  25950. */
  25951. uvs: Vector4;
  25952. /**
  25953. * The current speed of the particle.
  25954. */
  25955. velocity: Vector3;
  25956. /**
  25957. * The pivot point in the particle local space.
  25958. */
  25959. pivot: Vector3;
  25960. /**
  25961. * Must the particle be translated from its pivot point in its local space ?
  25962. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25963. * Default : false
  25964. */
  25965. translateFromPivot: boolean;
  25966. /**
  25967. * Is the particle active or not ?
  25968. */
  25969. alive: boolean;
  25970. /**
  25971. * Is the particle visible or not ?
  25972. */
  25973. isVisible: boolean;
  25974. /**
  25975. * Index of this particle in the global "positions" array (Internal use)
  25976. * @hidden
  25977. */
  25978. _pos: number;
  25979. /**
  25980. * @hidden Index of this particle in the global "indices" array (Internal use)
  25981. */
  25982. _ind: number;
  25983. /**
  25984. * @hidden ModelShape of this particle (Internal use)
  25985. */
  25986. _model: ModelShape;
  25987. /**
  25988. * ModelShape id of this particle
  25989. */
  25990. shapeId: number;
  25991. /**
  25992. * Index of the particle in its shape id (Internal use)
  25993. */
  25994. idxInShape: number;
  25995. /**
  25996. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25997. */
  25998. _modelBoundingInfo: BoundingInfo;
  25999. /**
  26000. * @hidden Particle BoundingInfo object (Internal use)
  26001. */
  26002. _boundingInfo: BoundingInfo;
  26003. /**
  26004. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26005. */
  26006. _sps: SolidParticleSystem;
  26007. /**
  26008. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26009. */
  26010. _stillInvisible: boolean;
  26011. /**
  26012. * @hidden Last computed particle rotation matrix
  26013. */
  26014. _rotationMatrix: number[];
  26015. /**
  26016. * Parent particle Id, if any.
  26017. * Default null.
  26018. */
  26019. parentId: Nullable<number>;
  26020. /**
  26021. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26022. * The possible values are :
  26023. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26024. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26025. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26026. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26027. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26028. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26029. * */
  26030. cullingStrategy: number;
  26031. /**
  26032. * @hidden Internal global position in the SPS.
  26033. */
  26034. _globalPosition: Vector3;
  26035. /**
  26036. * Creates a Solid Particle object.
  26037. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26038. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26039. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26040. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26041. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26042. * @param shapeId (integer) is the model shape identifier in the SPS.
  26043. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26044. * @param sps defines the sps it is associated to
  26045. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26046. */
  26047. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26048. /**
  26049. * Legacy support, changed scale to scaling
  26050. */
  26051. /**
  26052. * Legacy support, changed scale to scaling
  26053. */
  26054. scale: Vector3;
  26055. /**
  26056. * Legacy support, changed quaternion to rotationQuaternion
  26057. */
  26058. /**
  26059. * Legacy support, changed quaternion to rotationQuaternion
  26060. */
  26061. quaternion: Nullable<Quaternion>;
  26062. /**
  26063. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26064. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26065. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26066. * @returns true if it intersects
  26067. */
  26068. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26069. /**
  26070. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26071. * A particle is in the frustum if its bounding box intersects the frustum
  26072. * @param frustumPlanes defines the frustum to test
  26073. * @returns true if the particle is in the frustum planes
  26074. */
  26075. isInFrustum(frustumPlanes: Plane[]): boolean;
  26076. /**
  26077. * get the rotation matrix of the particle
  26078. * @hidden
  26079. */
  26080. getRotationMatrix(m: Matrix): void;
  26081. }
  26082. /**
  26083. * Represents the shape of the model used by one particle of a solid particle system.
  26084. * SPS internal tool, don't use it manually.
  26085. */
  26086. export class ModelShape {
  26087. /**
  26088. * The shape id
  26089. * @hidden
  26090. */
  26091. shapeID: number;
  26092. /**
  26093. * flat array of model positions (internal use)
  26094. * @hidden
  26095. */
  26096. _shape: Vector3[];
  26097. /**
  26098. * flat array of model UVs (internal use)
  26099. * @hidden
  26100. */
  26101. _shapeUV: number[];
  26102. /**
  26103. * length of the shape in the model indices array (internal use)
  26104. * @hidden
  26105. */
  26106. _indicesLength: number;
  26107. /**
  26108. * Custom position function (internal use)
  26109. * @hidden
  26110. */
  26111. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26112. /**
  26113. * Custom vertex function (internal use)
  26114. * @hidden
  26115. */
  26116. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26117. /**
  26118. * 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.
  26119. * SPS internal tool, don't use it manually.
  26120. * @hidden
  26121. */
  26122. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  26123. }
  26124. /**
  26125. * Represents a Depth Sorted Particle in the solid particle system.
  26126. */
  26127. export class DepthSortedParticle {
  26128. /**
  26129. * Index of the particle in the "indices" array
  26130. */
  26131. ind: number;
  26132. /**
  26133. * Length of the particle shape in the "indices" array
  26134. */
  26135. indicesLength: number;
  26136. /**
  26137. * Squared distance from the particle to the camera
  26138. */
  26139. sqDistance: number;
  26140. }
  26141. }
  26142. declare module "babylonjs/Collisions/meshCollisionData" {
  26143. import { Collider } from "babylonjs/Collisions/collider";
  26144. import { Vector3 } from "babylonjs/Maths/math.vector";
  26145. import { Nullable } from "babylonjs/types";
  26146. import { Observer } from "babylonjs/Misc/observable";
  26147. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26148. /**
  26149. * @hidden
  26150. */
  26151. export class _MeshCollisionData {
  26152. _checkCollisions: boolean;
  26153. _collisionMask: number;
  26154. _collisionGroup: number;
  26155. _collider: Nullable<Collider>;
  26156. _oldPositionForCollisions: Vector3;
  26157. _diffPositionForCollisions: Vector3;
  26158. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26159. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26160. }
  26161. }
  26162. declare module "babylonjs/Meshes/abstractMesh" {
  26163. import { Observable } from "babylonjs/Misc/observable";
  26164. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26165. import { Camera } from "babylonjs/Cameras/camera";
  26166. import { Scene, IDisposable } from "babylonjs/scene";
  26167. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26168. import { Node } from "babylonjs/node";
  26169. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26170. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26171. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26172. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26173. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26174. import { Material } from "babylonjs/Materials/material";
  26175. import { Light } from "babylonjs/Lights/light";
  26176. import { Skeleton } from "babylonjs/Bones/skeleton";
  26177. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26178. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26179. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26180. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26181. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26182. import { Plane } from "babylonjs/Maths/math.plane";
  26183. import { Ray } from "babylonjs/Culling/ray";
  26184. import { Collider } from "babylonjs/Collisions/collider";
  26185. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26186. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26187. /** @hidden */
  26188. class _FacetDataStorage {
  26189. facetPositions: Vector3[];
  26190. facetNormals: Vector3[];
  26191. facetPartitioning: number[][];
  26192. facetNb: number;
  26193. partitioningSubdivisions: number;
  26194. partitioningBBoxRatio: number;
  26195. facetDataEnabled: boolean;
  26196. facetParameters: any;
  26197. bbSize: Vector3;
  26198. subDiv: {
  26199. max: number;
  26200. X: number;
  26201. Y: number;
  26202. Z: number;
  26203. };
  26204. facetDepthSort: boolean;
  26205. facetDepthSortEnabled: boolean;
  26206. depthSortedIndices: IndicesArray;
  26207. depthSortedFacets: {
  26208. ind: number;
  26209. sqDistance: number;
  26210. }[];
  26211. facetDepthSortFunction: (f1: {
  26212. ind: number;
  26213. sqDistance: number;
  26214. }, f2: {
  26215. ind: number;
  26216. sqDistance: number;
  26217. }) => number;
  26218. facetDepthSortFrom: Vector3;
  26219. facetDepthSortOrigin: Vector3;
  26220. invertedMatrix: Matrix;
  26221. }
  26222. /**
  26223. * @hidden
  26224. **/
  26225. class _InternalAbstractMeshDataInfo {
  26226. _hasVertexAlpha: boolean;
  26227. _useVertexColors: boolean;
  26228. _numBoneInfluencers: number;
  26229. _applyFog: boolean;
  26230. _receiveShadows: boolean;
  26231. _facetData: _FacetDataStorage;
  26232. _visibility: number;
  26233. _skeleton: Nullable<Skeleton>;
  26234. _layerMask: number;
  26235. _computeBonesUsingShaders: boolean;
  26236. _isActive: boolean;
  26237. _onlyForInstances: boolean;
  26238. _isActiveIntermediate: boolean;
  26239. _onlyForInstancesIntermediate: boolean;
  26240. }
  26241. /**
  26242. * Class used to store all common mesh properties
  26243. */
  26244. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26245. /** No occlusion */
  26246. static OCCLUSION_TYPE_NONE: number;
  26247. /** Occlusion set to optimisitic */
  26248. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26249. /** Occlusion set to strict */
  26250. static OCCLUSION_TYPE_STRICT: number;
  26251. /** Use an accurante occlusion algorithm */
  26252. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26253. /** Use a conservative occlusion algorithm */
  26254. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26255. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26256. * Test order :
  26257. * Is the bounding sphere outside the frustum ?
  26258. * If not, are the bounding box vertices outside the frustum ?
  26259. * It not, then the cullable object is in the frustum.
  26260. */
  26261. static readonly CULLINGSTRATEGY_STANDARD: number;
  26262. /** Culling strategy : Bounding Sphere Only.
  26263. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26264. * It's also less accurate than the standard because some not visible objects can still be selected.
  26265. * Test : is the bounding sphere outside the frustum ?
  26266. * If not, then the cullable object is in the frustum.
  26267. */
  26268. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26269. /** Culling strategy : Optimistic Inclusion.
  26270. * This in an inclusion test first, then the standard exclusion test.
  26271. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26272. * 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.
  26273. * Anyway, it's as accurate as the standard strategy.
  26274. * Test :
  26275. * Is the cullable object bounding sphere center in the frustum ?
  26276. * If not, apply the default culling strategy.
  26277. */
  26278. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26279. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26280. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26281. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26282. * 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.
  26283. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26284. * Test :
  26285. * Is the cullable object bounding sphere center in the frustum ?
  26286. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26287. */
  26288. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26289. /**
  26290. * No billboard
  26291. */
  26292. static readonly BILLBOARDMODE_NONE: number;
  26293. /** Billboard on X axis */
  26294. static readonly BILLBOARDMODE_X: number;
  26295. /** Billboard on Y axis */
  26296. static readonly BILLBOARDMODE_Y: number;
  26297. /** Billboard on Z axis */
  26298. static readonly BILLBOARDMODE_Z: number;
  26299. /** Billboard on all axes */
  26300. static readonly BILLBOARDMODE_ALL: number;
  26301. /** @hidden */
  26302. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26303. /**
  26304. * The culling strategy to use to check whether the mesh must be rendered or not.
  26305. * This value can be changed at any time and will be used on the next render mesh selection.
  26306. * The possible values are :
  26307. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26308. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26309. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26310. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26311. * Please read each static variable documentation to get details about the culling process.
  26312. * */
  26313. cullingStrategy: number;
  26314. /**
  26315. * Gets the number of facets in the mesh
  26316. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26317. */
  26318. readonly facetNb: number;
  26319. /**
  26320. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26321. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26322. */
  26323. partitioningSubdivisions: number;
  26324. /**
  26325. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26326. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26327. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26328. */
  26329. partitioningBBoxRatio: number;
  26330. /**
  26331. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26332. * Works only for updatable meshes.
  26333. * Doesn't work with multi-materials
  26334. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26335. */
  26336. mustDepthSortFacets: boolean;
  26337. /**
  26338. * The location (Vector3) where the facet depth sort must be computed from.
  26339. * By default, the active camera position.
  26340. * Used only when facet depth sort is enabled
  26341. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26342. */
  26343. facetDepthSortFrom: Vector3;
  26344. /**
  26345. * gets a boolean indicating if facetData is enabled
  26346. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26347. */
  26348. readonly isFacetDataEnabled: boolean;
  26349. /** @hidden */
  26350. _updateNonUniformScalingState(value: boolean): boolean;
  26351. /**
  26352. * An event triggered when this mesh collides with another one
  26353. */
  26354. onCollideObservable: Observable<AbstractMesh>;
  26355. /** Set a function to call when this mesh collides with another one */
  26356. onCollide: () => void;
  26357. /**
  26358. * An event triggered when the collision's position changes
  26359. */
  26360. onCollisionPositionChangeObservable: Observable<Vector3>;
  26361. /** Set a function to call when the collision's position changes */
  26362. onCollisionPositionChange: () => void;
  26363. /**
  26364. * An event triggered when material is changed
  26365. */
  26366. onMaterialChangedObservable: Observable<AbstractMesh>;
  26367. /**
  26368. * Gets or sets the orientation for POV movement & rotation
  26369. */
  26370. definedFacingForward: boolean;
  26371. /** @hidden */
  26372. _occlusionQuery: Nullable<WebGLQuery>;
  26373. /** @hidden */
  26374. _renderingGroup: Nullable<RenderingGroup>;
  26375. /**
  26376. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26377. */
  26378. /**
  26379. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26380. */
  26381. visibility: number;
  26382. /** Gets or sets the alpha index used to sort transparent meshes
  26383. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26384. */
  26385. alphaIndex: number;
  26386. /**
  26387. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26388. */
  26389. isVisible: boolean;
  26390. /**
  26391. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26392. */
  26393. isPickable: boolean;
  26394. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26395. showSubMeshesBoundingBox: boolean;
  26396. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26397. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26398. */
  26399. isBlocker: boolean;
  26400. /**
  26401. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26402. */
  26403. enablePointerMoveEvents: boolean;
  26404. /**
  26405. * Specifies the rendering group id for this mesh (0 by default)
  26406. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26407. */
  26408. renderingGroupId: number;
  26409. private _material;
  26410. /** Gets or sets current material */
  26411. material: Nullable<Material>;
  26412. /**
  26413. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26414. * @see http://doc.babylonjs.com/babylon101/shadows
  26415. */
  26416. receiveShadows: boolean;
  26417. /** Defines color to use when rendering outline */
  26418. outlineColor: Color3;
  26419. /** Define width to use when rendering outline */
  26420. outlineWidth: number;
  26421. /** Defines color to use when rendering overlay */
  26422. overlayColor: Color3;
  26423. /** Defines alpha to use when rendering overlay */
  26424. overlayAlpha: number;
  26425. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26426. hasVertexAlpha: boolean;
  26427. /** 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) */
  26428. useVertexColors: boolean;
  26429. /**
  26430. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26431. */
  26432. computeBonesUsingShaders: boolean;
  26433. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26434. numBoneInfluencers: number;
  26435. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26436. applyFog: boolean;
  26437. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26438. useOctreeForRenderingSelection: boolean;
  26439. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26440. useOctreeForPicking: boolean;
  26441. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26442. useOctreeForCollisions: boolean;
  26443. /**
  26444. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26445. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26446. */
  26447. layerMask: number;
  26448. /**
  26449. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26450. */
  26451. alwaysSelectAsActiveMesh: boolean;
  26452. /**
  26453. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26454. */
  26455. doNotSyncBoundingInfo: boolean;
  26456. /**
  26457. * Gets or sets the current action manager
  26458. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26459. */
  26460. actionManager: Nullable<AbstractActionManager>;
  26461. private _meshCollisionData;
  26462. /**
  26463. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26464. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26465. */
  26466. ellipsoid: Vector3;
  26467. /**
  26468. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26469. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26470. */
  26471. ellipsoidOffset: Vector3;
  26472. /**
  26473. * Gets or sets a collision mask used to mask collisions (default is -1).
  26474. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26475. */
  26476. collisionMask: number;
  26477. /**
  26478. * Gets or sets the current collision group mask (-1 by default).
  26479. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26480. */
  26481. collisionGroup: number;
  26482. /**
  26483. * Defines edge width used when edgesRenderer is enabled
  26484. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26485. */
  26486. edgesWidth: number;
  26487. /**
  26488. * Defines edge color used when edgesRenderer is enabled
  26489. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26490. */
  26491. edgesColor: Color4;
  26492. /** @hidden */
  26493. _edgesRenderer: Nullable<IEdgesRenderer>;
  26494. /** @hidden */
  26495. _masterMesh: Nullable<AbstractMesh>;
  26496. /** @hidden */
  26497. _boundingInfo: Nullable<BoundingInfo>;
  26498. /** @hidden */
  26499. _renderId: number;
  26500. /**
  26501. * Gets or sets the list of subMeshes
  26502. * @see http://doc.babylonjs.com/how_to/multi_materials
  26503. */
  26504. subMeshes: SubMesh[];
  26505. /** @hidden */
  26506. _intersectionsInProgress: AbstractMesh[];
  26507. /** @hidden */
  26508. _unIndexed: boolean;
  26509. /** @hidden */
  26510. _lightSources: Light[];
  26511. /** Gets the list of lights affecting that mesh */
  26512. readonly lightSources: Light[];
  26513. /** @hidden */
  26514. readonly _positions: Nullable<Vector3[]>;
  26515. /** @hidden */
  26516. _waitingData: {
  26517. lods: Nullable<any>;
  26518. actions: Nullable<any>;
  26519. freezeWorldMatrix: Nullable<boolean>;
  26520. };
  26521. /** @hidden */
  26522. _bonesTransformMatrices: Nullable<Float32Array>;
  26523. /** @hidden */
  26524. _transformMatrixTexture: Nullable<RawTexture>;
  26525. /**
  26526. * Gets or sets a skeleton to apply skining transformations
  26527. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26528. */
  26529. skeleton: Nullable<Skeleton>;
  26530. /**
  26531. * An event triggered when the mesh is rebuilt.
  26532. */
  26533. onRebuildObservable: Observable<AbstractMesh>;
  26534. /**
  26535. * Creates a new AbstractMesh
  26536. * @param name defines the name of the mesh
  26537. * @param scene defines the hosting scene
  26538. */
  26539. constructor(name: string, scene?: Nullable<Scene>);
  26540. /**
  26541. * Returns the string "AbstractMesh"
  26542. * @returns "AbstractMesh"
  26543. */
  26544. getClassName(): string;
  26545. /**
  26546. * Gets a string representation of the current mesh
  26547. * @param fullDetails defines a boolean indicating if full details must be included
  26548. * @returns a string representation of the current mesh
  26549. */
  26550. toString(fullDetails?: boolean): string;
  26551. /**
  26552. * @hidden
  26553. */
  26554. protected _getEffectiveParent(): Nullable<Node>;
  26555. /** @hidden */
  26556. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26557. /** @hidden */
  26558. _rebuild(): void;
  26559. /** @hidden */
  26560. _resyncLightSources(): void;
  26561. /** @hidden */
  26562. _resyncLighSource(light: Light): void;
  26563. /** @hidden */
  26564. _unBindEffect(): void;
  26565. /** @hidden */
  26566. _removeLightSource(light: Light): void;
  26567. private _markSubMeshesAsDirty;
  26568. /** @hidden */
  26569. _markSubMeshesAsLightDirty(): void;
  26570. /** @hidden */
  26571. _markSubMeshesAsAttributesDirty(): void;
  26572. /** @hidden */
  26573. _markSubMeshesAsMiscDirty(): void;
  26574. /**
  26575. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26576. */
  26577. scaling: Vector3;
  26578. /**
  26579. * Returns true if the mesh is blocked. Implemented by child classes
  26580. */
  26581. readonly isBlocked: boolean;
  26582. /**
  26583. * Returns the mesh itself by default. Implemented by child classes
  26584. * @param camera defines the camera to use to pick the right LOD level
  26585. * @returns the currentAbstractMesh
  26586. */
  26587. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26588. /**
  26589. * Returns 0 by default. Implemented by child classes
  26590. * @returns an integer
  26591. */
  26592. getTotalVertices(): number;
  26593. /**
  26594. * Returns a positive integer : the total number of indices in this mesh geometry.
  26595. * @returns the numner of indices or zero if the mesh has no geometry.
  26596. */
  26597. getTotalIndices(): number;
  26598. /**
  26599. * Returns null by default. Implemented by child classes
  26600. * @returns null
  26601. */
  26602. getIndices(): Nullable<IndicesArray>;
  26603. /**
  26604. * Returns the array of the requested vertex data kind. Implemented by child classes
  26605. * @param kind defines the vertex data kind to use
  26606. * @returns null
  26607. */
  26608. getVerticesData(kind: string): Nullable<FloatArray>;
  26609. /**
  26610. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26611. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26612. * Note that a new underlying VertexBuffer object is created each call.
  26613. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26614. * @param kind defines vertex data kind:
  26615. * * VertexBuffer.PositionKind
  26616. * * VertexBuffer.UVKind
  26617. * * VertexBuffer.UV2Kind
  26618. * * VertexBuffer.UV3Kind
  26619. * * VertexBuffer.UV4Kind
  26620. * * VertexBuffer.UV5Kind
  26621. * * VertexBuffer.UV6Kind
  26622. * * VertexBuffer.ColorKind
  26623. * * VertexBuffer.MatricesIndicesKind
  26624. * * VertexBuffer.MatricesIndicesExtraKind
  26625. * * VertexBuffer.MatricesWeightsKind
  26626. * * VertexBuffer.MatricesWeightsExtraKind
  26627. * @param data defines the data source
  26628. * @param updatable defines if the data must be flagged as updatable (or static)
  26629. * @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
  26630. * @returns the current mesh
  26631. */
  26632. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26633. /**
  26634. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26635. * If the mesh has no geometry, it is simply returned as it is.
  26636. * @param kind defines vertex data kind:
  26637. * * VertexBuffer.PositionKind
  26638. * * VertexBuffer.UVKind
  26639. * * VertexBuffer.UV2Kind
  26640. * * VertexBuffer.UV3Kind
  26641. * * VertexBuffer.UV4Kind
  26642. * * VertexBuffer.UV5Kind
  26643. * * VertexBuffer.UV6Kind
  26644. * * VertexBuffer.ColorKind
  26645. * * VertexBuffer.MatricesIndicesKind
  26646. * * VertexBuffer.MatricesIndicesExtraKind
  26647. * * VertexBuffer.MatricesWeightsKind
  26648. * * VertexBuffer.MatricesWeightsExtraKind
  26649. * @param data defines the data source
  26650. * @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
  26651. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26652. * @returns the current mesh
  26653. */
  26654. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26655. /**
  26656. * Sets the mesh indices,
  26657. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26658. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26659. * @param totalVertices Defines the total number of vertices
  26660. * @returns the current mesh
  26661. */
  26662. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26663. /**
  26664. * Gets a boolean indicating if specific vertex data is present
  26665. * @param kind defines the vertex data kind to use
  26666. * @returns true is data kind is present
  26667. */
  26668. isVerticesDataPresent(kind: string): boolean;
  26669. /**
  26670. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26671. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26672. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26673. * @returns a BoundingInfo
  26674. */
  26675. getBoundingInfo(): BoundingInfo;
  26676. /**
  26677. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26678. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26679. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26680. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26681. * @returns the current mesh
  26682. */
  26683. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26684. /**
  26685. * Overwrite the current bounding info
  26686. * @param boundingInfo defines the new bounding info
  26687. * @returns the current mesh
  26688. */
  26689. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26690. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26691. readonly useBones: boolean;
  26692. /** @hidden */
  26693. _preActivate(): void;
  26694. /** @hidden */
  26695. _preActivateForIntermediateRendering(renderId: number): void;
  26696. /** @hidden */
  26697. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26698. /** @hidden */
  26699. _postActivate(): void;
  26700. /** @hidden */
  26701. _freeze(): void;
  26702. /** @hidden */
  26703. _unFreeze(): void;
  26704. /**
  26705. * Gets the current world matrix
  26706. * @returns a Matrix
  26707. */
  26708. getWorldMatrix(): Matrix;
  26709. /** @hidden */
  26710. _getWorldMatrixDeterminant(): number;
  26711. /**
  26712. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26713. */
  26714. readonly isAnInstance: boolean;
  26715. /**
  26716. * Perform relative position change from the point of view of behind the front of the mesh.
  26717. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26718. * Supports definition of mesh facing forward or backward
  26719. * @param amountRight defines the distance on the right axis
  26720. * @param amountUp defines the distance on the up axis
  26721. * @param amountForward defines the distance on the forward axis
  26722. * @returns the current mesh
  26723. */
  26724. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26725. /**
  26726. * Calculate relative position change from the point of view of behind the front of the mesh.
  26727. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26728. * Supports definition of mesh facing forward or backward
  26729. * @param amountRight defines the distance on the right axis
  26730. * @param amountUp defines the distance on the up axis
  26731. * @param amountForward defines the distance on the forward axis
  26732. * @returns the new displacement vector
  26733. */
  26734. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26735. /**
  26736. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26737. * Supports definition of mesh facing forward or backward
  26738. * @param flipBack defines the flip
  26739. * @param twirlClockwise defines the twirl
  26740. * @param tiltRight defines the tilt
  26741. * @returns the current mesh
  26742. */
  26743. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26744. /**
  26745. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26746. * Supports definition of mesh facing forward or backward.
  26747. * @param flipBack defines the flip
  26748. * @param twirlClockwise defines the twirl
  26749. * @param tiltRight defines the tilt
  26750. * @returns the new rotation vector
  26751. */
  26752. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26753. /**
  26754. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26755. * This means the mesh underlying bounding box and sphere are recomputed.
  26756. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26757. * @returns the current mesh
  26758. */
  26759. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26760. /** @hidden */
  26761. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26762. /** @hidden */
  26763. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26764. /** @hidden */
  26765. _updateBoundingInfo(): AbstractMesh;
  26766. /** @hidden */
  26767. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26768. /** @hidden */
  26769. protected _afterComputeWorldMatrix(): void;
  26770. /** @hidden */
  26771. readonly _effectiveMesh: AbstractMesh;
  26772. /**
  26773. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26774. * A mesh is in the frustum if its bounding box intersects the frustum
  26775. * @param frustumPlanes defines the frustum to test
  26776. * @returns true if the mesh is in the frustum planes
  26777. */
  26778. isInFrustum(frustumPlanes: Plane[]): boolean;
  26779. /**
  26780. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26781. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26782. * @param frustumPlanes defines the frustum to test
  26783. * @returns true if the mesh is completely in the frustum planes
  26784. */
  26785. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26786. /**
  26787. * True if the mesh intersects another mesh or a SolidParticle object
  26788. * @param mesh defines a target mesh or SolidParticle to test
  26789. * @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)
  26790. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26791. * @returns true if there is an intersection
  26792. */
  26793. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26794. /**
  26795. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26796. * @param point defines the point to test
  26797. * @returns true if there is an intersection
  26798. */
  26799. intersectsPoint(point: Vector3): boolean;
  26800. /**
  26801. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26802. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26803. */
  26804. checkCollisions: boolean;
  26805. /**
  26806. * Gets Collider object used to compute collisions (not physics)
  26807. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26808. */
  26809. readonly collider: Nullable<Collider>;
  26810. /**
  26811. * Move the mesh using collision engine
  26812. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26813. * @param displacement defines the requested displacement vector
  26814. * @returns the current mesh
  26815. */
  26816. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26817. private _onCollisionPositionChange;
  26818. /** @hidden */
  26819. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26820. /** @hidden */
  26821. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26822. /** @hidden */
  26823. _checkCollision(collider: Collider): AbstractMesh;
  26824. /** @hidden */
  26825. _generatePointsArray(): boolean;
  26826. /**
  26827. * Checks if the passed Ray intersects with the mesh
  26828. * @param ray defines the ray to use
  26829. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26830. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26831. * @returns the picking info
  26832. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26833. */
  26834. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26835. /**
  26836. * Clones the current mesh
  26837. * @param name defines the mesh name
  26838. * @param newParent defines the new mesh parent
  26839. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26840. * @returns the new mesh
  26841. */
  26842. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26843. /**
  26844. * Disposes all the submeshes of the current meshnp
  26845. * @returns the current mesh
  26846. */
  26847. releaseSubMeshes(): AbstractMesh;
  26848. /**
  26849. * Releases resources associated with this abstract mesh.
  26850. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26851. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26852. */
  26853. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26854. /**
  26855. * Adds the passed mesh as a child to the current mesh
  26856. * @param mesh defines the child mesh
  26857. * @returns the current mesh
  26858. */
  26859. addChild(mesh: AbstractMesh): AbstractMesh;
  26860. /**
  26861. * Removes the passed mesh from the current mesh children list
  26862. * @param mesh defines the child mesh
  26863. * @returns the current mesh
  26864. */
  26865. removeChild(mesh: AbstractMesh): AbstractMesh;
  26866. /** @hidden */
  26867. private _initFacetData;
  26868. /**
  26869. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26870. * This method can be called within the render loop.
  26871. * 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
  26872. * @returns the current mesh
  26873. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26874. */
  26875. updateFacetData(): AbstractMesh;
  26876. /**
  26877. * Returns the facetLocalNormals array.
  26878. * The normals are expressed in the mesh local spac
  26879. * @returns an array of Vector3
  26880. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26881. */
  26882. getFacetLocalNormals(): Vector3[];
  26883. /**
  26884. * Returns the facetLocalPositions array.
  26885. * The facet positions are expressed in the mesh local space
  26886. * @returns an array of Vector3
  26887. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26888. */
  26889. getFacetLocalPositions(): Vector3[];
  26890. /**
  26891. * Returns the facetLocalPartioning array
  26892. * @returns an array of array of numbers
  26893. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26894. */
  26895. getFacetLocalPartitioning(): number[][];
  26896. /**
  26897. * Returns the i-th facet position in the world system.
  26898. * This method allocates a new Vector3 per call
  26899. * @param i defines the facet index
  26900. * @returns a new Vector3
  26901. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26902. */
  26903. getFacetPosition(i: number): Vector3;
  26904. /**
  26905. * Sets the reference Vector3 with the i-th facet position in the world system
  26906. * @param i defines the facet index
  26907. * @param ref defines the target vector
  26908. * @returns the current mesh
  26909. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26910. */
  26911. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26912. /**
  26913. * Returns the i-th facet normal in the world system.
  26914. * This method allocates a new Vector3 per call
  26915. * @param i defines the facet index
  26916. * @returns a new Vector3
  26917. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26918. */
  26919. getFacetNormal(i: number): Vector3;
  26920. /**
  26921. * Sets the reference Vector3 with the i-th facet normal in the world system
  26922. * @param i defines the facet index
  26923. * @param ref defines the target vector
  26924. * @returns the current mesh
  26925. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26926. */
  26927. getFacetNormalToRef(i: number, ref: Vector3): this;
  26928. /**
  26929. * 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)
  26930. * @param x defines x coordinate
  26931. * @param y defines y coordinate
  26932. * @param z defines z coordinate
  26933. * @returns the array of facet indexes
  26934. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26935. */
  26936. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26937. /**
  26938. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26939. * @param projected sets as the (x,y,z) world projection on the facet
  26940. * @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
  26941. * @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
  26942. * @param x defines x coordinate
  26943. * @param y defines y coordinate
  26944. * @param z defines z coordinate
  26945. * @returns the face index if found (or null instead)
  26946. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26947. */
  26948. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26949. /**
  26950. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26951. * @param projected sets as the (x,y,z) local projection on the facet
  26952. * @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
  26953. * @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
  26954. * @param x defines x coordinate
  26955. * @param y defines y coordinate
  26956. * @param z defines z coordinate
  26957. * @returns the face index if found (or null instead)
  26958. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26959. */
  26960. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26961. /**
  26962. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26963. * @returns the parameters
  26964. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26965. */
  26966. getFacetDataParameters(): any;
  26967. /**
  26968. * Disables the feature FacetData and frees the related memory
  26969. * @returns the current mesh
  26970. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26971. */
  26972. disableFacetData(): AbstractMesh;
  26973. /**
  26974. * Updates the AbstractMesh indices array
  26975. * @param indices defines the data source
  26976. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26977. * @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)
  26978. * @returns the current mesh
  26979. */
  26980. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26981. /**
  26982. * Creates new normals data for the mesh
  26983. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26984. * @returns the current mesh
  26985. */
  26986. createNormals(updatable: boolean): AbstractMesh;
  26987. /**
  26988. * Align the mesh with a normal
  26989. * @param normal defines the normal to use
  26990. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26991. * @returns the current mesh
  26992. */
  26993. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26994. /** @hidden */
  26995. _checkOcclusionQuery(): boolean;
  26996. /**
  26997. * Disables the mesh edge rendering mode
  26998. * @returns the currentAbstractMesh
  26999. */
  27000. disableEdgesRendering(): AbstractMesh;
  27001. /**
  27002. * Enables the edge rendering mode on the mesh.
  27003. * This mode makes the mesh edges visible
  27004. * @param epsilon defines the maximal distance between two angles to detect a face
  27005. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27006. * @returns the currentAbstractMesh
  27007. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27008. */
  27009. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27010. }
  27011. }
  27012. declare module "babylonjs/Actions/actionEvent" {
  27013. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27014. import { Nullable } from "babylonjs/types";
  27015. import { Sprite } from "babylonjs/Sprites/sprite";
  27016. import { Scene } from "babylonjs/scene";
  27017. import { Vector2 } from "babylonjs/Maths/math.vector";
  27018. /**
  27019. * Interface used to define ActionEvent
  27020. */
  27021. export interface IActionEvent {
  27022. /** The mesh or sprite that triggered the action */
  27023. source: any;
  27024. /** The X mouse cursor position at the time of the event */
  27025. pointerX: number;
  27026. /** The Y mouse cursor position at the time of the event */
  27027. pointerY: number;
  27028. /** The mesh that is currently pointed at (can be null) */
  27029. meshUnderPointer: Nullable<AbstractMesh>;
  27030. /** the original (browser) event that triggered the ActionEvent */
  27031. sourceEvent?: any;
  27032. /** additional data for the event */
  27033. additionalData?: any;
  27034. }
  27035. /**
  27036. * ActionEvent is the event being sent when an action is triggered.
  27037. */
  27038. export class ActionEvent implements IActionEvent {
  27039. /** The mesh or sprite that triggered the action */
  27040. source: any;
  27041. /** The X mouse cursor position at the time of the event */
  27042. pointerX: number;
  27043. /** The Y mouse cursor position at the time of the event */
  27044. pointerY: number;
  27045. /** The mesh that is currently pointed at (can be null) */
  27046. meshUnderPointer: Nullable<AbstractMesh>;
  27047. /** the original (browser) event that triggered the ActionEvent */
  27048. sourceEvent?: any;
  27049. /** additional data for the event */
  27050. additionalData?: any;
  27051. /**
  27052. * Creates a new ActionEvent
  27053. * @param source The mesh or sprite that triggered the action
  27054. * @param pointerX The X mouse cursor position at the time of the event
  27055. * @param pointerY The Y mouse cursor position at the time of the event
  27056. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27057. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27058. * @param additionalData additional data for the event
  27059. */
  27060. constructor(
  27061. /** The mesh or sprite that triggered the action */
  27062. source: any,
  27063. /** The X mouse cursor position at the time of the event */
  27064. pointerX: number,
  27065. /** The Y mouse cursor position at the time of the event */
  27066. pointerY: number,
  27067. /** The mesh that is currently pointed at (can be null) */
  27068. meshUnderPointer: Nullable<AbstractMesh>,
  27069. /** the original (browser) event that triggered the ActionEvent */
  27070. sourceEvent?: any,
  27071. /** additional data for the event */
  27072. additionalData?: any);
  27073. /**
  27074. * Helper function to auto-create an ActionEvent from a source mesh.
  27075. * @param source The source mesh that triggered the event
  27076. * @param evt The original (browser) event
  27077. * @param additionalData additional data for the event
  27078. * @returns the new ActionEvent
  27079. */
  27080. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27081. /**
  27082. * Helper function to auto-create an ActionEvent from a source sprite
  27083. * @param source The source sprite that triggered the event
  27084. * @param scene Scene associated with the sprite
  27085. * @param evt The original (browser) event
  27086. * @param additionalData additional data for the event
  27087. * @returns the new ActionEvent
  27088. */
  27089. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27090. /**
  27091. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27092. * @param scene the scene where the event occurred
  27093. * @param evt The original (browser) event
  27094. * @returns the new ActionEvent
  27095. */
  27096. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27097. /**
  27098. * Helper function to auto-create an ActionEvent from a primitive
  27099. * @param prim defines the target primitive
  27100. * @param pointerPos defines the pointer position
  27101. * @param evt The original (browser) event
  27102. * @param additionalData additional data for the event
  27103. * @returns the new ActionEvent
  27104. */
  27105. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27106. }
  27107. }
  27108. declare module "babylonjs/Actions/abstractActionManager" {
  27109. import { IDisposable } from "babylonjs/scene";
  27110. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27111. import { IAction } from "babylonjs/Actions/action";
  27112. import { Nullable } from "babylonjs/types";
  27113. /**
  27114. * Abstract class used to decouple action Manager from scene and meshes.
  27115. * Do not instantiate.
  27116. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27117. */
  27118. export abstract class AbstractActionManager implements IDisposable {
  27119. /** Gets the list of active triggers */
  27120. static Triggers: {
  27121. [key: string]: number;
  27122. };
  27123. /** Gets the cursor to use when hovering items */
  27124. hoverCursor: string;
  27125. /** Gets the list of actions */
  27126. actions: IAction[];
  27127. /**
  27128. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27129. */
  27130. isRecursive: boolean;
  27131. /**
  27132. * Releases all associated resources
  27133. */
  27134. abstract dispose(): void;
  27135. /**
  27136. * Does this action manager has pointer triggers
  27137. */
  27138. abstract readonly hasPointerTriggers: boolean;
  27139. /**
  27140. * Does this action manager has pick triggers
  27141. */
  27142. abstract readonly hasPickTriggers: boolean;
  27143. /**
  27144. * Process a specific trigger
  27145. * @param trigger defines the trigger to process
  27146. * @param evt defines the event details to be processed
  27147. */
  27148. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27149. /**
  27150. * Does this action manager handles actions of any of the given triggers
  27151. * @param triggers defines the triggers to be tested
  27152. * @return a boolean indicating whether one (or more) of the triggers is handled
  27153. */
  27154. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27155. /**
  27156. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27157. * speed.
  27158. * @param triggerA defines the trigger to be tested
  27159. * @param triggerB defines the trigger to be tested
  27160. * @return a boolean indicating whether one (or more) of the triggers is handled
  27161. */
  27162. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27163. /**
  27164. * Does this action manager handles actions of a given trigger
  27165. * @param trigger defines the trigger to be tested
  27166. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27167. * @return whether the trigger is handled
  27168. */
  27169. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27170. /**
  27171. * Serialize this manager to a JSON object
  27172. * @param name defines the property name to store this manager
  27173. * @returns a JSON representation of this manager
  27174. */
  27175. abstract serialize(name: string): any;
  27176. /**
  27177. * Registers an action to this action manager
  27178. * @param action defines the action to be registered
  27179. * @return the action amended (prepared) after registration
  27180. */
  27181. abstract registerAction(action: IAction): Nullable<IAction>;
  27182. /**
  27183. * Unregisters an action to this action manager
  27184. * @param action defines the action to be unregistered
  27185. * @return a boolean indicating whether the action has been unregistered
  27186. */
  27187. abstract unregisterAction(action: IAction): Boolean;
  27188. /**
  27189. * Does exist one action manager with at least one trigger
  27190. **/
  27191. static readonly HasTriggers: boolean;
  27192. /**
  27193. * Does exist one action manager with at least one pick trigger
  27194. **/
  27195. static readonly HasPickTriggers: boolean;
  27196. /**
  27197. * Does exist one action manager that handles actions of a given trigger
  27198. * @param trigger defines the trigger to be tested
  27199. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27200. **/
  27201. static HasSpecificTrigger(trigger: number): boolean;
  27202. }
  27203. }
  27204. declare module "babylonjs/node" {
  27205. import { Scene } from "babylonjs/scene";
  27206. import { Nullable } from "babylonjs/types";
  27207. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27208. import { Engine } from "babylonjs/Engines/engine";
  27209. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27210. import { Observable } from "babylonjs/Misc/observable";
  27211. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27212. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27213. import { Animatable } from "babylonjs/Animations/animatable";
  27214. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27215. import { Animation } from "babylonjs/Animations/animation";
  27216. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27217. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27218. /**
  27219. * Defines how a node can be built from a string name.
  27220. */
  27221. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27222. /**
  27223. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27224. */
  27225. export class Node implements IBehaviorAware<Node> {
  27226. /** @hidden */
  27227. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27228. private static _NodeConstructors;
  27229. /**
  27230. * Add a new node constructor
  27231. * @param type defines the type name of the node to construct
  27232. * @param constructorFunc defines the constructor function
  27233. */
  27234. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27235. /**
  27236. * Returns a node constructor based on type name
  27237. * @param type defines the type name
  27238. * @param name defines the new node name
  27239. * @param scene defines the hosting scene
  27240. * @param options defines optional options to transmit to constructors
  27241. * @returns the new constructor or null
  27242. */
  27243. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27244. /**
  27245. * Gets or sets the name of the node
  27246. */
  27247. name: string;
  27248. /**
  27249. * Gets or sets the id of the node
  27250. */
  27251. id: string;
  27252. /**
  27253. * Gets or sets the unique id of the node
  27254. */
  27255. uniqueId: number;
  27256. /**
  27257. * Gets or sets a string used to store user defined state for the node
  27258. */
  27259. state: string;
  27260. /**
  27261. * Gets or sets an object used to store user defined information for the node
  27262. */
  27263. metadata: any;
  27264. /**
  27265. * For internal use only. Please do not use.
  27266. */
  27267. reservedDataStore: any;
  27268. /**
  27269. * List of inspectable custom properties (used by the Inspector)
  27270. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27271. */
  27272. inspectableCustomProperties: IInspectable[];
  27273. /**
  27274. * Gets or sets a boolean used to define if the node must be serialized
  27275. */
  27276. doNotSerialize: boolean;
  27277. /** @hidden */
  27278. _isDisposed: boolean;
  27279. /**
  27280. * Gets a list of Animations associated with the node
  27281. */
  27282. animations: import("babylonjs/Animations/animation").Animation[];
  27283. protected _ranges: {
  27284. [name: string]: Nullable<AnimationRange>;
  27285. };
  27286. /**
  27287. * Callback raised when the node is ready to be used
  27288. */
  27289. onReady: Nullable<(node: Node) => void>;
  27290. private _isEnabled;
  27291. private _isParentEnabled;
  27292. private _isReady;
  27293. /** @hidden */
  27294. _currentRenderId: number;
  27295. private _parentUpdateId;
  27296. /** @hidden */
  27297. _childUpdateId: number;
  27298. /** @hidden */
  27299. _waitingParentId: Nullable<string>;
  27300. /** @hidden */
  27301. _scene: Scene;
  27302. /** @hidden */
  27303. _cache: any;
  27304. private _parentNode;
  27305. private _children;
  27306. /** @hidden */
  27307. _worldMatrix: Matrix;
  27308. /** @hidden */
  27309. _worldMatrixDeterminant: number;
  27310. /** @hidden */
  27311. _worldMatrixDeterminantIsDirty: boolean;
  27312. /** @hidden */
  27313. private _sceneRootNodesIndex;
  27314. /**
  27315. * Gets a boolean indicating if the node has been disposed
  27316. * @returns true if the node was disposed
  27317. */
  27318. isDisposed(): boolean;
  27319. /**
  27320. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27321. * @see https://doc.babylonjs.com/how_to/parenting
  27322. */
  27323. parent: Nullable<Node>;
  27324. private addToSceneRootNodes;
  27325. private removeFromSceneRootNodes;
  27326. private _animationPropertiesOverride;
  27327. /**
  27328. * Gets or sets the animation properties override
  27329. */
  27330. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27331. /**
  27332. * Gets a string idenfifying the name of the class
  27333. * @returns "Node" string
  27334. */
  27335. getClassName(): string;
  27336. /** @hidden */
  27337. readonly _isNode: boolean;
  27338. /**
  27339. * An event triggered when the mesh is disposed
  27340. */
  27341. onDisposeObservable: Observable<Node>;
  27342. private _onDisposeObserver;
  27343. /**
  27344. * Sets a callback that will be raised when the node will be disposed
  27345. */
  27346. onDispose: () => void;
  27347. /**
  27348. * Creates a new Node
  27349. * @param name the name and id to be given to this node
  27350. * @param scene the scene this node will be added to
  27351. * @param addToRootNodes the node will be added to scene.rootNodes
  27352. */
  27353. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27354. /**
  27355. * Gets the scene of the node
  27356. * @returns a scene
  27357. */
  27358. getScene(): Scene;
  27359. /**
  27360. * Gets the engine of the node
  27361. * @returns a Engine
  27362. */
  27363. getEngine(): Engine;
  27364. private _behaviors;
  27365. /**
  27366. * Attach a behavior to the node
  27367. * @see http://doc.babylonjs.com/features/behaviour
  27368. * @param behavior defines the behavior to attach
  27369. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27370. * @returns the current Node
  27371. */
  27372. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27373. /**
  27374. * Remove an attached behavior
  27375. * @see http://doc.babylonjs.com/features/behaviour
  27376. * @param behavior defines the behavior to attach
  27377. * @returns the current Node
  27378. */
  27379. removeBehavior(behavior: Behavior<Node>): Node;
  27380. /**
  27381. * Gets the list of attached behaviors
  27382. * @see http://doc.babylonjs.com/features/behaviour
  27383. */
  27384. readonly behaviors: Behavior<Node>[];
  27385. /**
  27386. * Gets an attached behavior by name
  27387. * @param name defines the name of the behavior to look for
  27388. * @see http://doc.babylonjs.com/features/behaviour
  27389. * @returns null if behavior was not found else the requested behavior
  27390. */
  27391. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27392. /**
  27393. * Returns the latest update of the World matrix
  27394. * @returns a Matrix
  27395. */
  27396. getWorldMatrix(): Matrix;
  27397. /** @hidden */
  27398. _getWorldMatrixDeterminant(): number;
  27399. /**
  27400. * Returns directly the latest state of the mesh World matrix.
  27401. * A Matrix is returned.
  27402. */
  27403. readonly worldMatrixFromCache: Matrix;
  27404. /** @hidden */
  27405. _initCache(): void;
  27406. /** @hidden */
  27407. updateCache(force?: boolean): void;
  27408. /** @hidden */
  27409. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27410. /** @hidden */
  27411. _updateCache(ignoreParentClass?: boolean): void;
  27412. /** @hidden */
  27413. _isSynchronized(): boolean;
  27414. /** @hidden */
  27415. _markSyncedWithParent(): void;
  27416. /** @hidden */
  27417. isSynchronizedWithParent(): boolean;
  27418. /** @hidden */
  27419. isSynchronized(): boolean;
  27420. /**
  27421. * Is this node ready to be used/rendered
  27422. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27423. * @return true if the node is ready
  27424. */
  27425. isReady(completeCheck?: boolean): boolean;
  27426. /**
  27427. * Is this node enabled?
  27428. * 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
  27429. * @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
  27430. * @return whether this node (and its parent) is enabled
  27431. */
  27432. isEnabled(checkAncestors?: boolean): boolean;
  27433. /** @hidden */
  27434. protected _syncParentEnabledState(): void;
  27435. /**
  27436. * Set the enabled state of this node
  27437. * @param value defines the new enabled state
  27438. */
  27439. setEnabled(value: boolean): void;
  27440. /**
  27441. * Is this node a descendant of the given node?
  27442. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27443. * @param ancestor defines the parent node to inspect
  27444. * @returns a boolean indicating if this node is a descendant of the given node
  27445. */
  27446. isDescendantOf(ancestor: Node): boolean;
  27447. /** @hidden */
  27448. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27449. /**
  27450. * Will return all nodes that have this node as ascendant
  27451. * @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
  27452. * @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
  27453. * @return all children nodes of all types
  27454. */
  27455. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27456. /**
  27457. * Get all child-meshes of this node
  27458. * @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)
  27459. * @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
  27460. * @returns an array of AbstractMesh
  27461. */
  27462. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27463. /**
  27464. * Get all direct children of this node
  27465. * @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
  27466. * @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)
  27467. * @returns an array of Node
  27468. */
  27469. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27470. /** @hidden */
  27471. _setReady(state: boolean): void;
  27472. /**
  27473. * Get an animation by name
  27474. * @param name defines the name of the animation to look for
  27475. * @returns null if not found else the requested animation
  27476. */
  27477. getAnimationByName(name: string): Nullable<Animation>;
  27478. /**
  27479. * Creates an animation range for this node
  27480. * @param name defines the name of the range
  27481. * @param from defines the starting key
  27482. * @param to defines the end key
  27483. */
  27484. createAnimationRange(name: string, from: number, to: number): void;
  27485. /**
  27486. * Delete a specific animation range
  27487. * @param name defines the name of the range to delete
  27488. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27489. */
  27490. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27491. /**
  27492. * Get an animation range by name
  27493. * @param name defines the name of the animation range to look for
  27494. * @returns null if not found else the requested animation range
  27495. */
  27496. getAnimationRange(name: string): Nullable<AnimationRange>;
  27497. /**
  27498. * Gets the list of all animation ranges defined on this node
  27499. * @returns an array
  27500. */
  27501. getAnimationRanges(): Nullable<AnimationRange>[];
  27502. /**
  27503. * Will start the animation sequence
  27504. * @param name defines the range frames for animation sequence
  27505. * @param loop defines if the animation should loop (false by default)
  27506. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27507. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27508. * @returns the object created for this animation. If range does not exist, it will return null
  27509. */
  27510. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27511. /**
  27512. * Serialize animation ranges into a JSON compatible object
  27513. * @returns serialization object
  27514. */
  27515. serializeAnimationRanges(): any;
  27516. /**
  27517. * Computes the world matrix of the node
  27518. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27519. * @returns the world matrix
  27520. */
  27521. computeWorldMatrix(force?: boolean): Matrix;
  27522. /**
  27523. * Releases resources associated with this node.
  27524. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27525. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27526. */
  27527. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27528. /**
  27529. * Parse animation range data from a serialization object and store them into a given node
  27530. * @param node defines where to store the animation ranges
  27531. * @param parsedNode defines the serialization object to read data from
  27532. * @param scene defines the hosting scene
  27533. */
  27534. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27535. /**
  27536. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27537. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27538. * @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
  27539. * @returns the new bounding vectors
  27540. */
  27541. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27542. min: Vector3;
  27543. max: Vector3;
  27544. };
  27545. }
  27546. }
  27547. declare module "babylonjs/Animations/animation" {
  27548. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27549. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27550. import { Color3 } from "babylonjs/Maths/math.color";
  27551. import { Nullable } from "babylonjs/types";
  27552. import { Scene } from "babylonjs/scene";
  27553. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27554. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27555. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27556. import { Node } from "babylonjs/node";
  27557. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27558. import { Size } from "babylonjs/Maths/math.size";
  27559. import { Animatable } from "babylonjs/Animations/animatable";
  27560. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27561. /**
  27562. * @hidden
  27563. */
  27564. export class _IAnimationState {
  27565. key: number;
  27566. repeatCount: number;
  27567. workValue?: any;
  27568. loopMode?: number;
  27569. offsetValue?: any;
  27570. highLimitValue?: any;
  27571. }
  27572. /**
  27573. * Class used to store any kind of animation
  27574. */
  27575. export class Animation {
  27576. /**Name of the animation */
  27577. name: string;
  27578. /**Property to animate */
  27579. targetProperty: string;
  27580. /**The frames per second of the animation */
  27581. framePerSecond: number;
  27582. /**The data type of the animation */
  27583. dataType: number;
  27584. /**The loop mode of the animation */
  27585. loopMode?: number | undefined;
  27586. /**Specifies if blending should be enabled */
  27587. enableBlending?: boolean | undefined;
  27588. /**
  27589. * Use matrix interpolation instead of using direct key value when animating matrices
  27590. */
  27591. static AllowMatricesInterpolation: boolean;
  27592. /**
  27593. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27594. */
  27595. static AllowMatrixDecomposeForInterpolation: boolean;
  27596. /**
  27597. * Stores the key frames of the animation
  27598. */
  27599. private _keys;
  27600. /**
  27601. * Stores the easing function of the animation
  27602. */
  27603. private _easingFunction;
  27604. /**
  27605. * @hidden Internal use only
  27606. */
  27607. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27608. /**
  27609. * The set of event that will be linked to this animation
  27610. */
  27611. private _events;
  27612. /**
  27613. * Stores an array of target property paths
  27614. */
  27615. targetPropertyPath: string[];
  27616. /**
  27617. * Stores the blending speed of the animation
  27618. */
  27619. blendingSpeed: number;
  27620. /**
  27621. * Stores the animation ranges for the animation
  27622. */
  27623. private _ranges;
  27624. /**
  27625. * @hidden Internal use
  27626. */
  27627. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27628. /**
  27629. * Sets up an animation
  27630. * @param property The property to animate
  27631. * @param animationType The animation type to apply
  27632. * @param framePerSecond The frames per second of the animation
  27633. * @param easingFunction The easing function used in the animation
  27634. * @returns The created animation
  27635. */
  27636. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27637. /**
  27638. * Create and start an animation on a node
  27639. * @param name defines the name of the global animation that will be run on all nodes
  27640. * @param node defines the root node where the animation will take place
  27641. * @param targetProperty defines property to animate
  27642. * @param framePerSecond defines the number of frame per second yo use
  27643. * @param totalFrame defines the number of frames in total
  27644. * @param from defines the initial value
  27645. * @param to defines the final value
  27646. * @param loopMode defines which loop mode you want to use (off by default)
  27647. * @param easingFunction defines the easing function to use (linear by default)
  27648. * @param onAnimationEnd defines the callback to call when animation end
  27649. * @returns the animatable created for this animation
  27650. */
  27651. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27652. /**
  27653. * Create and start an animation on a node and its descendants
  27654. * @param name defines the name of the global animation that will be run on all nodes
  27655. * @param node defines the root node where the animation will take place
  27656. * @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
  27657. * @param targetProperty defines property to animate
  27658. * @param framePerSecond defines the number of frame per second to use
  27659. * @param totalFrame defines the number of frames in total
  27660. * @param from defines the initial value
  27661. * @param to defines the final value
  27662. * @param loopMode defines which loop mode you want to use (off by default)
  27663. * @param easingFunction defines the easing function to use (linear by default)
  27664. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27665. * @returns the list of animatables created for all nodes
  27666. * @example https://www.babylonjs-playground.com/#MH0VLI
  27667. */
  27668. 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[]>;
  27669. /**
  27670. * Creates a new animation, merges it with the existing animations and starts it
  27671. * @param name Name of the animation
  27672. * @param node Node which contains the scene that begins the animations
  27673. * @param targetProperty Specifies which property to animate
  27674. * @param framePerSecond The frames per second of the animation
  27675. * @param totalFrame The total number of frames
  27676. * @param from The frame at the beginning of the animation
  27677. * @param to The frame at the end of the animation
  27678. * @param loopMode Specifies the loop mode of the animation
  27679. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27680. * @param onAnimationEnd Callback to run once the animation is complete
  27681. * @returns Nullable animation
  27682. */
  27683. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27684. /**
  27685. * Transition property of an host to the target Value
  27686. * @param property The property to transition
  27687. * @param targetValue The target Value of the property
  27688. * @param host The object where the property to animate belongs
  27689. * @param scene Scene used to run the animation
  27690. * @param frameRate Framerate (in frame/s) to use
  27691. * @param transition The transition type we want to use
  27692. * @param duration The duration of the animation, in milliseconds
  27693. * @param onAnimationEnd Callback trigger at the end of the animation
  27694. * @returns Nullable animation
  27695. */
  27696. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27697. /**
  27698. * Return the array of runtime animations currently using this animation
  27699. */
  27700. readonly runtimeAnimations: RuntimeAnimation[];
  27701. /**
  27702. * Specifies if any of the runtime animations are currently running
  27703. */
  27704. readonly hasRunningRuntimeAnimations: boolean;
  27705. /**
  27706. * Initializes the animation
  27707. * @param name Name of the animation
  27708. * @param targetProperty Property to animate
  27709. * @param framePerSecond The frames per second of the animation
  27710. * @param dataType The data type of the animation
  27711. * @param loopMode The loop mode of the animation
  27712. * @param enableBlending Specifies if blending should be enabled
  27713. */
  27714. constructor(
  27715. /**Name of the animation */
  27716. name: string,
  27717. /**Property to animate */
  27718. targetProperty: string,
  27719. /**The frames per second of the animation */
  27720. framePerSecond: number,
  27721. /**The data type of the animation */
  27722. dataType: number,
  27723. /**The loop mode of the animation */
  27724. loopMode?: number | undefined,
  27725. /**Specifies if blending should be enabled */
  27726. enableBlending?: boolean | undefined);
  27727. /**
  27728. * Converts the animation to a string
  27729. * @param fullDetails support for multiple levels of logging within scene loading
  27730. * @returns String form of the animation
  27731. */
  27732. toString(fullDetails?: boolean): string;
  27733. /**
  27734. * Add an event to this animation
  27735. * @param event Event to add
  27736. */
  27737. addEvent(event: AnimationEvent): void;
  27738. /**
  27739. * Remove all events found at the given frame
  27740. * @param frame The frame to remove events from
  27741. */
  27742. removeEvents(frame: number): void;
  27743. /**
  27744. * Retrieves all the events from the animation
  27745. * @returns Events from the animation
  27746. */
  27747. getEvents(): AnimationEvent[];
  27748. /**
  27749. * Creates an animation range
  27750. * @param name Name of the animation range
  27751. * @param from Starting frame of the animation range
  27752. * @param to Ending frame of the animation
  27753. */
  27754. createRange(name: string, from: number, to: number): void;
  27755. /**
  27756. * Deletes an animation range by name
  27757. * @param name Name of the animation range to delete
  27758. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27759. */
  27760. deleteRange(name: string, deleteFrames?: boolean): void;
  27761. /**
  27762. * Gets the animation range by name, or null if not defined
  27763. * @param name Name of the animation range
  27764. * @returns Nullable animation range
  27765. */
  27766. getRange(name: string): Nullable<AnimationRange>;
  27767. /**
  27768. * Gets the key frames from the animation
  27769. * @returns The key frames of the animation
  27770. */
  27771. getKeys(): Array<IAnimationKey>;
  27772. /**
  27773. * Gets the highest frame rate of the animation
  27774. * @returns Highest frame rate of the animation
  27775. */
  27776. getHighestFrame(): number;
  27777. /**
  27778. * Gets the easing function of the animation
  27779. * @returns Easing function of the animation
  27780. */
  27781. getEasingFunction(): IEasingFunction;
  27782. /**
  27783. * Sets the easing function of the animation
  27784. * @param easingFunction A custom mathematical formula for animation
  27785. */
  27786. setEasingFunction(easingFunction: EasingFunction): void;
  27787. /**
  27788. * Interpolates a scalar linearly
  27789. * @param startValue Start value of the animation curve
  27790. * @param endValue End value of the animation curve
  27791. * @param gradient Scalar amount to interpolate
  27792. * @returns Interpolated scalar value
  27793. */
  27794. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27795. /**
  27796. * Interpolates a scalar cubically
  27797. * @param startValue Start value of the animation curve
  27798. * @param outTangent End tangent of the animation
  27799. * @param endValue End value of the animation curve
  27800. * @param inTangent Start tangent of the animation curve
  27801. * @param gradient Scalar amount to interpolate
  27802. * @returns Interpolated scalar value
  27803. */
  27804. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27805. /**
  27806. * Interpolates a quaternion using a spherical linear interpolation
  27807. * @param startValue Start value of the animation curve
  27808. * @param endValue End value of the animation curve
  27809. * @param gradient Scalar amount to interpolate
  27810. * @returns Interpolated quaternion value
  27811. */
  27812. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27813. /**
  27814. * Interpolates a quaternion cubically
  27815. * @param startValue Start value of the animation curve
  27816. * @param outTangent End tangent of the animation curve
  27817. * @param endValue End value of the animation curve
  27818. * @param inTangent Start tangent of the animation curve
  27819. * @param gradient Scalar amount to interpolate
  27820. * @returns Interpolated quaternion value
  27821. */
  27822. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27823. /**
  27824. * Interpolates a Vector3 linearl
  27825. * @param startValue Start value of the animation curve
  27826. * @param endValue End value of the animation curve
  27827. * @param gradient Scalar amount to interpolate
  27828. * @returns Interpolated scalar value
  27829. */
  27830. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27831. /**
  27832. * Interpolates a Vector3 cubically
  27833. * @param startValue Start value of the animation curve
  27834. * @param outTangent End tangent of the animation
  27835. * @param endValue End value of the animation curve
  27836. * @param inTangent Start tangent of the animation curve
  27837. * @param gradient Scalar amount to interpolate
  27838. * @returns InterpolatedVector3 value
  27839. */
  27840. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27841. /**
  27842. * Interpolates a Vector2 linearly
  27843. * @param startValue Start value of the animation curve
  27844. * @param endValue End value of the animation curve
  27845. * @param gradient Scalar amount to interpolate
  27846. * @returns Interpolated Vector2 value
  27847. */
  27848. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27849. /**
  27850. * Interpolates a Vector2 cubically
  27851. * @param startValue Start value of the animation curve
  27852. * @param outTangent End tangent of the animation
  27853. * @param endValue End value of the animation curve
  27854. * @param inTangent Start tangent of the animation curve
  27855. * @param gradient Scalar amount to interpolate
  27856. * @returns Interpolated Vector2 value
  27857. */
  27858. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27859. /**
  27860. * Interpolates a size linearly
  27861. * @param startValue Start value of the animation curve
  27862. * @param endValue End value of the animation curve
  27863. * @param gradient Scalar amount to interpolate
  27864. * @returns Interpolated Size value
  27865. */
  27866. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27867. /**
  27868. * Interpolates a Color3 linearly
  27869. * @param startValue Start value of the animation curve
  27870. * @param endValue End value of the animation curve
  27871. * @param gradient Scalar amount to interpolate
  27872. * @returns Interpolated Color3 value
  27873. */
  27874. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27875. /**
  27876. * @hidden Internal use only
  27877. */
  27878. _getKeyValue(value: any): any;
  27879. /**
  27880. * @hidden Internal use only
  27881. */
  27882. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27883. /**
  27884. * Defines the function to use to interpolate matrices
  27885. * @param startValue defines the start matrix
  27886. * @param endValue defines the end matrix
  27887. * @param gradient defines the gradient between both matrices
  27888. * @param result defines an optional target matrix where to store the interpolation
  27889. * @returns the interpolated matrix
  27890. */
  27891. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27892. /**
  27893. * Makes a copy of the animation
  27894. * @returns Cloned animation
  27895. */
  27896. clone(): Animation;
  27897. /**
  27898. * Sets the key frames of the animation
  27899. * @param values The animation key frames to set
  27900. */
  27901. setKeys(values: Array<IAnimationKey>): void;
  27902. /**
  27903. * Serializes the animation to an object
  27904. * @returns Serialized object
  27905. */
  27906. serialize(): any;
  27907. /**
  27908. * Float animation type
  27909. */
  27910. private static _ANIMATIONTYPE_FLOAT;
  27911. /**
  27912. * Vector3 animation type
  27913. */
  27914. private static _ANIMATIONTYPE_VECTOR3;
  27915. /**
  27916. * Quaternion animation type
  27917. */
  27918. private static _ANIMATIONTYPE_QUATERNION;
  27919. /**
  27920. * Matrix animation type
  27921. */
  27922. private static _ANIMATIONTYPE_MATRIX;
  27923. /**
  27924. * Color3 animation type
  27925. */
  27926. private static _ANIMATIONTYPE_COLOR3;
  27927. /**
  27928. * Vector2 animation type
  27929. */
  27930. private static _ANIMATIONTYPE_VECTOR2;
  27931. /**
  27932. * Size animation type
  27933. */
  27934. private static _ANIMATIONTYPE_SIZE;
  27935. /**
  27936. * Relative Loop Mode
  27937. */
  27938. private static _ANIMATIONLOOPMODE_RELATIVE;
  27939. /**
  27940. * Cycle Loop Mode
  27941. */
  27942. private static _ANIMATIONLOOPMODE_CYCLE;
  27943. /**
  27944. * Constant Loop Mode
  27945. */
  27946. private static _ANIMATIONLOOPMODE_CONSTANT;
  27947. /**
  27948. * Get the float animation type
  27949. */
  27950. static readonly ANIMATIONTYPE_FLOAT: number;
  27951. /**
  27952. * Get the Vector3 animation type
  27953. */
  27954. static readonly ANIMATIONTYPE_VECTOR3: number;
  27955. /**
  27956. * Get the Vector2 animation type
  27957. */
  27958. static readonly ANIMATIONTYPE_VECTOR2: number;
  27959. /**
  27960. * Get the Size animation type
  27961. */
  27962. static readonly ANIMATIONTYPE_SIZE: number;
  27963. /**
  27964. * Get the Quaternion animation type
  27965. */
  27966. static readonly ANIMATIONTYPE_QUATERNION: number;
  27967. /**
  27968. * Get the Matrix animation type
  27969. */
  27970. static readonly ANIMATIONTYPE_MATRIX: number;
  27971. /**
  27972. * Get the Color3 animation type
  27973. */
  27974. static readonly ANIMATIONTYPE_COLOR3: number;
  27975. /**
  27976. * Get the Relative Loop Mode
  27977. */
  27978. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27979. /**
  27980. * Get the Cycle Loop Mode
  27981. */
  27982. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27983. /**
  27984. * Get the Constant Loop Mode
  27985. */
  27986. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27987. /** @hidden */
  27988. static _UniversalLerp(left: any, right: any, amount: number): any;
  27989. /**
  27990. * Parses an animation object and creates an animation
  27991. * @param parsedAnimation Parsed animation object
  27992. * @returns Animation object
  27993. */
  27994. static Parse(parsedAnimation: any): Animation;
  27995. /**
  27996. * Appends the serialized animations from the source animations
  27997. * @param source Source containing the animations
  27998. * @param destination Target to store the animations
  27999. */
  28000. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28001. }
  28002. }
  28003. declare module "babylonjs/Animations/animatable.interface" {
  28004. import { Nullable } from "babylonjs/types";
  28005. import { Animation } from "babylonjs/Animations/animation";
  28006. /**
  28007. * Interface containing an array of animations
  28008. */
  28009. export interface IAnimatable {
  28010. /**
  28011. * Array of animations
  28012. */
  28013. animations: Nullable<Array<Animation>>;
  28014. }
  28015. }
  28016. declare module "babylonjs/Materials/fresnelParameters" {
  28017. import { Color3 } from "babylonjs/Maths/math.color";
  28018. /**
  28019. * This represents all the required information to add a fresnel effect on a material:
  28020. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28021. */
  28022. export class FresnelParameters {
  28023. private _isEnabled;
  28024. /**
  28025. * Define if the fresnel effect is enable or not.
  28026. */
  28027. isEnabled: boolean;
  28028. /**
  28029. * Define the color used on edges (grazing angle)
  28030. */
  28031. leftColor: Color3;
  28032. /**
  28033. * Define the color used on center
  28034. */
  28035. rightColor: Color3;
  28036. /**
  28037. * Define bias applied to computed fresnel term
  28038. */
  28039. bias: number;
  28040. /**
  28041. * Defined the power exponent applied to fresnel term
  28042. */
  28043. power: number;
  28044. /**
  28045. * Clones the current fresnel and its valuues
  28046. * @returns a clone fresnel configuration
  28047. */
  28048. clone(): FresnelParameters;
  28049. /**
  28050. * Serializes the current fresnel parameters to a JSON representation.
  28051. * @return the JSON serialization
  28052. */
  28053. serialize(): any;
  28054. /**
  28055. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28056. * @param parsedFresnelParameters Define the JSON representation
  28057. * @returns the parsed parameters
  28058. */
  28059. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28060. }
  28061. }
  28062. declare module "babylonjs/Misc/decorators" {
  28063. import { Nullable } from "babylonjs/types";
  28064. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28065. import { Scene } from "babylonjs/scene";
  28066. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28067. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28068. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28069. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28070. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28071. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28072. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28073. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28074. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28075. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28076. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28077. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28078. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28079. /**
  28080. * Decorator used to define property that can be serialized as reference to a camera
  28081. * @param sourceName defines the name of the property to decorate
  28082. */
  28083. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28084. /**
  28085. * Class used to help serialization objects
  28086. */
  28087. export class SerializationHelper {
  28088. /** @hidden */
  28089. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28090. /** @hidden */
  28091. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28092. /** @hidden */
  28093. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28094. /** @hidden */
  28095. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28096. /**
  28097. * Appends the serialized animations from the source animations
  28098. * @param source Source containing the animations
  28099. * @param destination Target to store the animations
  28100. */
  28101. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28102. /**
  28103. * Static function used to serialized a specific entity
  28104. * @param entity defines the entity to serialize
  28105. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28106. * @returns a JSON compatible object representing the serialization of the entity
  28107. */
  28108. static Serialize<T>(entity: T, serializationObject?: any): any;
  28109. /**
  28110. * Creates a new entity from a serialization data object
  28111. * @param creationFunction defines a function used to instanciated the new entity
  28112. * @param source defines the source serialization data
  28113. * @param scene defines the hosting scene
  28114. * @param rootUrl defines the root url for resources
  28115. * @returns a new entity
  28116. */
  28117. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28118. /**
  28119. * Clones an object
  28120. * @param creationFunction defines the function used to instanciate the new object
  28121. * @param source defines the source object
  28122. * @returns the cloned object
  28123. */
  28124. static Clone<T>(creationFunction: () => T, source: T): T;
  28125. /**
  28126. * Instanciates a new object based on a source one (some data will be shared between both object)
  28127. * @param creationFunction defines the function used to instanciate the new object
  28128. * @param source defines the source object
  28129. * @returns the new object
  28130. */
  28131. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28132. }
  28133. }
  28134. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  28135. import { Nullable } from "babylonjs/types";
  28136. /**
  28137. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28138. */
  28139. export interface CubeMapInfo {
  28140. /**
  28141. * The pixel array for the front face.
  28142. * This is stored in format, left to right, up to down format.
  28143. */
  28144. front: Nullable<ArrayBufferView>;
  28145. /**
  28146. * The pixel array for the back face.
  28147. * This is stored in format, left to right, up to down format.
  28148. */
  28149. back: Nullable<ArrayBufferView>;
  28150. /**
  28151. * The pixel array for the left face.
  28152. * This is stored in format, left to right, up to down format.
  28153. */
  28154. left: Nullable<ArrayBufferView>;
  28155. /**
  28156. * The pixel array for the right face.
  28157. * This is stored in format, left to right, up to down format.
  28158. */
  28159. right: Nullable<ArrayBufferView>;
  28160. /**
  28161. * The pixel array for the up face.
  28162. * This is stored in format, left to right, up to down format.
  28163. */
  28164. up: Nullable<ArrayBufferView>;
  28165. /**
  28166. * The pixel array for the down face.
  28167. * This is stored in format, left to right, up to down format.
  28168. */
  28169. down: Nullable<ArrayBufferView>;
  28170. /**
  28171. * The size of the cubemap stored.
  28172. *
  28173. * Each faces will be size * size pixels.
  28174. */
  28175. size: number;
  28176. /**
  28177. * The format of the texture.
  28178. *
  28179. * RGBA, RGB.
  28180. */
  28181. format: number;
  28182. /**
  28183. * The type of the texture data.
  28184. *
  28185. * UNSIGNED_INT, FLOAT.
  28186. */
  28187. type: number;
  28188. /**
  28189. * Specifies whether the texture is in gamma space.
  28190. */
  28191. gammaSpace: boolean;
  28192. }
  28193. /**
  28194. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28195. */
  28196. export class PanoramaToCubeMapTools {
  28197. private static FACE_FRONT;
  28198. private static FACE_BACK;
  28199. private static FACE_RIGHT;
  28200. private static FACE_LEFT;
  28201. private static FACE_DOWN;
  28202. private static FACE_UP;
  28203. /**
  28204. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28205. *
  28206. * @param float32Array The source data.
  28207. * @param inputWidth The width of the input panorama.
  28208. * @param inputHeight The height of the input panorama.
  28209. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28210. * @return The cubemap data
  28211. */
  28212. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28213. private static CreateCubemapTexture;
  28214. private static CalcProjectionSpherical;
  28215. }
  28216. }
  28217. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28218. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28219. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28220. import { Nullable } from "babylonjs/types";
  28221. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28222. /**
  28223. * Helper class dealing with the extraction of spherical polynomial dataArray
  28224. * from a cube map.
  28225. */
  28226. export class CubeMapToSphericalPolynomialTools {
  28227. private static FileFaces;
  28228. /**
  28229. * Converts a texture to the according Spherical Polynomial data.
  28230. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28231. *
  28232. * @param texture The texture to extract the information from.
  28233. * @return The Spherical Polynomial data.
  28234. */
  28235. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28236. /**
  28237. * Converts a cubemap to the according Spherical Polynomial data.
  28238. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28239. *
  28240. * @param cubeInfo The Cube map to extract the information from.
  28241. * @return The Spherical Polynomial data.
  28242. */
  28243. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28244. }
  28245. }
  28246. declare module "babylonjs/Misc/guid" {
  28247. /**
  28248. * Class used to manipulate GUIDs
  28249. */
  28250. export class GUID {
  28251. /**
  28252. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28253. * Be aware Math.random() could cause collisions, but:
  28254. * "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"
  28255. * @returns a pseudo random id
  28256. */
  28257. static RandomId(): string;
  28258. }
  28259. }
  28260. declare module "babylonjs/Materials/Textures/baseTexture" {
  28261. import { Observable } from "babylonjs/Misc/observable";
  28262. import { Nullable } from "babylonjs/types";
  28263. import { Scene } from "babylonjs/scene";
  28264. import { Matrix } from "babylonjs/Maths/math.vector";
  28265. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28266. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28267. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28268. import { ISize } from "babylonjs/Maths/math.size";
  28269. /**
  28270. * Base class of all the textures in babylon.
  28271. * It groups all the common properties the materials, post process, lights... might need
  28272. * in order to make a correct use of the texture.
  28273. */
  28274. export class BaseTexture implements IAnimatable {
  28275. /**
  28276. * Default anisotropic filtering level for the application.
  28277. * It is set to 4 as a good tradeoff between perf and quality.
  28278. */
  28279. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28280. /**
  28281. * Gets or sets the unique id of the texture
  28282. */
  28283. uniqueId: number;
  28284. /**
  28285. * Define the name of the texture.
  28286. */
  28287. name: string;
  28288. /**
  28289. * Gets or sets an object used to store user defined information.
  28290. */
  28291. metadata: any;
  28292. /**
  28293. * For internal use only. Please do not use.
  28294. */
  28295. reservedDataStore: any;
  28296. private _hasAlpha;
  28297. /**
  28298. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28299. */
  28300. hasAlpha: boolean;
  28301. /**
  28302. * Defines if the alpha value should be determined via the rgb values.
  28303. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28304. */
  28305. getAlphaFromRGB: boolean;
  28306. /**
  28307. * Intensity or strength of the texture.
  28308. * It is commonly used by materials to fine tune the intensity of the texture
  28309. */
  28310. level: number;
  28311. /**
  28312. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28313. * This is part of the texture as textures usually maps to one uv set.
  28314. */
  28315. coordinatesIndex: number;
  28316. private _coordinatesMode;
  28317. /**
  28318. * How a texture is mapped.
  28319. *
  28320. * | Value | Type | Description |
  28321. * | ----- | ----------------------------------- | ----------- |
  28322. * | 0 | EXPLICIT_MODE | |
  28323. * | 1 | SPHERICAL_MODE | |
  28324. * | 2 | PLANAR_MODE | |
  28325. * | 3 | CUBIC_MODE | |
  28326. * | 4 | PROJECTION_MODE | |
  28327. * | 5 | SKYBOX_MODE | |
  28328. * | 6 | INVCUBIC_MODE | |
  28329. * | 7 | EQUIRECTANGULAR_MODE | |
  28330. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28331. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28332. */
  28333. coordinatesMode: number;
  28334. /**
  28335. * | Value | Type | Description |
  28336. * | ----- | ------------------ | ----------- |
  28337. * | 0 | CLAMP_ADDRESSMODE | |
  28338. * | 1 | WRAP_ADDRESSMODE | |
  28339. * | 2 | MIRROR_ADDRESSMODE | |
  28340. */
  28341. wrapU: number;
  28342. /**
  28343. * | Value | Type | Description |
  28344. * | ----- | ------------------ | ----------- |
  28345. * | 0 | CLAMP_ADDRESSMODE | |
  28346. * | 1 | WRAP_ADDRESSMODE | |
  28347. * | 2 | MIRROR_ADDRESSMODE | |
  28348. */
  28349. wrapV: number;
  28350. /**
  28351. * | Value | Type | Description |
  28352. * | ----- | ------------------ | ----------- |
  28353. * | 0 | CLAMP_ADDRESSMODE | |
  28354. * | 1 | WRAP_ADDRESSMODE | |
  28355. * | 2 | MIRROR_ADDRESSMODE | |
  28356. */
  28357. wrapR: number;
  28358. /**
  28359. * With compliant hardware and browser (supporting anisotropic filtering)
  28360. * this defines the level of anisotropic filtering in the texture.
  28361. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28362. */
  28363. anisotropicFilteringLevel: number;
  28364. /**
  28365. * Define if the texture is a cube texture or if false a 2d texture.
  28366. */
  28367. isCube: boolean;
  28368. /**
  28369. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28370. */
  28371. is3D: boolean;
  28372. /**
  28373. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28374. * HDR texture are usually stored in linear space.
  28375. * This only impacts the PBR and Background materials
  28376. */
  28377. gammaSpace: boolean;
  28378. /**
  28379. * Gets whether or not the texture contains RGBD data.
  28380. */
  28381. readonly isRGBD: boolean;
  28382. /**
  28383. * Is Z inverted in the texture (useful in a cube texture).
  28384. */
  28385. invertZ: boolean;
  28386. /**
  28387. * Are mip maps generated for this texture or not.
  28388. */
  28389. readonly noMipmap: boolean;
  28390. /**
  28391. * @hidden
  28392. */
  28393. lodLevelInAlpha: boolean;
  28394. /**
  28395. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28396. */
  28397. lodGenerationOffset: number;
  28398. /**
  28399. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28400. */
  28401. lodGenerationScale: number;
  28402. /**
  28403. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28404. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28405. * average roughness values.
  28406. */
  28407. linearSpecularLOD: boolean;
  28408. /**
  28409. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28410. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28411. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28412. */
  28413. irradianceTexture: Nullable<BaseTexture>;
  28414. /**
  28415. * Define if the texture is a render target.
  28416. */
  28417. isRenderTarget: boolean;
  28418. /**
  28419. * Define the unique id of the texture in the scene.
  28420. */
  28421. readonly uid: string;
  28422. /**
  28423. * Return a string representation of the texture.
  28424. * @returns the texture as a string
  28425. */
  28426. toString(): string;
  28427. /**
  28428. * Get the class name of the texture.
  28429. * @returns "BaseTexture"
  28430. */
  28431. getClassName(): string;
  28432. /**
  28433. * Define the list of animation attached to the texture.
  28434. */
  28435. animations: import("babylonjs/Animations/animation").Animation[];
  28436. /**
  28437. * An event triggered when the texture is disposed.
  28438. */
  28439. onDisposeObservable: Observable<BaseTexture>;
  28440. private _onDisposeObserver;
  28441. /**
  28442. * Callback triggered when the texture has been disposed.
  28443. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28444. */
  28445. onDispose: () => void;
  28446. /**
  28447. * Define the current state of the loading sequence when in delayed load mode.
  28448. */
  28449. delayLoadState: number;
  28450. private _scene;
  28451. /** @hidden */
  28452. _texture: Nullable<InternalTexture>;
  28453. private _uid;
  28454. /**
  28455. * Define if the texture is preventinga material to render or not.
  28456. * If not and the texture is not ready, the engine will use a default black texture instead.
  28457. */
  28458. readonly isBlocking: boolean;
  28459. /**
  28460. * Instantiates a new BaseTexture.
  28461. * Base class of all the textures in babylon.
  28462. * It groups all the common properties the materials, post process, lights... might need
  28463. * in order to make a correct use of the texture.
  28464. * @param scene Define the scene the texture blongs to
  28465. */
  28466. constructor(scene: Nullable<Scene>);
  28467. /**
  28468. * Get the scene the texture belongs to.
  28469. * @returns the scene or null if undefined
  28470. */
  28471. getScene(): Nullable<Scene>;
  28472. /**
  28473. * Get the texture transform matrix used to offset tile the texture for istance.
  28474. * @returns the transformation matrix
  28475. */
  28476. getTextureMatrix(): Matrix;
  28477. /**
  28478. * Get the texture reflection matrix used to rotate/transform the reflection.
  28479. * @returns the reflection matrix
  28480. */
  28481. getReflectionTextureMatrix(): Matrix;
  28482. /**
  28483. * Get the underlying lower level texture from Babylon.
  28484. * @returns the insternal texture
  28485. */
  28486. getInternalTexture(): Nullable<InternalTexture>;
  28487. /**
  28488. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28489. * @returns true if ready or not blocking
  28490. */
  28491. isReadyOrNotBlocking(): boolean;
  28492. /**
  28493. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28494. * @returns true if fully ready
  28495. */
  28496. isReady(): boolean;
  28497. private _cachedSize;
  28498. /**
  28499. * Get the size of the texture.
  28500. * @returns the texture size.
  28501. */
  28502. getSize(): ISize;
  28503. /**
  28504. * Get the base size of the texture.
  28505. * It can be different from the size if the texture has been resized for POT for instance
  28506. * @returns the base size
  28507. */
  28508. getBaseSize(): ISize;
  28509. /**
  28510. * Update the sampling mode of the texture.
  28511. * Default is Trilinear mode.
  28512. *
  28513. * | Value | Type | Description |
  28514. * | ----- | ------------------ | ----------- |
  28515. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28516. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28517. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28518. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28519. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28520. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28521. * | 7 | NEAREST_LINEAR | |
  28522. * | 8 | NEAREST_NEAREST | |
  28523. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28524. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28525. * | 11 | LINEAR_LINEAR | |
  28526. * | 12 | LINEAR_NEAREST | |
  28527. *
  28528. * > _mag_: magnification filter (close to the viewer)
  28529. * > _min_: minification filter (far from the viewer)
  28530. * > _mip_: filter used between mip map levels
  28531. *@param samplingMode Define the new sampling mode of the texture
  28532. */
  28533. updateSamplingMode(samplingMode: number): void;
  28534. /**
  28535. * Scales the texture if is `canRescale()`
  28536. * @param ratio the resize factor we want to use to rescale
  28537. */
  28538. scale(ratio: number): void;
  28539. /**
  28540. * Get if the texture can rescale.
  28541. */
  28542. readonly canRescale: boolean;
  28543. /** @hidden */
  28544. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28545. /** @hidden */
  28546. _rebuild(): void;
  28547. /**
  28548. * Triggers the load sequence in delayed load mode.
  28549. */
  28550. delayLoad(): void;
  28551. /**
  28552. * Clones the texture.
  28553. * @returns the cloned texture
  28554. */
  28555. clone(): Nullable<BaseTexture>;
  28556. /**
  28557. * Get the texture underlying type (INT, FLOAT...)
  28558. */
  28559. readonly textureType: number;
  28560. /**
  28561. * Get the texture underlying format (RGB, RGBA...)
  28562. */
  28563. readonly textureFormat: number;
  28564. /**
  28565. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28566. * This will returns an RGBA array buffer containing either in values (0-255) or
  28567. * float values (0-1) depending of the underlying buffer type.
  28568. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28569. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28570. * @param buffer defines a user defined buffer to fill with data (can be null)
  28571. * @returns The Array buffer containing the pixels data.
  28572. */
  28573. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28574. /**
  28575. * Release and destroy the underlying lower level texture aka internalTexture.
  28576. */
  28577. releaseInternalTexture(): void;
  28578. /**
  28579. * Get the polynomial representation of the texture data.
  28580. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28581. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28582. */
  28583. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28584. /** @hidden */
  28585. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28586. /** @hidden */
  28587. readonly _lodTextureMid: Nullable<BaseTexture>;
  28588. /** @hidden */
  28589. readonly _lodTextureLow: Nullable<BaseTexture>;
  28590. /**
  28591. * Dispose the texture and release its associated resources.
  28592. */
  28593. dispose(): void;
  28594. /**
  28595. * Serialize the texture into a JSON representation that can be parsed later on.
  28596. * @returns the JSON representation of the texture
  28597. */
  28598. serialize(): any;
  28599. /**
  28600. * Helper function to be called back once a list of texture contains only ready textures.
  28601. * @param textures Define the list of textures to wait for
  28602. * @param callback Define the callback triggered once the entire list will be ready
  28603. */
  28604. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28605. }
  28606. }
  28607. declare module "babylonjs/Materials/Textures/internalTexture" {
  28608. import { Observable } from "babylonjs/Misc/observable";
  28609. import { Nullable, int } from "babylonjs/types";
  28610. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28611. import { Engine } from "babylonjs/Engines/engine";
  28612. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28613. /**
  28614. * Class used to store data associated with WebGL texture data for the engine
  28615. * This class should not be used directly
  28616. */
  28617. export class InternalTexture {
  28618. /** @hidden */
  28619. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  28620. /**
  28621. * The source of the texture data is unknown
  28622. */
  28623. static DATASOURCE_UNKNOWN: number;
  28624. /**
  28625. * Texture data comes from an URL
  28626. */
  28627. static DATASOURCE_URL: number;
  28628. /**
  28629. * Texture data is only used for temporary storage
  28630. */
  28631. static DATASOURCE_TEMP: number;
  28632. /**
  28633. * Texture data comes from raw data (ArrayBuffer)
  28634. */
  28635. static DATASOURCE_RAW: number;
  28636. /**
  28637. * Texture content is dynamic (video or dynamic texture)
  28638. */
  28639. static DATASOURCE_DYNAMIC: number;
  28640. /**
  28641. * Texture content is generated by rendering to it
  28642. */
  28643. static DATASOURCE_RENDERTARGET: number;
  28644. /**
  28645. * Texture content is part of a multi render target process
  28646. */
  28647. static DATASOURCE_MULTIRENDERTARGET: number;
  28648. /**
  28649. * Texture data comes from a cube data file
  28650. */
  28651. static DATASOURCE_CUBE: number;
  28652. /**
  28653. * Texture data comes from a raw cube data
  28654. */
  28655. static DATASOURCE_CUBERAW: number;
  28656. /**
  28657. * Texture data come from a prefiltered cube data file
  28658. */
  28659. static DATASOURCE_CUBEPREFILTERED: number;
  28660. /**
  28661. * Texture content is raw 3D data
  28662. */
  28663. static DATASOURCE_RAW3D: number;
  28664. /**
  28665. * Texture content is a depth texture
  28666. */
  28667. static DATASOURCE_DEPTHTEXTURE: number;
  28668. /**
  28669. * Texture data comes from a raw cube data encoded with RGBD
  28670. */
  28671. static DATASOURCE_CUBERAW_RGBD: number;
  28672. /**
  28673. * Defines if the texture is ready
  28674. */
  28675. isReady: boolean;
  28676. /**
  28677. * Defines if the texture is a cube texture
  28678. */
  28679. isCube: boolean;
  28680. /**
  28681. * Defines if the texture contains 3D data
  28682. */
  28683. is3D: boolean;
  28684. /**
  28685. * Defines if the texture contains multiview data
  28686. */
  28687. isMultiview: boolean;
  28688. /**
  28689. * Gets the URL used to load this texture
  28690. */
  28691. url: string;
  28692. /**
  28693. * Gets the sampling mode of the texture
  28694. */
  28695. samplingMode: number;
  28696. /**
  28697. * Gets a boolean indicating if the texture needs mipmaps generation
  28698. */
  28699. generateMipMaps: boolean;
  28700. /**
  28701. * Gets the number of samples used by the texture (WebGL2+ only)
  28702. */
  28703. samples: number;
  28704. /**
  28705. * Gets the type of the texture (int, float...)
  28706. */
  28707. type: number;
  28708. /**
  28709. * Gets the format of the texture (RGB, RGBA...)
  28710. */
  28711. format: number;
  28712. /**
  28713. * Observable called when the texture is loaded
  28714. */
  28715. onLoadedObservable: Observable<InternalTexture>;
  28716. /**
  28717. * Gets the width of the texture
  28718. */
  28719. width: number;
  28720. /**
  28721. * Gets the height of the texture
  28722. */
  28723. height: number;
  28724. /**
  28725. * Gets the depth of the texture
  28726. */
  28727. depth: number;
  28728. /**
  28729. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28730. */
  28731. baseWidth: number;
  28732. /**
  28733. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28734. */
  28735. baseHeight: number;
  28736. /**
  28737. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28738. */
  28739. baseDepth: number;
  28740. /**
  28741. * Gets a boolean indicating if the texture is inverted on Y axis
  28742. */
  28743. invertY: boolean;
  28744. /** @hidden */
  28745. _invertVScale: boolean;
  28746. /** @hidden */
  28747. _associatedChannel: number;
  28748. /** @hidden */
  28749. _dataSource: number;
  28750. /** @hidden */
  28751. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  28752. /** @hidden */
  28753. _bufferView: Nullable<ArrayBufferView>;
  28754. /** @hidden */
  28755. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28756. /** @hidden */
  28757. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  28758. /** @hidden */
  28759. _size: number;
  28760. /** @hidden */
  28761. _extension: string;
  28762. /** @hidden */
  28763. _files: Nullable<string[]>;
  28764. /** @hidden */
  28765. _workingCanvas: Nullable<HTMLCanvasElement>;
  28766. /** @hidden */
  28767. _workingContext: Nullable<CanvasRenderingContext2D>;
  28768. /** @hidden */
  28769. _framebuffer: Nullable<WebGLFramebuffer>;
  28770. /** @hidden */
  28771. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28772. /** @hidden */
  28773. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28774. /** @hidden */
  28775. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28776. /** @hidden */
  28777. _attachments: Nullable<number[]>;
  28778. /** @hidden */
  28779. _cachedCoordinatesMode: Nullable<number>;
  28780. /** @hidden */
  28781. _cachedWrapU: Nullable<number>;
  28782. /** @hidden */
  28783. _cachedWrapV: Nullable<number>;
  28784. /** @hidden */
  28785. _cachedWrapR: Nullable<number>;
  28786. /** @hidden */
  28787. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28788. /** @hidden */
  28789. _isDisabled: boolean;
  28790. /** @hidden */
  28791. _compression: Nullable<string>;
  28792. /** @hidden */
  28793. _generateStencilBuffer: boolean;
  28794. /** @hidden */
  28795. _generateDepthBuffer: boolean;
  28796. /** @hidden */
  28797. _comparisonFunction: number;
  28798. /** @hidden */
  28799. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  28800. /** @hidden */
  28801. _lodGenerationScale: number;
  28802. /** @hidden */
  28803. _lodGenerationOffset: number;
  28804. /** @hidden */
  28805. _colorTextureArray: Nullable<WebGLTexture>;
  28806. /** @hidden */
  28807. _depthStencilTextureArray: Nullable<WebGLTexture>;
  28808. /** @hidden */
  28809. _lodTextureHigh: Nullable<BaseTexture>;
  28810. /** @hidden */
  28811. _lodTextureMid: Nullable<BaseTexture>;
  28812. /** @hidden */
  28813. _lodTextureLow: Nullable<BaseTexture>;
  28814. /** @hidden */
  28815. _isRGBD: boolean;
  28816. /** @hidden */
  28817. _linearSpecularLOD: boolean;
  28818. /** @hidden */
  28819. _irradianceTexture: Nullable<BaseTexture>;
  28820. /** @hidden */
  28821. _webGLTexture: Nullable<WebGLTexture>;
  28822. /** @hidden */
  28823. _references: number;
  28824. private _engine;
  28825. /**
  28826. * Gets the Engine the texture belongs to.
  28827. * @returns The babylon engine
  28828. */
  28829. getEngine(): Engine;
  28830. /**
  28831. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28832. */
  28833. readonly dataSource: number;
  28834. /**
  28835. * Creates a new InternalTexture
  28836. * @param engine defines the engine to use
  28837. * @param dataSource defines the type of data that will be used
  28838. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28839. */
  28840. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28841. /**
  28842. * Increments the number of references (ie. the number of Texture that point to it)
  28843. */
  28844. incrementReferences(): void;
  28845. /**
  28846. * Change the size of the texture (not the size of the content)
  28847. * @param width defines the new width
  28848. * @param height defines the new height
  28849. * @param depth defines the new depth (1 by default)
  28850. */
  28851. updateSize(width: int, height: int, depth?: int): void;
  28852. /** @hidden */
  28853. _rebuild(): void;
  28854. /** @hidden */
  28855. _swapAndDie(target: InternalTexture): void;
  28856. /**
  28857. * Dispose the current allocated resources
  28858. */
  28859. dispose(): void;
  28860. }
  28861. }
  28862. declare module "babylonjs/Materials/effect" {
  28863. import { Observable } from "babylonjs/Misc/observable";
  28864. import { Nullable } from "babylonjs/types";
  28865. import { IDisposable } from "babylonjs/scene";
  28866. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28867. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28868. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  28869. import { Engine } from "babylonjs/Engines/engine";
  28870. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28871. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28872. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28873. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28875. /**
  28876. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28877. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28878. */
  28879. export class EffectFallbacks {
  28880. private _defines;
  28881. private _currentRank;
  28882. private _maxRank;
  28883. private _mesh;
  28884. /**
  28885. * Removes the fallback from the bound mesh.
  28886. */
  28887. unBindMesh(): void;
  28888. /**
  28889. * Adds a fallback on the specified property.
  28890. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28891. * @param define The name of the define in the shader
  28892. */
  28893. addFallback(rank: number, define: string): void;
  28894. /**
  28895. * Sets the mesh to use CPU skinning when needing to fallback.
  28896. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28897. * @param mesh The mesh to use the fallbacks.
  28898. */
  28899. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28900. /**
  28901. * Checks to see if more fallbacks are still availible.
  28902. */
  28903. readonly isMoreFallbacks: boolean;
  28904. /**
  28905. * Removes the defines that should be removed when falling back.
  28906. * @param currentDefines defines the current define statements for the shader.
  28907. * @param effect defines the current effect we try to compile
  28908. * @returns The resulting defines with defines of the current rank removed.
  28909. */
  28910. reduce(currentDefines: string, effect: Effect): string;
  28911. }
  28912. /**
  28913. * Options to be used when creating an effect.
  28914. */
  28915. export class EffectCreationOptions {
  28916. /**
  28917. * Atrributes that will be used in the shader.
  28918. */
  28919. attributes: string[];
  28920. /**
  28921. * Uniform varible names that will be set in the shader.
  28922. */
  28923. uniformsNames: string[];
  28924. /**
  28925. * Uniform buffer varible names that will be set in the shader.
  28926. */
  28927. uniformBuffersNames: string[];
  28928. /**
  28929. * Sampler texture variable names that will be set in the shader.
  28930. */
  28931. samplers: string[];
  28932. /**
  28933. * Define statements that will be set in the shader.
  28934. */
  28935. defines: any;
  28936. /**
  28937. * Possible fallbacks for this effect to improve performance when needed.
  28938. */
  28939. fallbacks: Nullable<EffectFallbacks>;
  28940. /**
  28941. * Callback that will be called when the shader is compiled.
  28942. */
  28943. onCompiled: Nullable<(effect: Effect) => void>;
  28944. /**
  28945. * Callback that will be called if an error occurs during shader compilation.
  28946. */
  28947. onError: Nullable<(effect: Effect, errors: string) => void>;
  28948. /**
  28949. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28950. */
  28951. indexParameters: any;
  28952. /**
  28953. * Max number of lights that can be used in the shader.
  28954. */
  28955. maxSimultaneousLights: number;
  28956. /**
  28957. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28958. */
  28959. transformFeedbackVaryings: Nullable<string[]>;
  28960. }
  28961. /**
  28962. * Effect containing vertex and fragment shader that can be executed on an object.
  28963. */
  28964. export class Effect implements IDisposable {
  28965. /**
  28966. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28967. */
  28968. static ShadersRepository: string;
  28969. /**
  28970. * Name of the effect.
  28971. */
  28972. name: any;
  28973. /**
  28974. * String container all the define statements that should be set on the shader.
  28975. */
  28976. defines: string;
  28977. /**
  28978. * Callback that will be called when the shader is compiled.
  28979. */
  28980. onCompiled: Nullable<(effect: Effect) => void>;
  28981. /**
  28982. * Callback that will be called if an error occurs during shader compilation.
  28983. */
  28984. onError: Nullable<(effect: Effect, errors: string) => void>;
  28985. /**
  28986. * Callback that will be called when effect is bound.
  28987. */
  28988. onBind: Nullable<(effect: Effect) => void>;
  28989. /**
  28990. * Unique ID of the effect.
  28991. */
  28992. uniqueId: number;
  28993. /**
  28994. * Observable that will be called when the shader is compiled.
  28995. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28996. */
  28997. onCompileObservable: Observable<Effect>;
  28998. /**
  28999. * Observable that will be called if an error occurs during shader compilation.
  29000. */
  29001. onErrorObservable: Observable<Effect>;
  29002. /** @hidden */
  29003. _onBindObservable: Nullable<Observable<Effect>>;
  29004. /**
  29005. * Observable that will be called when effect is bound.
  29006. */
  29007. readonly onBindObservable: Observable<Effect>;
  29008. /** @hidden */
  29009. _bonesComputationForcedToCPU: boolean;
  29010. private static _uniqueIdSeed;
  29011. private _engine;
  29012. private _uniformBuffersNames;
  29013. private _uniformsNames;
  29014. private _samplerList;
  29015. private _samplers;
  29016. private _isReady;
  29017. private _compilationError;
  29018. private _attributesNames;
  29019. private _attributes;
  29020. private _uniforms;
  29021. /**
  29022. * Key for the effect.
  29023. * @hidden
  29024. */
  29025. _key: string;
  29026. private _indexParameters;
  29027. private _fallbacks;
  29028. private _vertexSourceCode;
  29029. private _fragmentSourceCode;
  29030. private _vertexSourceCodeOverride;
  29031. private _fragmentSourceCodeOverride;
  29032. private _transformFeedbackVaryings;
  29033. /**
  29034. * Compiled shader to webGL program.
  29035. * @hidden
  29036. */
  29037. _pipelineContext: Nullable<IPipelineContext>;
  29038. private _valueCache;
  29039. private static _baseCache;
  29040. /**
  29041. * Instantiates an effect.
  29042. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29043. * @param baseName Name of the effect.
  29044. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29045. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29046. * @param samplers List of sampler variables that will be passed to the shader.
  29047. * @param engine Engine to be used to render the effect
  29048. * @param defines Define statements to be added to the shader.
  29049. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29050. * @param onCompiled Callback that will be called when the shader is compiled.
  29051. * @param onError Callback that will be called if an error occurs during shader compilation.
  29052. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29053. */
  29054. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  29055. private _useFinalCode;
  29056. /**
  29057. * Unique key for this effect
  29058. */
  29059. readonly key: string;
  29060. /**
  29061. * If the effect has been compiled and prepared.
  29062. * @returns if the effect is compiled and prepared.
  29063. */
  29064. isReady(): boolean;
  29065. /**
  29066. * The engine the effect was initialized with.
  29067. * @returns the engine.
  29068. */
  29069. getEngine(): Engine;
  29070. /**
  29071. * The pipeline context for this effect
  29072. * @returns the associated pipeline context
  29073. */
  29074. getPipelineContext(): Nullable<IPipelineContext>;
  29075. /**
  29076. * The set of names of attribute variables for the shader.
  29077. * @returns An array of attribute names.
  29078. */
  29079. getAttributesNames(): string[];
  29080. /**
  29081. * Returns the attribute at the given index.
  29082. * @param index The index of the attribute.
  29083. * @returns The location of the attribute.
  29084. */
  29085. getAttributeLocation(index: number): number;
  29086. /**
  29087. * Returns the attribute based on the name of the variable.
  29088. * @param name of the attribute to look up.
  29089. * @returns the attribute location.
  29090. */
  29091. getAttributeLocationByName(name: string): number;
  29092. /**
  29093. * The number of attributes.
  29094. * @returns the numnber of attributes.
  29095. */
  29096. getAttributesCount(): number;
  29097. /**
  29098. * Gets the index of a uniform variable.
  29099. * @param uniformName of the uniform to look up.
  29100. * @returns the index.
  29101. */
  29102. getUniformIndex(uniformName: string): number;
  29103. /**
  29104. * Returns the attribute based on the name of the variable.
  29105. * @param uniformName of the uniform to look up.
  29106. * @returns the location of the uniform.
  29107. */
  29108. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29109. /**
  29110. * Returns an array of sampler variable names
  29111. * @returns The array of sampler variable neames.
  29112. */
  29113. getSamplers(): string[];
  29114. /**
  29115. * The error from the last compilation.
  29116. * @returns the error string.
  29117. */
  29118. getCompilationError(): string;
  29119. /**
  29120. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29121. * @param func The callback to be used.
  29122. */
  29123. executeWhenCompiled(func: (effect: Effect) => void): void;
  29124. private _checkIsReady;
  29125. /** @hidden */
  29126. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29127. /** @hidden */
  29128. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29129. /** @hidden */
  29130. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29131. /**
  29132. * Recompiles the webGL program
  29133. * @param vertexSourceCode The source code for the vertex shader.
  29134. * @param fragmentSourceCode The source code for the fragment shader.
  29135. * @param onCompiled Callback called when completed.
  29136. * @param onError Callback called on error.
  29137. * @hidden
  29138. */
  29139. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29140. /**
  29141. * Prepares the effect
  29142. * @hidden
  29143. */
  29144. _prepareEffect(): void;
  29145. /**
  29146. * Checks if the effect is supported. (Must be called after compilation)
  29147. */
  29148. readonly isSupported: boolean;
  29149. /**
  29150. * Binds a texture to the engine to be used as output of the shader.
  29151. * @param channel Name of the output variable.
  29152. * @param texture Texture to bind.
  29153. * @hidden
  29154. */
  29155. _bindTexture(channel: string, texture: InternalTexture): void;
  29156. /**
  29157. * Sets a texture on the engine to be used in the shader.
  29158. * @param channel Name of the sampler variable.
  29159. * @param texture Texture to set.
  29160. */
  29161. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29162. /**
  29163. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29164. * @param channel Name of the sampler variable.
  29165. * @param texture Texture to set.
  29166. */
  29167. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29168. /**
  29169. * Sets an array of textures on the engine to be used in the shader.
  29170. * @param channel Name of the variable.
  29171. * @param textures Textures to set.
  29172. */
  29173. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29174. /**
  29175. * 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)
  29176. * @param channel Name of the sampler variable.
  29177. * @param postProcess Post process to get the input texture from.
  29178. */
  29179. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29180. /**
  29181. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29182. * 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)
  29183. * @param channel Name of the sampler variable.
  29184. * @param postProcess Post process to get the output texture from.
  29185. */
  29186. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29187. /** @hidden */
  29188. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29189. /** @hidden */
  29190. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29191. /** @hidden */
  29192. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29193. /** @hidden */
  29194. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29195. /**
  29196. * Binds a buffer to a uniform.
  29197. * @param buffer Buffer to bind.
  29198. * @param name Name of the uniform variable to bind to.
  29199. */
  29200. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29201. /**
  29202. * Binds block to a uniform.
  29203. * @param blockName Name of the block to bind.
  29204. * @param index Index to bind.
  29205. */
  29206. bindUniformBlock(blockName: string, index: number): void;
  29207. /**
  29208. * Sets an interger value on a uniform variable.
  29209. * @param uniformName Name of the variable.
  29210. * @param value Value to be set.
  29211. * @returns this effect.
  29212. */
  29213. setInt(uniformName: string, value: number): Effect;
  29214. /**
  29215. * Sets an int array on a uniform variable.
  29216. * @param uniformName Name of the variable.
  29217. * @param array array to be set.
  29218. * @returns this effect.
  29219. */
  29220. setIntArray(uniformName: string, array: Int32Array): Effect;
  29221. /**
  29222. * 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)
  29223. * @param uniformName Name of the variable.
  29224. * @param array array to be set.
  29225. * @returns this effect.
  29226. */
  29227. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29228. /**
  29229. * 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)
  29230. * @param uniformName Name of the variable.
  29231. * @param array array to be set.
  29232. * @returns this effect.
  29233. */
  29234. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29235. /**
  29236. * 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)
  29237. * @param uniformName Name of the variable.
  29238. * @param array array to be set.
  29239. * @returns this effect.
  29240. */
  29241. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29242. /**
  29243. * Sets an float array on a uniform variable.
  29244. * @param uniformName Name of the variable.
  29245. * @param array array to be set.
  29246. * @returns this effect.
  29247. */
  29248. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29249. /**
  29250. * 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)
  29251. * @param uniformName Name of the variable.
  29252. * @param array array to be set.
  29253. * @returns this effect.
  29254. */
  29255. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29256. /**
  29257. * 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)
  29258. * @param uniformName Name of the variable.
  29259. * @param array array to be set.
  29260. * @returns this effect.
  29261. */
  29262. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29263. /**
  29264. * 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)
  29265. * @param uniformName Name of the variable.
  29266. * @param array array to be set.
  29267. * @returns this effect.
  29268. */
  29269. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29270. /**
  29271. * Sets an array on a uniform variable.
  29272. * @param uniformName Name of the variable.
  29273. * @param array array to be set.
  29274. * @returns this effect.
  29275. */
  29276. setArray(uniformName: string, array: number[]): Effect;
  29277. /**
  29278. * 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)
  29279. * @param uniformName Name of the variable.
  29280. * @param array array to be set.
  29281. * @returns this effect.
  29282. */
  29283. setArray2(uniformName: string, array: number[]): Effect;
  29284. /**
  29285. * 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)
  29286. * @param uniformName Name of the variable.
  29287. * @param array array to be set.
  29288. * @returns this effect.
  29289. */
  29290. setArray3(uniformName: string, array: number[]): Effect;
  29291. /**
  29292. * 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)
  29293. * @param uniformName Name of the variable.
  29294. * @param array array to be set.
  29295. * @returns this effect.
  29296. */
  29297. setArray4(uniformName: string, array: number[]): Effect;
  29298. /**
  29299. * Sets matrices on a uniform variable.
  29300. * @param uniformName Name of the variable.
  29301. * @param matrices matrices to be set.
  29302. * @returns this effect.
  29303. */
  29304. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29305. /**
  29306. * Sets matrix on a uniform variable.
  29307. * @param uniformName Name of the variable.
  29308. * @param matrix matrix to be set.
  29309. * @returns this effect.
  29310. */
  29311. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29312. /**
  29313. * 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)
  29314. * @param uniformName Name of the variable.
  29315. * @param matrix matrix to be set.
  29316. * @returns this effect.
  29317. */
  29318. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29319. /**
  29320. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29321. * @param uniformName Name of the variable.
  29322. * @param matrix matrix to be set.
  29323. * @returns this effect.
  29324. */
  29325. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29326. /**
  29327. * Sets a float on a uniform variable.
  29328. * @param uniformName Name of the variable.
  29329. * @param value value to be set.
  29330. * @returns this effect.
  29331. */
  29332. setFloat(uniformName: string, value: number): Effect;
  29333. /**
  29334. * Sets a boolean on a uniform variable.
  29335. * @param uniformName Name of the variable.
  29336. * @param bool value to be set.
  29337. * @returns this effect.
  29338. */
  29339. setBool(uniformName: string, bool: boolean): Effect;
  29340. /**
  29341. * Sets a Vector2 on a uniform variable.
  29342. * @param uniformName Name of the variable.
  29343. * @param vector2 vector2 to be set.
  29344. * @returns this effect.
  29345. */
  29346. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29347. /**
  29348. * Sets a float2 on a uniform variable.
  29349. * @param uniformName Name of the variable.
  29350. * @param x First float in float2.
  29351. * @param y Second float in float2.
  29352. * @returns this effect.
  29353. */
  29354. setFloat2(uniformName: string, x: number, y: number): Effect;
  29355. /**
  29356. * Sets a Vector3 on a uniform variable.
  29357. * @param uniformName Name of the variable.
  29358. * @param vector3 Value to be set.
  29359. * @returns this effect.
  29360. */
  29361. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29362. /**
  29363. * Sets a float3 on a uniform variable.
  29364. * @param uniformName Name of the variable.
  29365. * @param x First float in float3.
  29366. * @param y Second float in float3.
  29367. * @param z Third float in float3.
  29368. * @returns this effect.
  29369. */
  29370. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29371. /**
  29372. * Sets a Vector4 on a uniform variable.
  29373. * @param uniformName Name of the variable.
  29374. * @param vector4 Value to be set.
  29375. * @returns this effect.
  29376. */
  29377. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29378. /**
  29379. * Sets a float4 on a uniform variable.
  29380. * @param uniformName Name of the variable.
  29381. * @param x First float in float4.
  29382. * @param y Second float in float4.
  29383. * @param z Third float in float4.
  29384. * @param w Fourth float in float4.
  29385. * @returns this effect.
  29386. */
  29387. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29388. /**
  29389. * Sets a Color3 on a uniform variable.
  29390. * @param uniformName Name of the variable.
  29391. * @param color3 Value to be set.
  29392. * @returns this effect.
  29393. */
  29394. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29395. /**
  29396. * Sets a Color4 on a uniform variable.
  29397. * @param uniformName Name of the variable.
  29398. * @param color3 Value to be set.
  29399. * @param alpha Alpha value to be set.
  29400. * @returns this effect.
  29401. */
  29402. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29403. /**
  29404. * Sets a Color4 on a uniform variable
  29405. * @param uniformName defines the name of the variable
  29406. * @param color4 defines the value to be set
  29407. * @returns this effect.
  29408. */
  29409. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29410. /** Release all associated resources */
  29411. dispose(): void;
  29412. /**
  29413. * This function will add a new shader to the shader store
  29414. * @param name the name of the shader
  29415. * @param pixelShader optional pixel shader content
  29416. * @param vertexShader optional vertex shader content
  29417. */
  29418. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29419. /**
  29420. * Store of each shader (The can be looked up using effect.key)
  29421. */
  29422. static ShadersStore: {
  29423. [key: string]: string;
  29424. };
  29425. /**
  29426. * Store of each included file for a shader (The can be looked up using effect.key)
  29427. */
  29428. static IncludesShadersStore: {
  29429. [key: string]: string;
  29430. };
  29431. /**
  29432. * Resets the cache of effects.
  29433. */
  29434. static ResetCache(): void;
  29435. }
  29436. }
  29437. declare module "babylonjs/Materials/uniformBuffer" {
  29438. import { Nullable, FloatArray } from "babylonjs/types";
  29439. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  29440. import { Engine } from "babylonjs/Engines/engine";
  29441. import { Effect } from "babylonjs/Materials/effect";
  29442. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29443. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29444. import { Color3 } from "babylonjs/Maths/math.color";
  29445. /**
  29446. * Uniform buffer objects.
  29447. *
  29448. * Handles blocks of uniform on the GPU.
  29449. *
  29450. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29451. *
  29452. * For more information, please refer to :
  29453. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29454. */
  29455. export class UniformBuffer {
  29456. private _engine;
  29457. private _buffer;
  29458. private _data;
  29459. private _bufferData;
  29460. private _dynamic?;
  29461. private _uniformLocations;
  29462. private _uniformSizes;
  29463. private _uniformLocationPointer;
  29464. private _needSync;
  29465. private _noUBO;
  29466. private _currentEffect;
  29467. private static _MAX_UNIFORM_SIZE;
  29468. private static _tempBuffer;
  29469. /**
  29470. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  29471. * This is dynamic to allow compat with webgl 1 and 2.
  29472. * You will need to pass the name of the uniform as well as the value.
  29473. */
  29474. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  29475. /**
  29476. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  29477. * This is dynamic to allow compat with webgl 1 and 2.
  29478. * You will need to pass the name of the uniform as well as the value.
  29479. */
  29480. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  29481. /**
  29482. * Lambda to Update a single float in a uniform buffer.
  29483. * This is dynamic to allow compat with webgl 1 and 2.
  29484. * You will need to pass the name of the uniform as well as the value.
  29485. */
  29486. updateFloat: (name: string, x: number) => void;
  29487. /**
  29488. * Lambda to Update a vec2 of float in a uniform buffer.
  29489. * This is dynamic to allow compat with webgl 1 and 2.
  29490. * You will need to pass the name of the uniform as well as the value.
  29491. */
  29492. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  29493. /**
  29494. * Lambda to Update a vec3 of float in a uniform buffer.
  29495. * This is dynamic to allow compat with webgl 1 and 2.
  29496. * You will need to pass the name of the uniform as well as the value.
  29497. */
  29498. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  29499. /**
  29500. * Lambda to Update a vec4 of float in a uniform buffer.
  29501. * This is dynamic to allow compat with webgl 1 and 2.
  29502. * You will need to pass the name of the uniform as well as the value.
  29503. */
  29504. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  29505. /**
  29506. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  29507. * This is dynamic to allow compat with webgl 1 and 2.
  29508. * You will need to pass the name of the uniform as well as the value.
  29509. */
  29510. updateMatrix: (name: string, mat: Matrix) => void;
  29511. /**
  29512. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  29513. * This is dynamic to allow compat with webgl 1 and 2.
  29514. * You will need to pass the name of the uniform as well as the value.
  29515. */
  29516. updateVector3: (name: string, vector: Vector3) => void;
  29517. /**
  29518. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  29519. * This is dynamic to allow compat with webgl 1 and 2.
  29520. * You will need to pass the name of the uniform as well as the value.
  29521. */
  29522. updateVector4: (name: string, vector: Vector4) => void;
  29523. /**
  29524. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  29525. * This is dynamic to allow compat with webgl 1 and 2.
  29526. * You will need to pass the name of the uniform as well as the value.
  29527. */
  29528. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  29529. /**
  29530. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  29531. * This is dynamic to allow compat with webgl 1 and 2.
  29532. * You will need to pass the name of the uniform as well as the value.
  29533. */
  29534. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  29535. /**
  29536. * Instantiates a new Uniform buffer objects.
  29537. *
  29538. * Handles blocks of uniform on the GPU.
  29539. *
  29540. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29541. *
  29542. * For more information, please refer to :
  29543. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29544. * @param engine Define the engine the buffer is associated with
  29545. * @param data Define the data contained in the buffer
  29546. * @param dynamic Define if the buffer is updatable
  29547. */
  29548. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  29549. /**
  29550. * Indicates if the buffer is using the WebGL2 UBO implementation,
  29551. * or just falling back on setUniformXXX calls.
  29552. */
  29553. readonly useUbo: boolean;
  29554. /**
  29555. * Indicates if the WebGL underlying uniform buffer is in sync
  29556. * with the javascript cache data.
  29557. */
  29558. readonly isSync: boolean;
  29559. /**
  29560. * Indicates if the WebGL underlying uniform buffer is dynamic.
  29561. * Also, a dynamic UniformBuffer will disable cache verification and always
  29562. * update the underlying WebGL uniform buffer to the GPU.
  29563. * @returns if Dynamic, otherwise false
  29564. */
  29565. isDynamic(): boolean;
  29566. /**
  29567. * The data cache on JS side.
  29568. * @returns the underlying data as a float array
  29569. */
  29570. getData(): Float32Array;
  29571. /**
  29572. * The underlying WebGL Uniform buffer.
  29573. * @returns the webgl buffer
  29574. */
  29575. getBuffer(): Nullable<DataBuffer>;
  29576. /**
  29577. * std140 layout specifies how to align data within an UBO structure.
  29578. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  29579. * for specs.
  29580. */
  29581. private _fillAlignment;
  29582. /**
  29583. * Adds an uniform in the buffer.
  29584. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  29585. * for the layout to be correct !
  29586. * @param name Name of the uniform, as used in the uniform block in the shader.
  29587. * @param size Data size, or data directly.
  29588. */
  29589. addUniform(name: string, size: number | number[]): void;
  29590. /**
  29591. * Adds a Matrix 4x4 to the uniform buffer.
  29592. * @param name Name of the uniform, as used in the uniform block in the shader.
  29593. * @param mat A 4x4 matrix.
  29594. */
  29595. addMatrix(name: string, mat: Matrix): void;
  29596. /**
  29597. * Adds a vec2 to the uniform buffer.
  29598. * @param name Name of the uniform, as used in the uniform block in the shader.
  29599. * @param x Define the x component value of the vec2
  29600. * @param y Define the y component value of the vec2
  29601. */
  29602. addFloat2(name: string, x: number, y: number): void;
  29603. /**
  29604. * Adds a vec3 to the uniform buffer.
  29605. * @param name Name of the uniform, as used in the uniform block in the shader.
  29606. * @param x Define the x component value of the vec3
  29607. * @param y Define the y component value of the vec3
  29608. * @param z Define the z component value of the vec3
  29609. */
  29610. addFloat3(name: string, x: number, y: number, z: number): void;
  29611. /**
  29612. * Adds a vec3 to the uniform buffer.
  29613. * @param name Name of the uniform, as used in the uniform block in the shader.
  29614. * @param color Define the vec3 from a Color
  29615. */
  29616. addColor3(name: string, color: Color3): void;
  29617. /**
  29618. * Adds a vec4 to the uniform buffer.
  29619. * @param name Name of the uniform, as used in the uniform block in the shader.
  29620. * @param color Define the rgb components from a Color
  29621. * @param alpha Define the a component of the vec4
  29622. */
  29623. addColor4(name: string, color: Color3, alpha: number): void;
  29624. /**
  29625. * Adds a vec3 to the uniform buffer.
  29626. * @param name Name of the uniform, as used in the uniform block in the shader.
  29627. * @param vector Define the vec3 components from a Vector
  29628. */
  29629. addVector3(name: string, vector: Vector3): void;
  29630. /**
  29631. * Adds a Matrix 3x3 to the uniform buffer.
  29632. * @param name Name of the uniform, as used in the uniform block in the shader.
  29633. */
  29634. addMatrix3x3(name: string): void;
  29635. /**
  29636. * Adds a Matrix 2x2 to the uniform buffer.
  29637. * @param name Name of the uniform, as used in the uniform block in the shader.
  29638. */
  29639. addMatrix2x2(name: string): void;
  29640. /**
  29641. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  29642. */
  29643. create(): void;
  29644. /** @hidden */
  29645. _rebuild(): void;
  29646. /**
  29647. * Updates the WebGL Uniform Buffer on the GPU.
  29648. * If the `dynamic` flag is set to true, no cache comparison is done.
  29649. * Otherwise, the buffer will be updated only if the cache differs.
  29650. */
  29651. update(): void;
  29652. /**
  29653. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  29654. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29655. * @param data Define the flattened data
  29656. * @param size Define the size of the data.
  29657. */
  29658. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  29659. private _updateMatrix3x3ForUniform;
  29660. private _updateMatrix3x3ForEffect;
  29661. private _updateMatrix2x2ForEffect;
  29662. private _updateMatrix2x2ForUniform;
  29663. private _updateFloatForEffect;
  29664. private _updateFloatForUniform;
  29665. private _updateFloat2ForEffect;
  29666. private _updateFloat2ForUniform;
  29667. private _updateFloat3ForEffect;
  29668. private _updateFloat3ForUniform;
  29669. private _updateFloat4ForEffect;
  29670. private _updateFloat4ForUniform;
  29671. private _updateMatrixForEffect;
  29672. private _updateMatrixForUniform;
  29673. private _updateVector3ForEffect;
  29674. private _updateVector3ForUniform;
  29675. private _updateVector4ForEffect;
  29676. private _updateVector4ForUniform;
  29677. private _updateColor3ForEffect;
  29678. private _updateColor3ForUniform;
  29679. private _updateColor4ForEffect;
  29680. private _updateColor4ForUniform;
  29681. /**
  29682. * Sets a sampler uniform on the effect.
  29683. * @param name Define the name of the sampler.
  29684. * @param texture Define the texture to set in the sampler
  29685. */
  29686. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  29687. /**
  29688. * Directly updates the value of the uniform in the cache AND on the GPU.
  29689. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29690. * @param data Define the flattened data
  29691. */
  29692. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  29693. /**
  29694. * Binds this uniform buffer to an effect.
  29695. * @param effect Define the effect to bind the buffer to
  29696. * @param name Name of the uniform block in the shader.
  29697. */
  29698. bindToEffect(effect: Effect, name: string): void;
  29699. /**
  29700. * Disposes the uniform buffer.
  29701. */
  29702. dispose(): void;
  29703. }
  29704. }
  29705. declare module "babylonjs/Audio/analyser" {
  29706. import { Scene } from "babylonjs/scene";
  29707. /**
  29708. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29709. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29710. */
  29711. export class Analyser {
  29712. /**
  29713. * Gets or sets the smoothing
  29714. * @ignorenaming
  29715. */
  29716. SMOOTHING: number;
  29717. /**
  29718. * Gets or sets the FFT table size
  29719. * @ignorenaming
  29720. */
  29721. FFT_SIZE: number;
  29722. /**
  29723. * Gets or sets the bar graph amplitude
  29724. * @ignorenaming
  29725. */
  29726. BARGRAPHAMPLITUDE: number;
  29727. /**
  29728. * Gets or sets the position of the debug canvas
  29729. * @ignorenaming
  29730. */
  29731. DEBUGCANVASPOS: {
  29732. x: number;
  29733. y: number;
  29734. };
  29735. /**
  29736. * Gets or sets the debug canvas size
  29737. * @ignorenaming
  29738. */
  29739. DEBUGCANVASSIZE: {
  29740. width: number;
  29741. height: number;
  29742. };
  29743. private _byteFreqs;
  29744. private _byteTime;
  29745. private _floatFreqs;
  29746. private _webAudioAnalyser;
  29747. private _debugCanvas;
  29748. private _debugCanvasContext;
  29749. private _scene;
  29750. private _registerFunc;
  29751. private _audioEngine;
  29752. /**
  29753. * Creates a new analyser
  29754. * @param scene defines hosting scene
  29755. */
  29756. constructor(scene: Scene);
  29757. /**
  29758. * Get the number of data values you will have to play with for the visualization
  29759. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29760. * @returns a number
  29761. */
  29762. getFrequencyBinCount(): number;
  29763. /**
  29764. * Gets the current frequency data as a byte array
  29765. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29766. * @returns a Uint8Array
  29767. */
  29768. getByteFrequencyData(): Uint8Array;
  29769. /**
  29770. * Gets the current waveform as a byte array
  29771. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29772. * @returns a Uint8Array
  29773. */
  29774. getByteTimeDomainData(): Uint8Array;
  29775. /**
  29776. * Gets the current frequency data as a float array
  29777. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29778. * @returns a Float32Array
  29779. */
  29780. getFloatFrequencyData(): Float32Array;
  29781. /**
  29782. * Renders the debug canvas
  29783. */
  29784. drawDebugCanvas(): void;
  29785. /**
  29786. * Stops rendering the debug canvas and removes it
  29787. */
  29788. stopDebugCanvas(): void;
  29789. /**
  29790. * Connects two audio nodes
  29791. * @param inputAudioNode defines first node to connect
  29792. * @param outputAudioNode defines second node to connect
  29793. */
  29794. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29795. /**
  29796. * Releases all associated resources
  29797. */
  29798. dispose(): void;
  29799. }
  29800. }
  29801. declare module "babylonjs/Audio/audioEngine" {
  29802. import { IDisposable } from "babylonjs/scene";
  29803. import { Analyser } from "babylonjs/Audio/analyser";
  29804. import { Nullable } from "babylonjs/types";
  29805. import { Observable } from "babylonjs/Misc/observable";
  29806. /**
  29807. * This represents an audio engine and it is responsible
  29808. * to play, synchronize and analyse sounds throughout the application.
  29809. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29810. */
  29811. export interface IAudioEngine extends IDisposable {
  29812. /**
  29813. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29814. */
  29815. readonly canUseWebAudio: boolean;
  29816. /**
  29817. * Gets the current AudioContext if available.
  29818. */
  29819. readonly audioContext: Nullable<AudioContext>;
  29820. /**
  29821. * The master gain node defines the global audio volume of your audio engine.
  29822. */
  29823. readonly masterGain: GainNode;
  29824. /**
  29825. * Gets whether or not mp3 are supported by your browser.
  29826. */
  29827. readonly isMP3supported: boolean;
  29828. /**
  29829. * Gets whether or not ogg are supported by your browser.
  29830. */
  29831. readonly isOGGsupported: boolean;
  29832. /**
  29833. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29834. * @ignoreNaming
  29835. */
  29836. WarnedWebAudioUnsupported: boolean;
  29837. /**
  29838. * Defines if the audio engine relies on a custom unlocked button.
  29839. * In this case, the embedded button will not be displayed.
  29840. */
  29841. useCustomUnlockedButton: boolean;
  29842. /**
  29843. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29844. */
  29845. readonly unlocked: boolean;
  29846. /**
  29847. * Event raised when audio has been unlocked on the browser.
  29848. */
  29849. onAudioUnlockedObservable: Observable<AudioEngine>;
  29850. /**
  29851. * Event raised when audio has been locked on the browser.
  29852. */
  29853. onAudioLockedObservable: Observable<AudioEngine>;
  29854. /**
  29855. * Flags the audio engine in Locked state.
  29856. * This happens due to new browser policies preventing audio to autoplay.
  29857. */
  29858. lock(): void;
  29859. /**
  29860. * Unlocks the audio engine once a user action has been done on the dom.
  29861. * This is helpful to resume play once browser policies have been satisfied.
  29862. */
  29863. unlock(): void;
  29864. }
  29865. /**
  29866. * This represents the default audio engine used in babylon.
  29867. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29868. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29869. */
  29870. export class AudioEngine implements IAudioEngine {
  29871. private _audioContext;
  29872. private _audioContextInitialized;
  29873. private _muteButton;
  29874. private _hostElement;
  29875. /**
  29876. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29877. */
  29878. canUseWebAudio: boolean;
  29879. /**
  29880. * The master gain node defines the global audio volume of your audio engine.
  29881. */
  29882. masterGain: GainNode;
  29883. /**
  29884. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29885. * @ignoreNaming
  29886. */
  29887. WarnedWebAudioUnsupported: boolean;
  29888. /**
  29889. * Gets whether or not mp3 are supported by your browser.
  29890. */
  29891. isMP3supported: boolean;
  29892. /**
  29893. * Gets whether or not ogg are supported by your browser.
  29894. */
  29895. isOGGsupported: boolean;
  29896. /**
  29897. * Gets whether audio has been unlocked on the device.
  29898. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  29899. * a user interaction has happened.
  29900. */
  29901. unlocked: boolean;
  29902. /**
  29903. * Defines if the audio engine relies on a custom unlocked button.
  29904. * In this case, the embedded button will not be displayed.
  29905. */
  29906. useCustomUnlockedButton: boolean;
  29907. /**
  29908. * Event raised when audio has been unlocked on the browser.
  29909. */
  29910. onAudioUnlockedObservable: Observable<AudioEngine>;
  29911. /**
  29912. * Event raised when audio has been locked on the browser.
  29913. */
  29914. onAudioLockedObservable: Observable<AudioEngine>;
  29915. /**
  29916. * Gets the current AudioContext if available.
  29917. */
  29918. readonly audioContext: Nullable<AudioContext>;
  29919. private _connectedAnalyser;
  29920. /**
  29921. * Instantiates a new audio engine.
  29922. *
  29923. * There should be only one per page as some browsers restrict the number
  29924. * of audio contexts you can create.
  29925. * @param hostElement defines the host element where to display the mute icon if necessary
  29926. */
  29927. constructor(hostElement?: Nullable<HTMLElement>);
  29928. /**
  29929. * Flags the audio engine in Locked state.
  29930. * This happens due to new browser policies preventing audio to autoplay.
  29931. */
  29932. lock(): void;
  29933. /**
  29934. * Unlocks the audio engine once a user action has been done on the dom.
  29935. * This is helpful to resume play once browser policies have been satisfied.
  29936. */
  29937. unlock(): void;
  29938. private _resumeAudioContext;
  29939. private _initializeAudioContext;
  29940. private _tryToRun;
  29941. private _triggerRunningState;
  29942. private _triggerSuspendedState;
  29943. private _displayMuteButton;
  29944. private _moveButtonToTopLeft;
  29945. private _onResize;
  29946. private _hideMuteButton;
  29947. /**
  29948. * Destroy and release the resources associated with the audio ccontext.
  29949. */
  29950. dispose(): void;
  29951. /**
  29952. * Gets the global volume sets on the master gain.
  29953. * @returns the global volume if set or -1 otherwise
  29954. */
  29955. getGlobalVolume(): number;
  29956. /**
  29957. * Sets the global volume of your experience (sets on the master gain).
  29958. * @param newVolume Defines the new global volume of the application
  29959. */
  29960. setGlobalVolume(newVolume: number): void;
  29961. /**
  29962. * Connect the audio engine to an audio analyser allowing some amazing
  29963. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  29964. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  29965. * @param analyser The analyser to connect to the engine
  29966. */
  29967. connectToAnalyser(analyser: Analyser): void;
  29968. }
  29969. }
  29970. declare module "babylonjs/Loading/loadingScreen" {
  29971. /**
  29972. * Interface used to present a loading screen while loading a scene
  29973. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29974. */
  29975. export interface ILoadingScreen {
  29976. /**
  29977. * Function called to display the loading screen
  29978. */
  29979. displayLoadingUI: () => void;
  29980. /**
  29981. * Function called to hide the loading screen
  29982. */
  29983. hideLoadingUI: () => void;
  29984. /**
  29985. * Gets or sets the color to use for the background
  29986. */
  29987. loadingUIBackgroundColor: string;
  29988. /**
  29989. * Gets or sets the text to display while loading
  29990. */
  29991. loadingUIText: string;
  29992. }
  29993. /**
  29994. * Class used for the default loading screen
  29995. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29996. */
  29997. export class DefaultLoadingScreen implements ILoadingScreen {
  29998. private _renderingCanvas;
  29999. private _loadingText;
  30000. private _loadingDivBackgroundColor;
  30001. private _loadingDiv;
  30002. private _loadingTextDiv;
  30003. /** Gets or sets the logo url to use for the default loading screen */
  30004. static DefaultLogoUrl: string;
  30005. /** Gets or sets the spinner url to use for the default loading screen */
  30006. static DefaultSpinnerUrl: string;
  30007. /**
  30008. * Creates a new default loading screen
  30009. * @param _renderingCanvas defines the canvas used to render the scene
  30010. * @param _loadingText defines the default text to display
  30011. * @param _loadingDivBackgroundColor defines the default background color
  30012. */
  30013. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30014. /**
  30015. * Function called to display the loading screen
  30016. */
  30017. displayLoadingUI(): void;
  30018. /**
  30019. * Function called to hide the loading screen
  30020. */
  30021. hideLoadingUI(): void;
  30022. /**
  30023. * Gets or sets the text to display while loading
  30024. */
  30025. loadingUIText: string;
  30026. /**
  30027. * Gets or sets the color to use for the background
  30028. */
  30029. loadingUIBackgroundColor: string;
  30030. private _resizeLoadingUI;
  30031. }
  30032. }
  30033. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  30034. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30035. import { Engine } from "babylonjs/Engines/engine";
  30036. import { Nullable } from "babylonjs/types";
  30037. /** @hidden */
  30038. export class WebGLPipelineContext implements IPipelineContext {
  30039. engine: Engine;
  30040. program: Nullable<WebGLProgram>;
  30041. context?: WebGLRenderingContext;
  30042. vertexShader?: WebGLShader;
  30043. fragmentShader?: WebGLShader;
  30044. isParallelCompiled: boolean;
  30045. onCompiled?: () => void;
  30046. transformFeedback?: WebGLTransformFeedback | null;
  30047. readonly isAsync: boolean;
  30048. readonly isReady: boolean;
  30049. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  30050. }
  30051. }
  30052. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  30053. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30054. /** @hidden */
  30055. export class WebGLDataBuffer extends DataBuffer {
  30056. private _buffer;
  30057. constructor(resource: WebGLBuffer);
  30058. readonly underlyingResource: any;
  30059. }
  30060. }
  30061. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  30062. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30063. /** @hidden */
  30064. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30065. attributeProcessor(attribute: string): string;
  30066. varyingProcessor(varying: string, isFragment: boolean): string;
  30067. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30068. }
  30069. }
  30070. declare module "babylonjs/Misc/perfCounter" {
  30071. /**
  30072. * This class is used to track a performance counter which is number based.
  30073. * The user has access to many properties which give statistics of different nature.
  30074. *
  30075. * The implementer can track two kinds of Performance Counter: time and count.
  30076. * 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.
  30077. * 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.
  30078. */
  30079. export class PerfCounter {
  30080. /**
  30081. * Gets or sets a global boolean to turn on and off all the counters
  30082. */
  30083. static Enabled: boolean;
  30084. /**
  30085. * Returns the smallest value ever
  30086. */
  30087. readonly min: number;
  30088. /**
  30089. * Returns the biggest value ever
  30090. */
  30091. readonly max: number;
  30092. /**
  30093. * Returns the average value since the performance counter is running
  30094. */
  30095. readonly average: number;
  30096. /**
  30097. * Returns the average value of the last second the counter was monitored
  30098. */
  30099. readonly lastSecAverage: number;
  30100. /**
  30101. * Returns the current value
  30102. */
  30103. readonly current: number;
  30104. /**
  30105. * Gets the accumulated total
  30106. */
  30107. readonly total: number;
  30108. /**
  30109. * Gets the total value count
  30110. */
  30111. readonly count: number;
  30112. /**
  30113. * Creates a new counter
  30114. */
  30115. constructor();
  30116. /**
  30117. * Call this method to start monitoring a new frame.
  30118. * 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.
  30119. */
  30120. fetchNewFrame(): void;
  30121. /**
  30122. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30123. * @param newCount the count value to add to the monitored count
  30124. * @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.
  30125. */
  30126. addCount(newCount: number, fetchResult: boolean): void;
  30127. /**
  30128. * Start monitoring this performance counter
  30129. */
  30130. beginMonitoring(): void;
  30131. /**
  30132. * Compute the time lapsed since the previous beginMonitoring() call.
  30133. * @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
  30134. */
  30135. endMonitoring(newFrame?: boolean): void;
  30136. private _fetchResult;
  30137. private _startMonitoringTime;
  30138. private _min;
  30139. private _max;
  30140. private _average;
  30141. private _current;
  30142. private _totalValueCount;
  30143. private _totalAccumulated;
  30144. private _lastSecAverage;
  30145. private _lastSecAccumulated;
  30146. private _lastSecTime;
  30147. private _lastSecValueCount;
  30148. }
  30149. }
  30150. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  30151. /**
  30152. * Interface for any object that can request an animation frame
  30153. */
  30154. export interface ICustomAnimationFrameRequester {
  30155. /**
  30156. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30157. */
  30158. renderFunction?: Function;
  30159. /**
  30160. * Called to request the next frame to render to
  30161. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30162. */
  30163. requestAnimationFrame: Function;
  30164. /**
  30165. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30166. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30167. */
  30168. requestID?: number;
  30169. }
  30170. }
  30171. declare module "babylonjs/Materials/Textures/videoTexture" {
  30172. import { Observable } from "babylonjs/Misc/observable";
  30173. import { Nullable } from "babylonjs/types";
  30174. import { Scene } from "babylonjs/scene";
  30175. import { Texture } from "babylonjs/Materials/Textures/texture";
  30176. /**
  30177. * Settings for finer control over video usage
  30178. */
  30179. export interface VideoTextureSettings {
  30180. /**
  30181. * Applies `autoplay` to video, if specified
  30182. */
  30183. autoPlay?: boolean;
  30184. /**
  30185. * Applies `loop` to video, if specified
  30186. */
  30187. loop?: boolean;
  30188. /**
  30189. * Automatically updates internal texture from video at every frame in the render loop
  30190. */
  30191. autoUpdateTexture: boolean;
  30192. /**
  30193. * Image src displayed during the video loading or until the user interacts with the video.
  30194. */
  30195. poster?: string;
  30196. }
  30197. /**
  30198. * If you want to display a video in your scene, this is the special texture for that.
  30199. * This special texture works similar to other textures, with the exception of a few parameters.
  30200. * @see https://doc.babylonjs.com/how_to/video_texture
  30201. */
  30202. export class VideoTexture extends Texture {
  30203. /**
  30204. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30205. */
  30206. readonly autoUpdateTexture: boolean;
  30207. /**
  30208. * The video instance used by the texture internally
  30209. */
  30210. readonly video: HTMLVideoElement;
  30211. private _onUserActionRequestedObservable;
  30212. /**
  30213. * Event triggerd when a dom action is required by the user to play the video.
  30214. * This happens due to recent changes in browser policies preventing video to auto start.
  30215. */
  30216. readonly onUserActionRequestedObservable: Observable<Texture>;
  30217. private _generateMipMaps;
  30218. private _engine;
  30219. private _stillImageCaptured;
  30220. private _displayingPosterTexture;
  30221. private _settings;
  30222. private _createInternalTextureOnEvent;
  30223. /**
  30224. * Creates a video texture.
  30225. * If you want to display a video in your scene, this is the special texture for that.
  30226. * This special texture works similar to other textures, with the exception of a few parameters.
  30227. * @see https://doc.babylonjs.com/how_to/video_texture
  30228. * @param name optional name, will detect from video source, if not defined
  30229. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30230. * @param scene is obviously the current scene.
  30231. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30232. * @param invertY is false by default but can be used to invert video on Y axis
  30233. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30234. * @param settings allows finer control over video usage
  30235. */
  30236. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30237. private _getName;
  30238. private _getVideo;
  30239. private _createInternalTexture;
  30240. private reset;
  30241. /**
  30242. * @hidden Internal method to initiate `update`.
  30243. */
  30244. _rebuild(): void;
  30245. /**
  30246. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30247. */
  30248. update(): void;
  30249. /**
  30250. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30251. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30252. */
  30253. updateTexture(isVisible: boolean): void;
  30254. protected _updateInternalTexture: () => void;
  30255. /**
  30256. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30257. * @param url New url.
  30258. */
  30259. updateURL(url: string): void;
  30260. /**
  30261. * Dispose the texture and release its associated resources.
  30262. */
  30263. dispose(): void;
  30264. /**
  30265. * Creates a video texture straight from a stream.
  30266. * @param scene Define the scene the texture should be created in
  30267. * @param stream Define the stream the texture should be created from
  30268. * @returns The created video texture as a promise
  30269. */
  30270. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30271. /**
  30272. * Creates a video texture straight from your WebCam video feed.
  30273. * @param scene Define the scene the texture should be created in
  30274. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30275. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30276. * @returns The created video texture as a promise
  30277. */
  30278. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30279. minWidth: number;
  30280. maxWidth: number;
  30281. minHeight: number;
  30282. maxHeight: number;
  30283. deviceId: string;
  30284. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30285. /**
  30286. * Creates a video texture straight from your WebCam video feed.
  30287. * @param scene Define the scene the texture should be created in
  30288. * @param onReady Define a callback to triggered once the texture will be ready
  30289. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30290. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30291. */
  30292. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30293. minWidth: number;
  30294. maxWidth: number;
  30295. minHeight: number;
  30296. maxHeight: number;
  30297. deviceId: string;
  30298. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30299. }
  30300. }
  30301. declare module "babylonjs/Engines/engine" {
  30302. import { Observable } from "babylonjs/Misc/observable";
  30303. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  30304. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  30305. import { Scene } from "babylonjs/scene";
  30306. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30307. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30308. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  30309. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30310. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30311. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30312. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  30313. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30314. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  30315. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  30316. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  30317. import { WebRequest } from "babylonjs/Misc/webRequest";
  30318. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  30319. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30320. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30321. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30322. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  30323. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30324. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  30325. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30326. import { Material } from "babylonjs/Materials/material";
  30327. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30328. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30329. /**
  30330. * Defines the interface used by objects containing a viewport (like a camera)
  30331. */
  30332. interface IViewportOwnerLike {
  30333. /**
  30334. * Gets or sets the viewport
  30335. */
  30336. viewport: IViewportLike;
  30337. }
  30338. /**
  30339. * Interface for attribute information associated with buffer instanciation
  30340. */
  30341. export class InstancingAttributeInfo {
  30342. /**
  30343. * Index/offset of the attribute in the vertex shader
  30344. */
  30345. index: number;
  30346. /**
  30347. * size of the attribute, 1, 2, 3 or 4
  30348. */
  30349. attributeSize: number;
  30350. /**
  30351. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30352. * default is FLOAT
  30353. */
  30354. attribyteType: number;
  30355. /**
  30356. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30357. */
  30358. normalized: boolean;
  30359. /**
  30360. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30361. */
  30362. offset: number;
  30363. /**
  30364. * Name of the GLSL attribute, for debugging purpose only
  30365. */
  30366. attributeName: string;
  30367. }
  30368. /**
  30369. * Define options used to create a depth texture
  30370. */
  30371. export class DepthTextureCreationOptions {
  30372. /** Specifies whether or not a stencil should be allocated in the texture */
  30373. generateStencil?: boolean;
  30374. /** Specifies whether or not bilinear filtering is enable on the texture */
  30375. bilinearFiltering?: boolean;
  30376. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  30377. comparisonFunction?: number;
  30378. /** Specifies if the created texture is a cube texture */
  30379. isCube?: boolean;
  30380. }
  30381. /**
  30382. * Class used to describe the capabilities of the engine relatively to the current browser
  30383. */
  30384. export class EngineCapabilities {
  30385. /** Maximum textures units per fragment shader */
  30386. maxTexturesImageUnits: number;
  30387. /** Maximum texture units per vertex shader */
  30388. maxVertexTextureImageUnits: number;
  30389. /** Maximum textures units in the entire pipeline */
  30390. maxCombinedTexturesImageUnits: number;
  30391. /** Maximum texture size */
  30392. maxTextureSize: number;
  30393. /** Maximum cube texture size */
  30394. maxCubemapTextureSize: number;
  30395. /** Maximum render texture size */
  30396. maxRenderTextureSize: number;
  30397. /** Maximum number of vertex attributes */
  30398. maxVertexAttribs: number;
  30399. /** Maximum number of varyings */
  30400. maxVaryingVectors: number;
  30401. /** Maximum number of uniforms per vertex shader */
  30402. maxVertexUniformVectors: number;
  30403. /** Maximum number of uniforms per fragment shader */
  30404. maxFragmentUniformVectors: number;
  30405. /** Defines if standard derivates (dx/dy) are supported */
  30406. standardDerivatives: boolean;
  30407. /** Defines if s3tc texture compression is supported */
  30408. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  30409. /** Defines if pvrtc texture compression is supported */
  30410. pvrtc: any;
  30411. /** Defines if etc1 texture compression is supported */
  30412. etc1: any;
  30413. /** Defines if etc2 texture compression is supported */
  30414. etc2: any;
  30415. /** Defines if astc texture compression is supported */
  30416. astc: any;
  30417. /** Defines if float textures are supported */
  30418. textureFloat: boolean;
  30419. /** Defines if vertex array objects are supported */
  30420. vertexArrayObject: boolean;
  30421. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30422. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  30423. /** Gets the maximum level of anisotropy supported */
  30424. maxAnisotropy: number;
  30425. /** Defines if instancing is supported */
  30426. instancedArrays: boolean;
  30427. /** Defines if 32 bits indices are supported */
  30428. uintIndices: boolean;
  30429. /** Defines if high precision shaders are supported */
  30430. highPrecisionShaderSupported: boolean;
  30431. /** Defines if depth reading in the fragment shader is supported */
  30432. fragmentDepthSupported: boolean;
  30433. /** Defines if float texture linear filtering is supported*/
  30434. textureFloatLinearFiltering: boolean;
  30435. /** Defines if rendering to float textures is supported */
  30436. textureFloatRender: boolean;
  30437. /** Defines if half float textures are supported*/
  30438. textureHalfFloat: boolean;
  30439. /** Defines if half float texture linear filtering is supported*/
  30440. textureHalfFloatLinearFiltering: boolean;
  30441. /** Defines if rendering to half float textures is supported */
  30442. textureHalfFloatRender: boolean;
  30443. /** Defines if textureLOD shader command is supported */
  30444. textureLOD: boolean;
  30445. /** Defines if draw buffers extension is supported */
  30446. drawBuffersExtension: boolean;
  30447. /** Defines if depth textures are supported */
  30448. depthTextureExtension: boolean;
  30449. /** Defines if float color buffer are supported */
  30450. colorBufferFloat: boolean;
  30451. /** Gets disjoint timer query extension (null if not supported) */
  30452. timerQuery: EXT_disjoint_timer_query;
  30453. /** Defines if timestamp can be used with timer query */
  30454. canUseTimestampForTimerQuery: boolean;
  30455. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30456. multiview: any;
  30457. /** Function used to let the system compiles shaders in background */
  30458. parallelShaderCompile: {
  30459. COMPLETION_STATUS_KHR: number;
  30460. };
  30461. }
  30462. /** Interface defining initialization parameters for Engine class */
  30463. export interface EngineOptions extends WebGLContextAttributes {
  30464. /**
  30465. * Defines if the engine should no exceed a specified device ratio
  30466. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30467. */
  30468. limitDeviceRatio?: number;
  30469. /**
  30470. * Defines if webvr should be enabled automatically
  30471. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30472. */
  30473. autoEnableWebVR?: boolean;
  30474. /**
  30475. * Defines if webgl2 should be turned off even if supported
  30476. * @see http://doc.babylonjs.com/features/webgl2
  30477. */
  30478. disableWebGL2Support?: boolean;
  30479. /**
  30480. * Defines if webaudio should be initialized as well
  30481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30482. */
  30483. audioEngine?: boolean;
  30484. /**
  30485. * Defines if animations should run using a deterministic lock step
  30486. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30487. */
  30488. deterministicLockstep?: boolean;
  30489. /** Defines the maximum steps to use with deterministic lock step mode */
  30490. lockstepMaxSteps?: number;
  30491. /**
  30492. * Defines that engine should ignore context lost events
  30493. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30494. */
  30495. doNotHandleContextLost?: boolean;
  30496. /**
  30497. * Defines that engine should ignore modifying touch action attribute and style
  30498. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30499. */
  30500. doNotHandleTouchAction?: boolean;
  30501. /**
  30502. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30503. */
  30504. useHighPrecisionFloats?: boolean;
  30505. }
  30506. /**
  30507. * Defines the interface used by display changed events
  30508. */
  30509. export interface IDisplayChangedEventArgs {
  30510. /** Gets the vrDisplay object (if any) */
  30511. vrDisplay: Nullable<any>;
  30512. /** Gets a boolean indicating if webVR is supported */
  30513. vrSupported: boolean;
  30514. }
  30515. /**
  30516. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30517. */
  30518. export class Engine {
  30519. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30520. static ExceptionList: ({
  30521. key: string;
  30522. capture: string;
  30523. captureConstraint: number;
  30524. targets: string[];
  30525. } | {
  30526. key: string;
  30527. capture: null;
  30528. captureConstraint: null;
  30529. targets: string[];
  30530. })[];
  30531. /** Gets the list of created engines */
  30532. static readonly Instances: Engine[];
  30533. /**
  30534. * Gets the latest created engine
  30535. */
  30536. static readonly LastCreatedEngine: Nullable<Engine>;
  30537. /**
  30538. * Gets the latest created scene
  30539. */
  30540. static readonly LastCreatedScene: Nullable<Scene>;
  30541. /**
  30542. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  30543. * @param flag defines which part of the materials must be marked as dirty
  30544. * @param predicate defines a predicate used to filter which materials should be affected
  30545. */
  30546. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  30547. /** @hidden */
  30548. static _TextureLoaders: IInternalTextureLoader[];
  30549. /** Defines that alpha blending is disabled */
  30550. static readonly ALPHA_DISABLE: number;
  30551. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30552. static readonly ALPHA_ADD: number;
  30553. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30554. static readonly ALPHA_COMBINE: number;
  30555. /** Defines that alpha blending to DEST - SRC * DEST */
  30556. static readonly ALPHA_SUBTRACT: number;
  30557. /** Defines that alpha blending to SRC * DEST */
  30558. static readonly ALPHA_MULTIPLY: number;
  30559. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30560. static readonly ALPHA_MAXIMIZED: number;
  30561. /** Defines that alpha blending to SRC + DEST */
  30562. static readonly ALPHA_ONEONE: number;
  30563. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30564. static readonly ALPHA_PREMULTIPLIED: number;
  30565. /**
  30566. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30567. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30568. */
  30569. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30570. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30571. static readonly ALPHA_INTERPOLATE: number;
  30572. /**
  30573. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30574. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30575. */
  30576. static readonly ALPHA_SCREENMODE: number;
  30577. /** Defines that the ressource is not delayed*/
  30578. static readonly DELAYLOADSTATE_NONE: number;
  30579. /** Defines that the ressource was successfully delay loaded */
  30580. static readonly DELAYLOADSTATE_LOADED: number;
  30581. /** Defines that the ressource is currently delay loading */
  30582. static readonly DELAYLOADSTATE_LOADING: number;
  30583. /** Defines that the ressource is delayed and has not started loading */
  30584. static readonly DELAYLOADSTATE_NOTLOADED: number;
  30585. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30586. static readonly NEVER: number;
  30587. /** 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 */
  30588. static readonly ALWAYS: number;
  30589. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30590. static readonly LESS: number;
  30591. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  30592. static readonly EQUAL: number;
  30593. /** 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 */
  30594. static readonly LEQUAL: number;
  30595. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  30596. static readonly GREATER: number;
  30597. /** 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 */
  30598. static readonly GEQUAL: number;
  30599. /** 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 */
  30600. static readonly NOTEQUAL: number;
  30601. /** Passed to stencilOperation to specify that stencil value must be kept */
  30602. static readonly KEEP: number;
  30603. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30604. static readonly REPLACE: number;
  30605. /** Passed to stencilOperation to specify that stencil value must be incremented */
  30606. static readonly INCR: number;
  30607. /** Passed to stencilOperation to specify that stencil value must be decremented */
  30608. static readonly DECR: number;
  30609. /** Passed to stencilOperation to specify that stencil value must be inverted */
  30610. static readonly INVERT: number;
  30611. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  30612. static readonly INCR_WRAP: number;
  30613. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  30614. static readonly DECR_WRAP: number;
  30615. /** Texture is not repeating outside of 0..1 UVs */
  30616. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  30617. /** Texture is repeating outside of 0..1 UVs */
  30618. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  30619. /** Texture is repeating and mirrored */
  30620. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  30621. /** ALPHA */
  30622. static readonly TEXTUREFORMAT_ALPHA: number;
  30623. /** LUMINANCE */
  30624. static readonly TEXTUREFORMAT_LUMINANCE: number;
  30625. /** LUMINANCE_ALPHA */
  30626. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  30627. /** RGB */
  30628. static readonly TEXTUREFORMAT_RGB: number;
  30629. /** RGBA */
  30630. static readonly TEXTUREFORMAT_RGBA: number;
  30631. /** RED */
  30632. static readonly TEXTUREFORMAT_RED: number;
  30633. /** RED (2nd reference) */
  30634. static readonly TEXTUREFORMAT_R: number;
  30635. /** RG */
  30636. static readonly TEXTUREFORMAT_RG: number;
  30637. /** RED_INTEGER */
  30638. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  30639. /** RED_INTEGER (2nd reference) */
  30640. static readonly TEXTUREFORMAT_R_INTEGER: number;
  30641. /** RG_INTEGER */
  30642. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  30643. /** RGB_INTEGER */
  30644. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  30645. /** RGBA_INTEGER */
  30646. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  30647. /** UNSIGNED_BYTE */
  30648. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  30649. /** UNSIGNED_BYTE (2nd reference) */
  30650. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  30651. /** FLOAT */
  30652. static readonly TEXTURETYPE_FLOAT: number;
  30653. /** HALF_FLOAT */
  30654. static readonly TEXTURETYPE_HALF_FLOAT: number;
  30655. /** BYTE */
  30656. static readonly TEXTURETYPE_BYTE: number;
  30657. /** SHORT */
  30658. static readonly TEXTURETYPE_SHORT: number;
  30659. /** UNSIGNED_SHORT */
  30660. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  30661. /** INT */
  30662. static readonly TEXTURETYPE_INT: number;
  30663. /** UNSIGNED_INT */
  30664. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  30665. /** UNSIGNED_SHORT_4_4_4_4 */
  30666. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  30667. /** UNSIGNED_SHORT_5_5_5_1 */
  30668. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  30669. /** UNSIGNED_SHORT_5_6_5 */
  30670. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  30671. /** UNSIGNED_INT_2_10_10_10_REV */
  30672. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  30673. /** UNSIGNED_INT_24_8 */
  30674. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  30675. /** UNSIGNED_INT_10F_11F_11F_REV */
  30676. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  30677. /** UNSIGNED_INT_5_9_9_9_REV */
  30678. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  30679. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  30680. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  30681. /** nearest is mag = nearest and min = nearest and mip = linear */
  30682. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  30683. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30684. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  30685. /** Trilinear is mag = linear and min = linear and mip = linear */
  30686. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  30687. /** nearest is mag = nearest and min = nearest and mip = linear */
  30688. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  30689. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30690. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  30691. /** Trilinear is mag = linear and min = linear and mip = linear */
  30692. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  30693. /** mag = nearest and min = nearest and mip = nearest */
  30694. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  30695. /** mag = nearest and min = linear and mip = nearest */
  30696. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  30697. /** mag = nearest and min = linear and mip = linear */
  30698. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  30699. /** mag = nearest and min = linear and mip = none */
  30700. static readonly TEXTURE_NEAREST_LINEAR: number;
  30701. /** mag = nearest and min = nearest and mip = none */
  30702. static readonly TEXTURE_NEAREST_NEAREST: number;
  30703. /** mag = linear and min = nearest and mip = nearest */
  30704. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  30705. /** mag = linear and min = nearest and mip = linear */
  30706. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  30707. /** mag = linear and min = linear and mip = none */
  30708. static readonly TEXTURE_LINEAR_LINEAR: number;
  30709. /** mag = linear and min = nearest and mip = none */
  30710. static readonly TEXTURE_LINEAR_NEAREST: number;
  30711. /** Explicit coordinates mode */
  30712. static readonly TEXTURE_EXPLICIT_MODE: number;
  30713. /** Spherical coordinates mode */
  30714. static readonly TEXTURE_SPHERICAL_MODE: number;
  30715. /** Planar coordinates mode */
  30716. static readonly TEXTURE_PLANAR_MODE: number;
  30717. /** Cubic coordinates mode */
  30718. static readonly TEXTURE_CUBIC_MODE: number;
  30719. /** Projection coordinates mode */
  30720. static readonly TEXTURE_PROJECTION_MODE: number;
  30721. /** Skybox coordinates mode */
  30722. static readonly TEXTURE_SKYBOX_MODE: number;
  30723. /** Inverse Cubic coordinates mode */
  30724. static readonly TEXTURE_INVCUBIC_MODE: number;
  30725. /** Equirectangular coordinates mode */
  30726. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  30727. /** Equirectangular Fixed coordinates mode */
  30728. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  30729. /** Equirectangular Fixed Mirrored coordinates mode */
  30730. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  30731. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30732. static readonly SCALEMODE_FLOOR: number;
  30733. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30734. static readonly SCALEMODE_NEAREST: number;
  30735. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30736. static readonly SCALEMODE_CEILING: number;
  30737. /**
  30738. * Returns the current npm package of the sdk
  30739. */
  30740. static readonly NpmPackage: string;
  30741. /**
  30742. * Returns the current version of the framework
  30743. */
  30744. static readonly Version: string;
  30745. /**
  30746. * Returns a string describing the current engine
  30747. */
  30748. readonly description: string;
  30749. /**
  30750. * Gets or sets the epsilon value used by collision engine
  30751. */
  30752. static CollisionsEpsilon: number;
  30753. /**
  30754. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30755. */
  30756. static ShadersRepository: string;
  30757. /**
  30758. * Method called to create the default loading screen.
  30759. * This can be overriden in your own app.
  30760. * @param canvas The rendering canvas element
  30761. * @returns The loading screen
  30762. */
  30763. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30764. /**
  30765. * Method called to create the default rescale post process on each engine.
  30766. */
  30767. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30768. /** @hidden */
  30769. _shaderProcessor: IShaderProcessor;
  30770. /**
  30771. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30772. */
  30773. forcePOTTextures: boolean;
  30774. /**
  30775. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30776. */
  30777. isFullscreen: boolean;
  30778. /**
  30779. * Gets a boolean indicating if the pointer is currently locked
  30780. */
  30781. isPointerLock: boolean;
  30782. /**
  30783. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30784. */
  30785. cullBackFaces: boolean;
  30786. /**
  30787. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30788. */
  30789. renderEvenInBackground: boolean;
  30790. /**
  30791. * Gets or sets a boolean indicating that cache can be kept between frames
  30792. */
  30793. preventCacheWipeBetweenFrames: boolean;
  30794. /**
  30795. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  30796. **/
  30797. enableOfflineSupport: boolean;
  30798. /**
  30799. * 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)
  30800. **/
  30801. disableManifestCheck: boolean;
  30802. /**
  30803. * Gets the list of created scenes
  30804. */
  30805. scenes: Scene[];
  30806. /**
  30807. * Event raised when a new scene is created
  30808. */
  30809. onNewSceneAddedObservable: Observable<Scene>;
  30810. /**
  30811. * Gets the list of created postprocesses
  30812. */
  30813. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  30814. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30815. validateShaderPrograms: boolean;
  30816. /**
  30817. * Observable event triggered each time the rendering canvas is resized
  30818. */
  30819. onResizeObservable: Observable<Engine>;
  30820. /**
  30821. * Observable event triggered each time the canvas loses focus
  30822. */
  30823. onCanvasBlurObservable: Observable<Engine>;
  30824. /**
  30825. * Observable event triggered each time the canvas gains focus
  30826. */
  30827. onCanvasFocusObservable: Observable<Engine>;
  30828. /**
  30829. * Observable event triggered each time the canvas receives pointerout event
  30830. */
  30831. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30832. /**
  30833. * Observable event triggered before each texture is initialized
  30834. */
  30835. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30836. /**
  30837. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30838. */
  30839. disableUniformBuffers: boolean;
  30840. /** @hidden */
  30841. _uniformBuffers: UniformBuffer[];
  30842. /**
  30843. * Gets a boolean indicating that the engine supports uniform buffers
  30844. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30845. */
  30846. readonly supportsUniformBuffers: boolean;
  30847. /**
  30848. * Observable raised when the engine begins a new frame
  30849. */
  30850. onBeginFrameObservable: Observable<Engine>;
  30851. /**
  30852. * If set, will be used to request the next animation frame for the render loop
  30853. */
  30854. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30855. /**
  30856. * Observable raised when the engine ends the current frame
  30857. */
  30858. onEndFrameObservable: Observable<Engine>;
  30859. /**
  30860. * Observable raised when the engine is about to compile a shader
  30861. */
  30862. onBeforeShaderCompilationObservable: Observable<Engine>;
  30863. /**
  30864. * Observable raised when the engine has jsut compiled a shader
  30865. */
  30866. onAfterShaderCompilationObservable: Observable<Engine>;
  30867. /** @hidden */
  30868. _gl: WebGLRenderingContext;
  30869. private _renderingCanvas;
  30870. private _windowIsBackground;
  30871. private _webGLVersion;
  30872. protected _highPrecisionShadersAllowed: boolean;
  30873. /** @hidden */
  30874. readonly _shouldUseHighPrecisionShader: boolean;
  30875. /**
  30876. * Gets a boolean indicating that only power of 2 textures are supported
  30877. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30878. */
  30879. readonly needPOTTextures: boolean;
  30880. /** @hidden */
  30881. _badOS: boolean;
  30882. /** @hidden */
  30883. _badDesktopOS: boolean;
  30884. /**
  30885. * Gets the audio engine
  30886. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30887. * @ignorenaming
  30888. */
  30889. static audioEngine: IAudioEngine;
  30890. /**
  30891. * Default AudioEngine factory responsible of creating the Audio Engine.
  30892. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30893. */
  30894. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30895. /**
  30896. * Default offline support factory responsible of creating a tool used to store data locally.
  30897. * By default, this will create a Database object if the workload has been embedded.
  30898. */
  30899. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  30900. private _onFocus;
  30901. private _onBlur;
  30902. private _onCanvasPointerOut;
  30903. private _onCanvasBlur;
  30904. private _onCanvasFocus;
  30905. private _onFullscreenChange;
  30906. private _onPointerLockChange;
  30907. private _hardwareScalingLevel;
  30908. /** @hidden */
  30909. _caps: EngineCapabilities;
  30910. private _pointerLockRequested;
  30911. private _isStencilEnable;
  30912. private _colorWrite;
  30913. private _loadingScreen;
  30914. /** @hidden */
  30915. _drawCalls: PerfCounter;
  30916. private _glVersion;
  30917. private _glRenderer;
  30918. private _glVendor;
  30919. private _videoTextureSupported;
  30920. private _renderingQueueLaunched;
  30921. private _activeRenderLoops;
  30922. private _deterministicLockstep;
  30923. private _lockstepMaxSteps;
  30924. /**
  30925. * Observable signaled when a context lost event is raised
  30926. */
  30927. onContextLostObservable: Observable<Engine>;
  30928. /**
  30929. * Observable signaled when a context restored event is raised
  30930. */
  30931. onContextRestoredObservable: Observable<Engine>;
  30932. private _onContextLost;
  30933. private _onContextRestored;
  30934. private _contextWasLost;
  30935. /** @hidden */
  30936. _doNotHandleContextLost: boolean;
  30937. /**
  30938. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30939. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30940. */
  30941. doNotHandleContextLost: boolean;
  30942. private _performanceMonitor;
  30943. private _fps;
  30944. private _deltaTime;
  30945. /**
  30946. * Turn this value on if you want to pause FPS computation when in background
  30947. */
  30948. disablePerformanceMonitorInBackground: boolean;
  30949. /**
  30950. * Gets the performance monitor attached to this engine
  30951. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  30952. */
  30953. readonly performanceMonitor: PerformanceMonitor;
  30954. /**
  30955. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30956. */
  30957. disableVertexArrayObjects: boolean;
  30958. /** @hidden */
  30959. protected _depthCullingState: _DepthCullingState;
  30960. /** @hidden */
  30961. protected _stencilState: _StencilState;
  30962. /** @hidden */
  30963. protected _alphaState: _AlphaState;
  30964. /** @hidden */
  30965. protected _alphaMode: number;
  30966. /** @hidden */
  30967. _internalTexturesCache: InternalTexture[];
  30968. /** @hidden */
  30969. protected _activeChannel: number;
  30970. private _currentTextureChannel;
  30971. /** @hidden */
  30972. protected _boundTexturesCache: {
  30973. [key: string]: Nullable<InternalTexture>;
  30974. };
  30975. /** @hidden */
  30976. protected _currentEffect: Nullable<Effect>;
  30977. /** @hidden */
  30978. protected _currentProgram: Nullable<WebGLProgram>;
  30979. private _compiledEffects;
  30980. private _vertexAttribArraysEnabled;
  30981. /** @hidden */
  30982. protected _cachedViewport: Nullable<IViewportLike>;
  30983. private _cachedVertexArrayObject;
  30984. /** @hidden */
  30985. protected _cachedVertexBuffers: any;
  30986. /** @hidden */
  30987. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30988. /** @hidden */
  30989. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30990. /** @hidden */
  30991. _currentRenderTarget: Nullable<InternalTexture>;
  30992. private _uintIndicesCurrentlySet;
  30993. private _currentBoundBuffer;
  30994. /** @hidden */
  30995. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30996. private _currentBufferPointers;
  30997. private _currentInstanceLocations;
  30998. private _currentInstanceBuffers;
  30999. private _textureUnits;
  31000. /** @hidden */
  31001. _workingCanvas: Nullable<HTMLCanvasElement>;
  31002. /** @hidden */
  31003. _workingContext: Nullable<CanvasRenderingContext2D>;
  31004. private _rescalePostProcess;
  31005. private _dummyFramebuffer;
  31006. private _externalData;
  31007. /** @hidden */
  31008. _bindedRenderFunction: any;
  31009. private _vaoRecordInProgress;
  31010. private _mustWipeVertexAttributes;
  31011. private _emptyTexture;
  31012. private _emptyCubeTexture;
  31013. private _emptyTexture3D;
  31014. /** @hidden */
  31015. _frameHandler: number;
  31016. private _nextFreeTextureSlots;
  31017. private _maxSimultaneousTextures;
  31018. private _activeRequests;
  31019. private _texturesSupported;
  31020. /** @hidden */
  31021. _textureFormatInUse: Nullable<string>;
  31022. /**
  31023. * Gets the list of texture formats supported
  31024. */
  31025. readonly texturesSupported: Array<string>;
  31026. /**
  31027. * Gets the list of texture formats in use
  31028. */
  31029. readonly textureFormatInUse: Nullable<string>;
  31030. /**
  31031. * Gets the current viewport
  31032. */
  31033. readonly currentViewport: Nullable<IViewportLike>;
  31034. /**
  31035. * Gets the default empty texture
  31036. */
  31037. readonly emptyTexture: InternalTexture;
  31038. /**
  31039. * Gets the default empty 3D texture
  31040. */
  31041. readonly emptyTexture3D: InternalTexture;
  31042. /**
  31043. * Gets the default empty cube texture
  31044. */
  31045. readonly emptyCubeTexture: InternalTexture;
  31046. /**
  31047. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31048. */
  31049. readonly premultipliedAlpha: boolean;
  31050. /**
  31051. * Creates a new engine
  31052. * @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
  31053. * @param antialias defines enable antialiasing (default: false)
  31054. * @param options defines further options to be sent to the getContext() function
  31055. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31056. */
  31057. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31058. /**
  31059. * Initializes a webVR display and starts listening to display change events
  31060. * The onVRDisplayChangedObservable will be notified upon these changes
  31061. * @returns The onVRDisplayChangedObservable
  31062. */
  31063. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31064. /** @hidden */
  31065. _prepareVRComponent(): void;
  31066. /** @hidden */
  31067. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  31068. /** @hidden */
  31069. _submitVRFrame(): void;
  31070. /**
  31071. * Call this function to leave webVR mode
  31072. * Will do nothing if webVR is not supported or if there is no webVR device
  31073. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31074. */
  31075. disableVR(): void;
  31076. /**
  31077. * Gets a boolean indicating that the system is in VR mode and is presenting
  31078. * @returns true if VR mode is engaged
  31079. */
  31080. isVRPresenting(): boolean;
  31081. /** @hidden */
  31082. _requestVRFrame(): void;
  31083. private _disableTouchAction;
  31084. private _rebuildInternalTextures;
  31085. private _rebuildEffects;
  31086. /**
  31087. * Gets a boolean indicating if all created effects are ready
  31088. * @returns true if all effects are ready
  31089. */
  31090. areAllEffectsReady(): boolean;
  31091. private _rebuildBuffers;
  31092. private _initGLContext;
  31093. /**
  31094. * Gets version of the current webGL context
  31095. */
  31096. readonly webGLVersion: number;
  31097. /**
  31098. * Gets a string idenfifying the name of the class
  31099. * @returns "Engine" string
  31100. */
  31101. getClassName(): string;
  31102. /**
  31103. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31104. */
  31105. readonly isStencilEnable: boolean;
  31106. /** @hidden */
  31107. _prepareWorkingCanvas(): void;
  31108. /**
  31109. * Reset the texture cache to empty state
  31110. */
  31111. resetTextureCache(): void;
  31112. /**
  31113. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31114. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31115. * @returns true if engine is in deterministic lock step mode
  31116. */
  31117. isDeterministicLockStep(): boolean;
  31118. /**
  31119. * Gets the max steps when engine is running in deterministic lock step
  31120. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31121. * @returns the max steps
  31122. */
  31123. getLockstepMaxSteps(): number;
  31124. /**
  31125. * Gets an object containing information about the current webGL context
  31126. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31127. */
  31128. getGlInfo(): {
  31129. vendor: string;
  31130. renderer: string;
  31131. version: string;
  31132. };
  31133. /**
  31134. * Gets current aspect ratio
  31135. * @param viewportOwner defines the camera to use to get the aspect ratio
  31136. * @param useScreen defines if screen size must be used (or the current render target if any)
  31137. * @returns a number defining the aspect ratio
  31138. */
  31139. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31140. /**
  31141. * Gets current screen aspect ratio
  31142. * @returns a number defining the aspect ratio
  31143. */
  31144. getScreenAspectRatio(): number;
  31145. /**
  31146. * Gets the current render width
  31147. * @param useScreen defines if screen size must be used (or the current render target if any)
  31148. * @returns a number defining the current render width
  31149. */
  31150. getRenderWidth(useScreen?: boolean): number;
  31151. /**
  31152. * Gets the current render height
  31153. * @param useScreen defines if screen size must be used (or the current render target if any)
  31154. * @returns a number defining the current render height
  31155. */
  31156. getRenderHeight(useScreen?: boolean): number;
  31157. /**
  31158. * Gets the HTML canvas attached with the current webGL context
  31159. * @returns a HTML canvas
  31160. */
  31161. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31162. /**
  31163. * Gets the client rect of the HTML canvas attached with the current webGL context
  31164. * @returns a client rectanglee
  31165. */
  31166. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31167. /**
  31168. * Defines the hardware scaling level.
  31169. * By default the hardware scaling level is computed from the window device ratio.
  31170. * 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.
  31171. * @param level defines the level to use
  31172. */
  31173. setHardwareScalingLevel(level: number): void;
  31174. /**
  31175. * Gets the current hardware scaling level.
  31176. * By default the hardware scaling level is computed from the window device ratio.
  31177. * 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.
  31178. * @returns a number indicating the current hardware scaling level
  31179. */
  31180. getHardwareScalingLevel(): number;
  31181. /**
  31182. * Gets the list of loaded textures
  31183. * @returns an array containing all loaded textures
  31184. */
  31185. getLoadedTexturesCache(): InternalTexture[];
  31186. /**
  31187. * Gets the object containing all engine capabilities
  31188. * @returns the EngineCapabilities object
  31189. */
  31190. getCaps(): EngineCapabilities;
  31191. /**
  31192. * Gets the current depth function
  31193. * @returns a number defining the depth function
  31194. */
  31195. getDepthFunction(): Nullable<number>;
  31196. /**
  31197. * Sets the current depth function
  31198. * @param depthFunc defines the function to use
  31199. */
  31200. setDepthFunction(depthFunc: number): void;
  31201. /**
  31202. * Sets the current depth function to GREATER
  31203. */
  31204. setDepthFunctionToGreater(): void;
  31205. /**
  31206. * Sets the current depth function to GEQUAL
  31207. */
  31208. setDepthFunctionToGreaterOrEqual(): void;
  31209. /**
  31210. * Sets the current depth function to LESS
  31211. */
  31212. setDepthFunctionToLess(): void;
  31213. private _cachedStencilBuffer;
  31214. private _cachedStencilFunction;
  31215. private _cachedStencilMask;
  31216. private _cachedStencilOperationPass;
  31217. private _cachedStencilOperationFail;
  31218. private _cachedStencilOperationDepthFail;
  31219. private _cachedStencilReference;
  31220. /**
  31221. * Caches the the state of the stencil buffer
  31222. */
  31223. cacheStencilState(): void;
  31224. /**
  31225. * Restores the state of the stencil buffer
  31226. */
  31227. restoreStencilState(): void;
  31228. /**
  31229. * Sets the current depth function to LEQUAL
  31230. */
  31231. setDepthFunctionToLessOrEqual(): void;
  31232. /**
  31233. * Gets a boolean indicating if stencil buffer is enabled
  31234. * @returns the current stencil buffer state
  31235. */
  31236. getStencilBuffer(): boolean;
  31237. /**
  31238. * Enable or disable the stencil buffer
  31239. * @param enable defines if the stencil buffer must be enabled or disabled
  31240. */
  31241. setStencilBuffer(enable: boolean): void;
  31242. /**
  31243. * Gets the current stencil mask
  31244. * @returns a number defining the new stencil mask to use
  31245. */
  31246. getStencilMask(): number;
  31247. /**
  31248. * Sets the current stencil mask
  31249. * @param mask defines the new stencil mask to use
  31250. */
  31251. setStencilMask(mask: number): void;
  31252. /**
  31253. * Gets the current stencil function
  31254. * @returns a number defining the stencil function to use
  31255. */
  31256. getStencilFunction(): number;
  31257. /**
  31258. * Gets the current stencil reference value
  31259. * @returns a number defining the stencil reference value to use
  31260. */
  31261. getStencilFunctionReference(): number;
  31262. /**
  31263. * Gets the current stencil mask
  31264. * @returns a number defining the stencil mask to use
  31265. */
  31266. getStencilFunctionMask(): number;
  31267. /**
  31268. * Sets the current stencil function
  31269. * @param stencilFunc defines the new stencil function to use
  31270. */
  31271. setStencilFunction(stencilFunc: number): void;
  31272. /**
  31273. * Sets the current stencil reference
  31274. * @param reference defines the new stencil reference to use
  31275. */
  31276. setStencilFunctionReference(reference: number): void;
  31277. /**
  31278. * Sets the current stencil mask
  31279. * @param mask defines the new stencil mask to use
  31280. */
  31281. setStencilFunctionMask(mask: number): void;
  31282. /**
  31283. * Gets the current stencil operation when stencil fails
  31284. * @returns a number defining stencil operation to use when stencil fails
  31285. */
  31286. getStencilOperationFail(): number;
  31287. /**
  31288. * Gets the current stencil operation when depth fails
  31289. * @returns a number defining stencil operation to use when depth fails
  31290. */
  31291. getStencilOperationDepthFail(): number;
  31292. /**
  31293. * Gets the current stencil operation when stencil passes
  31294. * @returns a number defining stencil operation to use when stencil passes
  31295. */
  31296. getStencilOperationPass(): number;
  31297. /**
  31298. * Sets the stencil operation to use when stencil fails
  31299. * @param operation defines the stencil operation to use when stencil fails
  31300. */
  31301. setStencilOperationFail(operation: number): void;
  31302. /**
  31303. * Sets the stencil operation to use when depth fails
  31304. * @param operation defines the stencil operation to use when depth fails
  31305. */
  31306. setStencilOperationDepthFail(operation: number): void;
  31307. /**
  31308. * Sets the stencil operation to use when stencil passes
  31309. * @param operation defines the stencil operation to use when stencil passes
  31310. */
  31311. setStencilOperationPass(operation: number): void;
  31312. /**
  31313. * Sets a boolean indicating if the dithering state is enabled or disabled
  31314. * @param value defines the dithering state
  31315. */
  31316. setDitheringState(value: boolean): void;
  31317. /**
  31318. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31319. * @param value defines the rasterizer state
  31320. */
  31321. setRasterizerState(value: boolean): void;
  31322. /**
  31323. * stop executing a render loop function and remove it from the execution array
  31324. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31325. */
  31326. stopRenderLoop(renderFunction?: () => void): void;
  31327. /** @hidden */
  31328. _renderLoop(): void;
  31329. /**
  31330. * Register and execute a render loop. The engine can have more than one render function
  31331. * @param renderFunction defines the function to continuously execute
  31332. */
  31333. runRenderLoop(renderFunction: () => void): void;
  31334. /**
  31335. * Toggle full screen mode
  31336. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31337. */
  31338. switchFullscreen(requestPointerLock: boolean): void;
  31339. /**
  31340. * Enters full screen mode
  31341. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31342. */
  31343. enterFullscreen(requestPointerLock: boolean): void;
  31344. /**
  31345. * Exits full screen mode
  31346. */
  31347. exitFullscreen(): void;
  31348. /**
  31349. * Enters Pointerlock mode
  31350. */
  31351. enterPointerlock(): void;
  31352. /**
  31353. * Exits Pointerlock mode
  31354. */
  31355. exitPointerlock(): void;
  31356. /**
  31357. * Clear the current render buffer or the current render target (if any is set up)
  31358. * @param color defines the color to use
  31359. * @param backBuffer defines if the back buffer must be cleared
  31360. * @param depth defines if the depth buffer must be cleared
  31361. * @param stencil defines if the stencil buffer must be cleared
  31362. */
  31363. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31364. /**
  31365. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31366. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31367. * @param y defines the y-coordinate of the corner of the clear rectangle
  31368. * @param width defines the width of the clear rectangle
  31369. * @param height defines the height of the clear rectangle
  31370. * @param clearColor defines the clear color
  31371. */
  31372. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31373. /**
  31374. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31375. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31376. * @param y defines the y-coordinate of the corner of the clear rectangle
  31377. * @param width defines the width of the clear rectangle
  31378. * @param height defines the height of the clear rectangle
  31379. */
  31380. enableScissor(x: number, y: number, width: number, height: number): void;
  31381. /**
  31382. * Disable previously set scissor test rectangle
  31383. */
  31384. disableScissor(): void;
  31385. private _viewportCached;
  31386. /** @hidden */
  31387. _viewport(x: number, y: number, width: number, height: number): void;
  31388. /**
  31389. * Set the WebGL's viewport
  31390. * @param viewport defines the viewport element to be used
  31391. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31392. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31393. */
  31394. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31395. /**
  31396. * Directly set the WebGL Viewport
  31397. * @param x defines the x coordinate of the viewport (in screen space)
  31398. * @param y defines the y coordinate of the viewport (in screen space)
  31399. * @param width defines the width of the viewport (in screen space)
  31400. * @param height defines the height of the viewport (in screen space)
  31401. * @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
  31402. */
  31403. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31404. /**
  31405. * Begin a new frame
  31406. */
  31407. beginFrame(): void;
  31408. /**
  31409. * Enf the current frame
  31410. */
  31411. endFrame(): void;
  31412. /**
  31413. * Resize the view according to the canvas' size
  31414. */
  31415. resize(): void;
  31416. /**
  31417. * Force a specific size of the canvas
  31418. * @param width defines the new canvas' width
  31419. * @param height defines the new canvas' height
  31420. */
  31421. setSize(width: number, height: number): void;
  31422. /**
  31423. * Binds the frame buffer to the specified texture.
  31424. * @param texture The texture to render to or null for the default canvas
  31425. * @param faceIndex The face of the texture to render to in case of cube texture
  31426. * @param requiredWidth The width of the target to render to
  31427. * @param requiredHeight The height of the target to render to
  31428. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31429. * @param depthStencilTexture The depth stencil texture to use to render
  31430. * @param lodLevel defines le lod level to bind to the frame buffer
  31431. */
  31432. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31433. /** @hidden */
  31434. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31435. /**
  31436. * Unbind the current render target texture from the webGL context
  31437. * @param texture defines the render target texture to unbind
  31438. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31439. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31440. */
  31441. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31442. /**
  31443. * Force the mipmap generation for the given render target texture
  31444. * @param texture defines the render target texture to use
  31445. */
  31446. generateMipMapsForCubemap(texture: InternalTexture): void;
  31447. /**
  31448. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31449. */
  31450. flushFramebuffer(): void;
  31451. /**
  31452. * Unbind the current render target and bind the default framebuffer
  31453. */
  31454. restoreDefaultFramebuffer(): void;
  31455. /**
  31456. * Create an uniform buffer
  31457. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31458. * @param elements defines the content of the uniform buffer
  31459. * @returns the webGL uniform buffer
  31460. */
  31461. createUniformBuffer(elements: FloatArray): DataBuffer;
  31462. /**
  31463. * Create a dynamic uniform buffer
  31464. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31465. * @param elements defines the content of the uniform buffer
  31466. * @returns the webGL uniform buffer
  31467. */
  31468. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  31469. /**
  31470. * Update an existing uniform buffer
  31471. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31472. * @param uniformBuffer defines the target uniform buffer
  31473. * @param elements defines the content to update
  31474. * @param offset defines the offset in the uniform buffer where update should start
  31475. * @param count defines the size of the data to update
  31476. */
  31477. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  31478. private _resetVertexBufferBinding;
  31479. /**
  31480. * Creates a vertex buffer
  31481. * @param data the data for the vertex buffer
  31482. * @returns the new WebGL static buffer
  31483. */
  31484. createVertexBuffer(data: DataArray): DataBuffer;
  31485. /**
  31486. * Creates a dynamic vertex buffer
  31487. * @param data the data for the dynamic vertex buffer
  31488. * @returns the new WebGL dynamic buffer
  31489. */
  31490. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31491. /**
  31492. * Update a dynamic index buffer
  31493. * @param indexBuffer defines the target index buffer
  31494. * @param indices defines the data to update
  31495. * @param offset defines the offset in the target index buffer where update should start
  31496. */
  31497. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31498. /**
  31499. * Updates a dynamic vertex buffer.
  31500. * @param vertexBuffer the vertex buffer to update
  31501. * @param data the data used to update the vertex buffer
  31502. * @param byteOffset the byte offset of the data
  31503. * @param byteLength the byte length of the data
  31504. */
  31505. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  31506. private _resetIndexBufferBinding;
  31507. /**
  31508. * Creates a new index buffer
  31509. * @param indices defines the content of the index buffer
  31510. * @param updatable defines if the index buffer must be updatable
  31511. * @returns a new webGL buffer
  31512. */
  31513. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31514. /**
  31515. * Bind a webGL buffer to the webGL context
  31516. * @param buffer defines the buffer to bind
  31517. */
  31518. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31519. /**
  31520. * Bind an uniform buffer to the current webGL context
  31521. * @param buffer defines the buffer to bind
  31522. */
  31523. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  31524. /**
  31525. * Bind a buffer to the current webGL context at a given location
  31526. * @param buffer defines the buffer to bind
  31527. * @param location defines the index where to bind the buffer
  31528. */
  31529. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  31530. /**
  31531. * Bind a specific block at a given index in a specific shader program
  31532. * @param pipelineContext defines the pipeline context to use
  31533. * @param blockName defines the block name
  31534. * @param index defines the index where to bind the block
  31535. */
  31536. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  31537. private bindIndexBuffer;
  31538. private bindBuffer;
  31539. /**
  31540. * update the bound buffer with the given data
  31541. * @param data defines the data to update
  31542. */
  31543. updateArrayBuffer(data: Float32Array): void;
  31544. private _vertexAttribPointer;
  31545. private _bindIndexBufferWithCache;
  31546. private _bindVertexBuffersAttributes;
  31547. /**
  31548. * Records a vertex array object
  31549. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31550. * @param vertexBuffers defines the list of vertex buffers to store
  31551. * @param indexBuffer defines the index buffer to store
  31552. * @param effect defines the effect to store
  31553. * @returns the new vertex array object
  31554. */
  31555. recordVertexArrayObject(vertexBuffers: {
  31556. [key: string]: VertexBuffer;
  31557. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31558. /**
  31559. * Bind a specific vertex array object
  31560. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31561. * @param vertexArrayObject defines the vertex array object to bind
  31562. * @param indexBuffer defines the index buffer to bind
  31563. */
  31564. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31565. /**
  31566. * Bind webGl buffers directly to the webGL context
  31567. * @param vertexBuffer defines the vertex buffer to bind
  31568. * @param indexBuffer defines the index buffer to bind
  31569. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31570. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31571. * @param effect defines the effect associated with the vertex buffer
  31572. */
  31573. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31574. private _unbindVertexArrayObject;
  31575. /**
  31576. * Bind a list of vertex buffers to the webGL context
  31577. * @param vertexBuffers defines the list of vertex buffers to bind
  31578. * @param indexBuffer defines the index buffer to bind
  31579. * @param effect defines the effect associated with the vertex buffers
  31580. */
  31581. bindBuffers(vertexBuffers: {
  31582. [key: string]: Nullable<VertexBuffer>;
  31583. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31584. /**
  31585. * Unbind all instance attributes
  31586. */
  31587. unbindInstanceAttributes(): void;
  31588. /**
  31589. * Release and free the memory of a vertex array object
  31590. * @param vao defines the vertex array object to delete
  31591. */
  31592. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31593. /** @hidden */
  31594. _releaseBuffer(buffer: DataBuffer): boolean;
  31595. /**
  31596. * Creates a webGL buffer to use with instanciation
  31597. * @param capacity defines the size of the buffer
  31598. * @returns the webGL buffer
  31599. */
  31600. createInstancesBuffer(capacity: number): DataBuffer;
  31601. /**
  31602. * Delete a webGL buffer used with instanciation
  31603. * @param buffer defines the webGL buffer to delete
  31604. */
  31605. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  31606. /**
  31607. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31608. * @param instancesBuffer defines the webGL buffer to update and bind
  31609. * @param data defines the data to store in the buffer
  31610. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31611. */
  31612. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31613. /**
  31614. * Apply all cached states (depth, culling, stencil and alpha)
  31615. */
  31616. applyStates(): void;
  31617. /**
  31618. * Send a draw order
  31619. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31620. * @param indexStart defines the starting index
  31621. * @param indexCount defines the number of index to draw
  31622. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31623. */
  31624. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31625. /**
  31626. * Draw a list of points
  31627. * @param verticesStart defines the index of first vertex to draw
  31628. * @param verticesCount defines the count of vertices to draw
  31629. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31630. */
  31631. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31632. /**
  31633. * Draw a list of unindexed primitives
  31634. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31635. * @param verticesStart defines the index of first vertex to draw
  31636. * @param verticesCount defines the count of vertices to draw
  31637. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31638. */
  31639. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31640. /**
  31641. * Draw a list of indexed primitives
  31642. * @param fillMode defines the primitive to use
  31643. * @param indexStart defines the starting index
  31644. * @param indexCount defines the number of index to draw
  31645. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31646. */
  31647. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31648. /**
  31649. * Draw a list of unindexed primitives
  31650. * @param fillMode defines the primitive to use
  31651. * @param verticesStart defines the index of first vertex to draw
  31652. * @param verticesCount defines the count of vertices to draw
  31653. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31654. */
  31655. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31656. private _drawMode;
  31657. /** @hidden */
  31658. _releaseEffect(effect: Effect): void;
  31659. /** @hidden */
  31660. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31661. /**
  31662. * Create a new effect (used to store vertex/fragment shaders)
  31663. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31664. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  31665. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31666. * @param samplers defines an array of string used to represent textures
  31667. * @param defines defines the string containing the defines to use to compile the shaders
  31668. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31669. * @param onCompiled defines a function to call when the effect creation is successful
  31670. * @param onError defines a function to call when the effect creation has failed
  31671. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31672. * @returns the new Effect
  31673. */
  31674. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  31675. private _compileShader;
  31676. private _compileRawShader;
  31677. /**
  31678. * Directly creates a webGL program
  31679. * @param pipelineContext defines the pipeline context to attach to
  31680. * @param vertexCode defines the vertex shader code to use
  31681. * @param fragmentCode defines the fragment shader code to use
  31682. * @param context defines the webGL context to use (if not set, the current one will be used)
  31683. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31684. * @returns the new webGL program
  31685. */
  31686. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31687. /**
  31688. * Creates a webGL program
  31689. * @param pipelineContext defines the pipeline context to attach to
  31690. * @param vertexCode defines the vertex shader code to use
  31691. * @param fragmentCode defines the fragment shader code to use
  31692. * @param defines defines the string containing the defines to use to compile the shaders
  31693. * @param context defines the webGL context to use (if not set, the current one will be used)
  31694. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31695. * @returns the new webGL program
  31696. */
  31697. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31698. /**
  31699. * Creates a new pipeline context
  31700. * @returns the new pipeline
  31701. */
  31702. createPipelineContext(): WebGLPipelineContext;
  31703. private _createShaderProgram;
  31704. private _finalizePipelineContext;
  31705. /** @hidden */
  31706. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31707. /** @hidden */
  31708. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31709. /** @hidden */
  31710. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31711. /**
  31712. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31713. * @param pipelineContext defines the pipeline context to use
  31714. * @param uniformsNames defines the list of uniform names
  31715. * @returns an array of webGL uniform locations
  31716. */
  31717. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31718. /**
  31719. * Gets the lsit of active attributes for a given webGL program
  31720. * @param pipelineContext defines the pipeline context to use
  31721. * @param attributesNames defines the list of attribute names to get
  31722. * @returns an array of indices indicating the offset of each attribute
  31723. */
  31724. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31725. /**
  31726. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31727. * @param effect defines the effect to activate
  31728. */
  31729. enableEffect(effect: Nullable<Effect>): void;
  31730. /**
  31731. * Set the value of an uniform to an array of int32
  31732. * @param uniform defines the webGL uniform location where to store the value
  31733. * @param array defines the array of int32 to store
  31734. */
  31735. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31736. /**
  31737. * Set the value of an uniform to an array of int32 (stored as vec2)
  31738. * @param uniform defines the webGL uniform location where to store the value
  31739. * @param array defines the array of int32 to store
  31740. */
  31741. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31742. /**
  31743. * Set the value of an uniform to an array of int32 (stored as vec3)
  31744. * @param uniform defines the webGL uniform location where to store the value
  31745. * @param array defines the array of int32 to store
  31746. */
  31747. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31748. /**
  31749. * Set the value of an uniform to an array of int32 (stored as vec4)
  31750. * @param uniform defines the webGL uniform location where to store the value
  31751. * @param array defines the array of int32 to store
  31752. */
  31753. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31754. /**
  31755. * Set the value of an uniform to an array of float32
  31756. * @param uniform defines the webGL uniform location where to store the value
  31757. * @param array defines the array of float32 to store
  31758. */
  31759. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31760. /**
  31761. * Set the value of an uniform to an array of float32 (stored as vec2)
  31762. * @param uniform defines the webGL uniform location where to store the value
  31763. * @param array defines the array of float32 to store
  31764. */
  31765. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31766. /**
  31767. * Set the value of an uniform to an array of float32 (stored as vec3)
  31768. * @param uniform defines the webGL uniform location where to store the value
  31769. * @param array defines the array of float32 to store
  31770. */
  31771. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31772. /**
  31773. * Set the value of an uniform to an array of float32 (stored as vec4)
  31774. * @param uniform defines the webGL uniform location where to store the value
  31775. * @param array defines the array of float32 to store
  31776. */
  31777. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31778. /**
  31779. * Set the value of an uniform to an array of number
  31780. * @param uniform defines the webGL uniform location where to store the value
  31781. * @param array defines the array of number to store
  31782. */
  31783. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31784. /**
  31785. * Set the value of an uniform to an array of number (stored as vec2)
  31786. * @param uniform defines the webGL uniform location where to store the value
  31787. * @param array defines the array of number to store
  31788. */
  31789. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31790. /**
  31791. * Set the value of an uniform to an array of number (stored as vec3)
  31792. * @param uniform defines the webGL uniform location where to store the value
  31793. * @param array defines the array of number to store
  31794. */
  31795. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31796. /**
  31797. * Set the value of an uniform to an array of number (stored as vec4)
  31798. * @param uniform defines the webGL uniform location where to store the value
  31799. * @param array defines the array of number to store
  31800. */
  31801. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31802. /**
  31803. * Set the value of an uniform to an array of float32 (stored as matrices)
  31804. * @param uniform defines the webGL uniform location where to store the value
  31805. * @param matrices defines the array of float32 to store
  31806. */
  31807. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31808. /**
  31809. * Set the value of an uniform to a matrix (3x3)
  31810. * @param uniform defines the webGL uniform location where to store the value
  31811. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31812. */
  31813. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31814. /**
  31815. * Set the value of an uniform to a matrix (2x2)
  31816. * @param uniform defines the webGL uniform location where to store the value
  31817. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31818. */
  31819. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31820. /**
  31821. * Set the value of an uniform to a number (int)
  31822. * @param uniform defines the webGL uniform location where to store the value
  31823. * @param value defines the int number to store
  31824. */
  31825. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31826. /**
  31827. * Set the value of an uniform to a number (float)
  31828. * @param uniform defines the webGL uniform location where to store the value
  31829. * @param value defines the float number to store
  31830. */
  31831. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31832. /**
  31833. * Set the value of an uniform to a vec2
  31834. * @param uniform defines the webGL uniform location where to store the value
  31835. * @param x defines the 1st component of the value
  31836. * @param y defines the 2nd component of the value
  31837. */
  31838. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31839. /**
  31840. * Set the value of an uniform to a vec3
  31841. * @param uniform defines the webGL uniform location where to store the value
  31842. * @param x defines the 1st component of the value
  31843. * @param y defines the 2nd component of the value
  31844. * @param z defines the 3rd component of the value
  31845. */
  31846. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31847. /**
  31848. * Set the value of an uniform to a boolean
  31849. * @param uniform defines the webGL uniform location where to store the value
  31850. * @param bool defines the boolean to store
  31851. */
  31852. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  31853. /**
  31854. * Set the value of an uniform to a vec4
  31855. * @param uniform defines the webGL uniform location where to store the value
  31856. * @param x defines the 1st component of the value
  31857. * @param y defines the 2nd component of the value
  31858. * @param z defines the 3rd component of the value
  31859. * @param w defines the 4th component of the value
  31860. */
  31861. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31862. /**
  31863. * Sets a Color4 on a uniform variable
  31864. * @param uniform defines the uniform location
  31865. * @param color4 defines the value to be set
  31866. */
  31867. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  31868. /**
  31869. * Set various states to the webGL context
  31870. * @param culling defines backface culling state
  31871. * @param zOffset defines the value to apply to zOffset (0 by default)
  31872. * @param force defines if states must be applied even if cache is up to date
  31873. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31874. */
  31875. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31876. /**
  31877. * Set the z offset to apply to current rendering
  31878. * @param value defines the offset to apply
  31879. */
  31880. setZOffset(value: number): void;
  31881. /**
  31882. * Gets the current value of the zOffset
  31883. * @returns the current zOffset state
  31884. */
  31885. getZOffset(): number;
  31886. /**
  31887. * Enable or disable depth buffering
  31888. * @param enable defines the state to set
  31889. */
  31890. setDepthBuffer(enable: boolean): void;
  31891. /**
  31892. * Gets a boolean indicating if depth writing is enabled
  31893. * @returns the current depth writing state
  31894. */
  31895. getDepthWrite(): boolean;
  31896. /**
  31897. * Enable or disable depth writing
  31898. * @param enable defines the state to set
  31899. */
  31900. setDepthWrite(enable: boolean): void;
  31901. /**
  31902. * Enable or disable color writing
  31903. * @param enable defines the state to set
  31904. */
  31905. setColorWrite(enable: boolean): void;
  31906. /**
  31907. * Gets a boolean indicating if color writing is enabled
  31908. * @returns the current color writing state
  31909. */
  31910. getColorWrite(): boolean;
  31911. /**
  31912. * Sets alpha constants used by some alpha blending modes
  31913. * @param r defines the red component
  31914. * @param g defines the green component
  31915. * @param b defines the blue component
  31916. * @param a defines the alpha component
  31917. */
  31918. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31919. /**
  31920. * Sets the current alpha mode
  31921. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31922. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31923. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31924. */
  31925. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31926. /**
  31927. * Gets the current alpha mode
  31928. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31929. * @returns the current alpha mode
  31930. */
  31931. getAlphaMode(): number;
  31932. /**
  31933. * Clears the list of texture accessible through engine.
  31934. * This can help preventing texture load conflict due to name collision.
  31935. */
  31936. clearInternalTexturesCache(): void;
  31937. /**
  31938. * Force the entire cache to be cleared
  31939. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31940. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31941. */
  31942. wipeCaches(bruteForce?: boolean): void;
  31943. /**
  31944. * Set the compressed texture format to use, based on the formats you have, and the formats
  31945. * supported by the hardware / browser.
  31946. *
  31947. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31948. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31949. * to API arguments needed to compressed textures. This puts the burden on the container
  31950. * generator to house the arcane code for determining these for current & future formats.
  31951. *
  31952. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31953. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31954. *
  31955. * Note: The result of this call is not taken into account when a texture is base64.
  31956. *
  31957. * @param formatsAvailable defines the list of those format families you have created
  31958. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31959. *
  31960. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31961. * @returns The extension selected.
  31962. */
  31963. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31964. /** @hidden */
  31965. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31966. min: number;
  31967. mag: number;
  31968. };
  31969. /** @hidden */
  31970. _createTexture(): WebGLTexture;
  31971. /**
  31972. * Usually called from Texture.ts.
  31973. * Passed information to create a WebGLTexture
  31974. * @param urlArg defines a value which contains one of the following:
  31975. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31976. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31977. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31978. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31979. * @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)
  31980. * @param scene needed for loading to the correct scene
  31981. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31982. * @param onLoad optional callback to be called upon successful completion
  31983. * @param onError optional callback to be called upon failure
  31984. * @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
  31985. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31986. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31987. * @param forcedExtension defines the extension to use to pick the right loader
  31988. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31989. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31990. */
  31991. 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 | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  31992. /**
  31993. * @hidden
  31994. * Rescales a texture
  31995. * @param source input texutre
  31996. * @param destination destination texture
  31997. * @param scene scene to use to render the resize
  31998. * @param internalFormat format to use when resizing
  31999. * @param onComplete callback to be called when resize has completed
  32000. */
  32001. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  32002. private _unpackFlipYCached;
  32003. /**
  32004. * In case you are sharing the context with other applications, it might
  32005. * be interested to not cache the unpack flip y state to ensure a consistent
  32006. * value would be set.
  32007. */
  32008. enableUnpackFlipYCached: boolean;
  32009. /** @hidden */
  32010. _unpackFlipY(value: boolean): void;
  32011. /** @hidden */
  32012. _getUnpackAlignement(): number;
  32013. /**
  32014. * Creates a dynamic texture
  32015. * @param width defines the width of the texture
  32016. * @param height defines the height of the texture
  32017. * @param generateMipMaps defines if the engine should generate the mip levels
  32018. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32019. * @returns the dynamic texture inside an InternalTexture
  32020. */
  32021. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  32022. /**
  32023. * Update the sampling mode of a given texture
  32024. * @param samplingMode defines the required sampling mode
  32025. * @param texture defines the texture to update
  32026. */
  32027. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  32028. /**
  32029. * Update the content of a dynamic texture
  32030. * @param texture defines the texture to update
  32031. * @param canvas defines the canvas containing the source
  32032. * @param invertY defines if data must be stored with Y axis inverted
  32033. * @param premulAlpha defines if alpha is stored as premultiplied
  32034. * @param format defines the format of the data
  32035. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  32036. */
  32037. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  32038. /**
  32039. * Update a video texture
  32040. * @param texture defines the texture to update
  32041. * @param video defines the video element to use
  32042. * @param invertY defines if data must be stored with Y axis inverted
  32043. */
  32044. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32045. /**
  32046. * Updates a depth texture Comparison Mode and Function.
  32047. * If the comparison Function is equal to 0, the mode will be set to none.
  32048. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32049. * @param texture The texture to set the comparison function for
  32050. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32051. */
  32052. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32053. /** @hidden */
  32054. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32055. width: number;
  32056. height: number;
  32057. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32058. /**
  32059. * Creates a depth stencil texture.
  32060. * This is only available in WebGL 2 or with the depth texture extension available.
  32061. * @param size The size of face edge in the texture.
  32062. * @param options The options defining the texture.
  32063. * @returns The texture
  32064. */
  32065. createDepthStencilTexture(size: number | {
  32066. width: number;
  32067. height: number;
  32068. }, options: DepthTextureCreationOptions): InternalTexture;
  32069. /**
  32070. * Creates a depth stencil texture.
  32071. * This is only available in WebGL 2 or with the depth texture extension available.
  32072. * @param size The size of face edge in the texture.
  32073. * @param options The options defining the texture.
  32074. * @returns The texture
  32075. */
  32076. private _createDepthStencilTexture;
  32077. /**
  32078. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32079. * @param renderTarget The render target to set the frame buffer for
  32080. */
  32081. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32082. /**
  32083. * Creates a new render target texture
  32084. * @param size defines the size of the texture
  32085. * @param options defines the options used to create the texture
  32086. * @returns a new render target texture stored in an InternalTexture
  32087. */
  32088. createRenderTargetTexture(size: number | {
  32089. width: number;
  32090. height: number;
  32091. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  32092. /** @hidden */
  32093. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32094. /**
  32095. * Updates the sample count of a render target texture
  32096. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32097. * @param texture defines the texture to update
  32098. * @param samples defines the sample count to set
  32099. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32100. */
  32101. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32102. /** @hidden */
  32103. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32104. /** @hidden */
  32105. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32106. /** @hidden */
  32107. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32108. /** @hidden */
  32109. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  32110. /**
  32111. * @hidden
  32112. */
  32113. _setCubeMapTextureParams(loadMipmap: boolean): void;
  32114. private _prepareWebGLTextureContinuation;
  32115. private _prepareWebGLTexture;
  32116. /** @hidden */
  32117. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32118. /** @hidden */
  32119. _releaseFramebufferObjects(texture: InternalTexture): void;
  32120. /** @hidden */
  32121. _releaseTexture(texture: InternalTexture): void;
  32122. private setProgram;
  32123. private _boundUniforms;
  32124. /**
  32125. * Binds an effect to the webGL context
  32126. * @param effect defines the effect to bind
  32127. */
  32128. bindSamplers(effect: Effect): void;
  32129. private _activateCurrentTexture;
  32130. /** @hidden */
  32131. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32132. /** @hidden */
  32133. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32134. /**
  32135. * Sets a texture to the webGL context from a postprocess
  32136. * @param channel defines the channel to use
  32137. * @param postProcess defines the source postprocess
  32138. */
  32139. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32140. /**
  32141. * Binds the output of the passed in post process to the texture channel specified
  32142. * @param channel The channel the texture should be bound to
  32143. * @param postProcess The post process which's output should be bound
  32144. */
  32145. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32146. /**
  32147. * Unbind all textures from the webGL context
  32148. */
  32149. unbindAllTextures(): void;
  32150. /**
  32151. * Sets a texture to the according uniform.
  32152. * @param channel The texture channel
  32153. * @param uniform The uniform to set
  32154. * @param texture The texture to apply
  32155. */
  32156. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32157. /**
  32158. * Sets a depth stencil texture from a render target to the according uniform.
  32159. * @param channel The texture channel
  32160. * @param uniform The uniform to set
  32161. * @param texture The render target texture containing the depth stencil texture to apply
  32162. */
  32163. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32164. private _bindSamplerUniformToChannel;
  32165. private _getTextureWrapMode;
  32166. private _setTexture;
  32167. /**
  32168. * Sets an array of texture to the webGL context
  32169. * @param channel defines the channel where the texture array must be set
  32170. * @param uniform defines the associated uniform location
  32171. * @param textures defines the array of textures to bind
  32172. */
  32173. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32174. /** @hidden */
  32175. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32176. private _setTextureParameterFloat;
  32177. private _setTextureParameterInteger;
  32178. /**
  32179. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32180. * @param x defines the x coordinate of the rectangle where pixels must be read
  32181. * @param y defines the y coordinate of the rectangle where pixels must be read
  32182. * @param width defines the width of the rectangle where pixels must be read
  32183. * @param height defines the height of the rectangle where pixels must be read
  32184. * @returns a Uint8Array containing RGBA colors
  32185. */
  32186. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32187. /**
  32188. * Add an externaly attached data from its key.
  32189. * This method call will fail and return false, if such key already exists.
  32190. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32191. * @param key the unique key that identifies the data
  32192. * @param data the data object to associate to the key for this Engine instance
  32193. * @return true if no such key were already present and the data was added successfully, false otherwise
  32194. */
  32195. addExternalData<T>(key: string, data: T): boolean;
  32196. /**
  32197. * Get an externaly attached data from its key
  32198. * @param key the unique key that identifies the data
  32199. * @return the associated data, if present (can be null), or undefined if not present
  32200. */
  32201. getExternalData<T>(key: string): T;
  32202. /**
  32203. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32204. * @param key the unique key that identifies the data
  32205. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32206. * @return the associated data, can be null if the factory returned null.
  32207. */
  32208. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32209. /**
  32210. * Remove an externaly attached data from the Engine instance
  32211. * @param key the unique key that identifies the data
  32212. * @return true if the data was successfully removed, false if it doesn't exist
  32213. */
  32214. removeExternalData(key: string): boolean;
  32215. /**
  32216. * Unbind all vertex attributes from the webGL context
  32217. */
  32218. unbindAllAttributes(): void;
  32219. /**
  32220. * 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
  32221. */
  32222. releaseEffects(): void;
  32223. /**
  32224. * Dispose and release all associated resources
  32225. */
  32226. dispose(): void;
  32227. /**
  32228. * Display the loading screen
  32229. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32230. */
  32231. displayLoadingUI(): void;
  32232. /**
  32233. * Hide the loading screen
  32234. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32235. */
  32236. hideLoadingUI(): void;
  32237. /**
  32238. * Gets the current loading screen object
  32239. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32240. */
  32241. /**
  32242. * Sets the current loading screen object
  32243. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32244. */
  32245. loadingScreen: ILoadingScreen;
  32246. /**
  32247. * Sets the current loading screen text
  32248. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32249. */
  32250. loadingUIText: string;
  32251. /**
  32252. * Sets the current loading screen background color
  32253. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32254. */
  32255. loadingUIBackgroundColor: string;
  32256. /**
  32257. * Attach a new callback raised when context lost event is fired
  32258. * @param callback defines the callback to call
  32259. */
  32260. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32261. /**
  32262. * Attach a new callback raised when context restored event is fired
  32263. * @param callback defines the callback to call
  32264. */
  32265. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32266. /**
  32267. * Gets the source code of the vertex shader associated with a specific webGL program
  32268. * @param program defines the program to use
  32269. * @returns a string containing the source code of the vertex shader associated with the program
  32270. */
  32271. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32272. /**
  32273. * Gets the source code of the fragment shader associated with a specific webGL program
  32274. * @param program defines the program to use
  32275. * @returns a string containing the source code of the fragment shader associated with the program
  32276. */
  32277. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32278. /**
  32279. * Get the current error code of the webGL context
  32280. * @returns the error code
  32281. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32282. */
  32283. getError(): number;
  32284. /**
  32285. * Gets the current framerate
  32286. * @returns a number representing the framerate
  32287. */
  32288. getFps(): number;
  32289. /**
  32290. * Gets the time spent between current and previous frame
  32291. * @returns a number representing the delta time in ms
  32292. */
  32293. getDeltaTime(): number;
  32294. private _measureFps;
  32295. /** @hidden */
  32296. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32297. private _canRenderToFloatFramebuffer;
  32298. private _canRenderToHalfFloatFramebuffer;
  32299. private _canRenderToFramebuffer;
  32300. /** @hidden */
  32301. _getWebGLTextureType(type: number): number;
  32302. /** @hidden */
  32303. _getInternalFormat(format: number): number;
  32304. /** @hidden */
  32305. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32306. /** @hidden */
  32307. _getRGBAMultiSampleBufferFormat(type: number): number;
  32308. /** @hidden */
  32309. _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;
  32310. /** @hidden */
  32311. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32312. /**
  32313. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32314. * @returns true if the engine can be created
  32315. * @ignorenaming
  32316. */
  32317. static isSupported(): boolean;
  32318. /**
  32319. * Find the next highest power of two.
  32320. * @param x Number to start search from.
  32321. * @return Next highest power of two.
  32322. */
  32323. static CeilingPOT(x: number): number;
  32324. /**
  32325. * Find the next lowest power of two.
  32326. * @param x Number to start search from.
  32327. * @return Next lowest power of two.
  32328. */
  32329. static FloorPOT(x: number): number;
  32330. /**
  32331. * Find the nearest power of two.
  32332. * @param x Number to start search from.
  32333. * @return Next nearest power of two.
  32334. */
  32335. static NearestPOT(x: number): number;
  32336. /**
  32337. * Get the closest exponent of two
  32338. * @param value defines the value to approximate
  32339. * @param max defines the maximum value to return
  32340. * @param mode defines how to define the closest value
  32341. * @returns closest exponent of two of the given value
  32342. */
  32343. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32344. /**
  32345. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32346. * @param func - the function to be called
  32347. * @param requester - the object that will request the next frame. Falls back to window.
  32348. * @returns frame number
  32349. */
  32350. static QueueNewFrame(func: () => void, requester?: any): number;
  32351. /**
  32352. * Ask the browser to promote the current element to pointerlock mode
  32353. * @param element defines the DOM element to promote
  32354. */
  32355. static _RequestPointerlock(element: HTMLElement): void;
  32356. /**
  32357. * Asks the browser to exit pointerlock mode
  32358. */
  32359. static _ExitPointerlock(): void;
  32360. /**
  32361. * Ask the browser to promote the current element to fullscreen rendering mode
  32362. * @param element defines the DOM element to promote
  32363. */
  32364. static _RequestFullscreen(element: HTMLElement): void;
  32365. /**
  32366. * Asks the browser to exit fullscreen mode
  32367. */
  32368. static _ExitFullscreen(): void;
  32369. }
  32370. }
  32371. declare module "babylonjs/Engines/engineStore" {
  32372. import { Nullable } from "babylonjs/types";
  32373. import { Engine } from "babylonjs/Engines/engine";
  32374. import { Scene } from "babylonjs/scene";
  32375. /**
  32376. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32377. * during the life time of the application.
  32378. */
  32379. export class EngineStore {
  32380. /** Gets the list of created engines */
  32381. static Instances: import("babylonjs/Engines/engine").Engine[];
  32382. /** @hidden */
  32383. static _LastCreatedScene: Nullable<Scene>;
  32384. /**
  32385. * Gets the latest created engine
  32386. */
  32387. static readonly LastCreatedEngine: Nullable<Engine>;
  32388. /**
  32389. * Gets the latest created scene
  32390. */
  32391. static readonly LastCreatedScene: Nullable<Scene>;
  32392. /**
  32393. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32394. * @ignorenaming
  32395. */
  32396. static UseFallbackTexture: boolean;
  32397. /**
  32398. * Texture content used if a texture cannot loaded
  32399. * @ignorenaming
  32400. */
  32401. static FallbackTexture: string;
  32402. }
  32403. }
  32404. declare module "babylonjs/Misc/promise" {
  32405. /**
  32406. * Helper class that provides a small promise polyfill
  32407. */
  32408. export class PromisePolyfill {
  32409. /**
  32410. * Static function used to check if the polyfill is required
  32411. * If this is the case then the function will inject the polyfill to window.Promise
  32412. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32413. */
  32414. static Apply(force?: boolean): void;
  32415. }
  32416. }
  32417. declare module "babylonjs/Misc/tools" {
  32418. import { Nullable, float } from "babylonjs/types";
  32419. import { DomManagement } from "babylonjs/Misc/domManagement";
  32420. import { WebRequest } from "babylonjs/Misc/webRequest";
  32421. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32422. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32423. import { Camera } from "babylonjs/Cameras/camera";
  32424. import { Engine } from "babylonjs/Engines/engine";
  32425. interface IColor4Like {
  32426. r: float;
  32427. g: float;
  32428. b: float;
  32429. a: float;
  32430. }
  32431. /**
  32432. * Class containing a set of static utilities functions
  32433. */
  32434. export class Tools {
  32435. /**
  32436. * Gets or sets the base URL to use to load assets
  32437. */
  32438. static BaseUrl: string;
  32439. /**
  32440. * Enable/Disable Custom HTTP Request Headers globally.
  32441. * default = false
  32442. * @see CustomRequestHeaders
  32443. */
  32444. static UseCustomRequestHeaders: boolean;
  32445. /**
  32446. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32447. * i.e. when loading files, where the server/service expects an Authorization header
  32448. */
  32449. static CustomRequestHeaders: {
  32450. [key: string]: string;
  32451. };
  32452. /**
  32453. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32454. */
  32455. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32456. /**
  32457. * Default behaviour for cors in the application.
  32458. * It can be a string if the expected behavior is identical in the entire app.
  32459. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32460. */
  32461. static CorsBehavior: string | ((url: string | string[]) => string);
  32462. /**
  32463. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32464. * @ignorenaming
  32465. */
  32466. static UseFallbackTexture: boolean;
  32467. /**
  32468. * Use this object to register external classes like custom textures or material
  32469. * to allow the laoders to instantiate them
  32470. */
  32471. static RegisteredExternalClasses: {
  32472. [key: string]: Object;
  32473. };
  32474. /**
  32475. * Texture content used if a texture cannot loaded
  32476. * @ignorenaming
  32477. */
  32478. static fallbackTexture: string;
  32479. /**
  32480. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32481. * @param u defines the coordinate on X axis
  32482. * @param v defines the coordinate on Y axis
  32483. * @param width defines the width of the source data
  32484. * @param height defines the height of the source data
  32485. * @param pixels defines the source byte array
  32486. * @param color defines the output color
  32487. */
  32488. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32489. /**
  32490. * Interpolates between a and b via alpha
  32491. * @param a The lower value (returned when alpha = 0)
  32492. * @param b The upper value (returned when alpha = 1)
  32493. * @param alpha The interpolation-factor
  32494. * @return The mixed value
  32495. */
  32496. static Mix(a: number, b: number, alpha: number): number;
  32497. /**
  32498. * Tries to instantiate a new object from a given class name
  32499. * @param className defines the class name to instantiate
  32500. * @returns the new object or null if the system was not able to do the instantiation
  32501. */
  32502. static Instantiate(className: string): any;
  32503. /**
  32504. * Provides a slice function that will work even on IE
  32505. * @param data defines the array to slice
  32506. * @param start defines the start of the data (optional)
  32507. * @param end defines the end of the data (optional)
  32508. * @returns the new sliced array
  32509. */
  32510. static Slice<T>(data: T, start?: number, end?: number): T;
  32511. /**
  32512. * Polyfill for setImmediate
  32513. * @param action defines the action to execute after the current execution block
  32514. */
  32515. static SetImmediate(action: () => void): void;
  32516. /**
  32517. * Function indicating if a number is an exponent of 2
  32518. * @param value defines the value to test
  32519. * @returns true if the value is an exponent of 2
  32520. */
  32521. static IsExponentOfTwo(value: number): boolean;
  32522. private static _tmpFloatArray;
  32523. /**
  32524. * Returns the nearest 32-bit single precision float representation of a Number
  32525. * @param value A Number. If the parameter is of a different type, it will get converted
  32526. * to a number or to NaN if it cannot be converted
  32527. * @returns number
  32528. */
  32529. static FloatRound(value: number): number;
  32530. /**
  32531. * Extracts the filename from a path
  32532. * @param path defines the path to use
  32533. * @returns the filename
  32534. */
  32535. static GetFilename(path: string): string;
  32536. /**
  32537. * Extracts the "folder" part of a path (everything before the filename).
  32538. * @param uri The URI to extract the info from
  32539. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32540. * @returns The "folder" part of the path
  32541. */
  32542. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32543. /**
  32544. * Extracts text content from a DOM element hierarchy
  32545. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32546. */
  32547. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32548. /**
  32549. * Convert an angle in radians to degrees
  32550. * @param angle defines the angle to convert
  32551. * @returns the angle in degrees
  32552. */
  32553. static ToDegrees(angle: number): number;
  32554. /**
  32555. * Convert an angle in degrees to radians
  32556. * @param angle defines the angle to convert
  32557. * @returns the angle in radians
  32558. */
  32559. static ToRadians(angle: number): number;
  32560. /**
  32561. * Encode a buffer to a base64 string
  32562. * @param buffer defines the buffer to encode
  32563. * @returns the encoded string
  32564. */
  32565. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32566. /**
  32567. * Returns an array if obj is not an array
  32568. * @param obj defines the object to evaluate as an array
  32569. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32570. * @returns either obj directly if obj is an array or a new array containing obj
  32571. */
  32572. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32573. /**
  32574. * Gets the pointer prefix to use
  32575. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32576. */
  32577. static GetPointerPrefix(): string;
  32578. /**
  32579. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32580. * @param url define the url we are trying
  32581. * @param element define the dom element where to configure the cors policy
  32582. */
  32583. static SetCorsBehavior(url: string | string[], element: {
  32584. crossOrigin: string | null;
  32585. }): void;
  32586. /**
  32587. * Removes unwanted characters from an url
  32588. * @param url defines the url to clean
  32589. * @returns the cleaned url
  32590. */
  32591. static CleanUrl(url: string): string;
  32592. /**
  32593. * Gets or sets a function used to pre-process url before using them to load assets
  32594. */
  32595. static PreprocessUrl: (url: string) => string;
  32596. /**
  32597. * Loads an image as an HTMLImageElement.
  32598. * @param input url string, ArrayBuffer, or Blob to load
  32599. * @param onLoad callback called when the image successfully loads
  32600. * @param onError callback called when the image fails to load
  32601. * @param offlineProvider offline provider for caching
  32602. * @returns the HTMLImageElement of the loaded image
  32603. */
  32604. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32605. /**
  32606. * Loads a file
  32607. * @param url url string, ArrayBuffer, or Blob to load
  32608. * @param onSuccess callback called when the file successfully loads
  32609. * @param onProgress callback called while file is loading (if the server supports this mode)
  32610. * @param offlineProvider defines the offline provider for caching
  32611. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32612. * @param onError callback called when the file fails to load
  32613. * @returns a file request object
  32614. */
  32615. 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;
  32616. /**
  32617. * Loads a file from a url
  32618. * @param url the file url to load
  32619. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32620. */
  32621. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32622. /**
  32623. * Load a script (identified by an url). When the url returns, the
  32624. * content of this file is added into a new script element, attached to the DOM (body element)
  32625. * @param scriptUrl defines the url of the script to laod
  32626. * @param onSuccess defines the callback called when the script is loaded
  32627. * @param onError defines the callback to call if an error occurs
  32628. * @param scriptId defines the id of the script element
  32629. */
  32630. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32631. /**
  32632. * Load an asynchronous script (identified by an url). When the url returns, the
  32633. * content of this file is added into a new script element, attached to the DOM (body element)
  32634. * @param scriptUrl defines the url of the script to laod
  32635. * @param scriptId defines the id of the script element
  32636. * @returns a promise request object
  32637. */
  32638. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32639. /**
  32640. * Loads a file from a blob
  32641. * @param fileToLoad defines the blob to use
  32642. * @param callback defines the callback to call when data is loaded
  32643. * @param progressCallback defines the callback to call during loading process
  32644. * @returns a file request object
  32645. */
  32646. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32647. /**
  32648. * Loads a file
  32649. * @param fileToLoad defines the file to load
  32650. * @param callback defines the callback to call when data is loaded
  32651. * @param progressCallBack defines the callback to call during loading process
  32652. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32653. * @returns a file request object
  32654. */
  32655. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32656. /**
  32657. * Creates a data url from a given string content
  32658. * @param content defines the content to convert
  32659. * @returns the new data url link
  32660. */
  32661. static FileAsURL(content: string): string;
  32662. /**
  32663. * Format the given number to a specific decimal format
  32664. * @param value defines the number to format
  32665. * @param decimals defines the number of decimals to use
  32666. * @returns the formatted string
  32667. */
  32668. static Format(value: number, decimals?: number): string;
  32669. /**
  32670. * Tries to copy an object by duplicating every property
  32671. * @param source defines the source object
  32672. * @param destination defines the target object
  32673. * @param doNotCopyList defines a list of properties to avoid
  32674. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32675. */
  32676. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32677. /**
  32678. * Gets a boolean indicating if the given object has no own property
  32679. * @param obj defines the object to test
  32680. * @returns true if object has no own property
  32681. */
  32682. static IsEmpty(obj: any): boolean;
  32683. /**
  32684. * Function used to register events at window level
  32685. * @param events defines the events to register
  32686. */
  32687. static RegisterTopRootEvents(events: {
  32688. name: string;
  32689. handler: Nullable<(e: FocusEvent) => any>;
  32690. }[]): void;
  32691. /**
  32692. * Function used to unregister events from window level
  32693. * @param events defines the events to unregister
  32694. */
  32695. static UnregisterTopRootEvents(events: {
  32696. name: string;
  32697. handler: Nullable<(e: FocusEvent) => any>;
  32698. }[]): void;
  32699. /**
  32700. * @ignore
  32701. */
  32702. static _ScreenshotCanvas: HTMLCanvasElement;
  32703. /**
  32704. * Dumps the current bound framebuffer
  32705. * @param width defines the rendering width
  32706. * @param height defines the rendering height
  32707. * @param engine defines the hosting engine
  32708. * @param successCallback defines the callback triggered once the data are available
  32709. * @param mimeType defines the mime type of the result
  32710. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32711. */
  32712. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32713. /**
  32714. * Converts the canvas data to blob.
  32715. * This acts as a polyfill for browsers not supporting the to blob function.
  32716. * @param canvas Defines the canvas to extract the data from
  32717. * @param successCallback Defines the callback triggered once the data are available
  32718. * @param mimeType Defines the mime type of the result
  32719. */
  32720. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32721. /**
  32722. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32723. * @param successCallback defines the callback triggered once the data are available
  32724. * @param mimeType defines the mime type of the result
  32725. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32726. */
  32727. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32728. /**
  32729. * Downloads a blob in the browser
  32730. * @param blob defines the blob to download
  32731. * @param fileName defines the name of the downloaded file
  32732. */
  32733. static Download(blob: Blob, fileName: string): void;
  32734. /**
  32735. * Captures a screenshot of the current rendering
  32736. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32737. * @param engine defines the rendering engine
  32738. * @param camera defines the source camera
  32739. * @param size This parameter can be set to a single number or to an object with the
  32740. * following (optional) properties: precision, width, height. If a single number is passed,
  32741. * it will be used for both width and height. If an object is passed, the screenshot size
  32742. * will be derived from the parameters. The precision property is a multiplier allowing
  32743. * rendering at a higher or lower resolution
  32744. * @param successCallback defines the callback receives a single parameter which contains the
  32745. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32746. * src parameter of an <img> to display it
  32747. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32748. * Check your browser for supported MIME types
  32749. */
  32750. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  32751. /**
  32752. * Generates an image screenshot from the specified camera.
  32753. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32754. * @param engine The engine to use for rendering
  32755. * @param camera The camera to use for rendering
  32756. * @param size This parameter can be set to a single number or to an object with the
  32757. * following (optional) properties: precision, width, height. If a single number is passed,
  32758. * it will be used for both width and height. If an object is passed, the screenshot size
  32759. * will be derived from the parameters. The precision property is a multiplier allowing
  32760. * rendering at a higher or lower resolution
  32761. * @param successCallback The callback receives a single parameter which contains the
  32762. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32763. * src parameter of an <img> to display it
  32764. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32765. * Check your browser for supported MIME types
  32766. * @param samples Texture samples (default: 1)
  32767. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32768. * @param fileName A name for for the downloaded file.
  32769. */
  32770. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32771. /**
  32772. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32773. * Be aware Math.random() could cause collisions, but:
  32774. * "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"
  32775. * @returns a pseudo random id
  32776. */
  32777. static RandomId(): string;
  32778. /**
  32779. * Test if the given uri is a base64 string
  32780. * @param uri The uri to test
  32781. * @return True if the uri is a base64 string or false otherwise
  32782. */
  32783. static IsBase64(uri: string): boolean;
  32784. /**
  32785. * Decode the given base64 uri.
  32786. * @param uri The uri to decode
  32787. * @return The decoded base64 data.
  32788. */
  32789. static DecodeBase64(uri: string): ArrayBuffer;
  32790. /**
  32791. * Gets the absolute url.
  32792. * @param url the input url
  32793. * @return the absolute url
  32794. */
  32795. static GetAbsoluteUrl(url: string): string;
  32796. /**
  32797. * No log
  32798. */
  32799. static readonly NoneLogLevel: number;
  32800. /**
  32801. * Only message logs
  32802. */
  32803. static readonly MessageLogLevel: number;
  32804. /**
  32805. * Only warning logs
  32806. */
  32807. static readonly WarningLogLevel: number;
  32808. /**
  32809. * Only error logs
  32810. */
  32811. static readonly ErrorLogLevel: number;
  32812. /**
  32813. * All logs
  32814. */
  32815. static readonly AllLogLevel: number;
  32816. /**
  32817. * Gets a value indicating the number of loading errors
  32818. * @ignorenaming
  32819. */
  32820. static readonly errorsCount: number;
  32821. /**
  32822. * Callback called when a new log is added
  32823. */
  32824. static OnNewCacheEntry: (entry: string) => void;
  32825. /**
  32826. * Log a message to the console
  32827. * @param message defines the message to log
  32828. */
  32829. static Log(message: string): void;
  32830. /**
  32831. * Write a warning message to the console
  32832. * @param message defines the message to log
  32833. */
  32834. static Warn(message: string): void;
  32835. /**
  32836. * Write an error message to the console
  32837. * @param message defines the message to log
  32838. */
  32839. static Error(message: string): void;
  32840. /**
  32841. * Gets current log cache (list of logs)
  32842. */
  32843. static readonly LogCache: string;
  32844. /**
  32845. * Clears the log cache
  32846. */
  32847. static ClearLogCache(): void;
  32848. /**
  32849. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32850. */
  32851. static LogLevels: number;
  32852. /**
  32853. * Checks if the window object exists
  32854. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32855. */
  32856. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32857. /**
  32858. * No performance log
  32859. */
  32860. static readonly PerformanceNoneLogLevel: number;
  32861. /**
  32862. * Use user marks to log performance
  32863. */
  32864. static readonly PerformanceUserMarkLogLevel: number;
  32865. /**
  32866. * Log performance to the console
  32867. */
  32868. static readonly PerformanceConsoleLogLevel: number;
  32869. private static _performance;
  32870. /**
  32871. * Sets the current performance log level
  32872. */
  32873. static PerformanceLogLevel: number;
  32874. private static _StartPerformanceCounterDisabled;
  32875. private static _EndPerformanceCounterDisabled;
  32876. private static _StartUserMark;
  32877. private static _EndUserMark;
  32878. private static _StartPerformanceConsole;
  32879. private static _EndPerformanceConsole;
  32880. /**
  32881. * Starts a performance counter
  32882. */
  32883. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32884. /**
  32885. * Ends a specific performance coutner
  32886. */
  32887. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32888. /**
  32889. * Gets either window.performance.now() if supported or Date.now() else
  32890. */
  32891. static readonly Now: number;
  32892. /**
  32893. * This method will return the name of the class used to create the instance of the given object.
  32894. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32895. * @param object the object to get the class name from
  32896. * @param isType defines if the object is actually a type
  32897. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32898. */
  32899. static GetClassName(object: any, isType?: boolean): string;
  32900. /**
  32901. * Gets the first element of an array satisfying a given predicate
  32902. * @param array defines the array to browse
  32903. * @param predicate defines the predicate to use
  32904. * @returns null if not found or the element
  32905. */
  32906. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32907. /**
  32908. * This method will return the name of the full name of the class, including its owning module (if any).
  32909. * 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).
  32910. * @param object the object to get the class name from
  32911. * @param isType defines if the object is actually a type
  32912. * @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.
  32913. * @ignorenaming
  32914. */
  32915. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32916. /**
  32917. * Returns a promise that resolves after the given amount of time.
  32918. * @param delay Number of milliseconds to delay
  32919. * @returns Promise that resolves after the given amount of time
  32920. */
  32921. static DelayAsync(delay: number): Promise<void>;
  32922. }
  32923. /**
  32924. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32925. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32926. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32927. * @param name The name of the class, case should be preserved
  32928. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32929. */
  32930. export function className(name: string, module?: string): (target: Object) => void;
  32931. /**
  32932. * An implementation of a loop for asynchronous functions.
  32933. */
  32934. export class AsyncLoop {
  32935. /**
  32936. * Defines the number of iterations for the loop
  32937. */
  32938. iterations: number;
  32939. /**
  32940. * Defines the current index of the loop.
  32941. */
  32942. index: number;
  32943. private _done;
  32944. private _fn;
  32945. private _successCallback;
  32946. /**
  32947. * Constructor.
  32948. * @param iterations the number of iterations.
  32949. * @param func the function to run each iteration
  32950. * @param successCallback the callback that will be called upon succesful execution
  32951. * @param offset starting offset.
  32952. */
  32953. constructor(
  32954. /**
  32955. * Defines the number of iterations for the loop
  32956. */
  32957. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32958. /**
  32959. * Execute the next iteration. Must be called after the last iteration was finished.
  32960. */
  32961. executeNext(): void;
  32962. /**
  32963. * Break the loop and run the success callback.
  32964. */
  32965. breakLoop(): void;
  32966. /**
  32967. * Create and run an async loop.
  32968. * @param iterations the number of iterations.
  32969. * @param fn the function to run each iteration
  32970. * @param successCallback the callback that will be called upon succesful execution
  32971. * @param offset starting offset.
  32972. * @returns the created async loop object
  32973. */
  32974. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32975. /**
  32976. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32977. * @param iterations total number of iterations
  32978. * @param syncedIterations number of synchronous iterations in each async iteration.
  32979. * @param fn the function to call each iteration.
  32980. * @param callback a success call back that will be called when iterating stops.
  32981. * @param breakFunction a break condition (optional)
  32982. * @param timeout timeout settings for the setTimeout function. default - 0.
  32983. * @returns the created async loop object
  32984. */
  32985. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32986. }
  32987. }
  32988. declare module "babylonjs/Collisions/collisionCoordinator" {
  32989. import { Nullable } from "babylonjs/types";
  32990. import { Scene } from "babylonjs/scene";
  32991. import { Vector3 } from "babylonjs/Maths/math.vector";
  32992. import { Collider } from "babylonjs/Collisions/collider";
  32993. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32994. /** @hidden */
  32995. export interface ICollisionCoordinator {
  32996. createCollider(): Collider;
  32997. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32998. init(scene: Scene): void;
  32999. }
  33000. /** @hidden */
  33001. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33002. private _scene;
  33003. private _scaledPosition;
  33004. private _scaledVelocity;
  33005. private _finalPosition;
  33006. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33007. createCollider(): Collider;
  33008. init(scene: Scene): void;
  33009. private _collideWithWorld;
  33010. }
  33011. }
  33012. declare module "babylonjs/Inputs/scene.inputManager" {
  33013. import { Nullable } from "babylonjs/types";
  33014. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33015. import { Vector2 } from "babylonjs/Maths/math.vector";
  33016. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33017. import { Scene } from "babylonjs/scene";
  33018. /**
  33019. * Class used to manage all inputs for the scene.
  33020. */
  33021. export class InputManager {
  33022. /** The distance in pixel that you have to move to prevent some events */
  33023. static DragMovementThreshold: number;
  33024. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33025. static LongPressDelay: number;
  33026. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33027. static DoubleClickDelay: number;
  33028. /** If you need to check double click without raising a single click at first click, enable this flag */
  33029. static ExclusiveDoubleClickMode: boolean;
  33030. private _wheelEventName;
  33031. private _onPointerMove;
  33032. private _onPointerDown;
  33033. private _onPointerUp;
  33034. private _initClickEvent;
  33035. private _initActionManager;
  33036. private _delayedSimpleClick;
  33037. private _delayedSimpleClickTimeout;
  33038. private _previousDelayedSimpleClickTimeout;
  33039. private _meshPickProceed;
  33040. private _previousButtonPressed;
  33041. private _currentPickResult;
  33042. private _previousPickResult;
  33043. private _totalPointersPressed;
  33044. private _doubleClickOccured;
  33045. private _pointerOverMesh;
  33046. private _pickedDownMesh;
  33047. private _pickedUpMesh;
  33048. private _pointerX;
  33049. private _pointerY;
  33050. private _unTranslatedPointerX;
  33051. private _unTranslatedPointerY;
  33052. private _startingPointerPosition;
  33053. private _previousStartingPointerPosition;
  33054. private _startingPointerTime;
  33055. private _previousStartingPointerTime;
  33056. private _pointerCaptures;
  33057. private _onKeyDown;
  33058. private _onKeyUp;
  33059. private _onCanvasFocusObserver;
  33060. private _onCanvasBlurObserver;
  33061. private _scene;
  33062. /**
  33063. * Creates a new InputManager
  33064. * @param scene defines the hosting scene
  33065. */
  33066. constructor(scene: Scene);
  33067. /**
  33068. * Gets the mesh that is currently under the pointer
  33069. */
  33070. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33071. /**
  33072. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33073. */
  33074. readonly unTranslatedPointer: Vector2;
  33075. /**
  33076. * Gets or sets the current on-screen X position of the pointer
  33077. */
  33078. pointerX: number;
  33079. /**
  33080. * Gets or sets the current on-screen Y position of the pointer
  33081. */
  33082. pointerY: number;
  33083. private _updatePointerPosition;
  33084. private _processPointerMove;
  33085. private _setRayOnPointerInfo;
  33086. private _checkPrePointerObservable;
  33087. /**
  33088. * Use this method to simulate a pointer move on a mesh
  33089. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33090. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33091. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33092. */
  33093. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33094. /**
  33095. * Use this method to simulate a pointer down on a mesh
  33096. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33097. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33098. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33099. */
  33100. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33101. private _processPointerDown;
  33102. /** @hidden */
  33103. _isPointerSwiping(): boolean;
  33104. /**
  33105. * Use this method to simulate a pointer up on a mesh
  33106. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33107. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33108. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33109. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33110. */
  33111. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33112. private _processPointerUp;
  33113. /**
  33114. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33115. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33116. * @returns true if the pointer was captured
  33117. */
  33118. isPointerCaptured(pointerId?: number): boolean;
  33119. /**
  33120. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33121. * @param attachUp defines if you want to attach events to pointerup
  33122. * @param attachDown defines if you want to attach events to pointerdown
  33123. * @param attachMove defines if you want to attach events to pointermove
  33124. */
  33125. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33126. /**
  33127. * Detaches all event handlers
  33128. */
  33129. detachControl(): void;
  33130. /**
  33131. * Force the value of meshUnderPointer
  33132. * @param mesh defines the mesh to use
  33133. */
  33134. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33135. /**
  33136. * Gets the mesh under the pointer
  33137. * @returns a Mesh or null if no mesh is under the pointer
  33138. */
  33139. getPointerOverMesh(): Nullable<AbstractMesh>;
  33140. }
  33141. }
  33142. declare module "babylonjs/Animations/animationGroup" {
  33143. import { Animatable } from "babylonjs/Animations/animatable";
  33144. import { Animation } from "babylonjs/Animations/animation";
  33145. import { Scene, IDisposable } from "babylonjs/scene";
  33146. import { Observable } from "babylonjs/Misc/observable";
  33147. import { Nullable } from "babylonjs/types";
  33148. import "babylonjs/Animations/animatable";
  33149. /**
  33150. * This class defines the direct association between an animation and a target
  33151. */
  33152. export class TargetedAnimation {
  33153. /**
  33154. * Animation to perform
  33155. */
  33156. animation: Animation;
  33157. /**
  33158. * Target to animate
  33159. */
  33160. target: any;
  33161. /**
  33162. * Serialize the object
  33163. * @returns the JSON object representing the current entity
  33164. */
  33165. serialize(): any;
  33166. }
  33167. /**
  33168. * Use this class to create coordinated animations on multiple targets
  33169. */
  33170. export class AnimationGroup implements IDisposable {
  33171. /** The name of the animation group */
  33172. name: string;
  33173. private _scene;
  33174. private _targetedAnimations;
  33175. private _animatables;
  33176. private _from;
  33177. private _to;
  33178. private _isStarted;
  33179. private _isPaused;
  33180. private _speedRatio;
  33181. private _loopAnimation;
  33182. /**
  33183. * Gets or sets the unique id of the node
  33184. */
  33185. uniqueId: number;
  33186. /**
  33187. * This observable will notify when one animation have ended
  33188. */
  33189. onAnimationEndObservable: Observable<TargetedAnimation>;
  33190. /**
  33191. * Observer raised when one animation loops
  33192. */
  33193. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33194. /**
  33195. * This observable will notify when all animations have ended.
  33196. */
  33197. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33198. /**
  33199. * This observable will notify when all animations have paused.
  33200. */
  33201. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33202. /**
  33203. * This observable will notify when all animations are playing.
  33204. */
  33205. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33206. /**
  33207. * Gets the first frame
  33208. */
  33209. readonly from: number;
  33210. /**
  33211. * Gets the last frame
  33212. */
  33213. readonly to: number;
  33214. /**
  33215. * Define if the animations are started
  33216. */
  33217. readonly isStarted: boolean;
  33218. /**
  33219. * Gets a value indicating that the current group is playing
  33220. */
  33221. readonly isPlaying: boolean;
  33222. /**
  33223. * Gets or sets the speed ratio to use for all animations
  33224. */
  33225. /**
  33226. * Gets or sets the speed ratio to use for all animations
  33227. */
  33228. speedRatio: number;
  33229. /**
  33230. * Gets or sets if all animations should loop or not
  33231. */
  33232. loopAnimation: boolean;
  33233. /**
  33234. * Gets the targeted animations for this animation group
  33235. */
  33236. readonly targetedAnimations: Array<TargetedAnimation>;
  33237. /**
  33238. * returning the list of animatables controlled by this animation group.
  33239. */
  33240. readonly animatables: Array<Animatable>;
  33241. /**
  33242. * Instantiates a new Animation Group.
  33243. * This helps managing several animations at once.
  33244. * @see http://doc.babylonjs.com/how_to/group
  33245. * @param name Defines the name of the group
  33246. * @param scene Defines the scene the group belongs to
  33247. */
  33248. constructor(
  33249. /** The name of the animation group */
  33250. name: string, scene?: Nullable<Scene>);
  33251. /**
  33252. * Add an animation (with its target) in the group
  33253. * @param animation defines the animation we want to add
  33254. * @param target defines the target of the animation
  33255. * @returns the TargetedAnimation object
  33256. */
  33257. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33258. /**
  33259. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33260. * It can add constant keys at begin or end
  33261. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33262. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33263. * @returns the animation group
  33264. */
  33265. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33266. /**
  33267. * Start all animations on given targets
  33268. * @param loop defines if animations must loop
  33269. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33270. * @param from defines the from key (optional)
  33271. * @param to defines the to key (optional)
  33272. * @returns the current animation group
  33273. */
  33274. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33275. /**
  33276. * Pause all animations
  33277. * @returns the animation group
  33278. */
  33279. pause(): AnimationGroup;
  33280. /**
  33281. * Play all animations to initial state
  33282. * This function will start() the animations if they were not started or will restart() them if they were paused
  33283. * @param loop defines if animations must loop
  33284. * @returns the animation group
  33285. */
  33286. play(loop?: boolean): AnimationGroup;
  33287. /**
  33288. * Reset all animations to initial state
  33289. * @returns the animation group
  33290. */
  33291. reset(): AnimationGroup;
  33292. /**
  33293. * Restart animations from key 0
  33294. * @returns the animation group
  33295. */
  33296. restart(): AnimationGroup;
  33297. /**
  33298. * Stop all animations
  33299. * @returns the animation group
  33300. */
  33301. stop(): AnimationGroup;
  33302. /**
  33303. * Set animation weight for all animatables
  33304. * @param weight defines the weight to use
  33305. * @return the animationGroup
  33306. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33307. */
  33308. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33309. /**
  33310. * Synchronize and normalize all animatables with a source animatable
  33311. * @param root defines the root animatable to synchronize with
  33312. * @return the animationGroup
  33313. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33314. */
  33315. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33316. /**
  33317. * Goes to a specific frame in this animation group
  33318. * @param frame the frame number to go to
  33319. * @return the animationGroup
  33320. */
  33321. goToFrame(frame: number): AnimationGroup;
  33322. /**
  33323. * Dispose all associated resources
  33324. */
  33325. dispose(): void;
  33326. private _checkAnimationGroupEnded;
  33327. /**
  33328. * Clone the current animation group and returns a copy
  33329. * @param newName defines the name of the new group
  33330. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33331. * @returns the new aniamtion group
  33332. */
  33333. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33334. /**
  33335. * Serializes the animationGroup to an object
  33336. * @returns Serialized object
  33337. */
  33338. serialize(): any;
  33339. /**
  33340. * Returns a new AnimationGroup object parsed from the source provided.
  33341. * @param parsedAnimationGroup defines the source
  33342. * @param scene defines the scene that will receive the animationGroup
  33343. * @returns a new AnimationGroup
  33344. */
  33345. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33346. /**
  33347. * Returns the string "AnimationGroup"
  33348. * @returns "AnimationGroup"
  33349. */
  33350. getClassName(): string;
  33351. /**
  33352. * Creates a detailled string about the object
  33353. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33354. * @returns a string representing the object
  33355. */
  33356. toString(fullDetails?: boolean): string;
  33357. }
  33358. }
  33359. declare module "babylonjs/scene" {
  33360. import { Nullable } from "babylonjs/types";
  33361. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33362. import { Observable } from "babylonjs/Misc/observable";
  33363. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33364. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33365. import { Geometry } from "babylonjs/Meshes/geometry";
  33366. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33367. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33368. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33369. import { Mesh } from "babylonjs/Meshes/mesh";
  33370. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33371. import { Bone } from "babylonjs/Bones/bone";
  33372. import { Skeleton } from "babylonjs/Bones/skeleton";
  33373. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33374. import { Camera } from "babylonjs/Cameras/camera";
  33375. import { AbstractScene } from "babylonjs/abstractScene";
  33376. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33377. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33378. import { Material } from "babylonjs/Materials/material";
  33379. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33380. import { Effect } from "babylonjs/Materials/effect";
  33381. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33382. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33383. import { Light } from "babylonjs/Lights/light";
  33384. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33385. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33386. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33387. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33388. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33389. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33390. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33391. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33392. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33393. import { Engine } from "babylonjs/Engines/engine";
  33394. import { Node } from "babylonjs/node";
  33395. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33396. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33397. import { WebRequest } from "babylonjs/Misc/webRequest";
  33398. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33399. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33400. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33401. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33402. import { Plane } from "babylonjs/Maths/math.plane";
  33403. import { Ray } from "babylonjs/Culling/ray";
  33404. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33405. import { Animation } from "babylonjs/Animations/animation";
  33406. import { Animatable } from "babylonjs/Animations/animatable";
  33407. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33408. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33409. import { Collider } from "babylonjs/Collisions/collider";
  33410. /**
  33411. * Define an interface for all classes that will hold resources
  33412. */
  33413. export interface IDisposable {
  33414. /**
  33415. * Releases all held resources
  33416. */
  33417. dispose(): void;
  33418. }
  33419. /** Interface defining initialization parameters for Scene class */
  33420. export interface SceneOptions {
  33421. /**
  33422. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33423. * It will improve performance when the number of geometries becomes important.
  33424. */
  33425. useGeometryUniqueIdsMap?: boolean;
  33426. /**
  33427. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33428. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33429. */
  33430. useMaterialMeshMap?: boolean;
  33431. /**
  33432. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33433. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33434. */
  33435. useClonedMeshhMap?: boolean;
  33436. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33437. virtual?: boolean;
  33438. }
  33439. /**
  33440. * Represents a scene to be rendered by the engine.
  33441. * @see http://doc.babylonjs.com/features/scene
  33442. */
  33443. export class Scene extends AbstractScene implements IAnimatable {
  33444. private static _uniqueIdCounter;
  33445. /** The fog is deactivated */
  33446. static readonly FOGMODE_NONE: number;
  33447. /** The fog density is following an exponential function */
  33448. static readonly FOGMODE_EXP: number;
  33449. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33450. static readonly FOGMODE_EXP2: number;
  33451. /** The fog density is following a linear function. */
  33452. static readonly FOGMODE_LINEAR: number;
  33453. /**
  33454. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33455. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33456. */
  33457. static MinDeltaTime: number;
  33458. /**
  33459. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33460. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33461. */
  33462. static MaxDeltaTime: number;
  33463. /**
  33464. * Factory used to create the default material.
  33465. * @param name The name of the material to create
  33466. * @param scene The scene to create the material for
  33467. * @returns The default material
  33468. */
  33469. static DefaultMaterialFactory(scene: Scene): Material;
  33470. /**
  33471. * Factory used to create the a collision coordinator.
  33472. * @returns The collision coordinator
  33473. */
  33474. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33475. /** @hidden */
  33476. _inputManager: InputManager;
  33477. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33478. cameraToUseForPointers: Nullable<Camera>;
  33479. /** @hidden */
  33480. readonly _isScene: boolean;
  33481. /**
  33482. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33483. */
  33484. autoClear: boolean;
  33485. /**
  33486. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33487. */
  33488. autoClearDepthAndStencil: boolean;
  33489. /**
  33490. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33491. */
  33492. clearColor: Color4;
  33493. /**
  33494. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33495. */
  33496. ambientColor: Color3;
  33497. /**
  33498. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33499. * It should only be one of the following (if not the default embedded one):
  33500. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33501. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33502. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33503. * The material properties need to be setup according to the type of texture in use.
  33504. */
  33505. environmentBRDFTexture: BaseTexture;
  33506. /** @hidden */
  33507. protected _environmentTexture: Nullable<BaseTexture>;
  33508. /**
  33509. * Texture used in all pbr material as the reflection texture.
  33510. * As in the majority of the scene they are the same (exception for multi room and so on),
  33511. * this is easier to reference from here than from all the materials.
  33512. */
  33513. /**
  33514. * Texture used in all pbr material as the reflection texture.
  33515. * As in the majority of the scene they are the same (exception for multi room and so on),
  33516. * this is easier to set here than in all the materials.
  33517. */
  33518. environmentTexture: Nullable<BaseTexture>;
  33519. /** @hidden */
  33520. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33521. /**
  33522. * Default image processing configuration used either in the rendering
  33523. * Forward main pass or through the imageProcessingPostProcess if present.
  33524. * As in the majority of the scene they are the same (exception for multi camera),
  33525. * this is easier to reference from here than from all the materials and post process.
  33526. *
  33527. * No setter as we it is a shared configuration, you can set the values instead.
  33528. */
  33529. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33530. private _forceWireframe;
  33531. /**
  33532. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33533. */
  33534. forceWireframe: boolean;
  33535. private _forcePointsCloud;
  33536. /**
  33537. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33538. */
  33539. forcePointsCloud: boolean;
  33540. /**
  33541. * Gets or sets the active clipplane 1
  33542. */
  33543. clipPlane: Nullable<Plane>;
  33544. /**
  33545. * Gets or sets the active clipplane 2
  33546. */
  33547. clipPlane2: Nullable<Plane>;
  33548. /**
  33549. * Gets or sets the active clipplane 3
  33550. */
  33551. clipPlane3: Nullable<Plane>;
  33552. /**
  33553. * Gets or sets the active clipplane 4
  33554. */
  33555. clipPlane4: Nullable<Plane>;
  33556. /**
  33557. * Gets or sets a boolean indicating if animations are enabled
  33558. */
  33559. animationsEnabled: boolean;
  33560. private _animationPropertiesOverride;
  33561. /**
  33562. * Gets or sets the animation properties override
  33563. */
  33564. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33565. /**
  33566. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33567. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33568. */
  33569. useConstantAnimationDeltaTime: boolean;
  33570. /**
  33571. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33572. * Please note that it requires to run a ray cast through the scene on every frame
  33573. */
  33574. constantlyUpdateMeshUnderPointer: boolean;
  33575. /**
  33576. * Defines the HTML cursor to use when hovering over interactive elements
  33577. */
  33578. hoverCursor: string;
  33579. /**
  33580. * Defines the HTML default cursor to use (empty by default)
  33581. */
  33582. defaultCursor: string;
  33583. /**
  33584. * This is used to call preventDefault() on pointer down
  33585. * in order to block unwanted artifacts like system double clicks
  33586. */
  33587. preventDefaultOnPointerDown: boolean;
  33588. /**
  33589. * This is used to call preventDefault() on pointer up
  33590. * in order to block unwanted artifacts like system double clicks
  33591. */
  33592. preventDefaultOnPointerUp: boolean;
  33593. /**
  33594. * Gets or sets user defined metadata
  33595. */
  33596. metadata: any;
  33597. /**
  33598. * For internal use only. Please do not use.
  33599. */
  33600. reservedDataStore: any;
  33601. /**
  33602. * Gets the name of the plugin used to load this scene (null by default)
  33603. */
  33604. loadingPluginName: string;
  33605. /**
  33606. * Use this array to add regular expressions used to disable offline support for specific urls
  33607. */
  33608. disableOfflineSupportExceptionRules: RegExp[];
  33609. /**
  33610. * An event triggered when the scene is disposed.
  33611. */
  33612. onDisposeObservable: Observable<Scene>;
  33613. private _onDisposeObserver;
  33614. /** Sets a function to be executed when this scene is disposed. */
  33615. onDispose: () => void;
  33616. /**
  33617. * An event triggered before rendering the scene (right after animations and physics)
  33618. */
  33619. onBeforeRenderObservable: Observable<Scene>;
  33620. private _onBeforeRenderObserver;
  33621. /** Sets a function to be executed before rendering this scene */
  33622. beforeRender: Nullable<() => void>;
  33623. /**
  33624. * An event triggered after rendering the scene
  33625. */
  33626. onAfterRenderObservable: Observable<Scene>;
  33627. /**
  33628. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33629. */
  33630. onAfterRenderCameraObservable: Observable<Camera>;
  33631. private _onAfterRenderObserver;
  33632. /** Sets a function to be executed after rendering this scene */
  33633. afterRender: Nullable<() => void>;
  33634. /**
  33635. * An event triggered before animating the scene
  33636. */
  33637. onBeforeAnimationsObservable: Observable<Scene>;
  33638. /**
  33639. * An event triggered after animations processing
  33640. */
  33641. onAfterAnimationsObservable: Observable<Scene>;
  33642. /**
  33643. * An event triggered before draw calls are ready to be sent
  33644. */
  33645. onBeforeDrawPhaseObservable: Observable<Scene>;
  33646. /**
  33647. * An event triggered after draw calls have been sent
  33648. */
  33649. onAfterDrawPhaseObservable: Observable<Scene>;
  33650. /**
  33651. * An event triggered when the scene is ready
  33652. */
  33653. onReadyObservable: Observable<Scene>;
  33654. /**
  33655. * An event triggered before rendering a camera
  33656. */
  33657. onBeforeCameraRenderObservable: Observable<Camera>;
  33658. private _onBeforeCameraRenderObserver;
  33659. /** Sets a function to be executed before rendering a camera*/
  33660. beforeCameraRender: () => void;
  33661. /**
  33662. * An event triggered after rendering a camera
  33663. */
  33664. onAfterCameraRenderObservable: Observable<Camera>;
  33665. private _onAfterCameraRenderObserver;
  33666. /** Sets a function to be executed after rendering a camera*/
  33667. afterCameraRender: () => void;
  33668. /**
  33669. * An event triggered when active meshes evaluation is about to start
  33670. */
  33671. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33672. /**
  33673. * An event triggered when active meshes evaluation is done
  33674. */
  33675. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33676. /**
  33677. * An event triggered when particles rendering is about to start
  33678. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33679. */
  33680. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33681. /**
  33682. * An event triggered when particles rendering is done
  33683. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33684. */
  33685. onAfterParticlesRenderingObservable: Observable<Scene>;
  33686. /**
  33687. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33688. */
  33689. onDataLoadedObservable: Observable<Scene>;
  33690. /**
  33691. * An event triggered when a camera is created
  33692. */
  33693. onNewCameraAddedObservable: Observable<Camera>;
  33694. /**
  33695. * An event triggered when a camera is removed
  33696. */
  33697. onCameraRemovedObservable: Observable<Camera>;
  33698. /**
  33699. * An event triggered when a light is created
  33700. */
  33701. onNewLightAddedObservable: Observable<Light>;
  33702. /**
  33703. * An event triggered when a light is removed
  33704. */
  33705. onLightRemovedObservable: Observable<Light>;
  33706. /**
  33707. * An event triggered when a geometry is created
  33708. */
  33709. onNewGeometryAddedObservable: Observable<Geometry>;
  33710. /**
  33711. * An event triggered when a geometry is removed
  33712. */
  33713. onGeometryRemovedObservable: Observable<Geometry>;
  33714. /**
  33715. * An event triggered when a transform node is created
  33716. */
  33717. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33718. /**
  33719. * An event triggered when a transform node is removed
  33720. */
  33721. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33722. /**
  33723. * An event triggered when a mesh is created
  33724. */
  33725. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33726. /**
  33727. * An event triggered when a mesh is removed
  33728. */
  33729. onMeshRemovedObservable: Observable<AbstractMesh>;
  33730. /**
  33731. * An event triggered when a skeleton is created
  33732. */
  33733. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33734. /**
  33735. * An event triggered when a skeleton is removed
  33736. */
  33737. onSkeletonRemovedObservable: Observable<Skeleton>;
  33738. /**
  33739. * An event triggered when a material is created
  33740. */
  33741. onNewMaterialAddedObservable: Observable<Material>;
  33742. /**
  33743. * An event triggered when a material is removed
  33744. */
  33745. onMaterialRemovedObservable: Observable<Material>;
  33746. /**
  33747. * An event triggered when a texture is created
  33748. */
  33749. onNewTextureAddedObservable: Observable<BaseTexture>;
  33750. /**
  33751. * An event triggered when a texture is removed
  33752. */
  33753. onTextureRemovedObservable: Observable<BaseTexture>;
  33754. /**
  33755. * An event triggered when render targets are about to be rendered
  33756. * Can happen multiple times per frame.
  33757. */
  33758. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33759. /**
  33760. * An event triggered when render targets were rendered.
  33761. * Can happen multiple times per frame.
  33762. */
  33763. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33764. /**
  33765. * An event triggered before calculating deterministic simulation step
  33766. */
  33767. onBeforeStepObservable: Observable<Scene>;
  33768. /**
  33769. * An event triggered after calculating deterministic simulation step
  33770. */
  33771. onAfterStepObservable: Observable<Scene>;
  33772. /**
  33773. * An event triggered when the activeCamera property is updated
  33774. */
  33775. onActiveCameraChanged: Observable<Scene>;
  33776. /**
  33777. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33778. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33779. * 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)
  33780. */
  33781. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33782. /**
  33783. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33784. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33785. * 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)
  33786. */
  33787. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33788. /**
  33789. * This Observable will when a mesh has been imported into the scene.
  33790. */
  33791. onMeshImportedObservable: Observable<AbstractMesh>;
  33792. /**
  33793. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33794. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33795. */
  33796. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33797. /** @hidden */
  33798. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33799. /**
  33800. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33801. */
  33802. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33803. /**
  33804. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33805. */
  33806. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33807. /**
  33808. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33809. */
  33810. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33811. /** Callback called when a pointer move is detected */
  33812. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33813. /** Callback called when a pointer down is detected */
  33814. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33815. /** Callback called when a pointer up is detected */
  33816. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33817. /** Callback called when a pointer pick is detected */
  33818. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33819. /**
  33820. * 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).
  33821. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33822. */
  33823. onPrePointerObservable: Observable<PointerInfoPre>;
  33824. /**
  33825. * Observable event triggered each time an input event is received from the rendering canvas
  33826. */
  33827. onPointerObservable: Observable<PointerInfo>;
  33828. /**
  33829. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33830. */
  33831. readonly unTranslatedPointer: Vector2;
  33832. /**
  33833. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33834. */
  33835. static DragMovementThreshold: number;
  33836. /**
  33837. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33838. */
  33839. static LongPressDelay: number;
  33840. /**
  33841. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33842. */
  33843. static DoubleClickDelay: number;
  33844. /** If you need to check double click without raising a single click at first click, enable this flag */
  33845. static ExclusiveDoubleClickMode: boolean;
  33846. /** @hidden */
  33847. _mirroredCameraPosition: Nullable<Vector3>;
  33848. /**
  33849. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33850. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33851. */
  33852. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33853. /**
  33854. * Observable event triggered each time an keyboard event is received from the hosting window
  33855. */
  33856. onKeyboardObservable: Observable<KeyboardInfo>;
  33857. private _useRightHandedSystem;
  33858. /**
  33859. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33860. */
  33861. useRightHandedSystem: boolean;
  33862. private _timeAccumulator;
  33863. private _currentStepId;
  33864. private _currentInternalStep;
  33865. /**
  33866. * Sets the step Id used by deterministic lock step
  33867. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33868. * @param newStepId defines the step Id
  33869. */
  33870. setStepId(newStepId: number): void;
  33871. /**
  33872. * Gets the step Id used by deterministic lock step
  33873. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33874. * @returns the step Id
  33875. */
  33876. getStepId(): number;
  33877. /**
  33878. * Gets the internal step used by deterministic lock step
  33879. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33880. * @returns the internal step
  33881. */
  33882. getInternalStep(): number;
  33883. private _fogEnabled;
  33884. /**
  33885. * Gets or sets a boolean indicating if fog is enabled on this scene
  33886. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33887. * (Default is true)
  33888. */
  33889. fogEnabled: boolean;
  33890. private _fogMode;
  33891. /**
  33892. * Gets or sets the fog mode to use
  33893. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33894. * | mode | value |
  33895. * | --- | --- |
  33896. * | FOGMODE_NONE | 0 |
  33897. * | FOGMODE_EXP | 1 |
  33898. * | FOGMODE_EXP2 | 2 |
  33899. * | FOGMODE_LINEAR | 3 |
  33900. */
  33901. fogMode: number;
  33902. /**
  33903. * Gets or sets the fog color to use
  33904. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33905. * (Default is Color3(0.2, 0.2, 0.3))
  33906. */
  33907. fogColor: Color3;
  33908. /**
  33909. * Gets or sets the fog density to use
  33910. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33911. * (Default is 0.1)
  33912. */
  33913. fogDensity: number;
  33914. /**
  33915. * Gets or sets the fog start distance to use
  33916. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33917. * (Default is 0)
  33918. */
  33919. fogStart: number;
  33920. /**
  33921. * Gets or sets the fog end distance to use
  33922. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33923. * (Default is 1000)
  33924. */
  33925. fogEnd: number;
  33926. private _shadowsEnabled;
  33927. /**
  33928. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33929. */
  33930. shadowsEnabled: boolean;
  33931. private _lightsEnabled;
  33932. /**
  33933. * Gets or sets a boolean indicating if lights are enabled on this scene
  33934. */
  33935. lightsEnabled: boolean;
  33936. /** All of the active cameras added to this scene. */
  33937. activeCameras: Camera[];
  33938. /** @hidden */
  33939. _activeCamera: Nullable<Camera>;
  33940. /** Gets or sets the current active camera */
  33941. activeCamera: Nullable<Camera>;
  33942. private _defaultMaterial;
  33943. /** The default material used on meshes when no material is affected */
  33944. /** The default material used on meshes when no material is affected */
  33945. defaultMaterial: Material;
  33946. private _texturesEnabled;
  33947. /**
  33948. * Gets or sets a boolean indicating if textures are enabled on this scene
  33949. */
  33950. texturesEnabled: boolean;
  33951. /**
  33952. * Gets or sets a boolean indicating if particles are enabled on this scene
  33953. */
  33954. particlesEnabled: boolean;
  33955. /**
  33956. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33957. */
  33958. spritesEnabled: boolean;
  33959. private _skeletonsEnabled;
  33960. /**
  33961. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33962. */
  33963. skeletonsEnabled: boolean;
  33964. /**
  33965. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33966. */
  33967. lensFlaresEnabled: boolean;
  33968. /**
  33969. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33970. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33971. */
  33972. collisionsEnabled: boolean;
  33973. private _collisionCoordinator;
  33974. /** @hidden */
  33975. readonly collisionCoordinator: ICollisionCoordinator;
  33976. /**
  33977. * Defines the gravity applied to this scene (used only for collisions)
  33978. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33979. */
  33980. gravity: Vector3;
  33981. /**
  33982. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33983. */
  33984. postProcessesEnabled: boolean;
  33985. /**
  33986. * The list of postprocesses added to the scene
  33987. */
  33988. postProcesses: PostProcess[];
  33989. /**
  33990. * Gets the current postprocess manager
  33991. */
  33992. postProcessManager: PostProcessManager;
  33993. /**
  33994. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33995. */
  33996. renderTargetsEnabled: boolean;
  33997. /**
  33998. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33999. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34000. */
  34001. dumpNextRenderTargets: boolean;
  34002. /**
  34003. * The list of user defined render targets added to the scene
  34004. */
  34005. customRenderTargets: RenderTargetTexture[];
  34006. /**
  34007. * Defines if texture loading must be delayed
  34008. * If true, textures will only be loaded when they need to be rendered
  34009. */
  34010. useDelayedTextureLoading: boolean;
  34011. /**
  34012. * Gets the list of meshes imported to the scene through SceneLoader
  34013. */
  34014. importedMeshesFiles: String[];
  34015. /**
  34016. * Gets or sets a boolean indicating if probes are enabled on this scene
  34017. */
  34018. probesEnabled: boolean;
  34019. /**
  34020. * Gets or sets the current offline provider to use to store scene data
  34021. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34022. */
  34023. offlineProvider: IOfflineProvider;
  34024. /**
  34025. * Gets or sets the action manager associated with the scene
  34026. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34027. */
  34028. actionManager: AbstractActionManager;
  34029. private _meshesForIntersections;
  34030. /**
  34031. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34032. */
  34033. proceduralTexturesEnabled: boolean;
  34034. private _engine;
  34035. private _totalVertices;
  34036. /** @hidden */
  34037. _activeIndices: PerfCounter;
  34038. /** @hidden */
  34039. _activeParticles: PerfCounter;
  34040. /** @hidden */
  34041. _activeBones: PerfCounter;
  34042. private _animationRatio;
  34043. /** @hidden */
  34044. _animationTimeLast: number;
  34045. /** @hidden */
  34046. _animationTime: number;
  34047. /**
  34048. * Gets or sets a general scale for animation speed
  34049. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34050. */
  34051. animationTimeScale: number;
  34052. /** @hidden */
  34053. _cachedMaterial: Nullable<Material>;
  34054. /** @hidden */
  34055. _cachedEffect: Nullable<Effect>;
  34056. /** @hidden */
  34057. _cachedVisibility: Nullable<number>;
  34058. private _renderId;
  34059. private _frameId;
  34060. private _executeWhenReadyTimeoutId;
  34061. private _intermediateRendering;
  34062. private _viewUpdateFlag;
  34063. private _projectionUpdateFlag;
  34064. /** @hidden */
  34065. _toBeDisposed: Nullable<IDisposable>[];
  34066. private _activeRequests;
  34067. /** @hidden */
  34068. _pendingData: any[];
  34069. private _isDisposed;
  34070. /**
  34071. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34072. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34073. */
  34074. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34075. private _activeMeshes;
  34076. private _processedMaterials;
  34077. private _renderTargets;
  34078. /** @hidden */
  34079. _activeParticleSystems: SmartArray<IParticleSystem>;
  34080. private _activeSkeletons;
  34081. private _softwareSkinnedMeshes;
  34082. private _renderingManager;
  34083. /** @hidden */
  34084. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34085. private _transformMatrix;
  34086. private _sceneUbo;
  34087. /** @hidden */
  34088. _viewMatrix: Matrix;
  34089. private _projectionMatrix;
  34090. /** @hidden */
  34091. _forcedViewPosition: Nullable<Vector3>;
  34092. /** @hidden */
  34093. _frustumPlanes: Plane[];
  34094. /**
  34095. * Gets the list of frustum planes (built from the active camera)
  34096. */
  34097. readonly frustumPlanes: Plane[];
  34098. /**
  34099. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34100. * This is useful if there are more lights that the maximum simulteanous authorized
  34101. */
  34102. requireLightSorting: boolean;
  34103. /** @hidden */
  34104. readonly useMaterialMeshMap: boolean;
  34105. /** @hidden */
  34106. readonly useClonedMeshhMap: boolean;
  34107. private _externalData;
  34108. private _uid;
  34109. /**
  34110. * @hidden
  34111. * Backing store of defined scene components.
  34112. */
  34113. _components: ISceneComponent[];
  34114. /**
  34115. * @hidden
  34116. * Backing store of defined scene components.
  34117. */
  34118. _serializableComponents: ISceneSerializableComponent[];
  34119. /**
  34120. * List of components to register on the next registration step.
  34121. */
  34122. private _transientComponents;
  34123. /**
  34124. * Registers the transient components if needed.
  34125. */
  34126. private _registerTransientComponents;
  34127. /**
  34128. * @hidden
  34129. * Add a component to the scene.
  34130. * Note that the ccomponent could be registered on th next frame if this is called after
  34131. * the register component stage.
  34132. * @param component Defines the component to add to the scene
  34133. */
  34134. _addComponent(component: ISceneComponent): void;
  34135. /**
  34136. * @hidden
  34137. * Gets a component from the scene.
  34138. * @param name defines the name of the component to retrieve
  34139. * @returns the component or null if not present
  34140. */
  34141. _getComponent(name: string): Nullable<ISceneComponent>;
  34142. /**
  34143. * @hidden
  34144. * Defines the actions happening before camera updates.
  34145. */
  34146. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34147. /**
  34148. * @hidden
  34149. * Defines the actions happening before clear the canvas.
  34150. */
  34151. _beforeClearStage: Stage<SimpleStageAction>;
  34152. /**
  34153. * @hidden
  34154. * Defines the actions when collecting render targets for the frame.
  34155. */
  34156. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34157. /**
  34158. * @hidden
  34159. * Defines the actions happening for one camera in the frame.
  34160. */
  34161. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34162. /**
  34163. * @hidden
  34164. * Defines the actions happening during the per mesh ready checks.
  34165. */
  34166. _isReadyForMeshStage: Stage<MeshStageAction>;
  34167. /**
  34168. * @hidden
  34169. * Defines the actions happening before evaluate active mesh checks.
  34170. */
  34171. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34172. /**
  34173. * @hidden
  34174. * Defines the actions happening during the evaluate sub mesh checks.
  34175. */
  34176. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34177. /**
  34178. * @hidden
  34179. * Defines the actions happening during the active mesh stage.
  34180. */
  34181. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34182. /**
  34183. * @hidden
  34184. * Defines the actions happening during the per camera render target step.
  34185. */
  34186. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34187. /**
  34188. * @hidden
  34189. * Defines the actions happening just before the active camera is drawing.
  34190. */
  34191. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34192. /**
  34193. * @hidden
  34194. * Defines the actions happening just before a render target is drawing.
  34195. */
  34196. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34197. /**
  34198. * @hidden
  34199. * Defines the actions happening just before a rendering group is drawing.
  34200. */
  34201. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34202. /**
  34203. * @hidden
  34204. * Defines the actions happening just before a mesh is drawing.
  34205. */
  34206. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34207. /**
  34208. * @hidden
  34209. * Defines the actions happening just after a mesh has been drawn.
  34210. */
  34211. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34212. /**
  34213. * @hidden
  34214. * Defines the actions happening just after a rendering group has been drawn.
  34215. */
  34216. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34217. /**
  34218. * @hidden
  34219. * Defines the actions happening just after the active camera has been drawn.
  34220. */
  34221. _afterCameraDrawStage: Stage<CameraStageAction>;
  34222. /**
  34223. * @hidden
  34224. * Defines the actions happening just after a render target has been drawn.
  34225. */
  34226. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34227. /**
  34228. * @hidden
  34229. * Defines the actions happening just after rendering all cameras and computing intersections.
  34230. */
  34231. _afterRenderStage: Stage<SimpleStageAction>;
  34232. /**
  34233. * @hidden
  34234. * Defines the actions happening when a pointer move event happens.
  34235. */
  34236. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34237. /**
  34238. * @hidden
  34239. * Defines the actions happening when a pointer down event happens.
  34240. */
  34241. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34242. /**
  34243. * @hidden
  34244. * Defines the actions happening when a pointer up event happens.
  34245. */
  34246. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34247. /**
  34248. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34249. */
  34250. private geometriesByUniqueId;
  34251. /**
  34252. * Creates a new Scene
  34253. * @param engine defines the engine to use to render this scene
  34254. * @param options defines the scene options
  34255. */
  34256. constructor(engine: Engine, options?: SceneOptions);
  34257. /**
  34258. * Gets a string idenfifying the name of the class
  34259. * @returns "Scene" string
  34260. */
  34261. getClassName(): string;
  34262. private _defaultMeshCandidates;
  34263. /**
  34264. * @hidden
  34265. */
  34266. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34267. private _defaultSubMeshCandidates;
  34268. /**
  34269. * @hidden
  34270. */
  34271. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34272. /**
  34273. * Sets the default candidate providers for the scene.
  34274. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34275. * and getCollidingSubMeshCandidates to their default function
  34276. */
  34277. setDefaultCandidateProviders(): void;
  34278. /**
  34279. * Gets the mesh that is currently under the pointer
  34280. */
  34281. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34282. /**
  34283. * Gets or sets the current on-screen X position of the pointer
  34284. */
  34285. pointerX: number;
  34286. /**
  34287. * Gets or sets the current on-screen Y position of the pointer
  34288. */
  34289. pointerY: number;
  34290. /**
  34291. * Gets the cached material (ie. the latest rendered one)
  34292. * @returns the cached material
  34293. */
  34294. getCachedMaterial(): Nullable<Material>;
  34295. /**
  34296. * Gets the cached effect (ie. the latest rendered one)
  34297. * @returns the cached effect
  34298. */
  34299. getCachedEffect(): Nullable<Effect>;
  34300. /**
  34301. * Gets the cached visibility state (ie. the latest rendered one)
  34302. * @returns the cached visibility state
  34303. */
  34304. getCachedVisibility(): Nullable<number>;
  34305. /**
  34306. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34307. * @param material defines the current material
  34308. * @param effect defines the current effect
  34309. * @param visibility defines the current visibility state
  34310. * @returns true if one parameter is not cached
  34311. */
  34312. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34313. /**
  34314. * Gets the engine associated with the scene
  34315. * @returns an Engine
  34316. */
  34317. getEngine(): Engine;
  34318. /**
  34319. * Gets the total number of vertices rendered per frame
  34320. * @returns the total number of vertices rendered per frame
  34321. */
  34322. getTotalVertices(): number;
  34323. /**
  34324. * Gets the performance counter for total vertices
  34325. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34326. */
  34327. readonly totalVerticesPerfCounter: PerfCounter;
  34328. /**
  34329. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34330. * @returns the total number of active indices rendered per frame
  34331. */
  34332. getActiveIndices(): number;
  34333. /**
  34334. * Gets the performance counter for active indices
  34335. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34336. */
  34337. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34338. /**
  34339. * Gets the total number of active particles rendered per frame
  34340. * @returns the total number of active particles rendered per frame
  34341. */
  34342. getActiveParticles(): number;
  34343. /**
  34344. * Gets the performance counter for active particles
  34345. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34346. */
  34347. readonly activeParticlesPerfCounter: PerfCounter;
  34348. /**
  34349. * Gets the total number of active bones rendered per frame
  34350. * @returns the total number of active bones rendered per frame
  34351. */
  34352. getActiveBones(): number;
  34353. /**
  34354. * Gets the performance counter for active bones
  34355. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34356. */
  34357. readonly activeBonesPerfCounter: PerfCounter;
  34358. /**
  34359. * Gets the array of active meshes
  34360. * @returns an array of AbstractMesh
  34361. */
  34362. getActiveMeshes(): SmartArray<AbstractMesh>;
  34363. /**
  34364. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34365. * @returns a number
  34366. */
  34367. getAnimationRatio(): number;
  34368. /**
  34369. * Gets an unique Id for the current render phase
  34370. * @returns a number
  34371. */
  34372. getRenderId(): number;
  34373. /**
  34374. * Gets an unique Id for the current frame
  34375. * @returns a number
  34376. */
  34377. getFrameId(): number;
  34378. /** Call this function if you want to manually increment the render Id*/
  34379. incrementRenderId(): void;
  34380. private _createUbo;
  34381. /**
  34382. * Use this method to simulate a pointer move on a mesh
  34383. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34384. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34385. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34386. * @returns the current scene
  34387. */
  34388. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34389. /**
  34390. * Use this method to simulate a pointer down on a mesh
  34391. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34392. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34393. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34394. * @returns the current scene
  34395. */
  34396. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34397. /**
  34398. * Use this method to simulate a pointer up on a mesh
  34399. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34400. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34401. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34402. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34403. * @returns the current scene
  34404. */
  34405. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34406. /**
  34407. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34408. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34409. * @returns true if the pointer was captured
  34410. */
  34411. isPointerCaptured(pointerId?: number): boolean;
  34412. /**
  34413. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34414. * @param attachUp defines if you want to attach events to pointerup
  34415. * @param attachDown defines if you want to attach events to pointerdown
  34416. * @param attachMove defines if you want to attach events to pointermove
  34417. */
  34418. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34419. /** Detaches all event handlers*/
  34420. detachControl(): void;
  34421. /**
  34422. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34423. * Delay loaded resources are not taking in account
  34424. * @return true if all required resources are ready
  34425. */
  34426. isReady(): boolean;
  34427. /** Resets all cached information relative to material (including effect and visibility) */
  34428. resetCachedMaterial(): void;
  34429. /**
  34430. * Registers a function to be called before every frame render
  34431. * @param func defines the function to register
  34432. */
  34433. registerBeforeRender(func: () => void): void;
  34434. /**
  34435. * Unregisters a function called before every frame render
  34436. * @param func defines the function to unregister
  34437. */
  34438. unregisterBeforeRender(func: () => void): void;
  34439. /**
  34440. * Registers a function to be called after every frame render
  34441. * @param func defines the function to register
  34442. */
  34443. registerAfterRender(func: () => void): void;
  34444. /**
  34445. * Unregisters a function called after every frame render
  34446. * @param func defines the function to unregister
  34447. */
  34448. unregisterAfterRender(func: () => void): void;
  34449. private _executeOnceBeforeRender;
  34450. /**
  34451. * The provided function will run before render once and will be disposed afterwards.
  34452. * A timeout delay can be provided so that the function will be executed in N ms.
  34453. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34454. * @param func The function to be executed.
  34455. * @param timeout optional delay in ms
  34456. */
  34457. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34458. /** @hidden */
  34459. _addPendingData(data: any): void;
  34460. /** @hidden */
  34461. _removePendingData(data: any): void;
  34462. /**
  34463. * Returns the number of items waiting to be loaded
  34464. * @returns the number of items waiting to be loaded
  34465. */
  34466. getWaitingItemsCount(): number;
  34467. /**
  34468. * Returns a boolean indicating if the scene is still loading data
  34469. */
  34470. readonly isLoading: boolean;
  34471. /**
  34472. * Registers a function to be executed when the scene is ready
  34473. * @param {Function} func - the function to be executed
  34474. */
  34475. executeWhenReady(func: () => void): void;
  34476. /**
  34477. * Returns a promise that resolves when the scene is ready
  34478. * @returns A promise that resolves when the scene is ready
  34479. */
  34480. whenReadyAsync(): Promise<void>;
  34481. /** @hidden */
  34482. _checkIsReady(): void;
  34483. /**
  34484. * Gets all animatable attached to the scene
  34485. */
  34486. readonly animatables: Animatable[];
  34487. /**
  34488. * Resets the last animation time frame.
  34489. * Useful to override when animations start running when loading a scene for the first time.
  34490. */
  34491. resetLastAnimationTimeFrame(): void;
  34492. /**
  34493. * Gets the current view matrix
  34494. * @returns a Matrix
  34495. */
  34496. getViewMatrix(): Matrix;
  34497. /**
  34498. * Gets the current projection matrix
  34499. * @returns a Matrix
  34500. */
  34501. getProjectionMatrix(): Matrix;
  34502. /**
  34503. * Gets the current transform matrix
  34504. * @returns a Matrix made of View * Projection
  34505. */
  34506. getTransformMatrix(): Matrix;
  34507. /**
  34508. * Sets the current transform matrix
  34509. * @param viewL defines the View matrix to use
  34510. * @param projectionL defines the Projection matrix to use
  34511. * @param viewR defines the right View matrix to use (if provided)
  34512. * @param projectionR defines the right Projection matrix to use (if provided)
  34513. */
  34514. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34515. /**
  34516. * Gets the uniform buffer used to store scene data
  34517. * @returns a UniformBuffer
  34518. */
  34519. getSceneUniformBuffer(): UniformBuffer;
  34520. /**
  34521. * Gets an unique (relatively to the current scene) Id
  34522. * @returns an unique number for the scene
  34523. */
  34524. getUniqueId(): number;
  34525. /**
  34526. * Add a mesh to the list of scene's meshes
  34527. * @param newMesh defines the mesh to add
  34528. * @param recursive if all child meshes should also be added to the scene
  34529. */
  34530. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34531. /**
  34532. * Remove a mesh for the list of scene's meshes
  34533. * @param toRemove defines the mesh to remove
  34534. * @param recursive if all child meshes should also be removed from the scene
  34535. * @returns the index where the mesh was in the mesh list
  34536. */
  34537. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34538. /**
  34539. * Add a transform node to the list of scene's transform nodes
  34540. * @param newTransformNode defines the transform node to add
  34541. */
  34542. addTransformNode(newTransformNode: TransformNode): void;
  34543. /**
  34544. * Remove a transform node for the list of scene's transform nodes
  34545. * @param toRemove defines the transform node to remove
  34546. * @returns the index where the transform node was in the transform node list
  34547. */
  34548. removeTransformNode(toRemove: TransformNode): number;
  34549. /**
  34550. * Remove a skeleton for the list of scene's skeletons
  34551. * @param toRemove defines the skeleton to remove
  34552. * @returns the index where the skeleton was in the skeleton list
  34553. */
  34554. removeSkeleton(toRemove: Skeleton): number;
  34555. /**
  34556. * Remove a morph target for the list of scene's morph targets
  34557. * @param toRemove defines the morph target to remove
  34558. * @returns the index where the morph target was in the morph target list
  34559. */
  34560. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34561. /**
  34562. * Remove a light for the list of scene's lights
  34563. * @param toRemove defines the light to remove
  34564. * @returns the index where the light was in the light list
  34565. */
  34566. removeLight(toRemove: Light): number;
  34567. /**
  34568. * Remove a camera for the list of scene's cameras
  34569. * @param toRemove defines the camera to remove
  34570. * @returns the index where the camera was in the camera list
  34571. */
  34572. removeCamera(toRemove: Camera): number;
  34573. /**
  34574. * Remove a particle system for the list of scene's particle systems
  34575. * @param toRemove defines the particle system to remove
  34576. * @returns the index where the particle system was in the particle system list
  34577. */
  34578. removeParticleSystem(toRemove: IParticleSystem): number;
  34579. /**
  34580. * Remove a animation for the list of scene's animations
  34581. * @param toRemove defines the animation to remove
  34582. * @returns the index where the animation was in the animation list
  34583. */
  34584. removeAnimation(toRemove: Animation): number;
  34585. /**
  34586. * Will stop the animation of the given target
  34587. * @param target - the target
  34588. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34589. * @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)
  34590. */
  34591. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34592. /**
  34593. * Removes the given animation group from this scene.
  34594. * @param toRemove The animation group to remove
  34595. * @returns The index of the removed animation group
  34596. */
  34597. removeAnimationGroup(toRemove: AnimationGroup): number;
  34598. /**
  34599. * Removes the given multi-material from this scene.
  34600. * @param toRemove The multi-material to remove
  34601. * @returns The index of the removed multi-material
  34602. */
  34603. removeMultiMaterial(toRemove: MultiMaterial): number;
  34604. /**
  34605. * Removes the given material from this scene.
  34606. * @param toRemove The material to remove
  34607. * @returns The index of the removed material
  34608. */
  34609. removeMaterial(toRemove: Material): number;
  34610. /**
  34611. * Removes the given action manager from this scene.
  34612. * @param toRemove The action manager to remove
  34613. * @returns The index of the removed action manager
  34614. */
  34615. removeActionManager(toRemove: AbstractActionManager): number;
  34616. /**
  34617. * Removes the given texture from this scene.
  34618. * @param toRemove The texture to remove
  34619. * @returns The index of the removed texture
  34620. */
  34621. removeTexture(toRemove: BaseTexture): number;
  34622. /**
  34623. * Adds the given light to this scene
  34624. * @param newLight The light to add
  34625. */
  34626. addLight(newLight: Light): void;
  34627. /**
  34628. * Sorts the list list based on light priorities
  34629. */
  34630. sortLightsByPriority(): void;
  34631. /**
  34632. * Adds the given camera to this scene
  34633. * @param newCamera The camera to add
  34634. */
  34635. addCamera(newCamera: Camera): void;
  34636. /**
  34637. * Adds the given skeleton to this scene
  34638. * @param newSkeleton The skeleton to add
  34639. */
  34640. addSkeleton(newSkeleton: Skeleton): void;
  34641. /**
  34642. * Adds the given particle system to this scene
  34643. * @param newParticleSystem The particle system to add
  34644. */
  34645. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34646. /**
  34647. * Adds the given animation to this scene
  34648. * @param newAnimation The animation to add
  34649. */
  34650. addAnimation(newAnimation: Animation): void;
  34651. /**
  34652. * Adds the given animation group to this scene.
  34653. * @param newAnimationGroup The animation group to add
  34654. */
  34655. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34656. /**
  34657. * Adds the given multi-material to this scene
  34658. * @param newMultiMaterial The multi-material to add
  34659. */
  34660. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34661. /**
  34662. * Adds the given material to this scene
  34663. * @param newMaterial The material to add
  34664. */
  34665. addMaterial(newMaterial: Material): void;
  34666. /**
  34667. * Adds the given morph target to this scene
  34668. * @param newMorphTargetManager The morph target to add
  34669. */
  34670. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34671. /**
  34672. * Adds the given geometry to this scene
  34673. * @param newGeometry The geometry to add
  34674. */
  34675. addGeometry(newGeometry: Geometry): void;
  34676. /**
  34677. * Adds the given action manager to this scene
  34678. * @param newActionManager The action manager to add
  34679. */
  34680. addActionManager(newActionManager: AbstractActionManager): void;
  34681. /**
  34682. * Adds the given texture to this scene.
  34683. * @param newTexture The texture to add
  34684. */
  34685. addTexture(newTexture: BaseTexture): void;
  34686. /**
  34687. * Switch active camera
  34688. * @param newCamera defines the new active camera
  34689. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34690. */
  34691. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34692. /**
  34693. * sets the active camera of the scene using its ID
  34694. * @param id defines the camera's ID
  34695. * @return the new active camera or null if none found.
  34696. */
  34697. setActiveCameraByID(id: string): Nullable<Camera>;
  34698. /**
  34699. * sets the active camera of the scene using its name
  34700. * @param name defines the camera's name
  34701. * @returns the new active camera or null if none found.
  34702. */
  34703. setActiveCameraByName(name: string): Nullable<Camera>;
  34704. /**
  34705. * get an animation group using its name
  34706. * @param name defines the material's name
  34707. * @return the animation group or null if none found.
  34708. */
  34709. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34710. /**
  34711. * Get a material using its unique id
  34712. * @param uniqueId defines the material's unique id
  34713. * @return the material or null if none found.
  34714. */
  34715. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34716. /**
  34717. * get a material using its id
  34718. * @param id defines the material's ID
  34719. * @return the material or null if none found.
  34720. */
  34721. getMaterialByID(id: string): Nullable<Material>;
  34722. /**
  34723. * Gets a the last added material using a given id
  34724. * @param id defines the material's ID
  34725. * @return the last material with the given id or null if none found.
  34726. */
  34727. getLastMaterialByID(id: string): Nullable<Material>;
  34728. /**
  34729. * Gets a material using its name
  34730. * @param name defines the material's name
  34731. * @return the material or null if none found.
  34732. */
  34733. getMaterialByName(name: string): Nullable<Material>;
  34734. /**
  34735. * Gets a camera using its id
  34736. * @param id defines the id to look for
  34737. * @returns the camera or null if not found
  34738. */
  34739. getCameraByID(id: string): Nullable<Camera>;
  34740. /**
  34741. * Gets a camera using its unique id
  34742. * @param uniqueId defines the unique id to look for
  34743. * @returns the camera or null if not found
  34744. */
  34745. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34746. /**
  34747. * Gets a camera using its name
  34748. * @param name defines the camera's name
  34749. * @return the camera or null if none found.
  34750. */
  34751. getCameraByName(name: string): Nullable<Camera>;
  34752. /**
  34753. * Gets a bone using its id
  34754. * @param id defines the bone's id
  34755. * @return the bone or null if not found
  34756. */
  34757. getBoneByID(id: string): Nullable<Bone>;
  34758. /**
  34759. * Gets a bone using its id
  34760. * @param name defines the bone's name
  34761. * @return the bone or null if not found
  34762. */
  34763. getBoneByName(name: string): Nullable<Bone>;
  34764. /**
  34765. * Gets a light node using its name
  34766. * @param name defines the the light's name
  34767. * @return the light or null if none found.
  34768. */
  34769. getLightByName(name: string): Nullable<Light>;
  34770. /**
  34771. * Gets a light node using its id
  34772. * @param id defines the light's id
  34773. * @return the light or null if none found.
  34774. */
  34775. getLightByID(id: string): Nullable<Light>;
  34776. /**
  34777. * Gets a light node using its scene-generated unique ID
  34778. * @param uniqueId defines the light's unique id
  34779. * @return the light or null if none found.
  34780. */
  34781. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34782. /**
  34783. * Gets a particle system by id
  34784. * @param id defines the particle system id
  34785. * @return the corresponding system or null if none found
  34786. */
  34787. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34788. /**
  34789. * Gets a geometry using its ID
  34790. * @param id defines the geometry's id
  34791. * @return the geometry or null if none found.
  34792. */
  34793. getGeometryByID(id: string): Nullable<Geometry>;
  34794. private _getGeometryByUniqueID;
  34795. /**
  34796. * Add a new geometry to this scene
  34797. * @param geometry defines the geometry to be added to the scene.
  34798. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34799. * @return a boolean defining if the geometry was added or not
  34800. */
  34801. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34802. /**
  34803. * Removes an existing geometry
  34804. * @param geometry defines the geometry to be removed from the scene
  34805. * @return a boolean defining if the geometry was removed or not
  34806. */
  34807. removeGeometry(geometry: Geometry): boolean;
  34808. /**
  34809. * Gets the list of geometries attached to the scene
  34810. * @returns an array of Geometry
  34811. */
  34812. getGeometries(): Geometry[];
  34813. /**
  34814. * Gets the first added mesh found of a given ID
  34815. * @param id defines the id to search for
  34816. * @return the mesh found or null if not found at all
  34817. */
  34818. getMeshByID(id: string): Nullable<AbstractMesh>;
  34819. /**
  34820. * Gets a list of meshes using their id
  34821. * @param id defines the id to search for
  34822. * @returns a list of meshes
  34823. */
  34824. getMeshesByID(id: string): Array<AbstractMesh>;
  34825. /**
  34826. * Gets the first added transform node found of a given ID
  34827. * @param id defines the id to search for
  34828. * @return the found transform node or null if not found at all.
  34829. */
  34830. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34831. /**
  34832. * Gets a transform node with its auto-generated unique id
  34833. * @param uniqueId efines the unique id to search for
  34834. * @return the found transform node or null if not found at all.
  34835. */
  34836. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34837. /**
  34838. * Gets a list of transform nodes using their id
  34839. * @param id defines the id to search for
  34840. * @returns a list of transform nodes
  34841. */
  34842. getTransformNodesByID(id: string): Array<TransformNode>;
  34843. /**
  34844. * Gets a mesh with its auto-generated unique id
  34845. * @param uniqueId defines the unique id to search for
  34846. * @return the found mesh or null if not found at all.
  34847. */
  34848. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34849. /**
  34850. * Gets a the last added mesh using a given id
  34851. * @param id defines the id to search for
  34852. * @return the found mesh or null if not found at all.
  34853. */
  34854. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34855. /**
  34856. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34857. * @param id defines the id to search for
  34858. * @return the found node or null if not found at all
  34859. */
  34860. getLastEntryByID(id: string): Nullable<Node>;
  34861. /**
  34862. * Gets a node (Mesh, Camera, Light) using a given id
  34863. * @param id defines the id to search for
  34864. * @return the found node or null if not found at all
  34865. */
  34866. getNodeByID(id: string): Nullable<Node>;
  34867. /**
  34868. * Gets a node (Mesh, Camera, Light) using a given name
  34869. * @param name defines the name to search for
  34870. * @return the found node or null if not found at all.
  34871. */
  34872. getNodeByName(name: string): Nullable<Node>;
  34873. /**
  34874. * Gets a mesh using a given name
  34875. * @param name defines the name to search for
  34876. * @return the found mesh or null if not found at all.
  34877. */
  34878. getMeshByName(name: string): Nullable<AbstractMesh>;
  34879. /**
  34880. * Gets a transform node using a given name
  34881. * @param name defines the name to search for
  34882. * @return the found transform node or null if not found at all.
  34883. */
  34884. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34885. /**
  34886. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34887. * @param id defines the id to search for
  34888. * @return the found skeleton or null if not found at all.
  34889. */
  34890. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34891. /**
  34892. * Gets a skeleton using a given auto generated unique id
  34893. * @param uniqueId defines the unique id to search for
  34894. * @return the found skeleton or null if not found at all.
  34895. */
  34896. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34897. /**
  34898. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34899. * @param id defines the id to search for
  34900. * @return the found skeleton or null if not found at all.
  34901. */
  34902. getSkeletonById(id: string): Nullable<Skeleton>;
  34903. /**
  34904. * Gets a skeleton using a given name
  34905. * @param name defines the name to search for
  34906. * @return the found skeleton or null if not found at all.
  34907. */
  34908. getSkeletonByName(name: string): Nullable<Skeleton>;
  34909. /**
  34910. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34911. * @param id defines the id to search for
  34912. * @return the found morph target manager or null if not found at all.
  34913. */
  34914. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34915. /**
  34916. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34917. * @param id defines the id to search for
  34918. * @return the found morph target or null if not found at all.
  34919. */
  34920. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34921. /**
  34922. * Gets a boolean indicating if the given mesh is active
  34923. * @param mesh defines the mesh to look for
  34924. * @returns true if the mesh is in the active list
  34925. */
  34926. isActiveMesh(mesh: AbstractMesh): boolean;
  34927. /**
  34928. * Return a unique id as a string which can serve as an identifier for the scene
  34929. */
  34930. readonly uid: string;
  34931. /**
  34932. * Add an externaly attached data from its key.
  34933. * This method call will fail and return false, if such key already exists.
  34934. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34935. * @param key the unique key that identifies the data
  34936. * @param data the data object to associate to the key for this Engine instance
  34937. * @return true if no such key were already present and the data was added successfully, false otherwise
  34938. */
  34939. addExternalData<T>(key: string, data: T): boolean;
  34940. /**
  34941. * Get an externaly attached data from its key
  34942. * @param key the unique key that identifies the data
  34943. * @return the associated data, if present (can be null), or undefined if not present
  34944. */
  34945. getExternalData<T>(key: string): Nullable<T>;
  34946. /**
  34947. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34948. * @param key the unique key that identifies the data
  34949. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34950. * @return the associated data, can be null if the factory returned null.
  34951. */
  34952. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34953. /**
  34954. * Remove an externaly attached data from the Engine instance
  34955. * @param key the unique key that identifies the data
  34956. * @return true if the data was successfully removed, false if it doesn't exist
  34957. */
  34958. removeExternalData(key: string): boolean;
  34959. private _evaluateSubMesh;
  34960. /**
  34961. * Clear the processed materials smart array preventing retention point in material dispose.
  34962. */
  34963. freeProcessedMaterials(): void;
  34964. private _preventFreeActiveMeshesAndRenderingGroups;
  34965. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34966. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34967. * when disposing several meshes in a row or a hierarchy of meshes.
  34968. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34969. */
  34970. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34971. /**
  34972. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34973. */
  34974. freeActiveMeshes(): void;
  34975. /**
  34976. * Clear the info related to rendering groups preventing retention points during dispose.
  34977. */
  34978. freeRenderingGroups(): void;
  34979. /** @hidden */
  34980. _isInIntermediateRendering(): boolean;
  34981. /**
  34982. * Lambda returning the list of potentially active meshes.
  34983. */
  34984. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34985. /**
  34986. * Lambda returning the list of potentially active sub meshes.
  34987. */
  34988. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34989. /**
  34990. * Lambda returning the list of potentially intersecting sub meshes.
  34991. */
  34992. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34993. /**
  34994. * Lambda returning the list of potentially colliding sub meshes.
  34995. */
  34996. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34997. private _activeMeshesFrozen;
  34998. /**
  34999. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35000. * @returns the current scene
  35001. */
  35002. freezeActiveMeshes(): Scene;
  35003. /**
  35004. * Use this function to restart evaluating active meshes on every frame
  35005. * @returns the current scene
  35006. */
  35007. unfreezeActiveMeshes(): Scene;
  35008. private _evaluateActiveMeshes;
  35009. private _activeMesh;
  35010. /**
  35011. * Update the transform matrix to update from the current active camera
  35012. * @param force defines a boolean used to force the update even if cache is up to date
  35013. */
  35014. updateTransformMatrix(force?: boolean): void;
  35015. private _bindFrameBuffer;
  35016. /** @hidden */
  35017. _allowPostProcessClearColor: boolean;
  35018. /** @hidden */
  35019. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35020. private _processSubCameras;
  35021. private _checkIntersections;
  35022. /** @hidden */
  35023. _advancePhysicsEngineStep(step: number): void;
  35024. /**
  35025. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35026. */
  35027. getDeterministicFrameTime: () => number;
  35028. /** @hidden */
  35029. _animate(): void;
  35030. /** Execute all animations (for a frame) */
  35031. animate(): void;
  35032. /**
  35033. * Render the scene
  35034. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35035. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35036. */
  35037. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35038. /**
  35039. * Freeze all materials
  35040. * A frozen material will not be updatable but should be faster to render
  35041. */
  35042. freezeMaterials(): void;
  35043. /**
  35044. * Unfreeze all materials
  35045. * A frozen material will not be updatable but should be faster to render
  35046. */
  35047. unfreezeMaterials(): void;
  35048. /**
  35049. * Releases all held ressources
  35050. */
  35051. dispose(): void;
  35052. /**
  35053. * Gets if the scene is already disposed
  35054. */
  35055. readonly isDisposed: boolean;
  35056. /**
  35057. * Call this function to reduce memory footprint of the scene.
  35058. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35059. */
  35060. clearCachedVertexData(): void;
  35061. /**
  35062. * This function will remove the local cached buffer data from texture.
  35063. * It will save memory but will prevent the texture from being rebuilt
  35064. */
  35065. cleanCachedTextureBuffer(): void;
  35066. /**
  35067. * Get the world extend vectors with an optional filter
  35068. *
  35069. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35070. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35071. */
  35072. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35073. min: Vector3;
  35074. max: Vector3;
  35075. };
  35076. /**
  35077. * Creates a ray that can be used to pick in the scene
  35078. * @param x defines the x coordinate of the origin (on-screen)
  35079. * @param y defines the y coordinate of the origin (on-screen)
  35080. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35081. * @param camera defines the camera to use for the picking
  35082. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35083. * @returns a Ray
  35084. */
  35085. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35086. /**
  35087. * Creates a ray that can be used to pick in the scene
  35088. * @param x defines the x coordinate of the origin (on-screen)
  35089. * @param y defines the y coordinate of the origin (on-screen)
  35090. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35091. * @param result defines the ray where to store the picking ray
  35092. * @param camera defines the camera to use for the picking
  35093. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35094. * @returns the current scene
  35095. */
  35096. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35097. /**
  35098. * Creates a ray that can be used to pick in the scene
  35099. * @param x defines the x coordinate of the origin (on-screen)
  35100. * @param y defines the y coordinate of the origin (on-screen)
  35101. * @param camera defines the camera to use for the picking
  35102. * @returns a Ray
  35103. */
  35104. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35105. /**
  35106. * Creates a ray that can be used to pick in the scene
  35107. * @param x defines the x coordinate of the origin (on-screen)
  35108. * @param y defines the y coordinate of the origin (on-screen)
  35109. * @param result defines the ray where to store the picking ray
  35110. * @param camera defines the camera to use for the picking
  35111. * @returns the current scene
  35112. */
  35113. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35114. /** Launch a ray to try to pick a mesh in the scene
  35115. * @param x position on screen
  35116. * @param y position on screen
  35117. * @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
  35118. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35119. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35120. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35121. * @returns a PickingInfo
  35122. */
  35123. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35124. /** Use the given ray to pick a mesh in the scene
  35125. * @param ray The ray to use to pick meshes
  35126. * @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
  35127. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35128. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35129. * @returns a PickingInfo
  35130. */
  35131. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35132. /**
  35133. * Launch a ray to try to pick a mesh in the scene
  35134. * @param x X position on screen
  35135. * @param y Y position on screen
  35136. * @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
  35137. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35138. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35139. * @returns an array of PickingInfo
  35140. */
  35141. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35142. /**
  35143. * Launch a ray to try to pick a mesh in the scene
  35144. * @param ray Ray to use
  35145. * @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
  35146. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35147. * @returns an array of PickingInfo
  35148. */
  35149. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35150. /**
  35151. * Force the value of meshUnderPointer
  35152. * @param mesh defines the mesh to use
  35153. */
  35154. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35155. /**
  35156. * Gets the mesh under the pointer
  35157. * @returns a Mesh or null if no mesh is under the pointer
  35158. */
  35159. getPointerOverMesh(): Nullable<AbstractMesh>;
  35160. /** @hidden */
  35161. _rebuildGeometries(): void;
  35162. /** @hidden */
  35163. _rebuildTextures(): void;
  35164. private _getByTags;
  35165. /**
  35166. * Get a list of meshes by tags
  35167. * @param tagsQuery defines the tags query to use
  35168. * @param forEach defines a predicate used to filter results
  35169. * @returns an array of Mesh
  35170. */
  35171. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35172. /**
  35173. * Get a list of cameras by tags
  35174. * @param tagsQuery defines the tags query to use
  35175. * @param forEach defines a predicate used to filter results
  35176. * @returns an array of Camera
  35177. */
  35178. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35179. /**
  35180. * Get a list of lights by tags
  35181. * @param tagsQuery defines the tags query to use
  35182. * @param forEach defines a predicate used to filter results
  35183. * @returns an array of Light
  35184. */
  35185. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35186. /**
  35187. * Get a list of materials by tags
  35188. * @param tagsQuery defines the tags query to use
  35189. * @param forEach defines a predicate used to filter results
  35190. * @returns an array of Material
  35191. */
  35192. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35193. /**
  35194. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35195. * This allowed control for front to back rendering or reversly depending of the special needs.
  35196. *
  35197. * @param renderingGroupId The rendering group id corresponding to its index
  35198. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35199. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35200. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35201. */
  35202. 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;
  35203. /**
  35204. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35205. *
  35206. * @param renderingGroupId The rendering group id corresponding to its index
  35207. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35208. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35209. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35210. */
  35211. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35212. /**
  35213. * Gets the current auto clear configuration for one rendering group of the rendering
  35214. * manager.
  35215. * @param index the rendering group index to get the information for
  35216. * @returns The auto clear setup for the requested rendering group
  35217. */
  35218. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35219. private _blockMaterialDirtyMechanism;
  35220. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35221. blockMaterialDirtyMechanism: boolean;
  35222. /**
  35223. * Will flag all materials as dirty to trigger new shader compilation
  35224. * @param flag defines the flag used to specify which material part must be marked as dirty
  35225. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35226. */
  35227. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35228. /** @hidden */
  35229. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  35230. /** @hidden */
  35231. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35232. }
  35233. }
  35234. declare module "babylonjs/assetContainer" {
  35235. import { AbstractScene } from "babylonjs/abstractScene";
  35236. import { Scene } from "babylonjs/scene";
  35237. import { Mesh } from "babylonjs/Meshes/mesh";
  35238. /**
  35239. * Set of assets to keep when moving a scene into an asset container.
  35240. */
  35241. export class KeepAssets extends AbstractScene {
  35242. }
  35243. /**
  35244. * Container with a set of assets that can be added or removed from a scene.
  35245. */
  35246. export class AssetContainer extends AbstractScene {
  35247. /**
  35248. * The scene the AssetContainer belongs to.
  35249. */
  35250. scene: Scene;
  35251. /**
  35252. * Instantiates an AssetContainer.
  35253. * @param scene The scene the AssetContainer belongs to.
  35254. */
  35255. constructor(scene: Scene);
  35256. /**
  35257. * Adds all the assets from the container to the scene.
  35258. */
  35259. addAllToScene(): void;
  35260. /**
  35261. * Removes all the assets in the container from the scene
  35262. */
  35263. removeAllFromScene(): void;
  35264. /**
  35265. * Disposes all the assets in the container
  35266. */
  35267. dispose(): void;
  35268. private _moveAssets;
  35269. /**
  35270. * Removes all the assets contained in the scene and adds them to the container.
  35271. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35272. */
  35273. moveAllFromScene(keepAssets?: KeepAssets): void;
  35274. /**
  35275. * 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.
  35276. * @returns the root mesh
  35277. */
  35278. createRootMesh(): Mesh;
  35279. }
  35280. }
  35281. declare module "babylonjs/abstractScene" {
  35282. import { Scene } from "babylonjs/scene";
  35283. import { Nullable } from "babylonjs/types";
  35284. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35285. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35286. import { Geometry } from "babylonjs/Meshes/geometry";
  35287. import { Skeleton } from "babylonjs/Bones/skeleton";
  35288. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35289. import { AssetContainer } from "babylonjs/assetContainer";
  35290. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35291. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35292. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35293. import { Material } from "babylonjs/Materials/material";
  35294. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35295. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35296. import { Camera } from "babylonjs/Cameras/camera";
  35297. import { Light } from "babylonjs/Lights/light";
  35298. import { Node } from "babylonjs/node";
  35299. import { Animation } from "babylonjs/Animations/animation";
  35300. /**
  35301. * Defines how the parser contract is defined.
  35302. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35303. */
  35304. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35305. /**
  35306. * Defines how the individual parser contract is defined.
  35307. * These parser can parse an individual asset
  35308. */
  35309. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35310. /**
  35311. * Base class of the scene acting as a container for the different elements composing a scene.
  35312. * This class is dynamically extended by the different components of the scene increasing
  35313. * flexibility and reducing coupling
  35314. */
  35315. export abstract class AbstractScene {
  35316. /**
  35317. * Stores the list of available parsers in the application.
  35318. */
  35319. private static _BabylonFileParsers;
  35320. /**
  35321. * Stores the list of available individual parsers in the application.
  35322. */
  35323. private static _IndividualBabylonFileParsers;
  35324. /**
  35325. * Adds a parser in the list of available ones
  35326. * @param name Defines the name of the parser
  35327. * @param parser Defines the parser to add
  35328. */
  35329. static AddParser(name: string, parser: BabylonFileParser): void;
  35330. /**
  35331. * Gets a general parser from the list of avaialble ones
  35332. * @param name Defines the name of the parser
  35333. * @returns the requested parser or null
  35334. */
  35335. static GetParser(name: string): Nullable<BabylonFileParser>;
  35336. /**
  35337. * Adds n individual parser in the list of available ones
  35338. * @param name Defines the name of the parser
  35339. * @param parser Defines the parser to add
  35340. */
  35341. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35342. /**
  35343. * Gets an individual parser from the list of avaialble ones
  35344. * @param name Defines the name of the parser
  35345. * @returns the requested parser or null
  35346. */
  35347. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35348. /**
  35349. * Parser json data and populate both a scene and its associated container object
  35350. * @param jsonData Defines the data to parse
  35351. * @param scene Defines the scene to parse the data for
  35352. * @param container Defines the container attached to the parsing sequence
  35353. * @param rootUrl Defines the root url of the data
  35354. */
  35355. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35356. /**
  35357. * Gets the list of root nodes (ie. nodes with no parent)
  35358. */
  35359. rootNodes: Node[];
  35360. /** All of the cameras added to this scene
  35361. * @see http://doc.babylonjs.com/babylon101/cameras
  35362. */
  35363. cameras: Camera[];
  35364. /**
  35365. * All of the lights added to this scene
  35366. * @see http://doc.babylonjs.com/babylon101/lights
  35367. */
  35368. lights: Light[];
  35369. /**
  35370. * All of the (abstract) meshes added to this scene
  35371. */
  35372. meshes: AbstractMesh[];
  35373. /**
  35374. * The list of skeletons added to the scene
  35375. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35376. */
  35377. skeletons: Skeleton[];
  35378. /**
  35379. * All of the particle systems added to this scene
  35380. * @see http://doc.babylonjs.com/babylon101/particles
  35381. */
  35382. particleSystems: IParticleSystem[];
  35383. /**
  35384. * Gets a list of Animations associated with the scene
  35385. */
  35386. animations: Animation[];
  35387. /**
  35388. * All of the animation groups added to this scene
  35389. * @see http://doc.babylonjs.com/how_to/group
  35390. */
  35391. animationGroups: AnimationGroup[];
  35392. /**
  35393. * All of the multi-materials added to this scene
  35394. * @see http://doc.babylonjs.com/how_to/multi_materials
  35395. */
  35396. multiMaterials: MultiMaterial[];
  35397. /**
  35398. * All of the materials added to this scene
  35399. * In the context of a Scene, it is not supposed to be modified manually.
  35400. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35401. * Note also that the order of the Material wihin the array is not significant and might change.
  35402. * @see http://doc.babylonjs.com/babylon101/materials
  35403. */
  35404. materials: Material[];
  35405. /**
  35406. * The list of morph target managers added to the scene
  35407. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35408. */
  35409. morphTargetManagers: MorphTargetManager[];
  35410. /**
  35411. * The list of geometries used in the scene.
  35412. */
  35413. geometries: Geometry[];
  35414. /**
  35415. * All of the tranform nodes added to this scene
  35416. * In the context of a Scene, it is not supposed to be modified manually.
  35417. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35418. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35419. * @see http://doc.babylonjs.com/how_to/transformnode
  35420. */
  35421. transformNodes: TransformNode[];
  35422. /**
  35423. * ActionManagers available on the scene.
  35424. */
  35425. actionManagers: AbstractActionManager[];
  35426. /**
  35427. * Textures to keep.
  35428. */
  35429. textures: BaseTexture[];
  35430. /**
  35431. * Environment texture for the scene
  35432. */
  35433. environmentTexture: Nullable<BaseTexture>;
  35434. }
  35435. }
  35436. declare module "babylonjs/Audio/sound" {
  35437. import { Observable } from "babylonjs/Misc/observable";
  35438. import { Vector3 } from "babylonjs/Maths/math.vector";
  35439. import { Nullable } from "babylonjs/types";
  35440. import { Scene } from "babylonjs/scene";
  35441. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35442. /**
  35443. * Interface used to define options for Sound class
  35444. */
  35445. export interface ISoundOptions {
  35446. /**
  35447. * Does the sound autoplay once loaded.
  35448. */
  35449. autoplay?: boolean;
  35450. /**
  35451. * Does the sound loop after it finishes playing once.
  35452. */
  35453. loop?: boolean;
  35454. /**
  35455. * Sound's volume
  35456. */
  35457. volume?: number;
  35458. /**
  35459. * Is it a spatial sound?
  35460. */
  35461. spatialSound?: boolean;
  35462. /**
  35463. * Maximum distance to hear that sound
  35464. */
  35465. maxDistance?: number;
  35466. /**
  35467. * Uses user defined attenuation function
  35468. */
  35469. useCustomAttenuation?: boolean;
  35470. /**
  35471. * Define the roll off factor of spatial sounds.
  35472. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35473. */
  35474. rolloffFactor?: number;
  35475. /**
  35476. * Define the reference distance the sound should be heard perfectly.
  35477. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35478. */
  35479. refDistance?: number;
  35480. /**
  35481. * Define the distance attenuation model the sound will follow.
  35482. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35483. */
  35484. distanceModel?: string;
  35485. /**
  35486. * Defines the playback speed (1 by default)
  35487. */
  35488. playbackRate?: number;
  35489. /**
  35490. * Defines if the sound is from a streaming source
  35491. */
  35492. streaming?: boolean;
  35493. /**
  35494. * Defines an optional length (in seconds) inside the sound file
  35495. */
  35496. length?: number;
  35497. /**
  35498. * Defines an optional offset (in seconds) inside the sound file
  35499. */
  35500. offset?: number;
  35501. /**
  35502. * If true, URLs will not be required to state the audio file codec to use.
  35503. */
  35504. skipCodecCheck?: boolean;
  35505. }
  35506. /**
  35507. * Defines a sound that can be played in the application.
  35508. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35509. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35510. */
  35511. export class Sound {
  35512. /**
  35513. * The name of the sound in the scene.
  35514. */
  35515. name: string;
  35516. /**
  35517. * Does the sound autoplay once loaded.
  35518. */
  35519. autoplay: boolean;
  35520. /**
  35521. * Does the sound loop after it finishes playing once.
  35522. */
  35523. loop: boolean;
  35524. /**
  35525. * Does the sound use a custom attenuation curve to simulate the falloff
  35526. * happening when the source gets further away from the camera.
  35527. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35528. */
  35529. useCustomAttenuation: boolean;
  35530. /**
  35531. * The sound track id this sound belongs to.
  35532. */
  35533. soundTrackId: number;
  35534. /**
  35535. * Is this sound currently played.
  35536. */
  35537. isPlaying: boolean;
  35538. /**
  35539. * Is this sound currently paused.
  35540. */
  35541. isPaused: boolean;
  35542. /**
  35543. * Does this sound enables spatial sound.
  35544. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35545. */
  35546. spatialSound: boolean;
  35547. /**
  35548. * Define the reference distance the sound should be heard perfectly.
  35549. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35550. */
  35551. refDistance: number;
  35552. /**
  35553. * Define the roll off factor of spatial sounds.
  35554. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35555. */
  35556. rolloffFactor: number;
  35557. /**
  35558. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35559. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35560. */
  35561. maxDistance: number;
  35562. /**
  35563. * Define the distance attenuation model the sound will follow.
  35564. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35565. */
  35566. distanceModel: string;
  35567. /**
  35568. * @hidden
  35569. * Back Compat
  35570. **/
  35571. onended: () => any;
  35572. /**
  35573. * Observable event when the current playing sound finishes.
  35574. */
  35575. onEndedObservable: Observable<Sound>;
  35576. private _panningModel;
  35577. private _playbackRate;
  35578. private _streaming;
  35579. private _startTime;
  35580. private _startOffset;
  35581. private _position;
  35582. /** @hidden */
  35583. _positionInEmitterSpace: boolean;
  35584. private _localDirection;
  35585. private _volume;
  35586. private _isReadyToPlay;
  35587. private _isDirectional;
  35588. private _readyToPlayCallback;
  35589. private _audioBuffer;
  35590. private _soundSource;
  35591. private _streamingSource;
  35592. private _soundPanner;
  35593. private _soundGain;
  35594. private _inputAudioNode;
  35595. private _outputAudioNode;
  35596. private _coneInnerAngle;
  35597. private _coneOuterAngle;
  35598. private _coneOuterGain;
  35599. private _scene;
  35600. private _connectedTransformNode;
  35601. private _customAttenuationFunction;
  35602. private _registerFunc;
  35603. private _isOutputConnected;
  35604. private _htmlAudioElement;
  35605. private _urlType;
  35606. private _length?;
  35607. private _offset?;
  35608. /** @hidden */
  35609. static _SceneComponentInitialization: (scene: Scene) => void;
  35610. /**
  35611. * Create a sound and attach it to a scene
  35612. * @param name Name of your sound
  35613. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35614. * @param scene defines the scene the sound belongs to
  35615. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35616. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35617. */
  35618. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35619. /**
  35620. * Release the sound and its associated resources
  35621. */
  35622. dispose(): void;
  35623. /**
  35624. * Gets if the sounds is ready to be played or not.
  35625. * @returns true if ready, otherwise false
  35626. */
  35627. isReady(): boolean;
  35628. private _soundLoaded;
  35629. /**
  35630. * Sets the data of the sound from an audiobuffer
  35631. * @param audioBuffer The audioBuffer containing the data
  35632. */
  35633. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35634. /**
  35635. * Updates the current sounds options such as maxdistance, loop...
  35636. * @param options A JSON object containing values named as the object properties
  35637. */
  35638. updateOptions(options: ISoundOptions): void;
  35639. private _createSpatialParameters;
  35640. private _updateSpatialParameters;
  35641. /**
  35642. * Switch the panning model to HRTF:
  35643. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35644. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35645. */
  35646. switchPanningModelToHRTF(): void;
  35647. /**
  35648. * Switch the panning model to Equal Power:
  35649. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35650. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35651. */
  35652. switchPanningModelToEqualPower(): void;
  35653. private _switchPanningModel;
  35654. /**
  35655. * Connect this sound to a sound track audio node like gain...
  35656. * @param soundTrackAudioNode the sound track audio node to connect to
  35657. */
  35658. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35659. /**
  35660. * Transform this sound into a directional source
  35661. * @param coneInnerAngle Size of the inner cone in degree
  35662. * @param coneOuterAngle Size of the outer cone in degree
  35663. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35664. */
  35665. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35666. /**
  35667. * Gets or sets the inner angle for the directional cone.
  35668. */
  35669. /**
  35670. * Gets or sets the inner angle for the directional cone.
  35671. */
  35672. directionalConeInnerAngle: number;
  35673. /**
  35674. * Gets or sets the outer angle for the directional cone.
  35675. */
  35676. /**
  35677. * Gets or sets the outer angle for the directional cone.
  35678. */
  35679. directionalConeOuterAngle: number;
  35680. /**
  35681. * Sets the position of the emitter if spatial sound is enabled
  35682. * @param newPosition Defines the new posisiton
  35683. */
  35684. setPosition(newPosition: Vector3): void;
  35685. /**
  35686. * Sets the local direction of the emitter if spatial sound is enabled
  35687. * @param newLocalDirection Defines the new local direction
  35688. */
  35689. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35690. private _updateDirection;
  35691. /** @hidden */
  35692. updateDistanceFromListener(): void;
  35693. /**
  35694. * Sets a new custom attenuation function for the sound.
  35695. * @param callback Defines the function used for the attenuation
  35696. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35697. */
  35698. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35699. /**
  35700. * Play the sound
  35701. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35702. * @param offset (optional) Start the sound at a specific time in seconds
  35703. * @param length (optional) Sound duration (in seconds)
  35704. */
  35705. play(time?: number, offset?: number, length?: number): void;
  35706. private _onended;
  35707. /**
  35708. * Stop the sound
  35709. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35710. */
  35711. stop(time?: number): void;
  35712. /**
  35713. * Put the sound in pause
  35714. */
  35715. pause(): void;
  35716. /**
  35717. * Sets a dedicated volume for this sounds
  35718. * @param newVolume Define the new volume of the sound
  35719. * @param time Define time for gradual change to new volume
  35720. */
  35721. setVolume(newVolume: number, time?: number): void;
  35722. /**
  35723. * Set the sound play back rate
  35724. * @param newPlaybackRate Define the playback rate the sound should be played at
  35725. */
  35726. setPlaybackRate(newPlaybackRate: number): void;
  35727. /**
  35728. * Gets the volume of the sound.
  35729. * @returns the volume of the sound
  35730. */
  35731. getVolume(): number;
  35732. /**
  35733. * Attach the sound to a dedicated mesh
  35734. * @param transformNode The transform node to connect the sound with
  35735. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35736. */
  35737. attachToMesh(transformNode: TransformNode): void;
  35738. /**
  35739. * Detach the sound from the previously attached mesh
  35740. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35741. */
  35742. detachFromMesh(): void;
  35743. private _onRegisterAfterWorldMatrixUpdate;
  35744. /**
  35745. * Clone the current sound in the scene.
  35746. * @returns the new sound clone
  35747. */
  35748. clone(): Nullable<Sound>;
  35749. /**
  35750. * Gets the current underlying audio buffer containing the data
  35751. * @returns the audio buffer
  35752. */
  35753. getAudioBuffer(): Nullable<AudioBuffer>;
  35754. /**
  35755. * Serializes the Sound in a JSON representation
  35756. * @returns the JSON representation of the sound
  35757. */
  35758. serialize(): any;
  35759. /**
  35760. * Parse a JSON representation of a sound to innstantiate in a given scene
  35761. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35762. * @param scene Define the scene the new parsed sound should be created in
  35763. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35764. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35765. * @returns the newly parsed sound
  35766. */
  35767. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35768. }
  35769. }
  35770. declare module "babylonjs/Actions/directAudioActions" {
  35771. import { Action } from "babylonjs/Actions/action";
  35772. import { Condition } from "babylonjs/Actions/condition";
  35773. import { Sound } from "babylonjs/Audio/sound";
  35774. /**
  35775. * This defines an action helpful to play a defined sound on a triggered action.
  35776. */
  35777. export class PlaySoundAction extends Action {
  35778. private _sound;
  35779. /**
  35780. * Instantiate the action
  35781. * @param triggerOptions defines the trigger options
  35782. * @param sound defines the sound to play
  35783. * @param condition defines the trigger related conditions
  35784. */
  35785. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35786. /** @hidden */
  35787. _prepare(): void;
  35788. /**
  35789. * Execute the action and play the sound.
  35790. */
  35791. execute(): void;
  35792. /**
  35793. * Serializes the actions and its related information.
  35794. * @param parent defines the object to serialize in
  35795. * @returns the serialized object
  35796. */
  35797. serialize(parent: any): any;
  35798. }
  35799. /**
  35800. * This defines an action helpful to stop a defined sound on a triggered action.
  35801. */
  35802. export class StopSoundAction extends Action {
  35803. private _sound;
  35804. /**
  35805. * Instantiate the action
  35806. * @param triggerOptions defines the trigger options
  35807. * @param sound defines the sound to stop
  35808. * @param condition defines the trigger related conditions
  35809. */
  35810. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35811. /** @hidden */
  35812. _prepare(): void;
  35813. /**
  35814. * Execute the action and stop the sound.
  35815. */
  35816. execute(): void;
  35817. /**
  35818. * Serializes the actions and its related information.
  35819. * @param parent defines the object to serialize in
  35820. * @returns the serialized object
  35821. */
  35822. serialize(parent: any): any;
  35823. }
  35824. }
  35825. declare module "babylonjs/Actions/interpolateValueAction" {
  35826. import { Action } from "babylonjs/Actions/action";
  35827. import { Condition } from "babylonjs/Actions/condition";
  35828. import { Observable } from "babylonjs/Misc/observable";
  35829. /**
  35830. * This defines an action responsible to change the value of a property
  35831. * by interpolating between its current value and the newly set one once triggered.
  35832. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35833. */
  35834. export class InterpolateValueAction extends Action {
  35835. /**
  35836. * Defines the path of the property where the value should be interpolated
  35837. */
  35838. propertyPath: string;
  35839. /**
  35840. * Defines the target value at the end of the interpolation.
  35841. */
  35842. value: any;
  35843. /**
  35844. * Defines the time it will take for the property to interpolate to the value.
  35845. */
  35846. duration: number;
  35847. /**
  35848. * Defines if the other scene animations should be stopped when the action has been triggered
  35849. */
  35850. stopOtherAnimations?: boolean;
  35851. /**
  35852. * Defines a callback raised once the interpolation animation has been done.
  35853. */
  35854. onInterpolationDone?: () => void;
  35855. /**
  35856. * Observable triggered once the interpolation animation has been done.
  35857. */
  35858. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35859. private _target;
  35860. private _effectiveTarget;
  35861. private _property;
  35862. /**
  35863. * Instantiate the action
  35864. * @param triggerOptions defines the trigger options
  35865. * @param target defines the object containing the value to interpolate
  35866. * @param propertyPath defines the path to the property in the target object
  35867. * @param value defines the target value at the end of the interpolation
  35868. * @param duration deines the time it will take for the property to interpolate to the value.
  35869. * @param condition defines the trigger related conditions
  35870. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35871. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35872. */
  35873. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35874. /** @hidden */
  35875. _prepare(): void;
  35876. /**
  35877. * Execute the action starts the value interpolation.
  35878. */
  35879. execute(): void;
  35880. /**
  35881. * Serializes the actions and its related information.
  35882. * @param parent defines the object to serialize in
  35883. * @returns the serialized object
  35884. */
  35885. serialize(parent: any): any;
  35886. }
  35887. }
  35888. declare module "babylonjs/Actions/index" {
  35889. export * from "babylonjs/Actions/action";
  35890. export * from "babylonjs/Actions/actionEvent";
  35891. export * from "babylonjs/Actions/actionManager";
  35892. export * from "babylonjs/Actions/condition";
  35893. export * from "babylonjs/Actions/directActions";
  35894. export * from "babylonjs/Actions/directAudioActions";
  35895. export * from "babylonjs/Actions/interpolateValueAction";
  35896. }
  35897. declare module "babylonjs/Animations/index" {
  35898. export * from "babylonjs/Animations/animatable";
  35899. export * from "babylonjs/Animations/animation";
  35900. export * from "babylonjs/Animations/animationGroup";
  35901. export * from "babylonjs/Animations/animationPropertiesOverride";
  35902. export * from "babylonjs/Animations/easing";
  35903. export * from "babylonjs/Animations/runtimeAnimation";
  35904. export * from "babylonjs/Animations/animationEvent";
  35905. export * from "babylonjs/Animations/animationGroup";
  35906. export * from "babylonjs/Animations/animationKey";
  35907. export * from "babylonjs/Animations/animationRange";
  35908. export * from "babylonjs/Animations/animatable.interface";
  35909. }
  35910. declare module "babylonjs/Audio/soundTrack" {
  35911. import { Sound } from "babylonjs/Audio/sound";
  35912. import { Analyser } from "babylonjs/Audio/analyser";
  35913. import { Scene } from "babylonjs/scene";
  35914. /**
  35915. * Options allowed during the creation of a sound track.
  35916. */
  35917. export interface ISoundTrackOptions {
  35918. /**
  35919. * The volume the sound track should take during creation
  35920. */
  35921. volume?: number;
  35922. /**
  35923. * Define if the sound track is the main sound track of the scene
  35924. */
  35925. mainTrack?: boolean;
  35926. }
  35927. /**
  35928. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35929. * It will be also used in a future release to apply effects on a specific track.
  35930. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35931. */
  35932. export class SoundTrack {
  35933. /**
  35934. * The unique identifier of the sound track in the scene.
  35935. */
  35936. id: number;
  35937. /**
  35938. * The list of sounds included in the sound track.
  35939. */
  35940. soundCollection: Array<Sound>;
  35941. private _outputAudioNode;
  35942. private _scene;
  35943. private _isMainTrack;
  35944. private _connectedAnalyser;
  35945. private _options;
  35946. private _isInitialized;
  35947. /**
  35948. * Creates a new sound track.
  35949. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35950. * @param scene Define the scene the sound track belongs to
  35951. * @param options
  35952. */
  35953. constructor(scene: Scene, options?: ISoundTrackOptions);
  35954. private _initializeSoundTrackAudioGraph;
  35955. /**
  35956. * Release the sound track and its associated resources
  35957. */
  35958. dispose(): void;
  35959. /**
  35960. * Adds a sound to this sound track
  35961. * @param sound define the cound to add
  35962. * @ignoreNaming
  35963. */
  35964. AddSound(sound: Sound): void;
  35965. /**
  35966. * Removes a sound to this sound track
  35967. * @param sound define the cound to remove
  35968. * @ignoreNaming
  35969. */
  35970. RemoveSound(sound: Sound): void;
  35971. /**
  35972. * Set a global volume for the full sound track.
  35973. * @param newVolume Define the new volume of the sound track
  35974. */
  35975. setVolume(newVolume: number): void;
  35976. /**
  35977. * Switch the panning model to HRTF:
  35978. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35979. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35980. */
  35981. switchPanningModelToHRTF(): void;
  35982. /**
  35983. * Switch the panning model to Equal Power:
  35984. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35985. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35986. */
  35987. switchPanningModelToEqualPower(): void;
  35988. /**
  35989. * Connect the sound track to an audio analyser allowing some amazing
  35990. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35991. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35992. * @param analyser The analyser to connect to the engine
  35993. */
  35994. connectToAnalyser(analyser: Analyser): void;
  35995. }
  35996. }
  35997. declare module "babylonjs/Audio/audioSceneComponent" {
  35998. import { Sound } from "babylonjs/Audio/sound";
  35999. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36000. import { Nullable } from "babylonjs/types";
  36001. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36002. import { Scene } from "babylonjs/scene";
  36003. import { AbstractScene } from "babylonjs/abstractScene";
  36004. module "babylonjs/abstractScene" {
  36005. interface AbstractScene {
  36006. /**
  36007. * The list of sounds used in the scene.
  36008. */
  36009. sounds: Nullable<Array<Sound>>;
  36010. }
  36011. }
  36012. module "babylonjs/scene" {
  36013. interface Scene {
  36014. /**
  36015. * @hidden
  36016. * Backing field
  36017. */
  36018. _mainSoundTrack: SoundTrack;
  36019. /**
  36020. * The main sound track played by the scene.
  36021. * It cotains your primary collection of sounds.
  36022. */
  36023. mainSoundTrack: SoundTrack;
  36024. /**
  36025. * The list of sound tracks added to the scene
  36026. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36027. */
  36028. soundTracks: Nullable<Array<SoundTrack>>;
  36029. /**
  36030. * Gets a sound using a given name
  36031. * @param name defines the name to search for
  36032. * @return the found sound or null if not found at all.
  36033. */
  36034. getSoundByName(name: string): Nullable<Sound>;
  36035. /**
  36036. * Gets or sets if audio support is enabled
  36037. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36038. */
  36039. audioEnabled: boolean;
  36040. /**
  36041. * Gets or sets if audio will be output to headphones
  36042. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36043. */
  36044. headphone: boolean;
  36045. }
  36046. }
  36047. /**
  36048. * Defines the sound scene component responsible to manage any sounds
  36049. * in a given scene.
  36050. */
  36051. export class AudioSceneComponent implements ISceneSerializableComponent {
  36052. /**
  36053. * The component name helpfull to identify the component in the list of scene components.
  36054. */
  36055. readonly name: string;
  36056. /**
  36057. * The scene the component belongs to.
  36058. */
  36059. scene: Scene;
  36060. private _audioEnabled;
  36061. /**
  36062. * Gets whether audio is enabled or not.
  36063. * Please use related enable/disable method to switch state.
  36064. */
  36065. readonly audioEnabled: boolean;
  36066. private _headphone;
  36067. /**
  36068. * Gets whether audio is outputing to headphone or not.
  36069. * Please use the according Switch methods to change output.
  36070. */
  36071. readonly headphone: boolean;
  36072. /**
  36073. * Creates a new instance of the component for the given scene
  36074. * @param scene Defines the scene to register the component in
  36075. */
  36076. constructor(scene: Scene);
  36077. /**
  36078. * Registers the component in a given scene
  36079. */
  36080. register(): void;
  36081. /**
  36082. * Rebuilds the elements related to this component in case of
  36083. * context lost for instance.
  36084. */
  36085. rebuild(): void;
  36086. /**
  36087. * Serializes the component data to the specified json object
  36088. * @param serializationObject The object to serialize to
  36089. */
  36090. serialize(serializationObject: any): void;
  36091. /**
  36092. * Adds all the elements from the container to the scene
  36093. * @param container the container holding the elements
  36094. */
  36095. addFromContainer(container: AbstractScene): void;
  36096. /**
  36097. * Removes all the elements in the container from the scene
  36098. * @param container contains the elements to remove
  36099. * @param dispose if the removed element should be disposed (default: false)
  36100. */
  36101. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36102. /**
  36103. * Disposes the component and the associated ressources.
  36104. */
  36105. dispose(): void;
  36106. /**
  36107. * Disables audio in the associated scene.
  36108. */
  36109. disableAudio(): void;
  36110. /**
  36111. * Enables audio in the associated scene.
  36112. */
  36113. enableAudio(): void;
  36114. /**
  36115. * Switch audio to headphone output.
  36116. */
  36117. switchAudioModeForHeadphones(): void;
  36118. /**
  36119. * Switch audio to normal speakers.
  36120. */
  36121. switchAudioModeForNormalSpeakers(): void;
  36122. private _afterRender;
  36123. }
  36124. }
  36125. declare module "babylonjs/Audio/weightedsound" {
  36126. import { Sound } from "babylonjs/Audio/sound";
  36127. /**
  36128. * Wraps one or more Sound objects and selects one with random weight for playback.
  36129. */
  36130. export class WeightedSound {
  36131. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36132. loop: boolean;
  36133. private _coneInnerAngle;
  36134. private _coneOuterAngle;
  36135. private _volume;
  36136. /** A Sound is currently playing. */
  36137. isPlaying: boolean;
  36138. /** A Sound is currently paused. */
  36139. isPaused: boolean;
  36140. private _sounds;
  36141. private _weights;
  36142. private _currentIndex?;
  36143. /**
  36144. * Creates a new WeightedSound from the list of sounds given.
  36145. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36146. * @param sounds Array of Sounds that will be selected from.
  36147. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36148. */
  36149. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36150. /**
  36151. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36152. */
  36153. /**
  36154. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36155. */
  36156. directionalConeInnerAngle: number;
  36157. /**
  36158. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36159. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36160. */
  36161. /**
  36162. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36163. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36164. */
  36165. directionalConeOuterAngle: number;
  36166. /**
  36167. * Playback volume.
  36168. */
  36169. /**
  36170. * Playback volume.
  36171. */
  36172. volume: number;
  36173. private _onended;
  36174. /**
  36175. * Suspend playback
  36176. */
  36177. pause(): void;
  36178. /**
  36179. * Stop playback
  36180. */
  36181. stop(): void;
  36182. /**
  36183. * Start playback.
  36184. * @param startOffset Position the clip head at a specific time in seconds.
  36185. */
  36186. play(startOffset?: number): void;
  36187. }
  36188. }
  36189. declare module "babylonjs/Audio/index" {
  36190. export * from "babylonjs/Audio/analyser";
  36191. export * from "babylonjs/Audio/audioEngine";
  36192. export * from "babylonjs/Audio/audioSceneComponent";
  36193. export * from "babylonjs/Audio/sound";
  36194. export * from "babylonjs/Audio/soundTrack";
  36195. export * from "babylonjs/Audio/weightedsound";
  36196. }
  36197. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36198. import { Behavior } from "babylonjs/Behaviors/behavior";
  36199. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36200. import { BackEase } from "babylonjs/Animations/easing";
  36201. /**
  36202. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36203. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36204. */
  36205. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36206. /**
  36207. * Gets the name of the behavior.
  36208. */
  36209. readonly name: string;
  36210. /**
  36211. * The easing function used by animations
  36212. */
  36213. static EasingFunction: BackEase;
  36214. /**
  36215. * The easing mode used by animations
  36216. */
  36217. static EasingMode: number;
  36218. /**
  36219. * The duration of the animation, in milliseconds
  36220. */
  36221. transitionDuration: number;
  36222. /**
  36223. * Length of the distance animated by the transition when lower radius is reached
  36224. */
  36225. lowerRadiusTransitionRange: number;
  36226. /**
  36227. * Length of the distance animated by the transition when upper radius is reached
  36228. */
  36229. upperRadiusTransitionRange: number;
  36230. private _autoTransitionRange;
  36231. /**
  36232. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36233. */
  36234. /**
  36235. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36236. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36237. */
  36238. autoTransitionRange: boolean;
  36239. private _attachedCamera;
  36240. private _onAfterCheckInputsObserver;
  36241. private _onMeshTargetChangedObserver;
  36242. /**
  36243. * Initializes the behavior.
  36244. */
  36245. init(): void;
  36246. /**
  36247. * Attaches the behavior to its arc rotate camera.
  36248. * @param camera Defines the camera to attach the behavior to
  36249. */
  36250. attach(camera: ArcRotateCamera): void;
  36251. /**
  36252. * Detaches the behavior from its current arc rotate camera.
  36253. */
  36254. detach(): void;
  36255. private _radiusIsAnimating;
  36256. private _radiusBounceTransition;
  36257. private _animatables;
  36258. private _cachedWheelPrecision;
  36259. /**
  36260. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36261. * @param radiusLimit The limit to check against.
  36262. * @return Bool to indicate if at limit.
  36263. */
  36264. private _isRadiusAtLimit;
  36265. /**
  36266. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36267. * @param radiusDelta The delta by which to animate to. Can be negative.
  36268. */
  36269. private _applyBoundRadiusAnimation;
  36270. /**
  36271. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36272. */
  36273. protected _clearAnimationLocks(): void;
  36274. /**
  36275. * Stops and removes all animations that have been applied to the camera
  36276. */
  36277. stopAllAnimations(): void;
  36278. }
  36279. }
  36280. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36281. import { Behavior } from "babylonjs/Behaviors/behavior";
  36282. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36283. import { ExponentialEase } from "babylonjs/Animations/easing";
  36284. import { Nullable } from "babylonjs/types";
  36285. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36286. import { Vector3 } from "babylonjs/Maths/math.vector";
  36287. /**
  36288. * 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.
  36289. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36290. */
  36291. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36292. /**
  36293. * Gets the name of the behavior.
  36294. */
  36295. readonly name: string;
  36296. private _mode;
  36297. private _radiusScale;
  36298. private _positionScale;
  36299. private _defaultElevation;
  36300. private _elevationReturnTime;
  36301. private _elevationReturnWaitTime;
  36302. private _zoomStopsAnimation;
  36303. private _framingTime;
  36304. /**
  36305. * The easing function used by animations
  36306. */
  36307. static EasingFunction: ExponentialEase;
  36308. /**
  36309. * The easing mode used by animations
  36310. */
  36311. static EasingMode: number;
  36312. /**
  36313. * Sets the current mode used by the behavior
  36314. */
  36315. /**
  36316. * Gets current mode used by the behavior.
  36317. */
  36318. mode: number;
  36319. /**
  36320. * Sets the scale applied to the radius (1 by default)
  36321. */
  36322. /**
  36323. * Gets the scale applied to the radius
  36324. */
  36325. radiusScale: number;
  36326. /**
  36327. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36328. */
  36329. /**
  36330. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36331. */
  36332. positionScale: number;
  36333. /**
  36334. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36335. * behaviour is triggered, in radians.
  36336. */
  36337. /**
  36338. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36339. * behaviour is triggered, in radians.
  36340. */
  36341. defaultElevation: number;
  36342. /**
  36343. * Sets the time (in milliseconds) taken to return to the default beta position.
  36344. * Negative value indicates camera should not return to default.
  36345. */
  36346. /**
  36347. * Gets the time (in milliseconds) taken to return to the default beta position.
  36348. * Negative value indicates camera should not return to default.
  36349. */
  36350. elevationReturnTime: number;
  36351. /**
  36352. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36353. */
  36354. /**
  36355. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36356. */
  36357. elevationReturnWaitTime: number;
  36358. /**
  36359. * Sets the flag that indicates if user zooming should stop animation.
  36360. */
  36361. /**
  36362. * Gets the flag that indicates if user zooming should stop animation.
  36363. */
  36364. zoomStopsAnimation: boolean;
  36365. /**
  36366. * Sets the transition time when framing the mesh, in milliseconds
  36367. */
  36368. /**
  36369. * Gets the transition time when framing the mesh, in milliseconds
  36370. */
  36371. framingTime: number;
  36372. /**
  36373. * Define if the behavior should automatically change the configured
  36374. * camera limits and sensibilities.
  36375. */
  36376. autoCorrectCameraLimitsAndSensibility: boolean;
  36377. private _onPrePointerObservableObserver;
  36378. private _onAfterCheckInputsObserver;
  36379. private _onMeshTargetChangedObserver;
  36380. private _attachedCamera;
  36381. private _isPointerDown;
  36382. private _lastInteractionTime;
  36383. /**
  36384. * Initializes the behavior.
  36385. */
  36386. init(): void;
  36387. /**
  36388. * Attaches the behavior to its arc rotate camera.
  36389. * @param camera Defines the camera to attach the behavior to
  36390. */
  36391. attach(camera: ArcRotateCamera): void;
  36392. /**
  36393. * Detaches the behavior from its current arc rotate camera.
  36394. */
  36395. detach(): void;
  36396. private _animatables;
  36397. private _betaIsAnimating;
  36398. private _betaTransition;
  36399. private _radiusTransition;
  36400. private _vectorTransition;
  36401. /**
  36402. * Targets the given mesh and updates zoom level accordingly.
  36403. * @param mesh The mesh to target.
  36404. * @param radius Optional. If a cached radius position already exists, overrides default.
  36405. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36406. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36407. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36408. */
  36409. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36410. /**
  36411. * Targets the given mesh with its children and updates zoom level accordingly.
  36412. * @param mesh The mesh to target.
  36413. * @param radius Optional. If a cached radius position already exists, overrides default.
  36414. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36415. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36416. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36417. */
  36418. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36419. /**
  36420. * Targets the given meshes with their children and updates zoom level accordingly.
  36421. * @param meshes The mesh to target.
  36422. * @param radius Optional. If a cached radius position already exists, overrides default.
  36423. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36424. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36425. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36426. */
  36427. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36428. /**
  36429. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36430. * @param minimumWorld Determines the smaller position of the bounding box extend
  36431. * @param maximumWorld Determines the bigger position of the bounding box extend
  36432. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36433. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36434. */
  36435. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36436. /**
  36437. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36438. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36439. * frustum width.
  36440. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36441. * to fully enclose the mesh in the viewing frustum.
  36442. */
  36443. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36444. /**
  36445. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36446. * is automatically returned to its default position (expected to be above ground plane).
  36447. */
  36448. private _maintainCameraAboveGround;
  36449. /**
  36450. * Returns the frustum slope based on the canvas ratio and camera FOV
  36451. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36452. */
  36453. private _getFrustumSlope;
  36454. /**
  36455. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36456. */
  36457. private _clearAnimationLocks;
  36458. /**
  36459. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36460. */
  36461. private _applyUserInteraction;
  36462. /**
  36463. * Stops and removes all animations that have been applied to the camera
  36464. */
  36465. stopAllAnimations(): void;
  36466. /**
  36467. * Gets a value indicating if the user is moving the camera
  36468. */
  36469. readonly isUserIsMoving: boolean;
  36470. /**
  36471. * The camera can move all the way towards the mesh.
  36472. */
  36473. static IgnoreBoundsSizeMode: number;
  36474. /**
  36475. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36476. */
  36477. static FitFrustumSidesMode: number;
  36478. }
  36479. }
  36480. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36481. import { Nullable } from "babylonjs/types";
  36482. import { Camera } from "babylonjs/Cameras/camera";
  36483. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36484. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36485. /**
  36486. * Base class for Camera Pointer Inputs.
  36487. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36488. * for example usage.
  36489. */
  36490. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36491. /**
  36492. * Defines the camera the input is attached to.
  36493. */
  36494. abstract camera: Camera;
  36495. /**
  36496. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36497. */
  36498. protected _altKey: boolean;
  36499. protected _ctrlKey: boolean;
  36500. protected _metaKey: boolean;
  36501. protected _shiftKey: boolean;
  36502. /**
  36503. * Which mouse buttons were pressed at time of last mouse event.
  36504. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36505. */
  36506. protected _buttonsPressed: number;
  36507. /**
  36508. * Defines the buttons associated with the input to handle camera move.
  36509. */
  36510. buttons: number[];
  36511. /**
  36512. * Attach the input controls to a specific dom element to get the input from.
  36513. * @param element Defines the element the controls should be listened from
  36514. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36515. */
  36516. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36517. /**
  36518. * Detach the current controls from the specified dom element.
  36519. * @param element Defines the element to stop listening the inputs from
  36520. */
  36521. detachControl(element: Nullable<HTMLElement>): void;
  36522. /**
  36523. * Gets the class name of the current input.
  36524. * @returns the class name
  36525. */
  36526. getClassName(): string;
  36527. /**
  36528. * Get the friendly name associated with the input class.
  36529. * @returns the input friendly name
  36530. */
  36531. getSimpleName(): string;
  36532. /**
  36533. * Called on pointer POINTERDOUBLETAP event.
  36534. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36535. */
  36536. protected onDoubleTap(type: string): void;
  36537. /**
  36538. * Called on pointer POINTERMOVE event if only a single touch is active.
  36539. * Override this method to provide functionality.
  36540. */
  36541. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36542. /**
  36543. * Called on pointer POINTERMOVE event if multiple touches are active.
  36544. * Override this method to provide functionality.
  36545. */
  36546. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36547. /**
  36548. * Called on JS contextmenu event.
  36549. * Override this method to provide functionality.
  36550. */
  36551. protected onContextMenu(evt: PointerEvent): void;
  36552. /**
  36553. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36554. * press.
  36555. * Override this method to provide functionality.
  36556. */
  36557. protected onButtonDown(evt: PointerEvent): void;
  36558. /**
  36559. * Called each time a new POINTERUP event occurs. Ie, for each button
  36560. * release.
  36561. * Override this method to provide functionality.
  36562. */
  36563. protected onButtonUp(evt: PointerEvent): void;
  36564. /**
  36565. * Called when window becomes inactive.
  36566. * Override this method to provide functionality.
  36567. */
  36568. protected onLostFocus(): void;
  36569. private _pointerInput;
  36570. private _observer;
  36571. private _onLostFocus;
  36572. private pointA;
  36573. private pointB;
  36574. }
  36575. }
  36576. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36577. import { Nullable } from "babylonjs/types";
  36578. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36579. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36580. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36581. /**
  36582. * Manage the pointers inputs to control an arc rotate camera.
  36583. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36584. */
  36585. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36586. /**
  36587. * Defines the camera the input is attached to.
  36588. */
  36589. camera: ArcRotateCamera;
  36590. /**
  36591. * Gets the class name of the current input.
  36592. * @returns the class name
  36593. */
  36594. getClassName(): string;
  36595. /**
  36596. * Defines the buttons associated with the input to handle camera move.
  36597. */
  36598. buttons: number[];
  36599. /**
  36600. * Defines the pointer angular sensibility along the X axis or how fast is
  36601. * the camera rotating.
  36602. */
  36603. angularSensibilityX: number;
  36604. /**
  36605. * Defines the pointer angular sensibility along the Y axis or how fast is
  36606. * the camera rotating.
  36607. */
  36608. angularSensibilityY: number;
  36609. /**
  36610. * Defines the pointer pinch precision or how fast is the camera zooming.
  36611. */
  36612. pinchPrecision: number;
  36613. /**
  36614. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36615. * from 0.
  36616. * It defines the percentage of current camera.radius to use as delta when
  36617. * pinch zoom is used.
  36618. */
  36619. pinchDeltaPercentage: number;
  36620. /**
  36621. * Defines the pointer panning sensibility or how fast is the camera moving.
  36622. */
  36623. panningSensibility: number;
  36624. /**
  36625. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36626. */
  36627. multiTouchPanning: boolean;
  36628. /**
  36629. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36630. * zoom (pinch) through multitouch.
  36631. */
  36632. multiTouchPanAndZoom: boolean;
  36633. /**
  36634. * Revers pinch action direction.
  36635. */
  36636. pinchInwards: boolean;
  36637. private _isPanClick;
  36638. private _twoFingerActivityCount;
  36639. private _isPinching;
  36640. /**
  36641. * Called on pointer POINTERMOVE event if only a single touch is active.
  36642. */
  36643. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36644. /**
  36645. * Called on pointer POINTERDOUBLETAP event.
  36646. */
  36647. protected onDoubleTap(type: string): void;
  36648. /**
  36649. * Called on pointer POINTERMOVE event if multiple touches are active.
  36650. */
  36651. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36652. /**
  36653. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36654. * press.
  36655. */
  36656. protected onButtonDown(evt: PointerEvent): void;
  36657. /**
  36658. * Called each time a new POINTERUP event occurs. Ie, for each button
  36659. * release.
  36660. */
  36661. protected onButtonUp(evt: PointerEvent): void;
  36662. /**
  36663. * Called when window becomes inactive.
  36664. */
  36665. protected onLostFocus(): void;
  36666. }
  36667. }
  36668. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36669. import { Nullable } from "babylonjs/types";
  36670. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36671. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36672. /**
  36673. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36674. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36675. */
  36676. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36677. /**
  36678. * Defines the camera the input is attached to.
  36679. */
  36680. camera: ArcRotateCamera;
  36681. /**
  36682. * Defines the list of key codes associated with the up action (increase alpha)
  36683. */
  36684. keysUp: number[];
  36685. /**
  36686. * Defines the list of key codes associated with the down action (decrease alpha)
  36687. */
  36688. keysDown: number[];
  36689. /**
  36690. * Defines the list of key codes associated with the left action (increase beta)
  36691. */
  36692. keysLeft: number[];
  36693. /**
  36694. * Defines the list of key codes associated with the right action (decrease beta)
  36695. */
  36696. keysRight: number[];
  36697. /**
  36698. * Defines the list of key codes associated with the reset action.
  36699. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36700. */
  36701. keysReset: number[];
  36702. /**
  36703. * Defines the panning sensibility of the inputs.
  36704. * (How fast is the camera paning)
  36705. */
  36706. panningSensibility: number;
  36707. /**
  36708. * Defines the zooming sensibility of the inputs.
  36709. * (How fast is the camera zooming)
  36710. */
  36711. zoomingSensibility: number;
  36712. /**
  36713. * Defines wether maintaining the alt key down switch the movement mode from
  36714. * orientation to zoom.
  36715. */
  36716. useAltToZoom: boolean;
  36717. /**
  36718. * Rotation speed of the camera
  36719. */
  36720. angularSpeed: number;
  36721. private _keys;
  36722. private _ctrlPressed;
  36723. private _altPressed;
  36724. private _onCanvasBlurObserver;
  36725. private _onKeyboardObserver;
  36726. private _engine;
  36727. private _scene;
  36728. /**
  36729. * Attach the input controls to a specific dom element to get the input from.
  36730. * @param element Defines the element the controls should be listened from
  36731. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36732. */
  36733. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36734. /**
  36735. * Detach the current controls from the specified dom element.
  36736. * @param element Defines the element to stop listening the inputs from
  36737. */
  36738. detachControl(element: Nullable<HTMLElement>): void;
  36739. /**
  36740. * Update the current camera state depending on the inputs that have been used this frame.
  36741. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36742. */
  36743. checkInputs(): void;
  36744. /**
  36745. * Gets the class name of the current intput.
  36746. * @returns the class name
  36747. */
  36748. getClassName(): string;
  36749. /**
  36750. * Get the friendly name associated with the input class.
  36751. * @returns the input friendly name
  36752. */
  36753. getSimpleName(): string;
  36754. }
  36755. }
  36756. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36757. import { Nullable } from "babylonjs/types";
  36758. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36759. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36760. /**
  36761. * Manage the mouse wheel inputs to control an arc rotate camera.
  36762. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36763. */
  36764. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36765. /**
  36766. * Defines the camera the input is attached to.
  36767. */
  36768. camera: ArcRotateCamera;
  36769. /**
  36770. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36771. */
  36772. wheelPrecision: number;
  36773. /**
  36774. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36775. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36776. */
  36777. wheelDeltaPercentage: number;
  36778. private _wheel;
  36779. private _observer;
  36780. private computeDeltaFromMouseWheelLegacyEvent;
  36781. /**
  36782. * Attach the input controls to a specific dom element to get the input from.
  36783. * @param element Defines the element the controls should be listened from
  36784. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36785. */
  36786. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36787. /**
  36788. * Detach the current controls from the specified dom element.
  36789. * @param element Defines the element to stop listening the inputs from
  36790. */
  36791. detachControl(element: Nullable<HTMLElement>): void;
  36792. /**
  36793. * Gets the class name of the current intput.
  36794. * @returns the class name
  36795. */
  36796. getClassName(): string;
  36797. /**
  36798. * Get the friendly name associated with the input class.
  36799. * @returns the input friendly name
  36800. */
  36801. getSimpleName(): string;
  36802. }
  36803. }
  36804. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36805. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36806. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36807. /**
  36808. * Default Inputs manager for the ArcRotateCamera.
  36809. * It groups all the default supported inputs for ease of use.
  36810. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36811. */
  36812. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36813. /**
  36814. * Instantiates a new ArcRotateCameraInputsManager.
  36815. * @param camera Defines the camera the inputs belong to
  36816. */
  36817. constructor(camera: ArcRotateCamera);
  36818. /**
  36819. * Add mouse wheel input support to the input manager.
  36820. * @returns the current input manager
  36821. */
  36822. addMouseWheel(): ArcRotateCameraInputsManager;
  36823. /**
  36824. * Add pointers input support to the input manager.
  36825. * @returns the current input manager
  36826. */
  36827. addPointers(): ArcRotateCameraInputsManager;
  36828. /**
  36829. * Add keyboard input support to the input manager.
  36830. * @returns the current input manager
  36831. */
  36832. addKeyboard(): ArcRotateCameraInputsManager;
  36833. }
  36834. }
  36835. declare module "babylonjs/Cameras/arcRotateCamera" {
  36836. import { Observable } from "babylonjs/Misc/observable";
  36837. import { Nullable } from "babylonjs/types";
  36838. import { Scene } from "babylonjs/scene";
  36839. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  36840. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36841. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36842. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36843. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36844. import { Camera } from "babylonjs/Cameras/camera";
  36845. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36846. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36847. import { Collider } from "babylonjs/Collisions/collider";
  36848. /**
  36849. * This represents an orbital type of camera.
  36850. *
  36851. * 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.
  36852. * 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.
  36853. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36854. */
  36855. export class ArcRotateCamera extends TargetCamera {
  36856. /**
  36857. * Defines the rotation angle of the camera along the longitudinal axis.
  36858. */
  36859. alpha: number;
  36860. /**
  36861. * Defines the rotation angle of the camera along the latitudinal axis.
  36862. */
  36863. beta: number;
  36864. /**
  36865. * Defines the radius of the camera from it s target point.
  36866. */
  36867. radius: number;
  36868. protected _target: Vector3;
  36869. protected _targetHost: Nullable<AbstractMesh>;
  36870. /**
  36871. * Defines the target point of the camera.
  36872. * The camera looks towards it form the radius distance.
  36873. */
  36874. target: Vector3;
  36875. /**
  36876. * Define the current local position of the camera in the scene
  36877. */
  36878. position: Vector3;
  36879. protected _upVector: Vector3;
  36880. protected _upToYMatrix: Matrix;
  36881. protected _YToUpMatrix: Matrix;
  36882. /**
  36883. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36884. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36885. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36886. */
  36887. upVector: Vector3;
  36888. /**
  36889. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36890. */
  36891. setMatUp(): void;
  36892. /**
  36893. * Current inertia value on the longitudinal axis.
  36894. * The bigger this number the longer it will take for the camera to stop.
  36895. */
  36896. inertialAlphaOffset: number;
  36897. /**
  36898. * Current inertia value on the latitudinal axis.
  36899. * The bigger this number the longer it will take for the camera to stop.
  36900. */
  36901. inertialBetaOffset: number;
  36902. /**
  36903. * Current inertia value on the radius axis.
  36904. * The bigger this number the longer it will take for the camera to stop.
  36905. */
  36906. inertialRadiusOffset: number;
  36907. /**
  36908. * Minimum allowed angle on the longitudinal axis.
  36909. * This can help limiting how the Camera is able to move in the scene.
  36910. */
  36911. lowerAlphaLimit: Nullable<number>;
  36912. /**
  36913. * Maximum allowed angle on the longitudinal axis.
  36914. * This can help limiting how the Camera is able to move in the scene.
  36915. */
  36916. upperAlphaLimit: Nullable<number>;
  36917. /**
  36918. * Minimum allowed angle on the latitudinal axis.
  36919. * This can help limiting how the Camera is able to move in the scene.
  36920. */
  36921. lowerBetaLimit: number;
  36922. /**
  36923. * Maximum allowed angle on the latitudinal axis.
  36924. * This can help limiting how the Camera is able to move in the scene.
  36925. */
  36926. upperBetaLimit: number;
  36927. /**
  36928. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36929. * This can help limiting how the Camera is able to move in the scene.
  36930. */
  36931. lowerRadiusLimit: Nullable<number>;
  36932. /**
  36933. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36934. * This can help limiting how the Camera is able to move in the scene.
  36935. */
  36936. upperRadiusLimit: Nullable<number>;
  36937. /**
  36938. * Defines the current inertia value used during panning of the camera along the X axis.
  36939. */
  36940. inertialPanningX: number;
  36941. /**
  36942. * Defines the current inertia value used during panning of the camera along the Y axis.
  36943. */
  36944. inertialPanningY: number;
  36945. /**
  36946. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36947. * Basically if your fingers moves away from more than this distance you will be considered
  36948. * in pinch mode.
  36949. */
  36950. pinchToPanMaxDistance: number;
  36951. /**
  36952. * Defines the maximum distance the camera can pan.
  36953. * This could help keeping the cammera always in your scene.
  36954. */
  36955. panningDistanceLimit: Nullable<number>;
  36956. /**
  36957. * Defines the target of the camera before paning.
  36958. */
  36959. panningOriginTarget: Vector3;
  36960. /**
  36961. * Defines the value of the inertia used during panning.
  36962. * 0 would mean stop inertia and one would mean no decelleration at all.
  36963. */
  36964. panningInertia: number;
  36965. /**
  36966. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36967. */
  36968. angularSensibilityX: number;
  36969. /**
  36970. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36971. */
  36972. angularSensibilityY: number;
  36973. /**
  36974. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36975. */
  36976. pinchPrecision: number;
  36977. /**
  36978. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36979. * It will be used instead of pinchDeltaPrecision if different from 0.
  36980. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36981. */
  36982. pinchDeltaPercentage: number;
  36983. /**
  36984. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36985. */
  36986. panningSensibility: number;
  36987. /**
  36988. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36989. */
  36990. keysUp: number[];
  36991. /**
  36992. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36993. */
  36994. keysDown: number[];
  36995. /**
  36996. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36997. */
  36998. keysLeft: number[];
  36999. /**
  37000. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37001. */
  37002. keysRight: number[];
  37003. /**
  37004. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37005. */
  37006. wheelPrecision: number;
  37007. /**
  37008. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37009. * It will be used instead of pinchDeltaPrecision if different from 0.
  37010. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37011. */
  37012. wheelDeltaPercentage: number;
  37013. /**
  37014. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37015. */
  37016. zoomOnFactor: number;
  37017. /**
  37018. * Defines a screen offset for the camera position.
  37019. */
  37020. targetScreenOffset: Vector2;
  37021. /**
  37022. * Allows the camera to be completely reversed.
  37023. * If false the camera can not arrive upside down.
  37024. */
  37025. allowUpsideDown: boolean;
  37026. /**
  37027. * Define if double tap/click is used to restore the previously saved state of the camera.
  37028. */
  37029. useInputToRestoreState: boolean;
  37030. /** @hidden */
  37031. _viewMatrix: Matrix;
  37032. /** @hidden */
  37033. _useCtrlForPanning: boolean;
  37034. /** @hidden */
  37035. _panningMouseButton: number;
  37036. /**
  37037. * Defines the input associated to the camera.
  37038. */
  37039. inputs: ArcRotateCameraInputsManager;
  37040. /** @hidden */
  37041. _reset: () => void;
  37042. /**
  37043. * Defines the allowed panning axis.
  37044. */
  37045. panningAxis: Vector3;
  37046. protected _localDirection: Vector3;
  37047. protected _transformedDirection: Vector3;
  37048. private _bouncingBehavior;
  37049. /**
  37050. * Gets the bouncing behavior of the camera if it has been enabled.
  37051. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37052. */
  37053. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37054. /**
  37055. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37056. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37057. */
  37058. useBouncingBehavior: boolean;
  37059. private _framingBehavior;
  37060. /**
  37061. * Gets the framing behavior of the camera if it has been enabled.
  37062. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37063. */
  37064. readonly framingBehavior: Nullable<FramingBehavior>;
  37065. /**
  37066. * Defines if the framing behavior of the camera is enabled on the camera.
  37067. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37068. */
  37069. useFramingBehavior: boolean;
  37070. private _autoRotationBehavior;
  37071. /**
  37072. * Gets the auto rotation behavior of the camera if it has been enabled.
  37073. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37074. */
  37075. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37076. /**
  37077. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37078. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37079. */
  37080. useAutoRotationBehavior: boolean;
  37081. /**
  37082. * Observable triggered when the mesh target has been changed on the camera.
  37083. */
  37084. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37085. /**
  37086. * Event raised when the camera is colliding with a mesh.
  37087. */
  37088. onCollide: (collidedMesh: AbstractMesh) => void;
  37089. /**
  37090. * Defines whether the camera should check collision with the objects oh the scene.
  37091. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37092. */
  37093. checkCollisions: boolean;
  37094. /**
  37095. * Defines the collision radius of the camera.
  37096. * This simulates a sphere around the camera.
  37097. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37098. */
  37099. collisionRadius: Vector3;
  37100. protected _collider: Collider;
  37101. protected _previousPosition: Vector3;
  37102. protected _collisionVelocity: Vector3;
  37103. protected _newPosition: Vector3;
  37104. protected _previousAlpha: number;
  37105. protected _previousBeta: number;
  37106. protected _previousRadius: number;
  37107. protected _collisionTriggered: boolean;
  37108. protected _targetBoundingCenter: Nullable<Vector3>;
  37109. private _computationVector;
  37110. /**
  37111. * Instantiates a new ArcRotateCamera in a given scene
  37112. * @param name Defines the name of the camera
  37113. * @param alpha Defines the camera rotation along the logitudinal axis
  37114. * @param beta Defines the camera rotation along the latitudinal axis
  37115. * @param radius Defines the camera distance from its target
  37116. * @param target Defines the camera target
  37117. * @param scene Defines the scene the camera belongs to
  37118. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37119. */
  37120. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37121. /** @hidden */
  37122. _initCache(): void;
  37123. /** @hidden */
  37124. _updateCache(ignoreParentClass?: boolean): void;
  37125. protected _getTargetPosition(): Vector3;
  37126. private _storedAlpha;
  37127. private _storedBeta;
  37128. private _storedRadius;
  37129. private _storedTarget;
  37130. /**
  37131. * Stores the current state of the camera (alpha, beta, radius and target)
  37132. * @returns the camera itself
  37133. */
  37134. storeState(): Camera;
  37135. /**
  37136. * @hidden
  37137. * Restored camera state. You must call storeState() first
  37138. */
  37139. _restoreStateValues(): boolean;
  37140. /** @hidden */
  37141. _isSynchronizedViewMatrix(): boolean;
  37142. /**
  37143. * Attached controls to the current camera.
  37144. * @param element Defines the element the controls should be listened from
  37145. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37146. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37147. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37148. */
  37149. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37150. /**
  37151. * Detach the current controls from the camera.
  37152. * The camera will stop reacting to inputs.
  37153. * @param element Defines the element to stop listening the inputs from
  37154. */
  37155. detachControl(element: HTMLElement): void;
  37156. /** @hidden */
  37157. _checkInputs(): void;
  37158. protected _checkLimits(): void;
  37159. /**
  37160. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37161. */
  37162. rebuildAnglesAndRadius(): void;
  37163. /**
  37164. * Use a position to define the current camera related information like aplha, beta and radius
  37165. * @param position Defines the position to set the camera at
  37166. */
  37167. setPosition(position: Vector3): void;
  37168. /**
  37169. * Defines the target the camera should look at.
  37170. * This will automatically adapt alpha beta and radius to fit within the new target.
  37171. * @param target Defines the new target as a Vector or a mesh
  37172. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37173. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37174. */
  37175. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37176. /** @hidden */
  37177. _getViewMatrix(): Matrix;
  37178. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37179. /**
  37180. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37181. * @param meshes Defines the mesh to zoom on
  37182. * @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)
  37183. */
  37184. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37185. /**
  37186. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37187. * The target will be changed but the radius
  37188. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37189. * @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)
  37190. */
  37191. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37192. min: Vector3;
  37193. max: Vector3;
  37194. distance: number;
  37195. }, doNotUpdateMaxZ?: boolean): void;
  37196. /**
  37197. * @override
  37198. * Override Camera.createRigCamera
  37199. */
  37200. createRigCamera(name: string, cameraIndex: number): Camera;
  37201. /**
  37202. * @hidden
  37203. * @override
  37204. * Override Camera._updateRigCameras
  37205. */
  37206. _updateRigCameras(): void;
  37207. /**
  37208. * Destroy the camera and release the current resources hold by it.
  37209. */
  37210. dispose(): void;
  37211. /**
  37212. * Gets the current object class name.
  37213. * @return the class name
  37214. */
  37215. getClassName(): string;
  37216. }
  37217. }
  37218. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37219. import { Behavior } from "babylonjs/Behaviors/behavior";
  37220. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37221. /**
  37222. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37223. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37224. */
  37225. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37226. /**
  37227. * Gets the name of the behavior.
  37228. */
  37229. readonly name: string;
  37230. private _zoomStopsAnimation;
  37231. private _idleRotationSpeed;
  37232. private _idleRotationWaitTime;
  37233. private _idleRotationSpinupTime;
  37234. /**
  37235. * Sets the flag that indicates if user zooming should stop animation.
  37236. */
  37237. /**
  37238. * Gets the flag that indicates if user zooming should stop animation.
  37239. */
  37240. zoomStopsAnimation: boolean;
  37241. /**
  37242. * Sets the default speed at which the camera rotates around the model.
  37243. */
  37244. /**
  37245. * Gets the default speed at which the camera rotates around the model.
  37246. */
  37247. idleRotationSpeed: number;
  37248. /**
  37249. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37250. */
  37251. /**
  37252. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37253. */
  37254. idleRotationWaitTime: number;
  37255. /**
  37256. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37257. */
  37258. /**
  37259. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37260. */
  37261. idleRotationSpinupTime: number;
  37262. /**
  37263. * Gets a value indicating if the camera is currently rotating because of this behavior
  37264. */
  37265. readonly rotationInProgress: boolean;
  37266. private _onPrePointerObservableObserver;
  37267. private _onAfterCheckInputsObserver;
  37268. private _attachedCamera;
  37269. private _isPointerDown;
  37270. private _lastFrameTime;
  37271. private _lastInteractionTime;
  37272. private _cameraRotationSpeed;
  37273. /**
  37274. * Initializes the behavior.
  37275. */
  37276. init(): void;
  37277. /**
  37278. * Attaches the behavior to its arc rotate camera.
  37279. * @param camera Defines the camera to attach the behavior to
  37280. */
  37281. attach(camera: ArcRotateCamera): void;
  37282. /**
  37283. * Detaches the behavior from its current arc rotate camera.
  37284. */
  37285. detach(): void;
  37286. /**
  37287. * Returns true if user is scrolling.
  37288. * @return true if user is scrolling.
  37289. */
  37290. private _userIsZooming;
  37291. private _lastFrameRadius;
  37292. private _shouldAnimationStopForInteraction;
  37293. /**
  37294. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37295. */
  37296. private _applyUserInteraction;
  37297. private _userIsMoving;
  37298. }
  37299. }
  37300. declare module "babylonjs/Behaviors/Cameras/index" {
  37301. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37302. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37303. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37304. }
  37305. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37306. import { Mesh } from "babylonjs/Meshes/mesh";
  37307. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37308. import { Behavior } from "babylonjs/Behaviors/behavior";
  37309. /**
  37310. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37311. */
  37312. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37313. private ui;
  37314. /**
  37315. * The name of the behavior
  37316. */
  37317. name: string;
  37318. /**
  37319. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37320. */
  37321. distanceAwayFromFace: number;
  37322. /**
  37323. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37324. */
  37325. distanceAwayFromBottomOfFace: number;
  37326. private _faceVectors;
  37327. private _target;
  37328. private _scene;
  37329. private _onRenderObserver;
  37330. private _tmpMatrix;
  37331. private _tmpVector;
  37332. /**
  37333. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37334. * @param ui The transform node that should be attched to the mesh
  37335. */
  37336. constructor(ui: TransformNode);
  37337. /**
  37338. * Initializes the behavior
  37339. */
  37340. init(): void;
  37341. private _closestFace;
  37342. private _zeroVector;
  37343. private _lookAtTmpMatrix;
  37344. private _lookAtToRef;
  37345. /**
  37346. * Attaches the AttachToBoxBehavior to the passed in mesh
  37347. * @param target The mesh that the specified node will be attached to
  37348. */
  37349. attach(target: Mesh): void;
  37350. /**
  37351. * Detaches the behavior from the mesh
  37352. */
  37353. detach(): void;
  37354. }
  37355. }
  37356. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37357. import { Behavior } from "babylonjs/Behaviors/behavior";
  37358. import { Mesh } from "babylonjs/Meshes/mesh";
  37359. /**
  37360. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37361. */
  37362. export class FadeInOutBehavior implements Behavior<Mesh> {
  37363. /**
  37364. * Time in milliseconds to delay before fading in (Default: 0)
  37365. */
  37366. delay: number;
  37367. /**
  37368. * Time in milliseconds for the mesh to fade in (Default: 300)
  37369. */
  37370. fadeInTime: number;
  37371. private _millisecondsPerFrame;
  37372. private _hovered;
  37373. private _hoverValue;
  37374. private _ownerNode;
  37375. /**
  37376. * Instatiates the FadeInOutBehavior
  37377. */
  37378. constructor();
  37379. /**
  37380. * The name of the behavior
  37381. */
  37382. readonly name: string;
  37383. /**
  37384. * Initializes the behavior
  37385. */
  37386. init(): void;
  37387. /**
  37388. * Attaches the fade behavior on the passed in mesh
  37389. * @param ownerNode The mesh that will be faded in/out once attached
  37390. */
  37391. attach(ownerNode: Mesh): void;
  37392. /**
  37393. * Detaches the behavior from the mesh
  37394. */
  37395. detach(): void;
  37396. /**
  37397. * Triggers the mesh to begin fading in or out
  37398. * @param value if the object should fade in or out (true to fade in)
  37399. */
  37400. fadeIn(value: boolean): void;
  37401. private _update;
  37402. private _setAllVisibility;
  37403. }
  37404. }
  37405. declare module "babylonjs/Misc/pivotTools" {
  37406. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37407. /**
  37408. * Class containing a set of static utilities functions for managing Pivots
  37409. * @hidden
  37410. */
  37411. export class PivotTools {
  37412. private static _PivotCached;
  37413. private static _OldPivotPoint;
  37414. private static _PivotTranslation;
  37415. private static _PivotTmpVector;
  37416. /** @hidden */
  37417. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37418. /** @hidden */
  37419. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37420. }
  37421. }
  37422. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37423. import { Scene } from "babylonjs/scene";
  37424. import { Vector4 } from "babylonjs/Maths/math.vector";
  37425. import { Mesh } from "babylonjs/Meshes/mesh";
  37426. import { Nullable } from "babylonjs/types";
  37427. import { Plane } from "babylonjs/Maths/math.plane";
  37428. /**
  37429. * Class containing static functions to help procedurally build meshes
  37430. */
  37431. export class PlaneBuilder {
  37432. /**
  37433. * Creates a plane mesh
  37434. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37435. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37436. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37437. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37438. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37440. * @param name defines the name of the mesh
  37441. * @param options defines the options used to create the mesh
  37442. * @param scene defines the hosting scene
  37443. * @returns the plane mesh
  37444. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37445. */
  37446. static CreatePlane(name: string, options: {
  37447. size?: number;
  37448. width?: number;
  37449. height?: number;
  37450. sideOrientation?: number;
  37451. frontUVs?: Vector4;
  37452. backUVs?: Vector4;
  37453. updatable?: boolean;
  37454. sourcePlane?: Plane;
  37455. }, scene?: Nullable<Scene>): Mesh;
  37456. }
  37457. }
  37458. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37459. import { Behavior } from "babylonjs/Behaviors/behavior";
  37460. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37461. import { Observable } from "babylonjs/Misc/observable";
  37462. import { Vector3 } from "babylonjs/Maths/math.vector";
  37463. import { Ray } from "babylonjs/Culling/ray";
  37464. import "babylonjs/Meshes/Builders/planeBuilder";
  37465. /**
  37466. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37467. */
  37468. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37469. private static _AnyMouseID;
  37470. /**
  37471. * Abstract mesh the behavior is set on
  37472. */
  37473. attachedNode: AbstractMesh;
  37474. private _dragPlane;
  37475. private _scene;
  37476. private _pointerObserver;
  37477. private _beforeRenderObserver;
  37478. private static _planeScene;
  37479. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37480. /**
  37481. * 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)
  37482. */
  37483. maxDragAngle: number;
  37484. /**
  37485. * @hidden
  37486. */
  37487. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37488. /**
  37489. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37490. */
  37491. currentDraggingPointerID: number;
  37492. /**
  37493. * The last position where the pointer hit the drag plane in world space
  37494. */
  37495. lastDragPosition: Vector3;
  37496. /**
  37497. * If the behavior is currently in a dragging state
  37498. */
  37499. dragging: boolean;
  37500. /**
  37501. * 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)
  37502. */
  37503. dragDeltaRatio: number;
  37504. /**
  37505. * If the drag plane orientation should be updated during the dragging (Default: true)
  37506. */
  37507. updateDragPlane: boolean;
  37508. private _debugMode;
  37509. private _moving;
  37510. /**
  37511. * Fires each time the attached mesh is dragged with the pointer
  37512. * * delta between last drag position and current drag position in world space
  37513. * * dragDistance along the drag axis
  37514. * * dragPlaneNormal normal of the current drag plane used during the drag
  37515. * * dragPlanePoint in world space where the drag intersects the drag plane
  37516. */
  37517. onDragObservable: Observable<{
  37518. delta: Vector3;
  37519. dragPlanePoint: Vector3;
  37520. dragPlaneNormal: Vector3;
  37521. dragDistance: number;
  37522. pointerId: number;
  37523. }>;
  37524. /**
  37525. * Fires each time a drag begins (eg. mouse down on mesh)
  37526. */
  37527. onDragStartObservable: Observable<{
  37528. dragPlanePoint: Vector3;
  37529. pointerId: number;
  37530. }>;
  37531. /**
  37532. * Fires each time a drag ends (eg. mouse release after drag)
  37533. */
  37534. onDragEndObservable: Observable<{
  37535. dragPlanePoint: Vector3;
  37536. pointerId: number;
  37537. }>;
  37538. /**
  37539. * If the attached mesh should be moved when dragged
  37540. */
  37541. moveAttached: boolean;
  37542. /**
  37543. * If the drag behavior will react to drag events (Default: true)
  37544. */
  37545. enabled: boolean;
  37546. /**
  37547. * If pointer events should start and release the drag (Default: true)
  37548. */
  37549. startAndReleaseDragOnPointerEvents: boolean;
  37550. /**
  37551. * If camera controls should be detached during the drag
  37552. */
  37553. detachCameraControls: boolean;
  37554. /**
  37555. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37556. */
  37557. useObjectOrienationForDragging: boolean;
  37558. private _options;
  37559. /**
  37560. * Creates a pointer drag behavior that can be attached to a mesh
  37561. * @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)
  37562. */
  37563. constructor(options?: {
  37564. dragAxis?: Vector3;
  37565. dragPlaneNormal?: Vector3;
  37566. });
  37567. /**
  37568. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37569. */
  37570. validateDrag: (targetPosition: Vector3) => boolean;
  37571. /**
  37572. * The name of the behavior
  37573. */
  37574. readonly name: string;
  37575. /**
  37576. * Initializes the behavior
  37577. */
  37578. init(): void;
  37579. private _tmpVector;
  37580. private _alternatePickedPoint;
  37581. private _worldDragAxis;
  37582. private _targetPosition;
  37583. private _attachedElement;
  37584. /**
  37585. * Attaches the drag behavior the passed in mesh
  37586. * @param ownerNode The mesh that will be dragged around once attached
  37587. */
  37588. attach(ownerNode: AbstractMesh): void;
  37589. /**
  37590. * Force relase the drag action by code.
  37591. */
  37592. releaseDrag(): void;
  37593. private _startDragRay;
  37594. private _lastPointerRay;
  37595. /**
  37596. * Simulates the start of a pointer drag event on the behavior
  37597. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37598. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37599. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37600. */
  37601. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37602. private _startDrag;
  37603. private _dragDelta;
  37604. private _moveDrag;
  37605. private _pickWithRayOnDragPlane;
  37606. private _pointA;
  37607. private _pointB;
  37608. private _pointC;
  37609. private _lineA;
  37610. private _lineB;
  37611. private _localAxis;
  37612. private _lookAt;
  37613. private _updateDragPlanePosition;
  37614. /**
  37615. * Detaches the behavior from the mesh
  37616. */
  37617. detach(): void;
  37618. }
  37619. }
  37620. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37621. import { Mesh } from "babylonjs/Meshes/mesh";
  37622. import { Behavior } from "babylonjs/Behaviors/behavior";
  37623. /**
  37624. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37625. */
  37626. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37627. private _dragBehaviorA;
  37628. private _dragBehaviorB;
  37629. private _startDistance;
  37630. private _initialScale;
  37631. private _targetScale;
  37632. private _ownerNode;
  37633. private _sceneRenderObserver;
  37634. /**
  37635. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37636. */
  37637. constructor();
  37638. /**
  37639. * The name of the behavior
  37640. */
  37641. readonly name: string;
  37642. /**
  37643. * Initializes the behavior
  37644. */
  37645. init(): void;
  37646. private _getCurrentDistance;
  37647. /**
  37648. * Attaches the scale behavior the passed in mesh
  37649. * @param ownerNode The mesh that will be scaled around once attached
  37650. */
  37651. attach(ownerNode: Mesh): void;
  37652. /**
  37653. * Detaches the behavior from the mesh
  37654. */
  37655. detach(): void;
  37656. }
  37657. }
  37658. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37659. import { Behavior } from "babylonjs/Behaviors/behavior";
  37660. import { Mesh } from "babylonjs/Meshes/mesh";
  37661. import { Observable } from "babylonjs/Misc/observable";
  37662. /**
  37663. * 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
  37664. */
  37665. export class SixDofDragBehavior implements Behavior<Mesh> {
  37666. private static _virtualScene;
  37667. private _ownerNode;
  37668. private _sceneRenderObserver;
  37669. private _scene;
  37670. private _targetPosition;
  37671. private _virtualOriginMesh;
  37672. private _virtualDragMesh;
  37673. private _pointerObserver;
  37674. private _moving;
  37675. private _startingOrientation;
  37676. /**
  37677. * 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)
  37678. */
  37679. private zDragFactor;
  37680. /**
  37681. * If the object should rotate to face the drag origin
  37682. */
  37683. rotateDraggedObject: boolean;
  37684. /**
  37685. * If the behavior is currently in a dragging state
  37686. */
  37687. dragging: boolean;
  37688. /**
  37689. * 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)
  37690. */
  37691. dragDeltaRatio: number;
  37692. /**
  37693. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37694. */
  37695. currentDraggingPointerID: number;
  37696. /**
  37697. * If camera controls should be detached during the drag
  37698. */
  37699. detachCameraControls: boolean;
  37700. /**
  37701. * Fires each time a drag starts
  37702. */
  37703. onDragStartObservable: Observable<{}>;
  37704. /**
  37705. * Fires each time a drag ends (eg. mouse release after drag)
  37706. */
  37707. onDragEndObservable: Observable<{}>;
  37708. /**
  37709. * 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
  37710. */
  37711. constructor();
  37712. /**
  37713. * The name of the behavior
  37714. */
  37715. readonly name: string;
  37716. /**
  37717. * Initializes the behavior
  37718. */
  37719. init(): void;
  37720. /**
  37721. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37722. */
  37723. private readonly _pointerCamera;
  37724. /**
  37725. * Attaches the scale behavior the passed in mesh
  37726. * @param ownerNode The mesh that will be scaled around once attached
  37727. */
  37728. attach(ownerNode: Mesh): void;
  37729. /**
  37730. * Detaches the behavior from the mesh
  37731. */
  37732. detach(): void;
  37733. }
  37734. }
  37735. declare module "babylonjs/Behaviors/Meshes/index" {
  37736. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37737. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37738. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37739. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37740. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37741. }
  37742. declare module "babylonjs/Behaviors/index" {
  37743. export * from "babylonjs/Behaviors/behavior";
  37744. export * from "babylonjs/Behaviors/Cameras/index";
  37745. export * from "babylonjs/Behaviors/Meshes/index";
  37746. }
  37747. declare module "babylonjs/Bones/boneIKController" {
  37748. import { Bone } from "babylonjs/Bones/bone";
  37749. import { Vector3 } from "babylonjs/Maths/math.vector";
  37750. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37751. import { Nullable } from "babylonjs/types";
  37752. /**
  37753. * Class used to apply inverse kinematics to bones
  37754. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37755. */
  37756. export class BoneIKController {
  37757. private static _tmpVecs;
  37758. private static _tmpQuat;
  37759. private static _tmpMats;
  37760. /**
  37761. * Gets or sets the target mesh
  37762. */
  37763. targetMesh: AbstractMesh;
  37764. /** Gets or sets the mesh used as pole */
  37765. poleTargetMesh: AbstractMesh;
  37766. /**
  37767. * Gets or sets the bone used as pole
  37768. */
  37769. poleTargetBone: Nullable<Bone>;
  37770. /**
  37771. * Gets or sets the target position
  37772. */
  37773. targetPosition: Vector3;
  37774. /**
  37775. * Gets or sets the pole target position
  37776. */
  37777. poleTargetPosition: Vector3;
  37778. /**
  37779. * Gets or sets the pole target local offset
  37780. */
  37781. poleTargetLocalOffset: Vector3;
  37782. /**
  37783. * Gets or sets the pole angle
  37784. */
  37785. poleAngle: number;
  37786. /**
  37787. * Gets or sets the mesh associated with the controller
  37788. */
  37789. mesh: AbstractMesh;
  37790. /**
  37791. * 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)
  37792. */
  37793. slerpAmount: number;
  37794. private _bone1Quat;
  37795. private _bone1Mat;
  37796. private _bone2Ang;
  37797. private _bone1;
  37798. private _bone2;
  37799. private _bone1Length;
  37800. private _bone2Length;
  37801. private _maxAngle;
  37802. private _maxReach;
  37803. private _rightHandedSystem;
  37804. private _bendAxis;
  37805. private _slerping;
  37806. private _adjustRoll;
  37807. /**
  37808. * Gets or sets maximum allowed angle
  37809. */
  37810. maxAngle: number;
  37811. /**
  37812. * Creates a new BoneIKController
  37813. * @param mesh defines the mesh to control
  37814. * @param bone defines the bone to control
  37815. * @param options defines options to set up the controller
  37816. */
  37817. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37818. targetMesh?: AbstractMesh;
  37819. poleTargetMesh?: AbstractMesh;
  37820. poleTargetBone?: Bone;
  37821. poleTargetLocalOffset?: Vector3;
  37822. poleAngle?: number;
  37823. bendAxis?: Vector3;
  37824. maxAngle?: number;
  37825. slerpAmount?: number;
  37826. });
  37827. private _setMaxAngle;
  37828. /**
  37829. * Force the controller to update the bones
  37830. */
  37831. update(): void;
  37832. }
  37833. }
  37834. declare module "babylonjs/Bones/boneLookController" {
  37835. import { Vector3 } from "babylonjs/Maths/math.vector";
  37836. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37837. import { Bone } from "babylonjs/Bones/bone";
  37838. import { Space } from "babylonjs/Maths/math.axis";
  37839. /**
  37840. * Class used to make a bone look toward a point in space
  37841. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37842. */
  37843. export class BoneLookController {
  37844. private static _tmpVecs;
  37845. private static _tmpQuat;
  37846. private static _tmpMats;
  37847. /**
  37848. * The target Vector3 that the bone will look at
  37849. */
  37850. target: Vector3;
  37851. /**
  37852. * The mesh that the bone is attached to
  37853. */
  37854. mesh: AbstractMesh;
  37855. /**
  37856. * The bone that will be looking to the target
  37857. */
  37858. bone: Bone;
  37859. /**
  37860. * The up axis of the coordinate system that is used when the bone is rotated
  37861. */
  37862. upAxis: Vector3;
  37863. /**
  37864. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37865. */
  37866. upAxisSpace: Space;
  37867. /**
  37868. * Used to make an adjustment to the yaw of the bone
  37869. */
  37870. adjustYaw: number;
  37871. /**
  37872. * Used to make an adjustment to the pitch of the bone
  37873. */
  37874. adjustPitch: number;
  37875. /**
  37876. * Used to make an adjustment to the roll of the bone
  37877. */
  37878. adjustRoll: number;
  37879. /**
  37880. * 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)
  37881. */
  37882. slerpAmount: number;
  37883. private _minYaw;
  37884. private _maxYaw;
  37885. private _minPitch;
  37886. private _maxPitch;
  37887. private _minYawSin;
  37888. private _minYawCos;
  37889. private _maxYawSin;
  37890. private _maxYawCos;
  37891. private _midYawConstraint;
  37892. private _minPitchTan;
  37893. private _maxPitchTan;
  37894. private _boneQuat;
  37895. private _slerping;
  37896. private _transformYawPitch;
  37897. private _transformYawPitchInv;
  37898. private _firstFrameSkipped;
  37899. private _yawRange;
  37900. private _fowardAxis;
  37901. /**
  37902. * Gets or sets the minimum yaw angle that the bone can look to
  37903. */
  37904. minYaw: number;
  37905. /**
  37906. * Gets or sets the maximum yaw angle that the bone can look to
  37907. */
  37908. maxYaw: number;
  37909. /**
  37910. * Gets or sets the minimum pitch angle that the bone can look to
  37911. */
  37912. minPitch: number;
  37913. /**
  37914. * Gets or sets the maximum pitch angle that the bone can look to
  37915. */
  37916. maxPitch: number;
  37917. /**
  37918. * Create a BoneLookController
  37919. * @param mesh the mesh that the bone belongs to
  37920. * @param bone the bone that will be looking to the target
  37921. * @param target the target Vector3 to look at
  37922. * @param options optional settings:
  37923. * * maxYaw: the maximum angle the bone will yaw to
  37924. * * minYaw: the minimum angle the bone will yaw to
  37925. * * maxPitch: the maximum angle the bone will pitch to
  37926. * * minPitch: the minimum angle the bone will yaw to
  37927. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37928. * * upAxis: the up axis of the coordinate system
  37929. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37930. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37931. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37932. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37933. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37934. * * adjustRoll: used to make an adjustment to the roll of the bone
  37935. **/
  37936. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37937. maxYaw?: number;
  37938. minYaw?: number;
  37939. maxPitch?: number;
  37940. minPitch?: number;
  37941. slerpAmount?: number;
  37942. upAxis?: Vector3;
  37943. upAxisSpace?: Space;
  37944. yawAxis?: Vector3;
  37945. pitchAxis?: Vector3;
  37946. adjustYaw?: number;
  37947. adjustPitch?: number;
  37948. adjustRoll?: number;
  37949. });
  37950. /**
  37951. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37952. */
  37953. update(): void;
  37954. private _getAngleDiff;
  37955. private _getAngleBetween;
  37956. private _isAngleBetween;
  37957. }
  37958. }
  37959. declare module "babylonjs/Bones/index" {
  37960. export * from "babylonjs/Bones/bone";
  37961. export * from "babylonjs/Bones/boneIKController";
  37962. export * from "babylonjs/Bones/boneLookController";
  37963. export * from "babylonjs/Bones/skeleton";
  37964. }
  37965. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  37966. import { Nullable } from "babylonjs/types";
  37967. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37968. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37969. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37970. /**
  37971. * Manage the gamepad inputs to control an arc rotate camera.
  37972. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37973. */
  37974. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37975. /**
  37976. * Defines the camera the input is attached to.
  37977. */
  37978. camera: ArcRotateCamera;
  37979. /**
  37980. * Defines the gamepad the input is gathering event from.
  37981. */
  37982. gamepad: Nullable<Gamepad>;
  37983. /**
  37984. * Defines the gamepad rotation sensiblity.
  37985. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37986. */
  37987. gamepadRotationSensibility: number;
  37988. /**
  37989. * Defines the gamepad move sensiblity.
  37990. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37991. */
  37992. gamepadMoveSensibility: number;
  37993. private _onGamepadConnectedObserver;
  37994. private _onGamepadDisconnectedObserver;
  37995. /**
  37996. * Attach the input controls to a specific dom element to get the input from.
  37997. * @param element Defines the element the controls should be listened from
  37998. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37999. */
  38000. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38001. /**
  38002. * Detach the current controls from the specified dom element.
  38003. * @param element Defines the element to stop listening the inputs from
  38004. */
  38005. detachControl(element: Nullable<HTMLElement>): void;
  38006. /**
  38007. * Update the current camera state depending on the inputs that have been used this frame.
  38008. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38009. */
  38010. checkInputs(): void;
  38011. /**
  38012. * Gets the class name of the current intput.
  38013. * @returns the class name
  38014. */
  38015. getClassName(): string;
  38016. /**
  38017. * Get the friendly name associated with the input class.
  38018. * @returns the input friendly name
  38019. */
  38020. getSimpleName(): string;
  38021. }
  38022. }
  38023. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38024. import { Nullable } from "babylonjs/types";
  38025. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38026. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38027. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38028. interface ArcRotateCameraInputsManager {
  38029. /**
  38030. * Add orientation input support to the input manager.
  38031. * @returns the current input manager
  38032. */
  38033. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38034. }
  38035. }
  38036. /**
  38037. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38038. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38039. */
  38040. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38041. /**
  38042. * Defines the camera the input is attached to.
  38043. */
  38044. camera: ArcRotateCamera;
  38045. /**
  38046. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38047. */
  38048. alphaCorrection: number;
  38049. /**
  38050. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38051. */
  38052. gammaCorrection: number;
  38053. private _alpha;
  38054. private _gamma;
  38055. private _dirty;
  38056. private _deviceOrientationHandler;
  38057. /**
  38058. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38059. */
  38060. constructor();
  38061. /**
  38062. * Attach the input controls to a specific dom element to get the input from.
  38063. * @param element Defines the element the controls should be listened from
  38064. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38065. */
  38066. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38067. /** @hidden */
  38068. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38069. /**
  38070. * Update the current camera state depending on the inputs that have been used this frame.
  38071. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38072. */
  38073. checkInputs(): void;
  38074. /**
  38075. * Detach the current controls from the specified dom element.
  38076. * @param element Defines the element to stop listening the inputs from
  38077. */
  38078. detachControl(element: Nullable<HTMLElement>): void;
  38079. /**
  38080. * Gets the class name of the current intput.
  38081. * @returns the class name
  38082. */
  38083. getClassName(): string;
  38084. /**
  38085. * Get the friendly name associated with the input class.
  38086. * @returns the input friendly name
  38087. */
  38088. getSimpleName(): string;
  38089. }
  38090. }
  38091. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38092. import { Nullable } from "babylonjs/types";
  38093. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38094. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38095. /**
  38096. * Listen to mouse events to control the camera.
  38097. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38098. */
  38099. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38100. /**
  38101. * Defines the camera the input is attached to.
  38102. */
  38103. camera: FlyCamera;
  38104. /**
  38105. * Defines if touch is enabled. (Default is true.)
  38106. */
  38107. touchEnabled: boolean;
  38108. /**
  38109. * Defines the buttons associated with the input to handle camera rotation.
  38110. */
  38111. buttons: number[];
  38112. /**
  38113. * Assign buttons for Yaw control.
  38114. */
  38115. buttonsYaw: number[];
  38116. /**
  38117. * Assign buttons for Pitch control.
  38118. */
  38119. buttonsPitch: number[];
  38120. /**
  38121. * Assign buttons for Roll control.
  38122. */
  38123. buttonsRoll: number[];
  38124. /**
  38125. * Detect if any button is being pressed while mouse is moved.
  38126. * -1 = Mouse locked.
  38127. * 0 = Left button.
  38128. * 1 = Middle Button.
  38129. * 2 = Right Button.
  38130. */
  38131. activeButton: number;
  38132. /**
  38133. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38134. * Higher values reduce its sensitivity.
  38135. */
  38136. angularSensibility: number;
  38137. private _mousemoveCallback;
  38138. private _observer;
  38139. private _rollObserver;
  38140. private previousPosition;
  38141. private noPreventDefault;
  38142. private element;
  38143. /**
  38144. * Listen to mouse events to control the camera.
  38145. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38146. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38147. */
  38148. constructor(touchEnabled?: boolean);
  38149. /**
  38150. * Attach the mouse control to the HTML DOM element.
  38151. * @param element Defines the element that listens to the input events.
  38152. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38153. */
  38154. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38155. /**
  38156. * Detach the current controls from the specified dom element.
  38157. * @param element Defines the element to stop listening the inputs from
  38158. */
  38159. detachControl(element: Nullable<HTMLElement>): void;
  38160. /**
  38161. * Gets the class name of the current input.
  38162. * @returns the class name.
  38163. */
  38164. getClassName(): string;
  38165. /**
  38166. * Get the friendly name associated with the input class.
  38167. * @returns the input's friendly name.
  38168. */
  38169. getSimpleName(): string;
  38170. private _pointerInput;
  38171. private _onMouseMove;
  38172. /**
  38173. * Rotate camera by mouse offset.
  38174. */
  38175. private rotateCamera;
  38176. }
  38177. }
  38178. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38179. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38180. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38181. /**
  38182. * Default Inputs manager for the FlyCamera.
  38183. * It groups all the default supported inputs for ease of use.
  38184. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38185. */
  38186. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38187. /**
  38188. * Instantiates a new FlyCameraInputsManager.
  38189. * @param camera Defines the camera the inputs belong to.
  38190. */
  38191. constructor(camera: FlyCamera);
  38192. /**
  38193. * Add keyboard input support to the input manager.
  38194. * @returns the new FlyCameraKeyboardMoveInput().
  38195. */
  38196. addKeyboard(): FlyCameraInputsManager;
  38197. /**
  38198. * Add mouse input support to the input manager.
  38199. * @param touchEnabled Enable touch screen support.
  38200. * @returns the new FlyCameraMouseInput().
  38201. */
  38202. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38203. }
  38204. }
  38205. declare module "babylonjs/Cameras/flyCamera" {
  38206. import { Scene } from "babylonjs/scene";
  38207. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38208. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38209. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38210. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38211. /**
  38212. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38213. * such as in a 3D Space Shooter or a Flight Simulator.
  38214. */
  38215. export class FlyCamera extends TargetCamera {
  38216. /**
  38217. * Define the collision ellipsoid of the camera.
  38218. * This is helpful for simulating a camera body, like a player's body.
  38219. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38220. */
  38221. ellipsoid: Vector3;
  38222. /**
  38223. * Define an offset for the position of the ellipsoid around the camera.
  38224. * This can be helpful if the camera is attached away from the player's body center,
  38225. * such as at its head.
  38226. */
  38227. ellipsoidOffset: Vector3;
  38228. /**
  38229. * Enable or disable collisions of the camera with the rest of the scene objects.
  38230. */
  38231. checkCollisions: boolean;
  38232. /**
  38233. * Enable or disable gravity on the camera.
  38234. */
  38235. applyGravity: boolean;
  38236. /**
  38237. * Define the current direction the camera is moving to.
  38238. */
  38239. cameraDirection: Vector3;
  38240. /**
  38241. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38242. * This overrides and empties cameraRotation.
  38243. */
  38244. rotationQuaternion: Quaternion;
  38245. /**
  38246. * Track Roll to maintain the wanted Rolling when looking around.
  38247. */
  38248. _trackRoll: number;
  38249. /**
  38250. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38251. */
  38252. rollCorrect: number;
  38253. /**
  38254. * Mimic a banked turn, Rolling the camera when Yawing.
  38255. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38256. */
  38257. bankedTurn: boolean;
  38258. /**
  38259. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38260. */
  38261. bankedTurnLimit: number;
  38262. /**
  38263. * Value of 0 disables the banked Roll.
  38264. * Value of 1 is equal to the Yaw angle in radians.
  38265. */
  38266. bankedTurnMultiplier: number;
  38267. /**
  38268. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38269. */
  38270. inputs: FlyCameraInputsManager;
  38271. /**
  38272. * Gets the input sensibility for mouse input.
  38273. * Higher values reduce sensitivity.
  38274. */
  38275. /**
  38276. * Sets the input sensibility for a mouse input.
  38277. * Higher values reduce sensitivity.
  38278. */
  38279. angularSensibility: number;
  38280. /**
  38281. * Get the keys for camera movement forward.
  38282. */
  38283. /**
  38284. * Set the keys for camera movement forward.
  38285. */
  38286. keysForward: number[];
  38287. /**
  38288. * Get the keys for camera movement backward.
  38289. */
  38290. keysBackward: number[];
  38291. /**
  38292. * Get the keys for camera movement up.
  38293. */
  38294. /**
  38295. * Set the keys for camera movement up.
  38296. */
  38297. keysUp: number[];
  38298. /**
  38299. * Get the keys for camera movement down.
  38300. */
  38301. /**
  38302. * Set the keys for camera movement down.
  38303. */
  38304. keysDown: number[];
  38305. /**
  38306. * Get the keys for camera movement left.
  38307. */
  38308. /**
  38309. * Set the keys for camera movement left.
  38310. */
  38311. keysLeft: number[];
  38312. /**
  38313. * Set the keys for camera movement right.
  38314. */
  38315. /**
  38316. * Set the keys for camera movement right.
  38317. */
  38318. keysRight: number[];
  38319. /**
  38320. * Event raised when the camera collides with a mesh in the scene.
  38321. */
  38322. onCollide: (collidedMesh: AbstractMesh) => void;
  38323. private _collider;
  38324. private _needMoveForGravity;
  38325. private _oldPosition;
  38326. private _diffPosition;
  38327. private _newPosition;
  38328. /** @hidden */
  38329. _localDirection: Vector3;
  38330. /** @hidden */
  38331. _transformedDirection: Vector3;
  38332. /**
  38333. * Instantiates a FlyCamera.
  38334. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38335. * such as in a 3D Space Shooter or a Flight Simulator.
  38336. * @param name Define the name of the camera in the scene.
  38337. * @param position Define the starting position of the camera in the scene.
  38338. * @param scene Define the scene the camera belongs to.
  38339. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38340. */
  38341. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38342. /**
  38343. * Attach a control to the HTML DOM element.
  38344. * @param element Defines the element that listens to the input events.
  38345. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38346. */
  38347. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38348. /**
  38349. * Detach a control from the HTML DOM element.
  38350. * The camera will stop reacting to that input.
  38351. * @param element Defines the element that listens to the input events.
  38352. */
  38353. detachControl(element: HTMLElement): void;
  38354. private _collisionMask;
  38355. /**
  38356. * Get the mask that the camera ignores in collision events.
  38357. */
  38358. /**
  38359. * Set the mask that the camera ignores in collision events.
  38360. */
  38361. collisionMask: number;
  38362. /** @hidden */
  38363. _collideWithWorld(displacement: Vector3): void;
  38364. /** @hidden */
  38365. private _onCollisionPositionChange;
  38366. /** @hidden */
  38367. _checkInputs(): void;
  38368. /** @hidden */
  38369. _decideIfNeedsToMove(): boolean;
  38370. /** @hidden */
  38371. _updatePosition(): void;
  38372. /**
  38373. * Restore the Roll to its target value at the rate specified.
  38374. * @param rate - Higher means slower restoring.
  38375. * @hidden
  38376. */
  38377. restoreRoll(rate: number): void;
  38378. /**
  38379. * Destroy the camera and release the current resources held by it.
  38380. */
  38381. dispose(): void;
  38382. /**
  38383. * Get the current object class name.
  38384. * @returns the class name.
  38385. */
  38386. getClassName(): string;
  38387. }
  38388. }
  38389. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38390. import { Nullable } from "babylonjs/types";
  38391. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38392. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38393. /**
  38394. * Listen to keyboard events to control the camera.
  38395. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38396. */
  38397. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38398. /**
  38399. * Defines the camera the input is attached to.
  38400. */
  38401. camera: FlyCamera;
  38402. /**
  38403. * The list of keyboard keys used to control the forward move of the camera.
  38404. */
  38405. keysForward: number[];
  38406. /**
  38407. * The list of keyboard keys used to control the backward move of the camera.
  38408. */
  38409. keysBackward: number[];
  38410. /**
  38411. * The list of keyboard keys used to control the forward move of the camera.
  38412. */
  38413. keysUp: number[];
  38414. /**
  38415. * The list of keyboard keys used to control the backward move of the camera.
  38416. */
  38417. keysDown: number[];
  38418. /**
  38419. * The list of keyboard keys used to control the right strafe move of the camera.
  38420. */
  38421. keysRight: number[];
  38422. /**
  38423. * The list of keyboard keys used to control the left strafe move of the camera.
  38424. */
  38425. keysLeft: number[];
  38426. private _keys;
  38427. private _onCanvasBlurObserver;
  38428. private _onKeyboardObserver;
  38429. private _engine;
  38430. private _scene;
  38431. /**
  38432. * Attach the input controls to a specific dom element to get the input from.
  38433. * @param element Defines the element the controls should be listened from
  38434. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38435. */
  38436. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38437. /**
  38438. * Detach the current controls from the specified dom element.
  38439. * @param element Defines the element to stop listening the inputs from
  38440. */
  38441. detachControl(element: Nullable<HTMLElement>): void;
  38442. /**
  38443. * Gets the class name of the current intput.
  38444. * @returns the class name
  38445. */
  38446. getClassName(): string;
  38447. /** @hidden */
  38448. _onLostFocus(e: FocusEvent): void;
  38449. /**
  38450. * Get the friendly name associated with the input class.
  38451. * @returns the input friendly name
  38452. */
  38453. getSimpleName(): string;
  38454. /**
  38455. * Update the current camera state depending on the inputs that have been used this frame.
  38456. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38457. */
  38458. checkInputs(): void;
  38459. }
  38460. }
  38461. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38462. import { Nullable } from "babylonjs/types";
  38463. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38464. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38465. /**
  38466. * Manage the mouse wheel inputs to control a follow camera.
  38467. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38468. */
  38469. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38470. /**
  38471. * Defines the camera the input is attached to.
  38472. */
  38473. camera: FollowCamera;
  38474. /**
  38475. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38476. */
  38477. axisControlRadius: boolean;
  38478. /**
  38479. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38480. */
  38481. axisControlHeight: boolean;
  38482. /**
  38483. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38484. */
  38485. axisControlRotation: boolean;
  38486. /**
  38487. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38488. * relation to mouseWheel events.
  38489. */
  38490. wheelPrecision: number;
  38491. /**
  38492. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38493. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38494. */
  38495. wheelDeltaPercentage: number;
  38496. private _wheel;
  38497. private _observer;
  38498. /**
  38499. * Attach the input controls to a specific dom element to get the input from.
  38500. * @param element Defines the element the controls should be listened from
  38501. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38502. */
  38503. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38504. /**
  38505. * Detach the current controls from the specified dom element.
  38506. * @param element Defines the element to stop listening the inputs from
  38507. */
  38508. detachControl(element: Nullable<HTMLElement>): void;
  38509. /**
  38510. * Gets the class name of the current intput.
  38511. * @returns the class name
  38512. */
  38513. getClassName(): string;
  38514. /**
  38515. * Get the friendly name associated with the input class.
  38516. * @returns the input friendly name
  38517. */
  38518. getSimpleName(): string;
  38519. }
  38520. }
  38521. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38522. import { Nullable } from "babylonjs/types";
  38523. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38524. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38525. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38526. /**
  38527. * Manage the pointers inputs to control an follow camera.
  38528. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38529. */
  38530. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38531. /**
  38532. * Defines the camera the input is attached to.
  38533. */
  38534. camera: FollowCamera;
  38535. /**
  38536. * Gets the class name of the current input.
  38537. * @returns the class name
  38538. */
  38539. getClassName(): string;
  38540. /**
  38541. * Defines the pointer angular sensibility along the X axis or how fast is
  38542. * the camera rotating.
  38543. * A negative number will reverse the axis direction.
  38544. */
  38545. angularSensibilityX: number;
  38546. /**
  38547. * Defines the pointer angular sensibility along the Y axis or how fast is
  38548. * the camera rotating.
  38549. * A negative number will reverse the axis direction.
  38550. */
  38551. angularSensibilityY: number;
  38552. /**
  38553. * Defines the pointer pinch precision or how fast is the camera zooming.
  38554. * A negative number will reverse the axis direction.
  38555. */
  38556. pinchPrecision: number;
  38557. /**
  38558. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38559. * from 0.
  38560. * It defines the percentage of current camera.radius to use as delta when
  38561. * pinch zoom is used.
  38562. */
  38563. pinchDeltaPercentage: number;
  38564. /**
  38565. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38566. */
  38567. axisXControlRadius: boolean;
  38568. /**
  38569. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38570. */
  38571. axisXControlHeight: boolean;
  38572. /**
  38573. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38574. */
  38575. axisXControlRotation: boolean;
  38576. /**
  38577. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38578. */
  38579. axisYControlRadius: boolean;
  38580. /**
  38581. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38582. */
  38583. axisYControlHeight: boolean;
  38584. /**
  38585. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38586. */
  38587. axisYControlRotation: boolean;
  38588. /**
  38589. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38590. */
  38591. axisPinchControlRadius: boolean;
  38592. /**
  38593. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38594. */
  38595. axisPinchControlHeight: boolean;
  38596. /**
  38597. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38598. */
  38599. axisPinchControlRotation: boolean;
  38600. /**
  38601. * Log error messages if basic misconfiguration has occurred.
  38602. */
  38603. warningEnable: boolean;
  38604. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38605. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38606. private _warningCounter;
  38607. private _warning;
  38608. }
  38609. }
  38610. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38611. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38612. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38613. /**
  38614. * Default Inputs manager for the FollowCamera.
  38615. * It groups all the default supported inputs for ease of use.
  38616. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38617. */
  38618. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38619. /**
  38620. * Instantiates a new FollowCameraInputsManager.
  38621. * @param camera Defines the camera the inputs belong to
  38622. */
  38623. constructor(camera: FollowCamera);
  38624. /**
  38625. * Add keyboard input support to the input manager.
  38626. * @returns the current input manager
  38627. */
  38628. addKeyboard(): FollowCameraInputsManager;
  38629. /**
  38630. * Add mouse wheel input support to the input manager.
  38631. * @returns the current input manager
  38632. */
  38633. addMouseWheel(): FollowCameraInputsManager;
  38634. /**
  38635. * Add pointers input support to the input manager.
  38636. * @returns the current input manager
  38637. */
  38638. addPointers(): FollowCameraInputsManager;
  38639. /**
  38640. * Add orientation input support to the input manager.
  38641. * @returns the current input manager
  38642. */
  38643. addVRDeviceOrientation(): FollowCameraInputsManager;
  38644. }
  38645. }
  38646. declare module "babylonjs/Cameras/followCamera" {
  38647. import { Nullable } from "babylonjs/types";
  38648. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38649. import { Scene } from "babylonjs/scene";
  38650. import { Vector3 } from "babylonjs/Maths/math.vector";
  38651. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38652. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38653. /**
  38654. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38655. * an arc rotate version arcFollowCamera are available.
  38656. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38657. */
  38658. export class FollowCamera extends TargetCamera {
  38659. /**
  38660. * Distance the follow camera should follow an object at
  38661. */
  38662. radius: number;
  38663. /**
  38664. * Minimum allowed distance of the camera to the axis of rotation
  38665. * (The camera can not get closer).
  38666. * This can help limiting how the Camera is able to move in the scene.
  38667. */
  38668. lowerRadiusLimit: Nullable<number>;
  38669. /**
  38670. * Maximum allowed distance of the camera to the axis of rotation
  38671. * (The camera can not get further).
  38672. * This can help limiting how the Camera is able to move in the scene.
  38673. */
  38674. upperRadiusLimit: Nullable<number>;
  38675. /**
  38676. * Define a rotation offset between the camera and the object it follows
  38677. */
  38678. rotationOffset: number;
  38679. /**
  38680. * Minimum allowed angle to camera position relative to target object.
  38681. * This can help limiting how the Camera is able to move in the scene.
  38682. */
  38683. lowerRotationOffsetLimit: Nullable<number>;
  38684. /**
  38685. * Maximum allowed angle to camera position relative to target object.
  38686. * This can help limiting how the Camera is able to move in the scene.
  38687. */
  38688. upperRotationOffsetLimit: Nullable<number>;
  38689. /**
  38690. * Define a height offset between the camera and the object it follows.
  38691. * It can help following an object from the top (like a car chaing a plane)
  38692. */
  38693. heightOffset: number;
  38694. /**
  38695. * Minimum allowed height of camera position relative to target object.
  38696. * This can help limiting how the Camera is able to move in the scene.
  38697. */
  38698. lowerHeightOffsetLimit: Nullable<number>;
  38699. /**
  38700. * Maximum allowed height of camera position relative to target object.
  38701. * This can help limiting how the Camera is able to move in the scene.
  38702. */
  38703. upperHeightOffsetLimit: Nullable<number>;
  38704. /**
  38705. * Define how fast the camera can accelerate to follow it s target.
  38706. */
  38707. cameraAcceleration: number;
  38708. /**
  38709. * Define the speed limit of the camera following an object.
  38710. */
  38711. maxCameraSpeed: number;
  38712. /**
  38713. * Define the target of the camera.
  38714. */
  38715. lockedTarget: Nullable<AbstractMesh>;
  38716. /**
  38717. * Defines the input associated with the camera.
  38718. */
  38719. inputs: FollowCameraInputsManager;
  38720. /**
  38721. * Instantiates the follow camera.
  38722. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38723. * @param name Define the name of the camera in the scene
  38724. * @param position Define the position of the camera
  38725. * @param scene Define the scene the camera belong to
  38726. * @param lockedTarget Define the target of the camera
  38727. */
  38728. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38729. private _follow;
  38730. /**
  38731. * Attached controls to the current camera.
  38732. * @param element Defines the element the controls should be listened from
  38733. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38734. */
  38735. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38736. /**
  38737. * Detach the current controls from the camera.
  38738. * The camera will stop reacting to inputs.
  38739. * @param element Defines the element to stop listening the inputs from
  38740. */
  38741. detachControl(element: HTMLElement): void;
  38742. /** @hidden */
  38743. _checkInputs(): void;
  38744. private _checkLimits;
  38745. /**
  38746. * Gets the camera class name.
  38747. * @returns the class name
  38748. */
  38749. getClassName(): string;
  38750. }
  38751. /**
  38752. * Arc Rotate version of the follow camera.
  38753. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38754. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38755. */
  38756. export class ArcFollowCamera extends TargetCamera {
  38757. /** The longitudinal angle of the camera */
  38758. alpha: number;
  38759. /** The latitudinal angle of the camera */
  38760. beta: number;
  38761. /** The radius of the camera from its target */
  38762. radius: number;
  38763. /** Define the camera target (the messh it should follow) */
  38764. target: Nullable<AbstractMesh>;
  38765. private _cartesianCoordinates;
  38766. /**
  38767. * Instantiates a new ArcFollowCamera
  38768. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38769. * @param name Define the name of the camera
  38770. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38771. * @param beta Define the rotation angle of the camera around the elevation axis
  38772. * @param radius Define the radius of the camera from its target point
  38773. * @param target Define the target of the camera
  38774. * @param scene Define the scene the camera belongs to
  38775. */
  38776. constructor(name: string,
  38777. /** The longitudinal angle of the camera */
  38778. alpha: number,
  38779. /** The latitudinal angle of the camera */
  38780. beta: number,
  38781. /** The radius of the camera from its target */
  38782. radius: number,
  38783. /** Define the camera target (the messh it should follow) */
  38784. target: Nullable<AbstractMesh>, scene: Scene);
  38785. private _follow;
  38786. /** @hidden */
  38787. _checkInputs(): void;
  38788. /**
  38789. * Returns the class name of the object.
  38790. * It is mostly used internally for serialization purposes.
  38791. */
  38792. getClassName(): string;
  38793. }
  38794. }
  38795. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38796. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38797. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38798. import { Nullable } from "babylonjs/types";
  38799. /**
  38800. * Manage the keyboard inputs to control the movement of a follow camera.
  38801. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38802. */
  38803. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38804. /**
  38805. * Defines the camera the input is attached to.
  38806. */
  38807. camera: FollowCamera;
  38808. /**
  38809. * Defines the list of key codes associated with the up action (increase heightOffset)
  38810. */
  38811. keysHeightOffsetIncr: number[];
  38812. /**
  38813. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38814. */
  38815. keysHeightOffsetDecr: number[];
  38816. /**
  38817. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38818. */
  38819. keysHeightOffsetModifierAlt: boolean;
  38820. /**
  38821. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38822. */
  38823. keysHeightOffsetModifierCtrl: boolean;
  38824. /**
  38825. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38826. */
  38827. keysHeightOffsetModifierShift: boolean;
  38828. /**
  38829. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38830. */
  38831. keysRotationOffsetIncr: number[];
  38832. /**
  38833. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38834. */
  38835. keysRotationOffsetDecr: number[];
  38836. /**
  38837. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38838. */
  38839. keysRotationOffsetModifierAlt: boolean;
  38840. /**
  38841. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38842. */
  38843. keysRotationOffsetModifierCtrl: boolean;
  38844. /**
  38845. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38846. */
  38847. keysRotationOffsetModifierShift: boolean;
  38848. /**
  38849. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38850. */
  38851. keysRadiusIncr: number[];
  38852. /**
  38853. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38854. */
  38855. keysRadiusDecr: number[];
  38856. /**
  38857. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38858. */
  38859. keysRadiusModifierAlt: boolean;
  38860. /**
  38861. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38862. */
  38863. keysRadiusModifierCtrl: boolean;
  38864. /**
  38865. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38866. */
  38867. keysRadiusModifierShift: boolean;
  38868. /**
  38869. * Defines the rate of change of heightOffset.
  38870. */
  38871. heightSensibility: number;
  38872. /**
  38873. * Defines the rate of change of rotationOffset.
  38874. */
  38875. rotationSensibility: number;
  38876. /**
  38877. * Defines the rate of change of radius.
  38878. */
  38879. radiusSensibility: number;
  38880. private _keys;
  38881. private _ctrlPressed;
  38882. private _altPressed;
  38883. private _shiftPressed;
  38884. private _onCanvasBlurObserver;
  38885. private _onKeyboardObserver;
  38886. private _engine;
  38887. private _scene;
  38888. /**
  38889. * Attach the input controls to a specific dom element to get the input from.
  38890. * @param element Defines the element the controls should be listened from
  38891. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38892. */
  38893. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38894. /**
  38895. * Detach the current controls from the specified dom element.
  38896. * @param element Defines the element to stop listening the inputs from
  38897. */
  38898. detachControl(element: Nullable<HTMLElement>): void;
  38899. /**
  38900. * Update the current camera state depending on the inputs that have been used this frame.
  38901. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38902. */
  38903. checkInputs(): void;
  38904. /**
  38905. * Gets the class name of the current input.
  38906. * @returns the class name
  38907. */
  38908. getClassName(): string;
  38909. /**
  38910. * Get the friendly name associated with the input class.
  38911. * @returns the input friendly name
  38912. */
  38913. getSimpleName(): string;
  38914. /**
  38915. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38916. * allow modification of the heightOffset value.
  38917. */
  38918. private _modifierHeightOffset;
  38919. /**
  38920. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38921. * allow modification of the rotationOffset value.
  38922. */
  38923. private _modifierRotationOffset;
  38924. /**
  38925. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38926. * allow modification of the radius value.
  38927. */
  38928. private _modifierRadius;
  38929. }
  38930. }
  38931. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  38932. import { Nullable } from "babylonjs/types";
  38933. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38934. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38935. import { Observable } from "babylonjs/Misc/observable";
  38936. module "babylonjs/Cameras/freeCameraInputsManager" {
  38937. interface FreeCameraInputsManager {
  38938. /**
  38939. * @hidden
  38940. */
  38941. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38942. /**
  38943. * Add orientation input support to the input manager.
  38944. * @returns the current input manager
  38945. */
  38946. addDeviceOrientation(): FreeCameraInputsManager;
  38947. }
  38948. }
  38949. /**
  38950. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38951. * Screen rotation is taken into account.
  38952. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38953. */
  38954. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38955. private _camera;
  38956. private _screenOrientationAngle;
  38957. private _constantTranform;
  38958. private _screenQuaternion;
  38959. private _alpha;
  38960. private _beta;
  38961. private _gamma;
  38962. /**
  38963. * Can be used to detect if a device orientation sensor is availible on a device
  38964. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38965. * @returns a promise that will resolve on orientation change
  38966. */
  38967. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38968. /**
  38969. * @hidden
  38970. */
  38971. _onDeviceOrientationChangedObservable: Observable<void>;
  38972. /**
  38973. * Instantiates a new input
  38974. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38975. */
  38976. constructor();
  38977. /**
  38978. * Define the camera controlled by the input.
  38979. */
  38980. camera: FreeCamera;
  38981. /**
  38982. * Attach the input controls to a specific dom element to get the input from.
  38983. * @param element Defines the element the controls should be listened from
  38984. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38985. */
  38986. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38987. private _orientationChanged;
  38988. private _deviceOrientation;
  38989. /**
  38990. * Detach the current controls from the specified dom element.
  38991. * @param element Defines the element to stop listening the inputs from
  38992. */
  38993. detachControl(element: Nullable<HTMLElement>): void;
  38994. /**
  38995. * Update the current camera state depending on the inputs that have been used this frame.
  38996. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38997. */
  38998. checkInputs(): void;
  38999. /**
  39000. * Gets the class name of the current intput.
  39001. * @returns the class name
  39002. */
  39003. getClassName(): string;
  39004. /**
  39005. * Get the friendly name associated with the input class.
  39006. * @returns the input friendly name
  39007. */
  39008. getSimpleName(): string;
  39009. }
  39010. }
  39011. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39012. import { Nullable } from "babylonjs/types";
  39013. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39014. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39015. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39016. /**
  39017. * Manage the gamepad inputs to control a free camera.
  39018. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39019. */
  39020. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39021. /**
  39022. * Define the camera the input is attached to.
  39023. */
  39024. camera: FreeCamera;
  39025. /**
  39026. * Define the Gamepad controlling the input
  39027. */
  39028. gamepad: Nullable<Gamepad>;
  39029. /**
  39030. * Defines the gamepad rotation sensiblity.
  39031. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39032. */
  39033. gamepadAngularSensibility: number;
  39034. /**
  39035. * Defines the gamepad move sensiblity.
  39036. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39037. */
  39038. gamepadMoveSensibility: number;
  39039. private _onGamepadConnectedObserver;
  39040. private _onGamepadDisconnectedObserver;
  39041. private _cameraTransform;
  39042. private _deltaTransform;
  39043. private _vector3;
  39044. private _vector2;
  39045. /**
  39046. * Attach the input controls to a specific dom element to get the input from.
  39047. * @param element Defines the element the controls should be listened from
  39048. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39049. */
  39050. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39051. /**
  39052. * Detach the current controls from the specified dom element.
  39053. * @param element Defines the element to stop listening the inputs from
  39054. */
  39055. detachControl(element: Nullable<HTMLElement>): void;
  39056. /**
  39057. * Update the current camera state depending on the inputs that have been used this frame.
  39058. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39059. */
  39060. checkInputs(): void;
  39061. /**
  39062. * Gets the class name of the current intput.
  39063. * @returns the class name
  39064. */
  39065. getClassName(): string;
  39066. /**
  39067. * Get the friendly name associated with the input class.
  39068. * @returns the input friendly name
  39069. */
  39070. getSimpleName(): string;
  39071. }
  39072. }
  39073. declare module "babylonjs/Misc/virtualJoystick" {
  39074. import { Nullable } from "babylonjs/types";
  39075. import { Vector3 } from "babylonjs/Maths/math.vector";
  39076. /**
  39077. * Defines the potential axis of a Joystick
  39078. */
  39079. export enum JoystickAxis {
  39080. /** X axis */
  39081. X = 0,
  39082. /** Y axis */
  39083. Y = 1,
  39084. /** Z axis */
  39085. Z = 2
  39086. }
  39087. /**
  39088. * Class used to define virtual joystick (used in touch mode)
  39089. */
  39090. export class VirtualJoystick {
  39091. /**
  39092. * Gets or sets a boolean indicating that left and right values must be inverted
  39093. */
  39094. reverseLeftRight: boolean;
  39095. /**
  39096. * Gets or sets a boolean indicating that up and down values must be inverted
  39097. */
  39098. reverseUpDown: boolean;
  39099. /**
  39100. * Gets the offset value for the position (ie. the change of the position value)
  39101. */
  39102. deltaPosition: Vector3;
  39103. /**
  39104. * Gets a boolean indicating if the virtual joystick was pressed
  39105. */
  39106. pressed: boolean;
  39107. /**
  39108. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39109. */
  39110. static Canvas: Nullable<HTMLCanvasElement>;
  39111. private static _globalJoystickIndex;
  39112. private static vjCanvasContext;
  39113. private static vjCanvasWidth;
  39114. private static vjCanvasHeight;
  39115. private static halfWidth;
  39116. private _action;
  39117. private _axisTargetedByLeftAndRight;
  39118. private _axisTargetedByUpAndDown;
  39119. private _joystickSensibility;
  39120. private _inversedSensibility;
  39121. private _joystickPointerID;
  39122. private _joystickColor;
  39123. private _joystickPointerPos;
  39124. private _joystickPreviousPointerPos;
  39125. private _joystickPointerStartPos;
  39126. private _deltaJoystickVector;
  39127. private _leftJoystick;
  39128. private _touches;
  39129. private _onPointerDownHandlerRef;
  39130. private _onPointerMoveHandlerRef;
  39131. private _onPointerUpHandlerRef;
  39132. private _onResize;
  39133. /**
  39134. * Creates a new virtual joystick
  39135. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39136. */
  39137. constructor(leftJoystick?: boolean);
  39138. /**
  39139. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39140. * @param newJoystickSensibility defines the new sensibility
  39141. */
  39142. setJoystickSensibility(newJoystickSensibility: number): void;
  39143. private _onPointerDown;
  39144. private _onPointerMove;
  39145. private _onPointerUp;
  39146. /**
  39147. * Change the color of the virtual joystick
  39148. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39149. */
  39150. setJoystickColor(newColor: string): void;
  39151. /**
  39152. * Defines a callback to call when the joystick is touched
  39153. * @param action defines the callback
  39154. */
  39155. setActionOnTouch(action: () => any): void;
  39156. /**
  39157. * Defines which axis you'd like to control for left & right
  39158. * @param axis defines the axis to use
  39159. */
  39160. setAxisForLeftRight(axis: JoystickAxis): void;
  39161. /**
  39162. * Defines which axis you'd like to control for up & down
  39163. * @param axis defines the axis to use
  39164. */
  39165. setAxisForUpDown(axis: JoystickAxis): void;
  39166. private _drawVirtualJoystick;
  39167. /**
  39168. * Release internal HTML canvas
  39169. */
  39170. releaseCanvas(): void;
  39171. }
  39172. }
  39173. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39174. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39175. import { Nullable } from "babylonjs/types";
  39176. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39177. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39178. module "babylonjs/Cameras/freeCameraInputsManager" {
  39179. interface FreeCameraInputsManager {
  39180. /**
  39181. * Add virtual joystick input support to the input manager.
  39182. * @returns the current input manager
  39183. */
  39184. addVirtualJoystick(): FreeCameraInputsManager;
  39185. }
  39186. }
  39187. /**
  39188. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39189. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39190. */
  39191. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39192. /**
  39193. * Defines the camera the input is attached to.
  39194. */
  39195. camera: FreeCamera;
  39196. private _leftjoystick;
  39197. private _rightjoystick;
  39198. /**
  39199. * Gets the left stick of the virtual joystick.
  39200. * @returns The virtual Joystick
  39201. */
  39202. getLeftJoystick(): VirtualJoystick;
  39203. /**
  39204. * Gets the right stick of the virtual joystick.
  39205. * @returns The virtual Joystick
  39206. */
  39207. getRightJoystick(): VirtualJoystick;
  39208. /**
  39209. * Update the current camera state depending on the inputs that have been used this frame.
  39210. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39211. */
  39212. checkInputs(): void;
  39213. /**
  39214. * Attach the input controls to a specific dom element to get the input from.
  39215. * @param element Defines the element the controls should be listened from
  39216. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39217. */
  39218. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39219. /**
  39220. * Detach the current controls from the specified dom element.
  39221. * @param element Defines the element to stop listening the inputs from
  39222. */
  39223. detachControl(element: Nullable<HTMLElement>): void;
  39224. /**
  39225. * Gets the class name of the current intput.
  39226. * @returns the class name
  39227. */
  39228. getClassName(): string;
  39229. /**
  39230. * Get the friendly name associated with the input class.
  39231. * @returns the input friendly name
  39232. */
  39233. getSimpleName(): string;
  39234. }
  39235. }
  39236. declare module "babylonjs/Cameras/Inputs/index" {
  39237. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39238. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39239. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39240. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39241. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39242. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39243. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39244. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39245. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39246. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39247. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39248. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39249. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39250. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39251. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39252. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39253. }
  39254. declare module "babylonjs/Cameras/touchCamera" {
  39255. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39256. import { Scene } from "babylonjs/scene";
  39257. import { Vector3 } from "babylonjs/Maths/math.vector";
  39258. /**
  39259. * This represents a FPS type of camera controlled by touch.
  39260. * This is like a universal camera minus the Gamepad controls.
  39261. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39262. */
  39263. export class TouchCamera extends FreeCamera {
  39264. /**
  39265. * Defines the touch sensibility for rotation.
  39266. * The higher the faster.
  39267. */
  39268. touchAngularSensibility: number;
  39269. /**
  39270. * Defines the touch sensibility for move.
  39271. * The higher the faster.
  39272. */
  39273. touchMoveSensibility: number;
  39274. /**
  39275. * Instantiates a new touch camera.
  39276. * This represents a FPS type of camera controlled by touch.
  39277. * This is like a universal camera minus the Gamepad controls.
  39278. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39279. * @param name Define the name of the camera in the scene
  39280. * @param position Define the start position of the camera in the scene
  39281. * @param scene Define the scene the camera belongs to
  39282. */
  39283. constructor(name: string, position: Vector3, scene: Scene);
  39284. /**
  39285. * Gets the current object class name.
  39286. * @return the class name
  39287. */
  39288. getClassName(): string;
  39289. /** @hidden */
  39290. _setupInputs(): void;
  39291. }
  39292. }
  39293. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39294. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39295. import { Scene } from "babylonjs/scene";
  39296. import { Vector3 } from "babylonjs/Maths/math.vector";
  39297. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39298. import { Axis } from "babylonjs/Maths/math.axis";
  39299. /**
  39300. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39301. * being tilted forward or back and left or right.
  39302. */
  39303. export class DeviceOrientationCamera extends FreeCamera {
  39304. private _initialQuaternion;
  39305. private _quaternionCache;
  39306. private _tmpDragQuaternion;
  39307. /**
  39308. * Creates a new device orientation camera
  39309. * @param name The name of the camera
  39310. * @param position The start position camera
  39311. * @param scene The scene the camera belongs to
  39312. */
  39313. constructor(name: string, position: Vector3, scene: Scene);
  39314. /**
  39315. * @hidden
  39316. * Disabled pointer input on first orientation sensor update (Default: true)
  39317. */
  39318. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  39319. private _dragFactor;
  39320. /**
  39321. * Enabled turning on the y axis when the orientation sensor is active
  39322. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39323. */
  39324. enableHorizontalDragging(dragFactor?: number): void;
  39325. /**
  39326. * Gets the current instance class name ("DeviceOrientationCamera").
  39327. * This helps avoiding instanceof at run time.
  39328. * @returns the class name
  39329. */
  39330. getClassName(): string;
  39331. /**
  39332. * @hidden
  39333. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39334. */
  39335. _checkInputs(): void;
  39336. /**
  39337. * Reset the camera to its default orientation on the specified axis only.
  39338. * @param axis The axis to reset
  39339. */
  39340. resetToCurrentRotation(axis?: Axis): void;
  39341. }
  39342. }
  39343. declare module "babylonjs/Gamepads/xboxGamepad" {
  39344. import { Observable } from "babylonjs/Misc/observable";
  39345. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39346. /**
  39347. * Defines supported buttons for XBox360 compatible gamepads
  39348. */
  39349. export enum Xbox360Button {
  39350. /** A */
  39351. A = 0,
  39352. /** B */
  39353. B = 1,
  39354. /** X */
  39355. X = 2,
  39356. /** Y */
  39357. Y = 3,
  39358. /** Start */
  39359. Start = 4,
  39360. /** Back */
  39361. Back = 5,
  39362. /** Left button */
  39363. LB = 6,
  39364. /** Right button */
  39365. RB = 7,
  39366. /** Left stick */
  39367. LeftStick = 8,
  39368. /** Right stick */
  39369. RightStick = 9
  39370. }
  39371. /** Defines values for XBox360 DPad */
  39372. export enum Xbox360Dpad {
  39373. /** Up */
  39374. Up = 0,
  39375. /** Down */
  39376. Down = 1,
  39377. /** Left */
  39378. Left = 2,
  39379. /** Right */
  39380. Right = 3
  39381. }
  39382. /**
  39383. * Defines a XBox360 gamepad
  39384. */
  39385. export class Xbox360Pad extends Gamepad {
  39386. private _leftTrigger;
  39387. private _rightTrigger;
  39388. private _onlefttriggerchanged;
  39389. private _onrighttriggerchanged;
  39390. private _onbuttondown;
  39391. private _onbuttonup;
  39392. private _ondpaddown;
  39393. private _ondpadup;
  39394. /** Observable raised when a button is pressed */
  39395. onButtonDownObservable: Observable<Xbox360Button>;
  39396. /** Observable raised when a button is released */
  39397. onButtonUpObservable: Observable<Xbox360Button>;
  39398. /** Observable raised when a pad is pressed */
  39399. onPadDownObservable: Observable<Xbox360Dpad>;
  39400. /** Observable raised when a pad is released */
  39401. onPadUpObservable: Observable<Xbox360Dpad>;
  39402. private _buttonA;
  39403. private _buttonB;
  39404. private _buttonX;
  39405. private _buttonY;
  39406. private _buttonBack;
  39407. private _buttonStart;
  39408. private _buttonLB;
  39409. private _buttonRB;
  39410. private _buttonLeftStick;
  39411. private _buttonRightStick;
  39412. private _dPadUp;
  39413. private _dPadDown;
  39414. private _dPadLeft;
  39415. private _dPadRight;
  39416. private _isXboxOnePad;
  39417. /**
  39418. * Creates a new XBox360 gamepad object
  39419. * @param id defines the id of this gamepad
  39420. * @param index defines its index
  39421. * @param gamepad defines the internal HTML gamepad object
  39422. * @param xboxOne defines if it is a XBox One gamepad
  39423. */
  39424. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39425. /**
  39426. * Defines the callback to call when left trigger is pressed
  39427. * @param callback defines the callback to use
  39428. */
  39429. onlefttriggerchanged(callback: (value: number) => void): void;
  39430. /**
  39431. * Defines the callback to call when right trigger is pressed
  39432. * @param callback defines the callback to use
  39433. */
  39434. onrighttriggerchanged(callback: (value: number) => void): void;
  39435. /**
  39436. * Gets the left trigger value
  39437. */
  39438. /**
  39439. * Sets the left trigger value
  39440. */
  39441. leftTrigger: number;
  39442. /**
  39443. * Gets the right trigger value
  39444. */
  39445. /**
  39446. * Sets the right trigger value
  39447. */
  39448. rightTrigger: number;
  39449. /**
  39450. * Defines the callback to call when a button is pressed
  39451. * @param callback defines the callback to use
  39452. */
  39453. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39454. /**
  39455. * Defines the callback to call when a button is released
  39456. * @param callback defines the callback to use
  39457. */
  39458. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39459. /**
  39460. * Defines the callback to call when a pad is pressed
  39461. * @param callback defines the callback to use
  39462. */
  39463. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39464. /**
  39465. * Defines the callback to call when a pad is released
  39466. * @param callback defines the callback to use
  39467. */
  39468. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39469. private _setButtonValue;
  39470. private _setDPadValue;
  39471. /**
  39472. * Gets the value of the `A` button
  39473. */
  39474. /**
  39475. * Sets the value of the `A` button
  39476. */
  39477. buttonA: number;
  39478. /**
  39479. * Gets the value of the `B` button
  39480. */
  39481. /**
  39482. * Sets the value of the `B` button
  39483. */
  39484. buttonB: number;
  39485. /**
  39486. * Gets the value of the `X` button
  39487. */
  39488. /**
  39489. * Sets the value of the `X` button
  39490. */
  39491. buttonX: number;
  39492. /**
  39493. * Gets the value of the `Y` button
  39494. */
  39495. /**
  39496. * Sets the value of the `Y` button
  39497. */
  39498. buttonY: number;
  39499. /**
  39500. * Gets the value of the `Start` button
  39501. */
  39502. /**
  39503. * Sets the value of the `Start` button
  39504. */
  39505. buttonStart: number;
  39506. /**
  39507. * Gets the value of the `Back` button
  39508. */
  39509. /**
  39510. * Sets the value of the `Back` button
  39511. */
  39512. buttonBack: number;
  39513. /**
  39514. * Gets the value of the `Left` button
  39515. */
  39516. /**
  39517. * Sets the value of the `Left` button
  39518. */
  39519. buttonLB: number;
  39520. /**
  39521. * Gets the value of the `Right` button
  39522. */
  39523. /**
  39524. * Sets the value of the `Right` button
  39525. */
  39526. buttonRB: number;
  39527. /**
  39528. * Gets the value of the Left joystick
  39529. */
  39530. /**
  39531. * Sets the value of the Left joystick
  39532. */
  39533. buttonLeftStick: number;
  39534. /**
  39535. * Gets the value of the Right joystick
  39536. */
  39537. /**
  39538. * Sets the value of the Right joystick
  39539. */
  39540. buttonRightStick: number;
  39541. /**
  39542. * Gets the value of D-pad up
  39543. */
  39544. /**
  39545. * Sets the value of D-pad up
  39546. */
  39547. dPadUp: number;
  39548. /**
  39549. * Gets the value of D-pad down
  39550. */
  39551. /**
  39552. * Sets the value of D-pad down
  39553. */
  39554. dPadDown: number;
  39555. /**
  39556. * Gets the value of D-pad left
  39557. */
  39558. /**
  39559. * Sets the value of D-pad left
  39560. */
  39561. dPadLeft: number;
  39562. /**
  39563. * Gets the value of D-pad right
  39564. */
  39565. /**
  39566. * Sets the value of D-pad right
  39567. */
  39568. dPadRight: number;
  39569. /**
  39570. * Force the gamepad to synchronize with device values
  39571. */
  39572. update(): void;
  39573. /**
  39574. * Disposes the gamepad
  39575. */
  39576. dispose(): void;
  39577. }
  39578. }
  39579. declare module "babylonjs/Gamepads/gamepadManager" {
  39580. import { Observable } from "babylonjs/Misc/observable";
  39581. import { Nullable } from "babylonjs/types";
  39582. import { Scene } from "babylonjs/scene";
  39583. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39584. /**
  39585. * Manager for handling gamepads
  39586. */
  39587. export class GamepadManager {
  39588. private _scene?;
  39589. private _babylonGamepads;
  39590. private _oneGamepadConnected;
  39591. /** @hidden */
  39592. _isMonitoring: boolean;
  39593. private _gamepadEventSupported;
  39594. private _gamepadSupport;
  39595. /**
  39596. * observable to be triggered when the gamepad controller has been connected
  39597. */
  39598. onGamepadConnectedObservable: Observable<Gamepad>;
  39599. /**
  39600. * observable to be triggered when the gamepad controller has been disconnected
  39601. */
  39602. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39603. private _onGamepadConnectedEvent;
  39604. private _onGamepadDisconnectedEvent;
  39605. /**
  39606. * Initializes the gamepad manager
  39607. * @param _scene BabylonJS scene
  39608. */
  39609. constructor(_scene?: Scene | undefined);
  39610. /**
  39611. * The gamepads in the game pad manager
  39612. */
  39613. readonly gamepads: Gamepad[];
  39614. /**
  39615. * Get the gamepad controllers based on type
  39616. * @param type The type of gamepad controller
  39617. * @returns Nullable gamepad
  39618. */
  39619. getGamepadByType(type?: number): Nullable<Gamepad>;
  39620. /**
  39621. * Disposes the gamepad manager
  39622. */
  39623. dispose(): void;
  39624. private _addNewGamepad;
  39625. private _startMonitoringGamepads;
  39626. private _stopMonitoringGamepads;
  39627. /** @hidden */
  39628. _checkGamepadsStatus(): void;
  39629. private _updateGamepadObjects;
  39630. }
  39631. }
  39632. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39633. import { Nullable } from "babylonjs/types";
  39634. import { Scene } from "babylonjs/scene";
  39635. import { ISceneComponent } from "babylonjs/sceneComponent";
  39636. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39637. module "babylonjs/scene" {
  39638. interface Scene {
  39639. /** @hidden */
  39640. _gamepadManager: Nullable<GamepadManager>;
  39641. /**
  39642. * Gets the gamepad manager associated with the scene
  39643. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39644. */
  39645. gamepadManager: GamepadManager;
  39646. }
  39647. }
  39648. module "babylonjs/Cameras/freeCameraInputsManager" {
  39649. /**
  39650. * Interface representing a free camera inputs manager
  39651. */
  39652. interface FreeCameraInputsManager {
  39653. /**
  39654. * Adds gamepad input support to the FreeCameraInputsManager.
  39655. * @returns the FreeCameraInputsManager
  39656. */
  39657. addGamepad(): FreeCameraInputsManager;
  39658. }
  39659. }
  39660. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39661. /**
  39662. * Interface representing an arc rotate camera inputs manager
  39663. */
  39664. interface ArcRotateCameraInputsManager {
  39665. /**
  39666. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39667. * @returns the camera inputs manager
  39668. */
  39669. addGamepad(): ArcRotateCameraInputsManager;
  39670. }
  39671. }
  39672. /**
  39673. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39674. */
  39675. export class GamepadSystemSceneComponent implements ISceneComponent {
  39676. /**
  39677. * The component name helpfull to identify the component in the list of scene components.
  39678. */
  39679. readonly name: string;
  39680. /**
  39681. * The scene the component belongs to.
  39682. */
  39683. scene: Scene;
  39684. /**
  39685. * Creates a new instance of the component for the given scene
  39686. * @param scene Defines the scene to register the component in
  39687. */
  39688. constructor(scene: Scene);
  39689. /**
  39690. * Registers the component in a given scene
  39691. */
  39692. register(): void;
  39693. /**
  39694. * Rebuilds the elements related to this component in case of
  39695. * context lost for instance.
  39696. */
  39697. rebuild(): void;
  39698. /**
  39699. * Disposes the component and the associated ressources
  39700. */
  39701. dispose(): void;
  39702. private _beforeCameraUpdate;
  39703. }
  39704. }
  39705. declare module "babylonjs/Cameras/universalCamera" {
  39706. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  39707. import { Scene } from "babylonjs/scene";
  39708. import { Vector3 } from "babylonjs/Maths/math.vector";
  39709. import "babylonjs/Gamepads/gamepadSceneComponent";
  39710. /**
  39711. * 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,
  39712. * which still works and will still be found in many Playgrounds.
  39713. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39714. */
  39715. export class UniversalCamera extends TouchCamera {
  39716. /**
  39717. * Defines the gamepad rotation sensiblity.
  39718. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39719. */
  39720. gamepadAngularSensibility: number;
  39721. /**
  39722. * Defines the gamepad move sensiblity.
  39723. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39724. */
  39725. gamepadMoveSensibility: number;
  39726. /**
  39727. * 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,
  39728. * which still works and will still be found in many Playgrounds.
  39729. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39730. * @param name Define the name of the camera in the scene
  39731. * @param position Define the start position of the camera in the scene
  39732. * @param scene Define the scene the camera belongs to
  39733. */
  39734. constructor(name: string, position: Vector3, scene: Scene);
  39735. /**
  39736. * Gets the current object class name.
  39737. * @return the class name
  39738. */
  39739. getClassName(): string;
  39740. }
  39741. }
  39742. declare module "babylonjs/Cameras/gamepadCamera" {
  39743. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39744. import { Scene } from "babylonjs/scene";
  39745. import { Vector3 } from "babylonjs/Maths/math.vector";
  39746. /**
  39747. * This represents a FPS type of camera. This is only here for back compat purpose.
  39748. * Please use the UniversalCamera instead as both are identical.
  39749. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39750. */
  39751. export class GamepadCamera extends UniversalCamera {
  39752. /**
  39753. * Instantiates a new Gamepad Camera
  39754. * This represents a FPS type of camera. This is only here for back compat purpose.
  39755. * Please use the UniversalCamera instead as both are identical.
  39756. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39757. * @param name Define the name of the camera in the scene
  39758. * @param position Define the start position of the camera in the scene
  39759. * @param scene Define the scene the camera belongs to
  39760. */
  39761. constructor(name: string, position: Vector3, scene: Scene);
  39762. /**
  39763. * Gets the current object class name.
  39764. * @return the class name
  39765. */
  39766. getClassName(): string;
  39767. }
  39768. }
  39769. declare module "babylonjs/Shaders/pass.fragment" {
  39770. /** @hidden */
  39771. export var passPixelShader: {
  39772. name: string;
  39773. shader: string;
  39774. };
  39775. }
  39776. declare module "babylonjs/Shaders/passCube.fragment" {
  39777. /** @hidden */
  39778. export var passCubePixelShader: {
  39779. name: string;
  39780. shader: string;
  39781. };
  39782. }
  39783. declare module "babylonjs/PostProcesses/passPostProcess" {
  39784. import { Nullable } from "babylonjs/types";
  39785. import { Camera } from "babylonjs/Cameras/camera";
  39786. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39787. import { Engine } from "babylonjs/Engines/engine";
  39788. import "babylonjs/Shaders/pass.fragment";
  39789. import "babylonjs/Shaders/passCube.fragment";
  39790. /**
  39791. * PassPostProcess which produces an output the same as it's input
  39792. */
  39793. export class PassPostProcess extends PostProcess {
  39794. /**
  39795. * Creates the PassPostProcess
  39796. * @param name The name of the effect.
  39797. * @param options The required width/height ratio to downsize to before computing the render pass.
  39798. * @param camera The camera to apply the render pass to.
  39799. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39800. * @param engine The engine which the post process will be applied. (default: current engine)
  39801. * @param reusable If the post process can be reused on the same frame. (default: false)
  39802. * @param textureType The type of texture to be used when performing the post processing.
  39803. * @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)
  39804. */
  39805. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39806. }
  39807. /**
  39808. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39809. */
  39810. export class PassCubePostProcess extends PostProcess {
  39811. private _face;
  39812. /**
  39813. * Gets or sets the cube face to display.
  39814. * * 0 is +X
  39815. * * 1 is -X
  39816. * * 2 is +Y
  39817. * * 3 is -Y
  39818. * * 4 is +Z
  39819. * * 5 is -Z
  39820. */
  39821. face: number;
  39822. /**
  39823. * Creates the PassCubePostProcess
  39824. * @param name The name of the effect.
  39825. * @param options The required width/height ratio to downsize to before computing the render pass.
  39826. * @param camera The camera to apply the render pass to.
  39827. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39828. * @param engine The engine which the post process will be applied. (default: current engine)
  39829. * @param reusable If the post process can be reused on the same frame. (default: false)
  39830. * @param textureType The type of texture to be used when performing the post processing.
  39831. * @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)
  39832. */
  39833. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39834. }
  39835. }
  39836. declare module "babylonjs/Shaders/anaglyph.fragment" {
  39837. /** @hidden */
  39838. export var anaglyphPixelShader: {
  39839. name: string;
  39840. shader: string;
  39841. };
  39842. }
  39843. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  39844. import { Engine } from "babylonjs/Engines/engine";
  39845. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39846. import { Camera } from "babylonjs/Cameras/camera";
  39847. import "babylonjs/Shaders/anaglyph.fragment";
  39848. /**
  39849. * Postprocess used to generate anaglyphic rendering
  39850. */
  39851. export class AnaglyphPostProcess extends PostProcess {
  39852. private _passedProcess;
  39853. /**
  39854. * Creates a new AnaglyphPostProcess
  39855. * @param name defines postprocess name
  39856. * @param options defines creation options or target ratio scale
  39857. * @param rigCameras defines cameras using this postprocess
  39858. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39859. * @param engine defines hosting engine
  39860. * @param reusable defines if the postprocess will be reused multiple times per frame
  39861. */
  39862. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39863. }
  39864. }
  39865. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  39866. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  39867. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39868. import { Scene } from "babylonjs/scene";
  39869. import { Vector3 } from "babylonjs/Maths/math.vector";
  39870. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39871. /**
  39872. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39873. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39874. */
  39875. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39876. /**
  39877. * Creates a new AnaglyphArcRotateCamera
  39878. * @param name defines camera name
  39879. * @param alpha defines alpha angle (in radians)
  39880. * @param beta defines beta angle (in radians)
  39881. * @param radius defines radius
  39882. * @param target defines camera target
  39883. * @param interaxialDistance defines distance between each color axis
  39884. * @param scene defines the hosting scene
  39885. */
  39886. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39887. /**
  39888. * Gets camera class name
  39889. * @returns AnaglyphArcRotateCamera
  39890. */
  39891. getClassName(): string;
  39892. }
  39893. }
  39894. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  39895. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39896. import { Scene } from "babylonjs/scene";
  39897. import { Vector3 } from "babylonjs/Maths/math.vector";
  39898. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39899. /**
  39900. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39901. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39902. */
  39903. export class AnaglyphFreeCamera extends FreeCamera {
  39904. /**
  39905. * Creates a new AnaglyphFreeCamera
  39906. * @param name defines camera name
  39907. * @param position defines initial position
  39908. * @param interaxialDistance defines distance between each color axis
  39909. * @param scene defines the hosting scene
  39910. */
  39911. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39912. /**
  39913. * Gets camera class name
  39914. * @returns AnaglyphFreeCamera
  39915. */
  39916. getClassName(): string;
  39917. }
  39918. }
  39919. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  39920. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39921. import { Scene } from "babylonjs/scene";
  39922. import { Vector3 } from "babylonjs/Maths/math.vector";
  39923. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39924. /**
  39925. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39926. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39927. */
  39928. export class AnaglyphGamepadCamera extends GamepadCamera {
  39929. /**
  39930. * Creates a new AnaglyphGamepadCamera
  39931. * @param name defines camera name
  39932. * @param position defines initial position
  39933. * @param interaxialDistance defines distance between each color axis
  39934. * @param scene defines the hosting scene
  39935. */
  39936. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39937. /**
  39938. * Gets camera class name
  39939. * @returns AnaglyphGamepadCamera
  39940. */
  39941. getClassName(): string;
  39942. }
  39943. }
  39944. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  39945. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39946. import { Scene } from "babylonjs/scene";
  39947. import { Vector3 } from "babylonjs/Maths/math.vector";
  39948. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39949. /**
  39950. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39951. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39952. */
  39953. export class AnaglyphUniversalCamera extends UniversalCamera {
  39954. /**
  39955. * Creates a new AnaglyphUniversalCamera
  39956. * @param name defines camera name
  39957. * @param position defines initial position
  39958. * @param interaxialDistance defines distance between each color axis
  39959. * @param scene defines the hosting scene
  39960. */
  39961. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39962. /**
  39963. * Gets camera class name
  39964. * @returns AnaglyphUniversalCamera
  39965. */
  39966. getClassName(): string;
  39967. }
  39968. }
  39969. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  39970. /** @hidden */
  39971. export var stereoscopicInterlacePixelShader: {
  39972. name: string;
  39973. shader: string;
  39974. };
  39975. }
  39976. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  39977. import { Camera } from "babylonjs/Cameras/camera";
  39978. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39979. import { Engine } from "babylonjs/Engines/engine";
  39980. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  39981. /**
  39982. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39983. */
  39984. export class StereoscopicInterlacePostProcess extends PostProcess {
  39985. private _stepSize;
  39986. private _passedProcess;
  39987. /**
  39988. * Initializes a StereoscopicInterlacePostProcess
  39989. * @param name The name of the effect.
  39990. * @param rigCameras The rig cameras to be appled to the post process
  39991. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39992. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39993. * @param engine The engine which the post process will be applied. (default: current engine)
  39994. * @param reusable If the post process can be reused on the same frame. (default: false)
  39995. */
  39996. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39997. }
  39998. }
  39999. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40000. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40001. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40002. import { Scene } from "babylonjs/scene";
  40003. import { Vector3 } from "babylonjs/Maths/math.vector";
  40004. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40005. /**
  40006. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40007. * @see http://doc.babylonjs.com/features/cameras
  40008. */
  40009. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40010. /**
  40011. * Creates a new StereoscopicArcRotateCamera
  40012. * @param name defines camera name
  40013. * @param alpha defines alpha angle (in radians)
  40014. * @param beta defines beta angle (in radians)
  40015. * @param radius defines radius
  40016. * @param target defines camera target
  40017. * @param interaxialDistance defines distance between each color axis
  40018. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40019. * @param scene defines the hosting scene
  40020. */
  40021. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40022. /**
  40023. * Gets camera class name
  40024. * @returns StereoscopicArcRotateCamera
  40025. */
  40026. getClassName(): string;
  40027. }
  40028. }
  40029. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40030. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40031. import { Scene } from "babylonjs/scene";
  40032. import { Vector3 } from "babylonjs/Maths/math.vector";
  40033. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40034. /**
  40035. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40036. * @see http://doc.babylonjs.com/features/cameras
  40037. */
  40038. export class StereoscopicFreeCamera extends FreeCamera {
  40039. /**
  40040. * Creates a new StereoscopicFreeCamera
  40041. * @param name defines camera name
  40042. * @param position defines initial position
  40043. * @param interaxialDistance defines distance between each color axis
  40044. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40045. * @param scene defines the hosting scene
  40046. */
  40047. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40048. /**
  40049. * Gets camera class name
  40050. * @returns StereoscopicFreeCamera
  40051. */
  40052. getClassName(): string;
  40053. }
  40054. }
  40055. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40056. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40057. import { Scene } from "babylonjs/scene";
  40058. import { Vector3 } from "babylonjs/Maths/math.vector";
  40059. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40060. /**
  40061. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40062. * @see http://doc.babylonjs.com/features/cameras
  40063. */
  40064. export class StereoscopicGamepadCamera extends GamepadCamera {
  40065. /**
  40066. * Creates a new StereoscopicGamepadCamera
  40067. * @param name defines camera name
  40068. * @param position defines initial position
  40069. * @param interaxialDistance defines distance between each color axis
  40070. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40071. * @param scene defines the hosting scene
  40072. */
  40073. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40074. /**
  40075. * Gets camera class name
  40076. * @returns StereoscopicGamepadCamera
  40077. */
  40078. getClassName(): string;
  40079. }
  40080. }
  40081. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40082. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40083. import { Scene } from "babylonjs/scene";
  40084. import { Vector3 } from "babylonjs/Maths/math.vector";
  40085. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40086. /**
  40087. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40088. * @see http://doc.babylonjs.com/features/cameras
  40089. */
  40090. export class StereoscopicUniversalCamera extends UniversalCamera {
  40091. /**
  40092. * Creates a new StereoscopicUniversalCamera
  40093. * @param name defines camera name
  40094. * @param position defines initial position
  40095. * @param interaxialDistance defines distance between each color axis
  40096. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40097. * @param scene defines the hosting scene
  40098. */
  40099. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40100. /**
  40101. * Gets camera class name
  40102. * @returns StereoscopicUniversalCamera
  40103. */
  40104. getClassName(): string;
  40105. }
  40106. }
  40107. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40108. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40109. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40110. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40111. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40112. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40113. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40114. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40115. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40116. }
  40117. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40118. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40119. import { Scene } from "babylonjs/scene";
  40120. import { Vector3 } from "babylonjs/Maths/math.vector";
  40121. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40122. /**
  40123. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40124. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40125. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40126. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40127. */
  40128. export class VirtualJoysticksCamera extends FreeCamera {
  40129. /**
  40130. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40131. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40132. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40133. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40134. * @param name Define the name of the camera in the scene
  40135. * @param position Define the start position of the camera in the scene
  40136. * @param scene Define the scene the camera belongs to
  40137. */
  40138. constructor(name: string, position: Vector3, scene: Scene);
  40139. /**
  40140. * Gets the current object class name.
  40141. * @return the class name
  40142. */
  40143. getClassName(): string;
  40144. }
  40145. }
  40146. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40147. import { Matrix } from "babylonjs/Maths/math.vector";
  40148. /**
  40149. * This represents all the required metrics to create a VR camera.
  40150. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40151. */
  40152. export class VRCameraMetrics {
  40153. /**
  40154. * Define the horizontal resolution off the screen.
  40155. */
  40156. hResolution: number;
  40157. /**
  40158. * Define the vertical resolution off the screen.
  40159. */
  40160. vResolution: number;
  40161. /**
  40162. * Define the horizontal screen size.
  40163. */
  40164. hScreenSize: number;
  40165. /**
  40166. * Define the vertical screen size.
  40167. */
  40168. vScreenSize: number;
  40169. /**
  40170. * Define the vertical screen center position.
  40171. */
  40172. vScreenCenter: number;
  40173. /**
  40174. * Define the distance of the eyes to the screen.
  40175. */
  40176. eyeToScreenDistance: number;
  40177. /**
  40178. * Define the distance between both lenses
  40179. */
  40180. lensSeparationDistance: number;
  40181. /**
  40182. * Define the distance between both viewer's eyes.
  40183. */
  40184. interpupillaryDistance: number;
  40185. /**
  40186. * Define the distortion factor of the VR postprocess.
  40187. * Please, touch with care.
  40188. */
  40189. distortionK: number[];
  40190. /**
  40191. * Define the chromatic aberration correction factors for the VR post process.
  40192. */
  40193. chromaAbCorrection: number[];
  40194. /**
  40195. * Define the scale factor of the post process.
  40196. * The smaller the better but the slower.
  40197. */
  40198. postProcessScaleFactor: number;
  40199. /**
  40200. * Define an offset for the lens center.
  40201. */
  40202. lensCenterOffset: number;
  40203. /**
  40204. * Define if the current vr camera should compensate the distortion of the lense or not.
  40205. */
  40206. compensateDistortion: boolean;
  40207. /**
  40208. * Defines if multiview should be enabled when rendering (Default: false)
  40209. */
  40210. multiviewEnabled: boolean;
  40211. /**
  40212. * Gets the rendering aspect ratio based on the provided resolutions.
  40213. */
  40214. readonly aspectRatio: number;
  40215. /**
  40216. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40217. */
  40218. readonly aspectRatioFov: number;
  40219. /**
  40220. * @hidden
  40221. */
  40222. readonly leftHMatrix: Matrix;
  40223. /**
  40224. * @hidden
  40225. */
  40226. readonly rightHMatrix: Matrix;
  40227. /**
  40228. * @hidden
  40229. */
  40230. readonly leftPreViewMatrix: Matrix;
  40231. /**
  40232. * @hidden
  40233. */
  40234. readonly rightPreViewMatrix: Matrix;
  40235. /**
  40236. * Get the default VRMetrics based on the most generic setup.
  40237. * @returns the default vr metrics
  40238. */
  40239. static GetDefault(): VRCameraMetrics;
  40240. }
  40241. }
  40242. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  40243. /** @hidden */
  40244. export var vrDistortionCorrectionPixelShader: {
  40245. name: string;
  40246. shader: string;
  40247. };
  40248. }
  40249. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  40250. import { Camera } from "babylonjs/Cameras/camera";
  40251. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40252. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40253. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  40254. /**
  40255. * VRDistortionCorrectionPostProcess used for mobile VR
  40256. */
  40257. export class VRDistortionCorrectionPostProcess extends PostProcess {
  40258. private _isRightEye;
  40259. private _distortionFactors;
  40260. private _postProcessScaleFactor;
  40261. private _lensCenterOffset;
  40262. private _scaleIn;
  40263. private _scaleFactor;
  40264. private _lensCenter;
  40265. /**
  40266. * Initializes the VRDistortionCorrectionPostProcess
  40267. * @param name The name of the effect.
  40268. * @param camera The camera to apply the render pass to.
  40269. * @param isRightEye If this is for the right eye distortion
  40270. * @param vrMetrics All the required metrics for the VR camera
  40271. */
  40272. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  40273. }
  40274. }
  40275. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  40276. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  40277. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40278. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40279. import { Scene } from "babylonjs/scene";
  40280. import { Vector3 } from "babylonjs/Maths/math.vector";
  40281. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40282. import "babylonjs/Cameras/RigModes/vrRigMode";
  40283. /**
  40284. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40285. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40286. */
  40287. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40288. /**
  40289. * Creates a new VRDeviceOrientationArcRotateCamera
  40290. * @param name defines camera name
  40291. * @param alpha defines the camera rotation along the logitudinal axis
  40292. * @param beta defines the camera rotation along the latitudinal axis
  40293. * @param radius defines the camera distance from its target
  40294. * @param target defines the camera target
  40295. * @param scene defines the scene the camera belongs to
  40296. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40297. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40298. */
  40299. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40300. /**
  40301. * Gets camera class name
  40302. * @returns VRDeviceOrientationArcRotateCamera
  40303. */
  40304. getClassName(): string;
  40305. }
  40306. }
  40307. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  40308. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40309. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40310. import { Scene } from "babylonjs/scene";
  40311. import { Vector3 } from "babylonjs/Maths/math.vector";
  40312. import "babylonjs/Cameras/RigModes/vrRigMode";
  40313. /**
  40314. * Camera used to simulate VR rendering (based on FreeCamera)
  40315. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40316. */
  40317. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40318. /**
  40319. * Creates a new VRDeviceOrientationFreeCamera
  40320. * @param name defines camera name
  40321. * @param position defines the start position of the camera
  40322. * @param scene defines the scene the camera belongs to
  40323. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40324. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40325. */
  40326. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40327. /**
  40328. * Gets camera class name
  40329. * @returns VRDeviceOrientationFreeCamera
  40330. */
  40331. getClassName(): string;
  40332. }
  40333. }
  40334. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40335. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40336. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40337. import { Scene } from "babylonjs/scene";
  40338. import { Vector3 } from "babylonjs/Maths/math.vector";
  40339. import "babylonjs/Gamepads/gamepadSceneComponent";
  40340. /**
  40341. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40342. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40343. */
  40344. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40345. /**
  40346. * Creates a new VRDeviceOrientationGamepadCamera
  40347. * @param name defines camera name
  40348. * @param position defines the start position of the camera
  40349. * @param scene defines the scene the camera belongs to
  40350. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40351. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40352. */
  40353. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40354. /**
  40355. * Gets camera class name
  40356. * @returns VRDeviceOrientationGamepadCamera
  40357. */
  40358. getClassName(): string;
  40359. }
  40360. }
  40361. declare module "babylonjs/Materials/pushMaterial" {
  40362. import { Nullable } from "babylonjs/types";
  40363. import { Scene } from "babylonjs/scene";
  40364. import { Matrix } from "babylonjs/Maths/math.vector";
  40365. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40366. import { Mesh } from "babylonjs/Meshes/mesh";
  40367. import { Material } from "babylonjs/Materials/material";
  40368. import { Effect } from "babylonjs/Materials/effect";
  40369. /**
  40370. * Base class of materials working in push mode in babylon JS
  40371. * @hidden
  40372. */
  40373. export class PushMaterial extends Material {
  40374. protected _activeEffect: Effect;
  40375. protected _normalMatrix: Matrix;
  40376. /**
  40377. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40378. * This means that the material can keep using a previous shader while a new one is being compiled.
  40379. * This is mostly used when shader parallel compilation is supported (true by default)
  40380. */
  40381. allowShaderHotSwapping: boolean;
  40382. constructor(name: string, scene: Scene);
  40383. getEffect(): Effect;
  40384. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40385. /**
  40386. * Binds the given world matrix to the active effect
  40387. *
  40388. * @param world the matrix to bind
  40389. */
  40390. bindOnlyWorldMatrix(world: Matrix): void;
  40391. /**
  40392. * Binds the given normal matrix to the active effect
  40393. *
  40394. * @param normalMatrix the matrix to bind
  40395. */
  40396. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40397. bind(world: Matrix, mesh?: Mesh): void;
  40398. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40399. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40400. }
  40401. }
  40402. declare module "babylonjs/Materials/materialFlags" {
  40403. /**
  40404. * This groups all the flags used to control the materials channel.
  40405. */
  40406. export class MaterialFlags {
  40407. private static _DiffuseTextureEnabled;
  40408. /**
  40409. * Are diffuse textures enabled in the application.
  40410. */
  40411. static DiffuseTextureEnabled: boolean;
  40412. private static _AmbientTextureEnabled;
  40413. /**
  40414. * Are ambient textures enabled in the application.
  40415. */
  40416. static AmbientTextureEnabled: boolean;
  40417. private static _OpacityTextureEnabled;
  40418. /**
  40419. * Are opacity textures enabled in the application.
  40420. */
  40421. static OpacityTextureEnabled: boolean;
  40422. private static _ReflectionTextureEnabled;
  40423. /**
  40424. * Are reflection textures enabled in the application.
  40425. */
  40426. static ReflectionTextureEnabled: boolean;
  40427. private static _EmissiveTextureEnabled;
  40428. /**
  40429. * Are emissive textures enabled in the application.
  40430. */
  40431. static EmissiveTextureEnabled: boolean;
  40432. private static _SpecularTextureEnabled;
  40433. /**
  40434. * Are specular textures enabled in the application.
  40435. */
  40436. static SpecularTextureEnabled: boolean;
  40437. private static _BumpTextureEnabled;
  40438. /**
  40439. * Are bump textures enabled in the application.
  40440. */
  40441. static BumpTextureEnabled: boolean;
  40442. private static _LightmapTextureEnabled;
  40443. /**
  40444. * Are lightmap textures enabled in the application.
  40445. */
  40446. static LightmapTextureEnabled: boolean;
  40447. private static _RefractionTextureEnabled;
  40448. /**
  40449. * Are refraction textures enabled in the application.
  40450. */
  40451. static RefractionTextureEnabled: boolean;
  40452. private static _ColorGradingTextureEnabled;
  40453. /**
  40454. * Are color grading textures enabled in the application.
  40455. */
  40456. static ColorGradingTextureEnabled: boolean;
  40457. private static _FresnelEnabled;
  40458. /**
  40459. * Are fresnels enabled in the application.
  40460. */
  40461. static FresnelEnabled: boolean;
  40462. private static _ClearCoatTextureEnabled;
  40463. /**
  40464. * Are clear coat textures enabled in the application.
  40465. */
  40466. static ClearCoatTextureEnabled: boolean;
  40467. private static _ClearCoatBumpTextureEnabled;
  40468. /**
  40469. * Are clear coat bump textures enabled in the application.
  40470. */
  40471. static ClearCoatBumpTextureEnabled: boolean;
  40472. private static _ClearCoatTintTextureEnabled;
  40473. /**
  40474. * Are clear coat tint textures enabled in the application.
  40475. */
  40476. static ClearCoatTintTextureEnabled: boolean;
  40477. private static _SheenTextureEnabled;
  40478. /**
  40479. * Are sheen textures enabled in the application.
  40480. */
  40481. static SheenTextureEnabled: boolean;
  40482. private static _AnisotropicTextureEnabled;
  40483. /**
  40484. * Are anisotropic textures enabled in the application.
  40485. */
  40486. static AnisotropicTextureEnabled: boolean;
  40487. private static _ThicknessTextureEnabled;
  40488. /**
  40489. * Are thickness textures enabled in the application.
  40490. */
  40491. static ThicknessTextureEnabled: boolean;
  40492. }
  40493. }
  40494. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  40495. /** @hidden */
  40496. export var defaultFragmentDeclaration: {
  40497. name: string;
  40498. shader: string;
  40499. };
  40500. }
  40501. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  40502. /** @hidden */
  40503. export var defaultUboDeclaration: {
  40504. name: string;
  40505. shader: string;
  40506. };
  40507. }
  40508. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  40509. /** @hidden */
  40510. export var lightFragmentDeclaration: {
  40511. name: string;
  40512. shader: string;
  40513. };
  40514. }
  40515. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  40516. /** @hidden */
  40517. export var lightUboDeclaration: {
  40518. name: string;
  40519. shader: string;
  40520. };
  40521. }
  40522. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  40523. /** @hidden */
  40524. export var lightsFragmentFunctions: {
  40525. name: string;
  40526. shader: string;
  40527. };
  40528. }
  40529. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  40530. /** @hidden */
  40531. export var shadowsFragmentFunctions: {
  40532. name: string;
  40533. shader: string;
  40534. };
  40535. }
  40536. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  40537. /** @hidden */
  40538. export var fresnelFunction: {
  40539. name: string;
  40540. shader: string;
  40541. };
  40542. }
  40543. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  40544. /** @hidden */
  40545. export var reflectionFunction: {
  40546. name: string;
  40547. shader: string;
  40548. };
  40549. }
  40550. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  40551. /** @hidden */
  40552. export var bumpFragmentFunctions: {
  40553. name: string;
  40554. shader: string;
  40555. };
  40556. }
  40557. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  40558. /** @hidden */
  40559. export var logDepthDeclaration: {
  40560. name: string;
  40561. shader: string;
  40562. };
  40563. }
  40564. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  40565. /** @hidden */
  40566. export var bumpFragment: {
  40567. name: string;
  40568. shader: string;
  40569. };
  40570. }
  40571. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  40572. /** @hidden */
  40573. export var depthPrePass: {
  40574. name: string;
  40575. shader: string;
  40576. };
  40577. }
  40578. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  40579. /** @hidden */
  40580. export var lightFragment: {
  40581. name: string;
  40582. shader: string;
  40583. };
  40584. }
  40585. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  40586. /** @hidden */
  40587. export var logDepthFragment: {
  40588. name: string;
  40589. shader: string;
  40590. };
  40591. }
  40592. declare module "babylonjs/Shaders/default.fragment" {
  40593. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  40594. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40595. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40596. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40597. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40598. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  40599. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  40600. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  40601. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  40602. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40603. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40604. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  40605. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  40606. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40607. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  40608. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  40609. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  40610. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  40611. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  40612. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  40613. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  40614. /** @hidden */
  40615. export var defaultPixelShader: {
  40616. name: string;
  40617. shader: string;
  40618. };
  40619. }
  40620. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  40621. /** @hidden */
  40622. export var defaultVertexDeclaration: {
  40623. name: string;
  40624. shader: string;
  40625. };
  40626. }
  40627. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  40628. /** @hidden */
  40629. export var bumpVertexDeclaration: {
  40630. name: string;
  40631. shader: string;
  40632. };
  40633. }
  40634. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  40635. /** @hidden */
  40636. export var bumpVertex: {
  40637. name: string;
  40638. shader: string;
  40639. };
  40640. }
  40641. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  40642. /** @hidden */
  40643. export var fogVertex: {
  40644. name: string;
  40645. shader: string;
  40646. };
  40647. }
  40648. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  40649. /** @hidden */
  40650. export var shadowsVertex: {
  40651. name: string;
  40652. shader: string;
  40653. };
  40654. }
  40655. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  40656. /** @hidden */
  40657. export var pointCloudVertex: {
  40658. name: string;
  40659. shader: string;
  40660. };
  40661. }
  40662. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  40663. /** @hidden */
  40664. export var logDepthVertex: {
  40665. name: string;
  40666. shader: string;
  40667. };
  40668. }
  40669. declare module "babylonjs/Shaders/default.vertex" {
  40670. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  40671. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40672. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40673. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  40674. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  40675. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  40676. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  40677. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  40678. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40679. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40680. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  40681. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  40682. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40683. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  40684. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  40685. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  40686. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  40687. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  40688. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  40689. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  40690. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  40691. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  40692. /** @hidden */
  40693. export var defaultVertexShader: {
  40694. name: string;
  40695. shader: string;
  40696. };
  40697. }
  40698. declare module "babylonjs/Materials/standardMaterial" {
  40699. import { SmartArray } from "babylonjs/Misc/smartArray";
  40700. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  40701. import { Nullable } from "babylonjs/types";
  40702. import { Scene } from "babylonjs/scene";
  40703. import { Matrix } from "babylonjs/Maths/math.vector";
  40704. import { Color3 } from "babylonjs/Maths/math.color";
  40705. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40706. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40707. import { Mesh } from "babylonjs/Meshes/mesh";
  40708. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  40709. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40710. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  40711. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  40712. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  40713. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40714. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40715. import "babylonjs/Shaders/default.fragment";
  40716. import "babylonjs/Shaders/default.vertex";
  40717. /** @hidden */
  40718. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40719. MAINUV1: boolean;
  40720. MAINUV2: boolean;
  40721. DIFFUSE: boolean;
  40722. DIFFUSEDIRECTUV: number;
  40723. AMBIENT: boolean;
  40724. AMBIENTDIRECTUV: number;
  40725. OPACITY: boolean;
  40726. OPACITYDIRECTUV: number;
  40727. OPACITYRGB: boolean;
  40728. REFLECTION: boolean;
  40729. EMISSIVE: boolean;
  40730. EMISSIVEDIRECTUV: number;
  40731. SPECULAR: boolean;
  40732. SPECULARDIRECTUV: number;
  40733. BUMP: boolean;
  40734. BUMPDIRECTUV: number;
  40735. PARALLAX: boolean;
  40736. PARALLAXOCCLUSION: boolean;
  40737. SPECULAROVERALPHA: boolean;
  40738. CLIPPLANE: boolean;
  40739. CLIPPLANE2: boolean;
  40740. CLIPPLANE3: boolean;
  40741. CLIPPLANE4: boolean;
  40742. ALPHATEST: boolean;
  40743. DEPTHPREPASS: boolean;
  40744. ALPHAFROMDIFFUSE: boolean;
  40745. POINTSIZE: boolean;
  40746. FOG: boolean;
  40747. SPECULARTERM: boolean;
  40748. DIFFUSEFRESNEL: boolean;
  40749. OPACITYFRESNEL: boolean;
  40750. REFLECTIONFRESNEL: boolean;
  40751. REFRACTIONFRESNEL: boolean;
  40752. EMISSIVEFRESNEL: boolean;
  40753. FRESNEL: boolean;
  40754. NORMAL: boolean;
  40755. UV1: boolean;
  40756. UV2: boolean;
  40757. VERTEXCOLOR: boolean;
  40758. VERTEXALPHA: boolean;
  40759. NUM_BONE_INFLUENCERS: number;
  40760. BonesPerMesh: number;
  40761. BONETEXTURE: boolean;
  40762. INSTANCES: boolean;
  40763. GLOSSINESS: boolean;
  40764. ROUGHNESS: boolean;
  40765. EMISSIVEASILLUMINATION: boolean;
  40766. LINKEMISSIVEWITHDIFFUSE: boolean;
  40767. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40768. LIGHTMAP: boolean;
  40769. LIGHTMAPDIRECTUV: number;
  40770. OBJECTSPACE_NORMALMAP: boolean;
  40771. USELIGHTMAPASSHADOWMAP: boolean;
  40772. REFLECTIONMAP_3D: boolean;
  40773. REFLECTIONMAP_SPHERICAL: boolean;
  40774. REFLECTIONMAP_PLANAR: boolean;
  40775. REFLECTIONMAP_CUBIC: boolean;
  40776. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40777. REFLECTIONMAP_PROJECTION: boolean;
  40778. REFLECTIONMAP_SKYBOX: boolean;
  40779. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40780. REFLECTIONMAP_EXPLICIT: boolean;
  40781. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40782. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40783. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40784. INVERTCUBICMAP: boolean;
  40785. LOGARITHMICDEPTH: boolean;
  40786. REFRACTION: boolean;
  40787. REFRACTIONMAP_3D: boolean;
  40788. REFLECTIONOVERALPHA: boolean;
  40789. TWOSIDEDLIGHTING: boolean;
  40790. SHADOWFLOAT: boolean;
  40791. MORPHTARGETS: boolean;
  40792. MORPHTARGETS_NORMAL: boolean;
  40793. MORPHTARGETS_TANGENT: boolean;
  40794. MORPHTARGETS_UV: boolean;
  40795. NUM_MORPH_INFLUENCERS: number;
  40796. NONUNIFORMSCALING: boolean;
  40797. PREMULTIPLYALPHA: boolean;
  40798. IMAGEPROCESSING: boolean;
  40799. VIGNETTE: boolean;
  40800. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40801. VIGNETTEBLENDMODEOPAQUE: boolean;
  40802. TONEMAPPING: boolean;
  40803. TONEMAPPING_ACES: boolean;
  40804. CONTRAST: boolean;
  40805. COLORCURVES: boolean;
  40806. COLORGRADING: boolean;
  40807. COLORGRADING3D: boolean;
  40808. SAMPLER3DGREENDEPTH: boolean;
  40809. SAMPLER3DBGRMAP: boolean;
  40810. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40811. MULTIVIEW: boolean;
  40812. /**
  40813. * If the reflection texture on this material is in linear color space
  40814. * @hidden
  40815. */
  40816. IS_REFLECTION_LINEAR: boolean;
  40817. /**
  40818. * If the refraction texture on this material is in linear color space
  40819. * @hidden
  40820. */
  40821. IS_REFRACTION_LINEAR: boolean;
  40822. EXPOSURE: boolean;
  40823. constructor();
  40824. setReflectionMode(modeToEnable: string): void;
  40825. }
  40826. /**
  40827. * This is the default material used in Babylon. It is the best trade off between quality
  40828. * and performances.
  40829. * @see http://doc.babylonjs.com/babylon101/materials
  40830. */
  40831. export class StandardMaterial extends PushMaterial {
  40832. private _diffuseTexture;
  40833. /**
  40834. * The basic texture of the material as viewed under a light.
  40835. */
  40836. diffuseTexture: Nullable<BaseTexture>;
  40837. private _ambientTexture;
  40838. /**
  40839. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40840. */
  40841. ambientTexture: Nullable<BaseTexture>;
  40842. private _opacityTexture;
  40843. /**
  40844. * Define the transparency of the material from a texture.
  40845. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40846. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40847. */
  40848. opacityTexture: Nullable<BaseTexture>;
  40849. private _reflectionTexture;
  40850. /**
  40851. * Define the texture used to display the reflection.
  40852. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40853. */
  40854. reflectionTexture: Nullable<BaseTexture>;
  40855. private _emissiveTexture;
  40856. /**
  40857. * Define texture of the material as if self lit.
  40858. * This will be mixed in the final result even in the absence of light.
  40859. */
  40860. emissiveTexture: Nullable<BaseTexture>;
  40861. private _specularTexture;
  40862. /**
  40863. * Define how the color and intensity of the highlight given by the light in the material.
  40864. */
  40865. specularTexture: Nullable<BaseTexture>;
  40866. private _bumpTexture;
  40867. /**
  40868. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40869. * 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.
  40870. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40871. */
  40872. bumpTexture: Nullable<BaseTexture>;
  40873. private _lightmapTexture;
  40874. /**
  40875. * Complex lighting can be computationally expensive to compute at runtime.
  40876. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40877. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40878. */
  40879. lightmapTexture: Nullable<BaseTexture>;
  40880. private _refractionTexture;
  40881. /**
  40882. * Define the texture used to display the refraction.
  40883. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40884. */
  40885. refractionTexture: Nullable<BaseTexture>;
  40886. /**
  40887. * The color of the material lit by the environmental background lighting.
  40888. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40889. */
  40890. ambientColor: Color3;
  40891. /**
  40892. * The basic color of the material as viewed under a light.
  40893. */
  40894. diffuseColor: Color3;
  40895. /**
  40896. * Define how the color and intensity of the highlight given by the light in the material.
  40897. */
  40898. specularColor: Color3;
  40899. /**
  40900. * Define the color of the material as if self lit.
  40901. * This will be mixed in the final result even in the absence of light.
  40902. */
  40903. emissiveColor: Color3;
  40904. /**
  40905. * Defines how sharp are the highlights in the material.
  40906. * The bigger the value the sharper giving a more glossy feeling to the result.
  40907. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40908. */
  40909. specularPower: number;
  40910. private _useAlphaFromDiffuseTexture;
  40911. /**
  40912. * Does the transparency come from the diffuse texture alpha channel.
  40913. */
  40914. useAlphaFromDiffuseTexture: boolean;
  40915. private _useEmissiveAsIllumination;
  40916. /**
  40917. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40918. */
  40919. useEmissiveAsIllumination: boolean;
  40920. private _linkEmissiveWithDiffuse;
  40921. /**
  40922. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40923. * the emissive level when the final color is close to one.
  40924. */
  40925. linkEmissiveWithDiffuse: boolean;
  40926. private _useSpecularOverAlpha;
  40927. /**
  40928. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40929. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40930. */
  40931. useSpecularOverAlpha: boolean;
  40932. private _useReflectionOverAlpha;
  40933. /**
  40934. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40935. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40936. */
  40937. useReflectionOverAlpha: boolean;
  40938. private _disableLighting;
  40939. /**
  40940. * Does lights from the scene impacts this material.
  40941. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40942. */
  40943. disableLighting: boolean;
  40944. private _useObjectSpaceNormalMap;
  40945. /**
  40946. * Allows using an object space normal map (instead of tangent space).
  40947. */
  40948. useObjectSpaceNormalMap: boolean;
  40949. private _useParallax;
  40950. /**
  40951. * Is parallax enabled or not.
  40952. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40953. */
  40954. useParallax: boolean;
  40955. private _useParallaxOcclusion;
  40956. /**
  40957. * Is parallax occlusion enabled or not.
  40958. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40959. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40960. */
  40961. useParallaxOcclusion: boolean;
  40962. /**
  40963. * 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.
  40964. */
  40965. parallaxScaleBias: number;
  40966. private _roughness;
  40967. /**
  40968. * Helps to define how blurry the reflections should appears in the material.
  40969. */
  40970. roughness: number;
  40971. /**
  40972. * In case of refraction, define the value of the index of refraction.
  40973. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40974. */
  40975. indexOfRefraction: number;
  40976. /**
  40977. * Invert the refraction texture alongside the y axis.
  40978. * It can be useful with procedural textures or probe for instance.
  40979. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40980. */
  40981. invertRefractionY: boolean;
  40982. /**
  40983. * Defines the alpha limits in alpha test mode.
  40984. */
  40985. alphaCutOff: number;
  40986. private _useLightmapAsShadowmap;
  40987. /**
  40988. * In case of light mapping, define whether the map contains light or shadow informations.
  40989. */
  40990. useLightmapAsShadowmap: boolean;
  40991. private _diffuseFresnelParameters;
  40992. /**
  40993. * Define the diffuse fresnel parameters of the material.
  40994. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40995. */
  40996. diffuseFresnelParameters: FresnelParameters;
  40997. private _opacityFresnelParameters;
  40998. /**
  40999. * Define the opacity fresnel parameters of the material.
  41000. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41001. */
  41002. opacityFresnelParameters: FresnelParameters;
  41003. private _reflectionFresnelParameters;
  41004. /**
  41005. * Define the reflection fresnel parameters of the material.
  41006. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41007. */
  41008. reflectionFresnelParameters: FresnelParameters;
  41009. private _refractionFresnelParameters;
  41010. /**
  41011. * Define the refraction fresnel parameters of the material.
  41012. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41013. */
  41014. refractionFresnelParameters: FresnelParameters;
  41015. private _emissiveFresnelParameters;
  41016. /**
  41017. * Define the emissive fresnel parameters of the material.
  41018. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41019. */
  41020. emissiveFresnelParameters: FresnelParameters;
  41021. private _useReflectionFresnelFromSpecular;
  41022. /**
  41023. * If true automatically deducts the fresnels values from the material specularity.
  41024. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41025. */
  41026. useReflectionFresnelFromSpecular: boolean;
  41027. private _useGlossinessFromSpecularMapAlpha;
  41028. /**
  41029. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41030. */
  41031. useGlossinessFromSpecularMapAlpha: boolean;
  41032. private _maxSimultaneousLights;
  41033. /**
  41034. * Defines the maximum number of lights that can be used in the material
  41035. */
  41036. maxSimultaneousLights: number;
  41037. private _invertNormalMapX;
  41038. /**
  41039. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41040. */
  41041. invertNormalMapX: boolean;
  41042. private _invertNormalMapY;
  41043. /**
  41044. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41045. */
  41046. invertNormalMapY: boolean;
  41047. private _twoSidedLighting;
  41048. /**
  41049. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41050. */
  41051. twoSidedLighting: boolean;
  41052. /**
  41053. * Default configuration related to image processing available in the standard Material.
  41054. */
  41055. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41056. /**
  41057. * Gets the image processing configuration used either in this material.
  41058. */
  41059. /**
  41060. * Sets the Default image processing configuration used either in the this material.
  41061. *
  41062. * If sets to null, the scene one is in use.
  41063. */
  41064. imageProcessingConfiguration: ImageProcessingConfiguration;
  41065. /**
  41066. * Keep track of the image processing observer to allow dispose and replace.
  41067. */
  41068. private _imageProcessingObserver;
  41069. /**
  41070. * Attaches a new image processing configuration to the Standard Material.
  41071. * @param configuration
  41072. */
  41073. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41074. /**
  41075. * Gets wether the color curves effect is enabled.
  41076. */
  41077. /**
  41078. * Sets wether the color curves effect is enabled.
  41079. */
  41080. cameraColorCurvesEnabled: boolean;
  41081. /**
  41082. * Gets wether the color grading effect is enabled.
  41083. */
  41084. /**
  41085. * Gets wether the color grading effect is enabled.
  41086. */
  41087. cameraColorGradingEnabled: boolean;
  41088. /**
  41089. * Gets wether tonemapping is enabled or not.
  41090. */
  41091. /**
  41092. * Sets wether tonemapping is enabled or not
  41093. */
  41094. cameraToneMappingEnabled: boolean;
  41095. /**
  41096. * The camera exposure used on this material.
  41097. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41098. * This corresponds to a photographic exposure.
  41099. */
  41100. /**
  41101. * The camera exposure used on this material.
  41102. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41103. * This corresponds to a photographic exposure.
  41104. */
  41105. cameraExposure: number;
  41106. /**
  41107. * Gets The camera contrast used on this material.
  41108. */
  41109. /**
  41110. * Sets The camera contrast used on this material.
  41111. */
  41112. cameraContrast: number;
  41113. /**
  41114. * Gets the Color Grading 2D Lookup Texture.
  41115. */
  41116. /**
  41117. * Sets the Color Grading 2D Lookup Texture.
  41118. */
  41119. cameraColorGradingTexture: Nullable<BaseTexture>;
  41120. /**
  41121. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41122. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41123. * 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;
  41124. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41125. */
  41126. /**
  41127. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41128. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41129. * 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;
  41130. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41131. */
  41132. cameraColorCurves: Nullable<ColorCurves>;
  41133. /**
  41134. * Custom callback helping to override the default shader used in the material.
  41135. */
  41136. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41137. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41138. protected _worldViewProjectionMatrix: Matrix;
  41139. protected _globalAmbientColor: Color3;
  41140. protected _useLogarithmicDepth: boolean;
  41141. /**
  41142. * Instantiates a new standard material.
  41143. * This is the default material used in Babylon. It is the best trade off between quality
  41144. * and performances.
  41145. * @see http://doc.babylonjs.com/babylon101/materials
  41146. * @param name Define the name of the material in the scene
  41147. * @param scene Define the scene the material belong to
  41148. */
  41149. constructor(name: string, scene: Scene);
  41150. /**
  41151. * Gets a boolean indicating that current material needs to register RTT
  41152. */
  41153. readonly hasRenderTargetTextures: boolean;
  41154. /**
  41155. * Gets the current class name of the material e.g. "StandardMaterial"
  41156. * Mainly use in serialization.
  41157. * @returns the class name
  41158. */
  41159. getClassName(): string;
  41160. /**
  41161. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41162. * You can try switching to logarithmic depth.
  41163. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41164. */
  41165. useLogarithmicDepth: boolean;
  41166. /**
  41167. * Specifies if the material will require alpha blending
  41168. * @returns a boolean specifying if alpha blending is needed
  41169. */
  41170. needAlphaBlending(): boolean;
  41171. /**
  41172. * Specifies if this material should be rendered in alpha test mode
  41173. * @returns a boolean specifying if an alpha test is needed.
  41174. */
  41175. needAlphaTesting(): boolean;
  41176. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41177. /**
  41178. * Get the texture used for alpha test purpose.
  41179. * @returns the diffuse texture in case of the standard material.
  41180. */
  41181. getAlphaTestTexture(): Nullable<BaseTexture>;
  41182. /**
  41183. * Get if the submesh is ready to be used and all its information available.
  41184. * Child classes can use it to update shaders
  41185. * @param mesh defines the mesh to check
  41186. * @param subMesh defines which submesh to check
  41187. * @param useInstances specifies that instances should be used
  41188. * @returns a boolean indicating that the submesh is ready or not
  41189. */
  41190. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41191. /**
  41192. * Builds the material UBO layouts.
  41193. * Used internally during the effect preparation.
  41194. */
  41195. buildUniformLayout(): void;
  41196. /**
  41197. * Unbinds the material from the mesh
  41198. */
  41199. unbind(): void;
  41200. /**
  41201. * Binds the submesh to this material by preparing the effect and shader to draw
  41202. * @param world defines the world transformation matrix
  41203. * @param mesh defines the mesh containing the submesh
  41204. * @param subMesh defines the submesh to bind the material to
  41205. */
  41206. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41207. /**
  41208. * Get the list of animatables in the material.
  41209. * @returns the list of animatables object used in the material
  41210. */
  41211. getAnimatables(): IAnimatable[];
  41212. /**
  41213. * Gets the active textures from the material
  41214. * @returns an array of textures
  41215. */
  41216. getActiveTextures(): BaseTexture[];
  41217. /**
  41218. * Specifies if the material uses a texture
  41219. * @param texture defines the texture to check against the material
  41220. * @returns a boolean specifying if the material uses the texture
  41221. */
  41222. hasTexture(texture: BaseTexture): boolean;
  41223. /**
  41224. * Disposes the material
  41225. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41226. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41227. */
  41228. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41229. /**
  41230. * Makes a duplicate of the material, and gives it a new name
  41231. * @param name defines the new name for the duplicated material
  41232. * @returns the cloned material
  41233. */
  41234. clone(name: string): StandardMaterial;
  41235. /**
  41236. * Serializes this material in a JSON representation
  41237. * @returns the serialized material object
  41238. */
  41239. serialize(): any;
  41240. /**
  41241. * Creates a standard material from parsed material data
  41242. * @param source defines the JSON representation of the material
  41243. * @param scene defines the hosting scene
  41244. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  41245. * @returns a new standard material
  41246. */
  41247. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  41248. /**
  41249. * Are diffuse textures enabled in the application.
  41250. */
  41251. static DiffuseTextureEnabled: boolean;
  41252. /**
  41253. * Are ambient textures enabled in the application.
  41254. */
  41255. static AmbientTextureEnabled: boolean;
  41256. /**
  41257. * Are opacity textures enabled in the application.
  41258. */
  41259. static OpacityTextureEnabled: boolean;
  41260. /**
  41261. * Are reflection textures enabled in the application.
  41262. */
  41263. static ReflectionTextureEnabled: boolean;
  41264. /**
  41265. * Are emissive textures enabled in the application.
  41266. */
  41267. static EmissiveTextureEnabled: boolean;
  41268. /**
  41269. * Are specular textures enabled in the application.
  41270. */
  41271. static SpecularTextureEnabled: boolean;
  41272. /**
  41273. * Are bump textures enabled in the application.
  41274. */
  41275. static BumpTextureEnabled: boolean;
  41276. /**
  41277. * Are lightmap textures enabled in the application.
  41278. */
  41279. static LightmapTextureEnabled: boolean;
  41280. /**
  41281. * Are refraction textures enabled in the application.
  41282. */
  41283. static RefractionTextureEnabled: boolean;
  41284. /**
  41285. * Are color grading textures enabled in the application.
  41286. */
  41287. static ColorGradingTextureEnabled: boolean;
  41288. /**
  41289. * Are fresnels enabled in the application.
  41290. */
  41291. static FresnelEnabled: boolean;
  41292. }
  41293. }
  41294. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  41295. import { Scene } from "babylonjs/scene";
  41296. import { Texture } from "babylonjs/Materials/Textures/texture";
  41297. /**
  41298. * A class extending Texture allowing drawing on a texture
  41299. * @see http://doc.babylonjs.com/how_to/dynamictexture
  41300. */
  41301. export class DynamicTexture extends Texture {
  41302. private _generateMipMaps;
  41303. private _canvas;
  41304. private _context;
  41305. private _engine;
  41306. /**
  41307. * Creates a DynamicTexture
  41308. * @param name defines the name of the texture
  41309. * @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
  41310. * @param scene defines the scene where you want the texture
  41311. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  41312. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  41313. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  41314. */
  41315. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  41316. /**
  41317. * Get the current class name of the texture useful for serialization or dynamic coding.
  41318. * @returns "DynamicTexture"
  41319. */
  41320. getClassName(): string;
  41321. /**
  41322. * Gets the current state of canRescale
  41323. */
  41324. readonly canRescale: boolean;
  41325. private _recreate;
  41326. /**
  41327. * Scales the texture
  41328. * @param ratio the scale factor to apply to both width and height
  41329. */
  41330. scale(ratio: number): void;
  41331. /**
  41332. * Resizes the texture
  41333. * @param width the new width
  41334. * @param height the new height
  41335. */
  41336. scaleTo(width: number, height: number): void;
  41337. /**
  41338. * Gets the context of the canvas used by the texture
  41339. * @returns the canvas context of the dynamic texture
  41340. */
  41341. getContext(): CanvasRenderingContext2D;
  41342. /**
  41343. * Clears the texture
  41344. */
  41345. clear(): void;
  41346. /**
  41347. * Updates the texture
  41348. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41349. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  41350. */
  41351. update(invertY?: boolean, premulAlpha?: boolean): void;
  41352. /**
  41353. * Draws text onto the texture
  41354. * @param text defines the text to be drawn
  41355. * @param x defines the placement of the text from the left
  41356. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  41357. * @param font defines the font to be used with font-style, font-size, font-name
  41358. * @param color defines the color used for the text
  41359. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  41360. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41361. * @param update defines whether texture is immediately update (default is true)
  41362. */
  41363. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  41364. /**
  41365. * Clones the texture
  41366. * @returns the clone of the texture.
  41367. */
  41368. clone(): DynamicTexture;
  41369. /**
  41370. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  41371. * @returns a serialized dynamic texture object
  41372. */
  41373. serialize(): any;
  41374. /** @hidden */
  41375. _rebuild(): void;
  41376. }
  41377. }
  41378. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41379. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41380. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41381. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41382. /** @hidden */
  41383. export var imageProcessingPixelShader: {
  41384. name: string;
  41385. shader: string;
  41386. };
  41387. }
  41388. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41389. import { Nullable } from "babylonjs/types";
  41390. import { Color4 } from "babylonjs/Maths/math.color";
  41391. import { Camera } from "babylonjs/Cameras/camera";
  41392. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41393. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41394. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41395. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41396. import { Engine } from "babylonjs/Engines/engine";
  41397. import "babylonjs/Shaders/imageProcessing.fragment";
  41398. import "babylonjs/Shaders/postprocess.vertex";
  41399. /**
  41400. * ImageProcessingPostProcess
  41401. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41402. */
  41403. export class ImageProcessingPostProcess extends PostProcess {
  41404. /**
  41405. * Default configuration related to image processing available in the PBR Material.
  41406. */
  41407. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41408. /**
  41409. * Gets the image processing configuration used either in this material.
  41410. */
  41411. /**
  41412. * Sets the Default image processing configuration used either in the this material.
  41413. *
  41414. * If sets to null, the scene one is in use.
  41415. */
  41416. imageProcessingConfiguration: ImageProcessingConfiguration;
  41417. /**
  41418. * Keep track of the image processing observer to allow dispose and replace.
  41419. */
  41420. private _imageProcessingObserver;
  41421. /**
  41422. * Attaches a new image processing configuration to the PBR Material.
  41423. * @param configuration
  41424. */
  41425. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41426. /**
  41427. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41428. */
  41429. /**
  41430. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41431. */
  41432. colorCurves: Nullable<ColorCurves>;
  41433. /**
  41434. * Gets wether the color curves effect is enabled.
  41435. */
  41436. /**
  41437. * Sets wether the color curves effect is enabled.
  41438. */
  41439. colorCurvesEnabled: boolean;
  41440. /**
  41441. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41442. */
  41443. /**
  41444. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41445. */
  41446. colorGradingTexture: Nullable<BaseTexture>;
  41447. /**
  41448. * Gets wether the color grading effect is enabled.
  41449. */
  41450. /**
  41451. * Gets wether the color grading effect is enabled.
  41452. */
  41453. colorGradingEnabled: boolean;
  41454. /**
  41455. * Gets exposure used in the effect.
  41456. */
  41457. /**
  41458. * Sets exposure used in the effect.
  41459. */
  41460. exposure: number;
  41461. /**
  41462. * Gets wether tonemapping is enabled or not.
  41463. */
  41464. /**
  41465. * Sets wether tonemapping is enabled or not
  41466. */
  41467. toneMappingEnabled: boolean;
  41468. /**
  41469. * Gets the type of tone mapping effect.
  41470. */
  41471. /**
  41472. * Sets the type of tone mapping effect.
  41473. */
  41474. toneMappingType: number;
  41475. /**
  41476. * Gets contrast used in the effect.
  41477. */
  41478. /**
  41479. * Sets contrast used in the effect.
  41480. */
  41481. contrast: number;
  41482. /**
  41483. * Gets Vignette stretch size.
  41484. */
  41485. /**
  41486. * Sets Vignette stretch size.
  41487. */
  41488. vignetteStretch: number;
  41489. /**
  41490. * Gets Vignette centre X Offset.
  41491. */
  41492. /**
  41493. * Sets Vignette centre X Offset.
  41494. */
  41495. vignetteCentreX: number;
  41496. /**
  41497. * Gets Vignette centre Y Offset.
  41498. */
  41499. /**
  41500. * Sets Vignette centre Y Offset.
  41501. */
  41502. vignetteCentreY: number;
  41503. /**
  41504. * Gets Vignette weight or intensity of the vignette effect.
  41505. */
  41506. /**
  41507. * Sets Vignette weight or intensity of the vignette effect.
  41508. */
  41509. vignetteWeight: number;
  41510. /**
  41511. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41512. * if vignetteEnabled is set to true.
  41513. */
  41514. /**
  41515. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41516. * if vignetteEnabled is set to true.
  41517. */
  41518. vignetteColor: Color4;
  41519. /**
  41520. * Gets Camera field of view used by the Vignette effect.
  41521. */
  41522. /**
  41523. * Sets Camera field of view used by the Vignette effect.
  41524. */
  41525. vignetteCameraFov: number;
  41526. /**
  41527. * Gets the vignette blend mode allowing different kind of effect.
  41528. */
  41529. /**
  41530. * Sets the vignette blend mode allowing different kind of effect.
  41531. */
  41532. vignetteBlendMode: number;
  41533. /**
  41534. * Gets wether the vignette effect is enabled.
  41535. */
  41536. /**
  41537. * Sets wether the vignette effect is enabled.
  41538. */
  41539. vignetteEnabled: boolean;
  41540. private _fromLinearSpace;
  41541. /**
  41542. * Gets wether the input of the processing is in Gamma or Linear Space.
  41543. */
  41544. /**
  41545. * Sets wether the input of the processing is in Gamma or Linear Space.
  41546. */
  41547. fromLinearSpace: boolean;
  41548. /**
  41549. * Defines cache preventing GC.
  41550. */
  41551. private _defines;
  41552. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41553. /**
  41554. * "ImageProcessingPostProcess"
  41555. * @returns "ImageProcessingPostProcess"
  41556. */
  41557. getClassName(): string;
  41558. protected _updateParameters(): void;
  41559. dispose(camera?: Camera): void;
  41560. }
  41561. }
  41562. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  41563. import { Scene } from "babylonjs/scene";
  41564. import { Color3 } from "babylonjs/Maths/math.color";
  41565. import { Mesh } from "babylonjs/Meshes/mesh";
  41566. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  41567. import { Nullable } from "babylonjs/types";
  41568. /**
  41569. * Class containing static functions to help procedurally build meshes
  41570. */
  41571. export class GroundBuilder {
  41572. /**
  41573. * Creates a ground mesh
  41574. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41575. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41577. * @param name defines the name of the mesh
  41578. * @param options defines the options used to create the mesh
  41579. * @param scene defines the hosting scene
  41580. * @returns the ground mesh
  41581. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41582. */
  41583. static CreateGround(name: string, options: {
  41584. width?: number;
  41585. height?: number;
  41586. subdivisions?: number;
  41587. subdivisionsX?: number;
  41588. subdivisionsY?: number;
  41589. updatable?: boolean;
  41590. }, scene: any): Mesh;
  41591. /**
  41592. * Creates a tiled ground mesh
  41593. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41594. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41595. * * 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
  41596. * * 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
  41597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41598. * @param name defines the name of the mesh
  41599. * @param options defines the options used to create the mesh
  41600. * @param scene defines the hosting scene
  41601. * @returns the tiled ground mesh
  41602. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41603. */
  41604. static CreateTiledGround(name: string, options: {
  41605. xmin: number;
  41606. zmin: number;
  41607. xmax: number;
  41608. zmax: number;
  41609. subdivisions?: {
  41610. w: number;
  41611. h: number;
  41612. };
  41613. precision?: {
  41614. w: number;
  41615. h: number;
  41616. };
  41617. updatable?: boolean;
  41618. }, scene?: Nullable<Scene>): Mesh;
  41619. /**
  41620. * Creates a ground mesh from a height map
  41621. * * The parameter `url` sets the URL of the height map image resource.
  41622. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41623. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41624. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41625. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41626. * * 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.
  41627. * * 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).
  41628. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41629. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41630. * @param name defines the name of the mesh
  41631. * @param url defines the url to the height map
  41632. * @param options defines the options used to create the mesh
  41633. * @param scene defines the hosting scene
  41634. * @returns the ground mesh
  41635. * @see https://doc.babylonjs.com/babylon101/height_map
  41636. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41637. */
  41638. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41639. width?: number;
  41640. height?: number;
  41641. subdivisions?: number;
  41642. minHeight?: number;
  41643. maxHeight?: number;
  41644. colorFilter?: Color3;
  41645. alphaFilter?: number;
  41646. updatable?: boolean;
  41647. onReady?: (mesh: GroundMesh) => void;
  41648. }, scene?: Nullable<Scene>): GroundMesh;
  41649. }
  41650. }
  41651. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  41652. import { Vector4 } from "babylonjs/Maths/math.vector";
  41653. import { Mesh } from "babylonjs/Meshes/mesh";
  41654. /**
  41655. * Class containing static functions to help procedurally build meshes
  41656. */
  41657. export class TorusBuilder {
  41658. /**
  41659. * Creates a torus mesh
  41660. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41661. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41662. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41663. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41664. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41666. * @param name defines the name of the mesh
  41667. * @param options defines the options used to create the mesh
  41668. * @param scene defines the hosting scene
  41669. * @returns the torus mesh
  41670. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41671. */
  41672. static CreateTorus(name: string, options: {
  41673. diameter?: number;
  41674. thickness?: number;
  41675. tessellation?: number;
  41676. updatable?: boolean;
  41677. sideOrientation?: number;
  41678. frontUVs?: Vector4;
  41679. backUVs?: Vector4;
  41680. }, scene: any): Mesh;
  41681. }
  41682. }
  41683. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  41684. import { Vector4 } from "babylonjs/Maths/math.vector";
  41685. import { Color4 } from "babylonjs/Maths/math.color";
  41686. import { Mesh } from "babylonjs/Meshes/mesh";
  41687. /**
  41688. * Class containing static functions to help procedurally build meshes
  41689. */
  41690. export class CylinderBuilder {
  41691. /**
  41692. * Creates a cylinder or a cone mesh
  41693. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41694. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41695. * * 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.
  41696. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41697. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41698. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41699. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41700. * * 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).
  41701. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41702. * * 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).
  41703. * * 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
  41704. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41705. * * 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
  41706. * * 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.
  41707. * * If `enclose` is false, a ring surface is one element.
  41708. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41709. * * 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
  41710. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41711. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41713. * @param name defines the name of the mesh
  41714. * @param options defines the options used to create the mesh
  41715. * @param scene defines the hosting scene
  41716. * @returns the cylinder mesh
  41717. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41718. */
  41719. static CreateCylinder(name: string, options: {
  41720. height?: number;
  41721. diameterTop?: number;
  41722. diameterBottom?: number;
  41723. diameter?: number;
  41724. tessellation?: number;
  41725. subdivisions?: number;
  41726. arc?: number;
  41727. faceColors?: Color4[];
  41728. faceUV?: Vector4[];
  41729. updatable?: boolean;
  41730. hasRings?: boolean;
  41731. enclose?: boolean;
  41732. cap?: number;
  41733. sideOrientation?: number;
  41734. frontUVs?: Vector4;
  41735. backUVs?: Vector4;
  41736. }, scene: any): Mesh;
  41737. }
  41738. }
  41739. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  41740. import { Observable } from "babylonjs/Misc/observable";
  41741. import { Nullable } from "babylonjs/types";
  41742. import { Camera } from "babylonjs/Cameras/camera";
  41743. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41744. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41745. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  41746. import { Scene } from "babylonjs/scene";
  41747. import { Vector3 } from "babylonjs/Maths/math.vector";
  41748. import { Color3 } from "babylonjs/Maths/math.color";
  41749. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  41750. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41751. import { Mesh } from "babylonjs/Meshes/mesh";
  41752. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  41753. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41754. import "babylonjs/Meshes/Builders/groundBuilder";
  41755. import "babylonjs/Meshes/Builders/torusBuilder";
  41756. import "babylonjs/Meshes/Builders/cylinderBuilder";
  41757. import "babylonjs/Gamepads/gamepadSceneComponent";
  41758. import "babylonjs/Animations/animatable";
  41759. /**
  41760. * Options to modify the vr teleportation behavior.
  41761. */
  41762. export interface VRTeleportationOptions {
  41763. /**
  41764. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41765. */
  41766. floorMeshName?: string;
  41767. /**
  41768. * A list of meshes to be used as the teleportation floor. (default: empty)
  41769. */
  41770. floorMeshes?: Mesh[];
  41771. }
  41772. /**
  41773. * Options to modify the vr experience helper's behavior.
  41774. */
  41775. export interface VRExperienceHelperOptions extends WebVROptions {
  41776. /**
  41777. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41778. */
  41779. createDeviceOrientationCamera?: boolean;
  41780. /**
  41781. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41782. */
  41783. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41784. /**
  41785. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41786. */
  41787. laserToggle?: boolean;
  41788. /**
  41789. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41790. */
  41791. floorMeshes?: Mesh[];
  41792. /**
  41793. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41794. */
  41795. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41796. }
  41797. /**
  41798. * Event containing information after VR has been entered
  41799. */
  41800. export class OnAfterEnteringVRObservableEvent {
  41801. /**
  41802. * If entering vr was successful
  41803. */
  41804. success: boolean;
  41805. }
  41806. /**
  41807. * Helps to quickly add VR support to an existing scene.
  41808. * See http://doc.babylonjs.com/how_to/webvr_helper
  41809. */
  41810. export class VRExperienceHelper {
  41811. /** Options to modify the vr experience helper's behavior. */
  41812. webVROptions: VRExperienceHelperOptions;
  41813. private _scene;
  41814. private _position;
  41815. private _btnVR;
  41816. private _btnVRDisplayed;
  41817. private _webVRsupported;
  41818. private _webVRready;
  41819. private _webVRrequesting;
  41820. private _webVRpresenting;
  41821. private _hasEnteredVR;
  41822. private _fullscreenVRpresenting;
  41823. private _canvas;
  41824. private _webVRCamera;
  41825. private _vrDeviceOrientationCamera;
  41826. private _deviceOrientationCamera;
  41827. private _existingCamera;
  41828. private _onKeyDown;
  41829. private _onVrDisplayPresentChange;
  41830. private _onVRDisplayChanged;
  41831. private _onVRRequestPresentStart;
  41832. private _onVRRequestPresentComplete;
  41833. /**
  41834. * Observable raised right before entering VR.
  41835. */
  41836. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41837. /**
  41838. * Observable raised when entering VR has completed.
  41839. */
  41840. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41841. /**
  41842. * Observable raised when exiting VR.
  41843. */
  41844. onExitingVRObservable: Observable<VRExperienceHelper>;
  41845. /**
  41846. * Observable raised when controller mesh is loaded.
  41847. */
  41848. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41849. /** Return this.onEnteringVRObservable
  41850. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41851. */
  41852. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41853. /** Return this.onExitingVRObservable
  41854. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41855. */
  41856. readonly onExitingVR: Observable<VRExperienceHelper>;
  41857. /** Return this.onControllerMeshLoadedObservable
  41858. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41859. */
  41860. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41861. private _rayLength;
  41862. private _useCustomVRButton;
  41863. private _teleportationRequested;
  41864. private _teleportActive;
  41865. private _floorMeshName;
  41866. private _floorMeshesCollection;
  41867. private _rotationAllowed;
  41868. private _teleportBackwardsVector;
  41869. private _teleportationTarget;
  41870. private _isDefaultTeleportationTarget;
  41871. private _postProcessMove;
  41872. private _teleportationFillColor;
  41873. private _teleportationBorderColor;
  41874. private _rotationAngle;
  41875. private _haloCenter;
  41876. private _cameraGazer;
  41877. private _padSensibilityUp;
  41878. private _padSensibilityDown;
  41879. private _leftController;
  41880. private _rightController;
  41881. /**
  41882. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41883. */
  41884. onNewMeshSelected: Observable<AbstractMesh>;
  41885. /**
  41886. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41887. */
  41888. onNewMeshPicked: Observable<PickingInfo>;
  41889. private _circleEase;
  41890. /**
  41891. * Observable raised before camera teleportation
  41892. */
  41893. onBeforeCameraTeleport: Observable<Vector3>;
  41894. /**
  41895. * Observable raised after camera teleportation
  41896. */
  41897. onAfterCameraTeleport: Observable<Vector3>;
  41898. /**
  41899. * Observable raised when current selected mesh gets unselected
  41900. */
  41901. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41902. private _raySelectionPredicate;
  41903. /**
  41904. * To be optionaly changed by user to define custom ray selection
  41905. */
  41906. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41907. /**
  41908. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41909. */
  41910. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41911. /**
  41912. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41913. */
  41914. teleportationEnabled: boolean;
  41915. private _defaultHeight;
  41916. private _teleportationInitialized;
  41917. private _interactionsEnabled;
  41918. private _interactionsRequested;
  41919. private _displayGaze;
  41920. private _displayLaserPointer;
  41921. /**
  41922. * The mesh used to display where the user is going to teleport.
  41923. */
  41924. /**
  41925. * Sets the mesh to be used to display where the user is going to teleport.
  41926. */
  41927. teleportationTarget: Mesh;
  41928. /**
  41929. * 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
  41930. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41931. * See http://doc.babylonjs.com/resources/baking_transformations
  41932. */
  41933. gazeTrackerMesh: Mesh;
  41934. /**
  41935. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41936. */
  41937. updateGazeTrackerScale: boolean;
  41938. /**
  41939. * If the gaze trackers color should be updated when selecting meshes
  41940. */
  41941. updateGazeTrackerColor: boolean;
  41942. /**
  41943. * The gaze tracking mesh corresponding to the left controller
  41944. */
  41945. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41946. /**
  41947. * The gaze tracking mesh corresponding to the right controller
  41948. */
  41949. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41950. /**
  41951. * If the ray of the gaze should be displayed.
  41952. */
  41953. /**
  41954. * Sets if the ray of the gaze should be displayed.
  41955. */
  41956. displayGaze: boolean;
  41957. /**
  41958. * If the ray of the LaserPointer should be displayed.
  41959. */
  41960. /**
  41961. * Sets if the ray of the LaserPointer should be displayed.
  41962. */
  41963. displayLaserPointer: boolean;
  41964. /**
  41965. * The deviceOrientationCamera used as the camera when not in VR.
  41966. */
  41967. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41968. /**
  41969. * Based on the current WebVR support, returns the current VR camera used.
  41970. */
  41971. readonly currentVRCamera: Nullable<Camera>;
  41972. /**
  41973. * The webVRCamera which is used when in VR.
  41974. */
  41975. readonly webVRCamera: WebVRFreeCamera;
  41976. /**
  41977. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41978. */
  41979. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41980. private readonly _teleportationRequestInitiated;
  41981. /**
  41982. * Defines wether or not Pointer lock should be requested when switching to
  41983. * full screen.
  41984. */
  41985. requestPointerLockOnFullScreen: boolean;
  41986. /**
  41987. * Instantiates a VRExperienceHelper.
  41988. * Helps to quickly add VR support to an existing scene.
  41989. * @param scene The scene the VRExperienceHelper belongs to.
  41990. * @param webVROptions Options to modify the vr experience helper's behavior.
  41991. */
  41992. constructor(scene: Scene,
  41993. /** Options to modify the vr experience helper's behavior. */
  41994. webVROptions?: VRExperienceHelperOptions);
  41995. private _onDefaultMeshLoaded;
  41996. private _onResize;
  41997. private _onFullscreenChange;
  41998. /**
  41999. * Gets a value indicating if we are currently in VR mode.
  42000. */
  42001. readonly isInVRMode: boolean;
  42002. private onVrDisplayPresentChange;
  42003. private onVRDisplayChanged;
  42004. private moveButtonToBottomRight;
  42005. private displayVRButton;
  42006. private updateButtonVisibility;
  42007. private _cachedAngularSensibility;
  42008. /**
  42009. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42010. * Otherwise, will use the fullscreen API.
  42011. */
  42012. enterVR(): void;
  42013. /**
  42014. * Attempt to exit VR, or fullscreen.
  42015. */
  42016. exitVR(): void;
  42017. /**
  42018. * The position of the vr experience helper.
  42019. */
  42020. /**
  42021. * Sets the position of the vr experience helper.
  42022. */
  42023. position: Vector3;
  42024. /**
  42025. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42026. */
  42027. enableInteractions(): void;
  42028. private readonly _noControllerIsActive;
  42029. private beforeRender;
  42030. private _isTeleportationFloor;
  42031. /**
  42032. * Adds a floor mesh to be used for teleportation.
  42033. * @param floorMesh the mesh to be used for teleportation.
  42034. */
  42035. addFloorMesh(floorMesh: Mesh): void;
  42036. /**
  42037. * Removes a floor mesh from being used for teleportation.
  42038. * @param floorMesh the mesh to be removed.
  42039. */
  42040. removeFloorMesh(floorMesh: Mesh): void;
  42041. /**
  42042. * Enables interactions and teleportation using the VR controllers and gaze.
  42043. * @param vrTeleportationOptions options to modify teleportation behavior.
  42044. */
  42045. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42046. private _onNewGamepadConnected;
  42047. private _tryEnableInteractionOnController;
  42048. private _onNewGamepadDisconnected;
  42049. private _enableInteractionOnController;
  42050. private _checkTeleportWithRay;
  42051. private _checkRotate;
  42052. private _checkTeleportBackwards;
  42053. private _enableTeleportationOnController;
  42054. private _createTeleportationCircles;
  42055. private _displayTeleportationTarget;
  42056. private _hideTeleportationTarget;
  42057. private _rotateCamera;
  42058. private _moveTeleportationSelectorTo;
  42059. private _workingVector;
  42060. private _workingQuaternion;
  42061. private _workingMatrix;
  42062. /**
  42063. * Teleports the users feet to the desired location
  42064. * @param location The location where the user's feet should be placed
  42065. */
  42066. teleportCamera(location: Vector3): void;
  42067. private _convertNormalToDirectionOfRay;
  42068. private _castRayAndSelectObject;
  42069. private _notifySelectedMeshUnselected;
  42070. /**
  42071. * Sets the color of the laser ray from the vr controllers.
  42072. * @param color new color for the ray.
  42073. */
  42074. changeLaserColor(color: Color3): void;
  42075. /**
  42076. * Sets the color of the ray from the vr headsets gaze.
  42077. * @param color new color for the ray.
  42078. */
  42079. changeGazeColor(color: Color3): void;
  42080. /**
  42081. * Exits VR and disposes of the vr experience helper
  42082. */
  42083. dispose(): void;
  42084. /**
  42085. * Gets the name of the VRExperienceHelper class
  42086. * @returns "VRExperienceHelper"
  42087. */
  42088. getClassName(): string;
  42089. }
  42090. }
  42091. declare module "babylonjs/Cameras/VR/index" {
  42092. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42093. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42094. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42095. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42096. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42097. export * from "babylonjs/Cameras/VR/webVRCamera";
  42098. }
  42099. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42100. import { Observable } from "babylonjs/Misc/observable";
  42101. import { Nullable } from "babylonjs/types";
  42102. import { IDisposable, Scene } from "babylonjs/scene";
  42103. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42104. /**
  42105. * Manages an XRSession to work with Babylon's engine
  42106. * @see https://doc.babylonjs.com/how_to/webxr
  42107. */
  42108. export class WebXRSessionManager implements IDisposable {
  42109. private scene;
  42110. /**
  42111. * Fires every time a new xrFrame arrives which can be used to update the camera
  42112. */
  42113. onXRFrameObservable: Observable<any>;
  42114. /**
  42115. * Fires when the xr session is ended either by the device or manually done
  42116. */
  42117. onXRSessionEnded: Observable<any>;
  42118. /**
  42119. * Underlying xr session
  42120. */
  42121. session: XRSession;
  42122. /**
  42123. * Type of reference space used when creating the session
  42124. */
  42125. referenceSpace: XRReferenceSpace;
  42126. /** @hidden */
  42127. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42128. /**
  42129. * Current XR frame
  42130. */
  42131. currentFrame: Nullable<XRFrame>;
  42132. private _xrNavigator;
  42133. private baseLayer;
  42134. /**
  42135. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42136. * @param scene The scene which the session should be created for
  42137. */
  42138. constructor(scene: Scene);
  42139. /**
  42140. * Initializes the manager
  42141. * After initialization enterXR can be called to start an XR session
  42142. * @returns Promise which resolves after it is initialized
  42143. */
  42144. initializeAsync(): Promise<void>;
  42145. /**
  42146. * Initializes an xr session
  42147. * @param xrSessionMode mode to initialize
  42148. * @returns a promise which will resolve once the session has been initialized
  42149. */
  42150. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42151. /**
  42152. * Sets the reference space on the xr session
  42153. * @param referenceSpace space to set
  42154. * @returns a promise that will resolve once the reference space has been set
  42155. */
  42156. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42157. /**
  42158. * Updates the render state of the session
  42159. * @param state state to set
  42160. * @returns a promise that resolves once the render state has been updated
  42161. */
  42162. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42163. /**
  42164. * Starts rendering to the xr layer
  42165. * @returns a promise that will resolve once rendering has started
  42166. */
  42167. startRenderingToXRAsync(): Promise<void>;
  42168. /**
  42169. * Stops the xrSession and restores the renderloop
  42170. * @returns Promise which resolves after it exits XR
  42171. */
  42172. exitXRAsync(): Promise<unknown>;
  42173. /**
  42174. * Checks if a session would be supported for the creation options specified
  42175. * @param sessionMode session mode to check if supported eg. immersive-vr
  42176. * @returns true if supported
  42177. */
  42178. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42179. /**
  42180. * @hidden
  42181. * Converts the render layer of xrSession to a render target
  42182. * @param session session to create render target for
  42183. * @param scene scene the new render target should be created for
  42184. */
  42185. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42186. /**
  42187. * Disposes of the session manager
  42188. */
  42189. dispose(): void;
  42190. }
  42191. }
  42192. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42193. import { Scene } from "babylonjs/scene";
  42194. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42195. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42196. /**
  42197. * WebXR Camera which holds the views for the xrSession
  42198. * @see https://doc.babylonjs.com/how_to/webxr
  42199. */
  42200. export class WebXRCamera extends FreeCamera {
  42201. private static _TmpMatrix;
  42202. /**
  42203. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42204. * @param name the name of the camera
  42205. * @param scene the scene to add the camera to
  42206. */
  42207. constructor(name: string, scene: Scene);
  42208. private _updateNumberOfRigCameras;
  42209. /** @hidden */
  42210. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42211. /**
  42212. * Updates the cameras position from the current pose information of the XR session
  42213. * @param xrSessionManager the session containing pose information
  42214. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42215. */
  42216. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42217. }
  42218. }
  42219. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42220. import { Nullable } from "babylonjs/types";
  42221. import { IDisposable } from "babylonjs/scene";
  42222. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42223. /**
  42224. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42225. */
  42226. export class WebXRManagedOutputCanvas implements IDisposable {
  42227. private helper;
  42228. private _canvas;
  42229. /**
  42230. * xrpresent context of the canvas which can be used to display/mirror xr content
  42231. */
  42232. canvasContext: WebGLRenderingContext;
  42233. /**
  42234. * xr layer for the canvas
  42235. */
  42236. xrLayer: Nullable<XRWebGLLayer>;
  42237. /**
  42238. * Initializes the xr layer for the session
  42239. * @param xrSession xr session
  42240. * @returns a promise that will resolve once the XR Layer has been created
  42241. */
  42242. initializeXRLayerAsync(xrSession: any): any;
  42243. /**
  42244. * Initializes the canvas to be added/removed upon entering/exiting xr
  42245. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42246. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42247. */
  42248. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42249. /**
  42250. * Disposes of the object
  42251. */
  42252. dispose(): void;
  42253. private _setManagedOutputCanvas;
  42254. private _addCanvas;
  42255. private _removeCanvas;
  42256. }
  42257. }
  42258. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42259. import { Observable } from "babylonjs/Misc/observable";
  42260. import { IDisposable, Scene } from "babylonjs/scene";
  42261. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  42262. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42263. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42264. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42265. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42266. /**
  42267. * States of the webXR experience
  42268. */
  42269. export enum WebXRState {
  42270. /**
  42271. * Transitioning to being in XR mode
  42272. */
  42273. ENTERING_XR = 0,
  42274. /**
  42275. * Transitioning to non XR mode
  42276. */
  42277. EXITING_XR = 1,
  42278. /**
  42279. * In XR mode and presenting
  42280. */
  42281. IN_XR = 2,
  42282. /**
  42283. * Not entered XR mode
  42284. */
  42285. NOT_IN_XR = 3
  42286. }
  42287. /**
  42288. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42289. * @see https://doc.babylonjs.com/how_to/webxr
  42290. */
  42291. export class WebXRExperienceHelper implements IDisposable {
  42292. private scene;
  42293. /**
  42294. * 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
  42295. */
  42296. container: AbstractMesh;
  42297. /**
  42298. * Camera used to render xr content
  42299. */
  42300. camera: WebXRCamera;
  42301. /**
  42302. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42303. */
  42304. state: WebXRState;
  42305. private _setState;
  42306. private static _TmpVector;
  42307. /**
  42308. * Fires when the state of the experience helper has changed
  42309. */
  42310. onStateChangedObservable: Observable<WebXRState>;
  42311. /** Session manager used to keep track of xr session */
  42312. sessionManager: WebXRSessionManager;
  42313. private _nonVRCamera;
  42314. private _originalSceneAutoClear;
  42315. private _supported;
  42316. /**
  42317. * Creates the experience helper
  42318. * @param scene the scene to attach the experience helper to
  42319. * @returns a promise for the experience helper
  42320. */
  42321. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42322. /**
  42323. * Creates a WebXRExperienceHelper
  42324. * @param scene The scene the helper should be created in
  42325. */
  42326. private constructor();
  42327. /**
  42328. * Exits XR mode and returns the scene to its original state
  42329. * @returns promise that resolves after xr mode has exited
  42330. */
  42331. exitXRAsync(): Promise<unknown>;
  42332. /**
  42333. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42334. * @param sessionCreationOptions options for the XR session
  42335. * @param referenceSpaceType frame of reference of the XR session
  42336. * @param outputCanvas the output canvas that will be used to enter XR mode
  42337. * @returns promise that resolves after xr mode has entered
  42338. */
  42339. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  42340. /**
  42341. * Updates the global position of the camera by moving the camera's container
  42342. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42343. * @param position The desired global position of the camera
  42344. */
  42345. setPositionOfCameraUsingContainer(position: Vector3): void;
  42346. /**
  42347. * Rotates the xr camera by rotating the camera's container around the camera's position
  42348. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42349. * @param rotation the desired quaternion rotation to apply to the camera
  42350. */
  42351. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42352. /**
  42353. * Disposes of the experience helper
  42354. */
  42355. dispose(): void;
  42356. }
  42357. }
  42358. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  42359. import { Nullable } from "babylonjs/types";
  42360. import { Observable } from "babylonjs/Misc/observable";
  42361. import { IDisposable, Scene } from "babylonjs/scene";
  42362. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42363. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42364. /**
  42365. * Button which can be used to enter a different mode of XR
  42366. */
  42367. export class WebXREnterExitUIButton {
  42368. /** button element */
  42369. element: HTMLElement;
  42370. /** XR initialization options for the button */
  42371. sessionMode: XRSessionMode;
  42372. /** Reference space type */
  42373. referenceSpaceType: XRReferenceSpaceType;
  42374. /**
  42375. * Creates a WebXREnterExitUIButton
  42376. * @param element button element
  42377. * @param sessionMode XR initialization session mode
  42378. * @param referenceSpaceType the type of reference space to be used
  42379. */
  42380. constructor(
  42381. /** button element */
  42382. element: HTMLElement,
  42383. /** XR initialization options for the button */
  42384. sessionMode: XRSessionMode,
  42385. /** Reference space type */
  42386. referenceSpaceType: XRReferenceSpaceType);
  42387. /**
  42388. * Overwritable function which can be used to update the button's visuals when the state changes
  42389. * @param activeButton the current active button in the UI
  42390. */
  42391. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42392. }
  42393. /**
  42394. * Options to create the webXR UI
  42395. */
  42396. export class WebXREnterExitUIOptions {
  42397. /**
  42398. * Context to enter xr with
  42399. */
  42400. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  42401. /**
  42402. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42403. */
  42404. customButtons?: Array<WebXREnterExitUIButton>;
  42405. }
  42406. /**
  42407. * UI to allow the user to enter/exit XR mode
  42408. */
  42409. export class WebXREnterExitUI implements IDisposable {
  42410. private scene;
  42411. private _overlay;
  42412. private _buttons;
  42413. private _activeButton;
  42414. /**
  42415. * Fired every time the active button is changed.
  42416. *
  42417. * When xr is entered via a button that launches xr that button will be the callback parameter
  42418. *
  42419. * When exiting xr the callback parameter will be null)
  42420. */
  42421. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42422. /**
  42423. * Creates UI to allow the user to enter/exit XR mode
  42424. * @param scene the scene to add the ui to
  42425. * @param helper the xr experience helper to enter/exit xr with
  42426. * @param options options to configure the UI
  42427. * @returns the created ui
  42428. */
  42429. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42430. private constructor();
  42431. private _updateButtons;
  42432. /**
  42433. * Disposes of the object
  42434. */
  42435. dispose(): void;
  42436. }
  42437. }
  42438. declare module "babylonjs/Cameras/XR/webXRController" {
  42439. import { Nullable } from "babylonjs/types";
  42440. import { Observable } from "babylonjs/Misc/observable";
  42441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42442. import { Ray } from "babylonjs/Culling/ray";
  42443. import { Scene } from "babylonjs/scene";
  42444. /**
  42445. * Represents an XR input
  42446. */
  42447. export class WebXRController {
  42448. private scene;
  42449. /** The underlying input source for the controller */
  42450. inputSource: XRInputSource;
  42451. private parentContainer;
  42452. /**
  42453. * 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
  42454. */
  42455. grip?: AbstractMesh;
  42456. /**
  42457. * Pointer which can be used to select objects or attach a visible laser to
  42458. */
  42459. pointer: AbstractMesh;
  42460. /**
  42461. * Event that fires when the controller is removed/disposed
  42462. */
  42463. onDisposeObservable: Observable<{}>;
  42464. private _tmpMatrix;
  42465. private _tmpQuaternion;
  42466. private _tmpVector;
  42467. /**
  42468. * Creates the controller
  42469. * @see https://doc.babylonjs.com/how_to/webxr
  42470. * @param scene the scene which the controller should be associated to
  42471. * @param inputSource the underlying input source for the controller
  42472. * @param parentContainer parent that the controller meshes should be children of
  42473. */
  42474. constructor(scene: Scene,
  42475. /** The underlying input source for the controller */
  42476. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42477. /**
  42478. * Updates the controller pose based on the given XRFrame
  42479. * @param xrFrame xr frame to update the pose with
  42480. * @param referenceSpace reference space to use
  42481. */
  42482. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42483. /**
  42484. * Gets a world space ray coming from the controller
  42485. * @param result the resulting ray
  42486. */
  42487. getWorldPointerRayToRef(result: Ray): void;
  42488. /**
  42489. * Disposes of the object
  42490. */
  42491. dispose(): void;
  42492. }
  42493. }
  42494. declare module "babylonjs/Cameras/XR/webXRInput" {
  42495. import { Observable } from "babylonjs/Misc/observable";
  42496. import { IDisposable } from "babylonjs/scene";
  42497. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42498. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  42499. /**
  42500. * XR input used to track XR inputs such as controllers/rays
  42501. */
  42502. export class WebXRInput implements IDisposable {
  42503. /**
  42504. * Base experience the input listens to
  42505. */
  42506. baseExperience: WebXRExperienceHelper;
  42507. /**
  42508. * XR controllers being tracked
  42509. */
  42510. controllers: Array<WebXRController>;
  42511. private _frameObserver;
  42512. private _stateObserver;
  42513. /**
  42514. * Event when a controller has been connected/added
  42515. */
  42516. onControllerAddedObservable: Observable<WebXRController>;
  42517. /**
  42518. * Event when a controller has been removed/disconnected
  42519. */
  42520. onControllerRemovedObservable: Observable<WebXRController>;
  42521. /**
  42522. * Initializes the WebXRInput
  42523. * @param baseExperience experience helper which the input should be created for
  42524. */
  42525. constructor(
  42526. /**
  42527. * Base experience the input listens to
  42528. */
  42529. baseExperience: WebXRExperienceHelper);
  42530. private _onInputSourcesChange;
  42531. private _addAndRemoveControllers;
  42532. /**
  42533. * Disposes of the object
  42534. */
  42535. dispose(): void;
  42536. }
  42537. }
  42538. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  42539. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42540. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  42541. /**
  42542. * Enables teleportation
  42543. */
  42544. export class WebXRControllerTeleportation {
  42545. private _teleportationFillColor;
  42546. private _teleportationBorderColor;
  42547. private _tmpRay;
  42548. private _tmpVector;
  42549. /**
  42550. * Creates a WebXRControllerTeleportation
  42551. * @param input input manager to add teleportation to
  42552. * @param floorMeshes floormeshes which can be teleported to
  42553. */
  42554. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  42555. }
  42556. }
  42557. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  42558. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  42559. /**
  42560. * Handles pointer input automatically for the pointer of XR controllers
  42561. */
  42562. export class WebXRControllerPointerSelection {
  42563. private static _idCounter;
  42564. private _tmpRay;
  42565. /**
  42566. * Creates a WebXRControllerPointerSelection
  42567. * @param input input manager to setup pointer selection
  42568. */
  42569. constructor(input: WebXRInput);
  42570. private _convertNormalToDirectionOfRay;
  42571. private _updatePointerDistance;
  42572. }
  42573. }
  42574. declare module "babylonjs/Loading/sceneLoader" {
  42575. import { Observable } from "babylonjs/Misc/observable";
  42576. import { Nullable } from "babylonjs/types";
  42577. import { Scene } from "babylonjs/scene";
  42578. import { Engine } from "babylonjs/Engines/engine";
  42579. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42580. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42581. import { AssetContainer } from "babylonjs/assetContainer";
  42582. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42583. import { Skeleton } from "babylonjs/Bones/skeleton";
  42584. /**
  42585. * Class used to represent data loading progression
  42586. */
  42587. export class SceneLoaderProgressEvent {
  42588. /** defines if data length to load can be evaluated */
  42589. readonly lengthComputable: boolean;
  42590. /** defines the loaded data length */
  42591. readonly loaded: number;
  42592. /** defines the data length to load */
  42593. readonly total: number;
  42594. /**
  42595. * Create a new progress event
  42596. * @param lengthComputable defines if data length to load can be evaluated
  42597. * @param loaded defines the loaded data length
  42598. * @param total defines the data length to load
  42599. */
  42600. constructor(
  42601. /** defines if data length to load can be evaluated */
  42602. lengthComputable: boolean,
  42603. /** defines the loaded data length */
  42604. loaded: number,
  42605. /** defines the data length to load */
  42606. total: number);
  42607. /**
  42608. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42609. * @param event defines the source event
  42610. * @returns a new SceneLoaderProgressEvent
  42611. */
  42612. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42613. }
  42614. /**
  42615. * Interface used by SceneLoader plugins to define supported file extensions
  42616. */
  42617. export interface ISceneLoaderPluginExtensions {
  42618. /**
  42619. * Defines the list of supported extensions
  42620. */
  42621. [extension: string]: {
  42622. isBinary: boolean;
  42623. };
  42624. }
  42625. /**
  42626. * Interface used by SceneLoader plugin factory
  42627. */
  42628. export interface ISceneLoaderPluginFactory {
  42629. /**
  42630. * Defines the name of the factory
  42631. */
  42632. name: string;
  42633. /**
  42634. * Function called to create a new plugin
  42635. * @return the new plugin
  42636. */
  42637. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42638. /**
  42639. * Boolean indicating if the plugin can direct load specific data
  42640. */
  42641. canDirectLoad?: (data: string) => boolean;
  42642. }
  42643. /**
  42644. * Interface used to define a SceneLoader plugin
  42645. */
  42646. export interface ISceneLoaderPlugin {
  42647. /**
  42648. * The friendly name of this plugin.
  42649. */
  42650. name: string;
  42651. /**
  42652. * The file extensions supported by this plugin.
  42653. */
  42654. extensions: string | ISceneLoaderPluginExtensions;
  42655. /**
  42656. * Import meshes into a scene.
  42657. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42658. * @param scene The scene to import into
  42659. * @param data The data to import
  42660. * @param rootUrl The root url for scene and resources
  42661. * @param meshes The meshes array to import into
  42662. * @param particleSystems The particle systems array to import into
  42663. * @param skeletons The skeletons array to import into
  42664. * @param onError The callback when import fails
  42665. * @returns True if successful or false otherwise
  42666. */
  42667. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42668. /**
  42669. * Load into a scene.
  42670. * @param scene The scene to load into
  42671. * @param data The data to import
  42672. * @param rootUrl The root url for scene and resources
  42673. * @param onError The callback when import fails
  42674. * @returns true if successful or false otherwise
  42675. */
  42676. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42677. /**
  42678. * The callback that returns true if the data can be directly loaded.
  42679. */
  42680. canDirectLoad?: (data: string) => boolean;
  42681. /**
  42682. * The callback that allows custom handling of the root url based on the response url.
  42683. */
  42684. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42685. /**
  42686. * Load into an asset container.
  42687. * @param scene The scene to load into
  42688. * @param data The data to import
  42689. * @param rootUrl The root url for scene and resources
  42690. * @param onError The callback when import fails
  42691. * @returns The loaded asset container
  42692. */
  42693. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42694. }
  42695. /**
  42696. * Interface used to define an async SceneLoader plugin
  42697. */
  42698. export interface ISceneLoaderPluginAsync {
  42699. /**
  42700. * The friendly name of this plugin.
  42701. */
  42702. name: string;
  42703. /**
  42704. * The file extensions supported by this plugin.
  42705. */
  42706. extensions: string | ISceneLoaderPluginExtensions;
  42707. /**
  42708. * Import meshes into a scene.
  42709. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42710. * @param scene The scene to import into
  42711. * @param data The data to import
  42712. * @param rootUrl The root url for scene and resources
  42713. * @param onProgress The callback when the load progresses
  42714. * @param fileName Defines the name of the file to load
  42715. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42716. */
  42717. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42718. meshes: AbstractMesh[];
  42719. particleSystems: IParticleSystem[];
  42720. skeletons: Skeleton[];
  42721. animationGroups: AnimationGroup[];
  42722. }>;
  42723. /**
  42724. * Load into a scene.
  42725. * @param scene The scene to load into
  42726. * @param data The data to import
  42727. * @param rootUrl The root url for scene and resources
  42728. * @param onProgress The callback when the load progresses
  42729. * @param fileName Defines the name of the file to load
  42730. * @returns Nothing
  42731. */
  42732. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42733. /**
  42734. * The callback that returns true if the data can be directly loaded.
  42735. */
  42736. canDirectLoad?: (data: string) => boolean;
  42737. /**
  42738. * The callback that allows custom handling of the root url based on the response url.
  42739. */
  42740. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42741. /**
  42742. * Load into an asset container.
  42743. * @param scene The scene to load into
  42744. * @param data The data to import
  42745. * @param rootUrl The root url for scene and resources
  42746. * @param onProgress The callback when the load progresses
  42747. * @param fileName Defines the name of the file to load
  42748. * @returns The loaded asset container
  42749. */
  42750. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42751. }
  42752. /**
  42753. * Class used to load scene from various file formats using registered plugins
  42754. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42755. */
  42756. export class SceneLoader {
  42757. /**
  42758. * No logging while loading
  42759. */
  42760. static readonly NO_LOGGING: number;
  42761. /**
  42762. * Minimal logging while loading
  42763. */
  42764. static readonly MINIMAL_LOGGING: number;
  42765. /**
  42766. * Summary logging while loading
  42767. */
  42768. static readonly SUMMARY_LOGGING: number;
  42769. /**
  42770. * Detailled logging while loading
  42771. */
  42772. static readonly DETAILED_LOGGING: number;
  42773. /**
  42774. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42775. */
  42776. static ForceFullSceneLoadingForIncremental: boolean;
  42777. /**
  42778. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42779. */
  42780. static ShowLoadingScreen: boolean;
  42781. /**
  42782. * Defines the current logging level (while loading the scene)
  42783. * @ignorenaming
  42784. */
  42785. static loggingLevel: number;
  42786. /**
  42787. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42788. */
  42789. static CleanBoneMatrixWeights: boolean;
  42790. /**
  42791. * Event raised when a plugin is used to load a scene
  42792. */
  42793. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42794. private static _registeredPlugins;
  42795. private static _getDefaultPlugin;
  42796. private static _getPluginForExtension;
  42797. private static _getPluginForDirectLoad;
  42798. private static _getPluginForFilename;
  42799. private static _getDirectLoad;
  42800. private static _loadData;
  42801. private static _getFileInfo;
  42802. /**
  42803. * Gets a plugin that can load the given extension
  42804. * @param extension defines the extension to load
  42805. * @returns a plugin or null if none works
  42806. */
  42807. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42808. /**
  42809. * Gets a boolean indicating that the given extension can be loaded
  42810. * @param extension defines the extension to load
  42811. * @returns true if the extension is supported
  42812. */
  42813. static IsPluginForExtensionAvailable(extension: string): boolean;
  42814. /**
  42815. * Adds a new plugin to the list of registered plugins
  42816. * @param plugin defines the plugin to add
  42817. */
  42818. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42819. /**
  42820. * Import meshes into a scene
  42821. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42822. * @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)
  42823. * @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)
  42824. * @param scene the instance of BABYLON.Scene to append to
  42825. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42826. * @param onProgress a callback with a progress event for each file being loaded
  42827. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42828. * @param pluginExtension the extension used to determine the plugin
  42829. * @returns The loaded plugin
  42830. */
  42831. 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>;
  42832. /**
  42833. * Import meshes into a scene
  42834. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42835. * @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)
  42836. * @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)
  42837. * @param scene the instance of BABYLON.Scene to append to
  42838. * @param onProgress a callback with a progress event for each file being loaded
  42839. * @param pluginExtension the extension used to determine the plugin
  42840. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42841. */
  42842. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42843. meshes: AbstractMesh[];
  42844. particleSystems: IParticleSystem[];
  42845. skeletons: Skeleton[];
  42846. animationGroups: AnimationGroup[];
  42847. }>;
  42848. /**
  42849. * Load a scene
  42850. * @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)
  42851. * @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)
  42852. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42853. * @param onSuccess a callback with the scene when import succeeds
  42854. * @param onProgress a callback with a progress event for each file being loaded
  42855. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42856. * @param pluginExtension the extension used to determine the plugin
  42857. * @returns The loaded plugin
  42858. */
  42859. 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>;
  42860. /**
  42861. * Load a scene
  42862. * @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)
  42863. * @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)
  42864. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42865. * @param onProgress a callback with a progress event for each file being loaded
  42866. * @param pluginExtension the extension used to determine the plugin
  42867. * @returns The loaded scene
  42868. */
  42869. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42870. /**
  42871. * Append a scene
  42872. * @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)
  42873. * @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)
  42874. * @param scene is the instance of BABYLON.Scene to append to
  42875. * @param onSuccess a callback with the scene when import succeeds
  42876. * @param onProgress a callback with a progress event for each file being loaded
  42877. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42878. * @param pluginExtension the extension used to determine the plugin
  42879. * @returns The loaded plugin
  42880. */
  42881. 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>;
  42882. /**
  42883. * Append a scene
  42884. * @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)
  42885. * @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)
  42886. * @param scene is the instance of BABYLON.Scene to append to
  42887. * @param onProgress a callback with a progress event for each file being loaded
  42888. * @param pluginExtension the extension used to determine the plugin
  42889. * @returns The given scene
  42890. */
  42891. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42892. /**
  42893. * Load a scene into an asset container
  42894. * @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)
  42895. * @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)
  42896. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42897. * @param onSuccess a callback with the scene when import succeeds
  42898. * @param onProgress a callback with a progress event for each file being loaded
  42899. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42900. * @param pluginExtension the extension used to determine the plugin
  42901. * @returns The loaded plugin
  42902. */
  42903. 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>;
  42904. /**
  42905. * Load a scene into an asset container
  42906. * @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)
  42907. * @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)
  42908. * @param scene is the instance of Scene to append to
  42909. * @param onProgress a callback with a progress event for each file being loaded
  42910. * @param pluginExtension the extension used to determine the plugin
  42911. * @returns The loaded asset container
  42912. */
  42913. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42914. }
  42915. }
  42916. declare module "babylonjs/Gamepads/Controllers/genericController" {
  42917. import { Scene } from "babylonjs/scene";
  42918. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42919. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42920. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42921. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42922. /**
  42923. * Generic Controller
  42924. */
  42925. export class GenericController extends WebVRController {
  42926. /**
  42927. * Base Url for the controller model.
  42928. */
  42929. static readonly MODEL_BASE_URL: string;
  42930. /**
  42931. * File name for the controller model.
  42932. */
  42933. static readonly MODEL_FILENAME: string;
  42934. /**
  42935. * Creates a new GenericController from a gamepad
  42936. * @param vrGamepad the gamepad that the controller should be created from
  42937. */
  42938. constructor(vrGamepad: any);
  42939. /**
  42940. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42941. * @param scene scene in which to add meshes
  42942. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42943. */
  42944. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42945. /**
  42946. * Called once for each button that changed state since the last frame
  42947. * @param buttonIdx Which button index changed
  42948. * @param state New state of the button
  42949. * @param changes Which properties on the state changed since last frame
  42950. */
  42951. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42952. }
  42953. }
  42954. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  42955. import { Observable } from "babylonjs/Misc/observable";
  42956. import { Scene } from "babylonjs/scene";
  42957. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42958. import { Ray } from "babylonjs/Culling/ray";
  42959. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42960. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42961. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42962. /**
  42963. * Defines the WindowsMotionController object that the state of the windows motion controller
  42964. */
  42965. export class WindowsMotionController extends WebVRController {
  42966. /**
  42967. * The base url used to load the left and right controller models
  42968. */
  42969. static MODEL_BASE_URL: string;
  42970. /**
  42971. * The name of the left controller model file
  42972. */
  42973. static MODEL_LEFT_FILENAME: string;
  42974. /**
  42975. * The name of the right controller model file
  42976. */
  42977. static MODEL_RIGHT_FILENAME: string;
  42978. /**
  42979. * The controller name prefix for this controller type
  42980. */
  42981. static readonly GAMEPAD_ID_PREFIX: string;
  42982. /**
  42983. * The controller id pattern for this controller type
  42984. */
  42985. private static readonly GAMEPAD_ID_PATTERN;
  42986. private _loadedMeshInfo;
  42987. private readonly _mapping;
  42988. /**
  42989. * Fired when the trackpad on this controller is clicked
  42990. */
  42991. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42992. /**
  42993. * Fired when the trackpad on this controller is modified
  42994. */
  42995. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42996. /**
  42997. * The current x and y values of this controller's trackpad
  42998. */
  42999. trackpad: StickValues;
  43000. /**
  43001. * Creates a new WindowsMotionController from a gamepad
  43002. * @param vrGamepad the gamepad that the controller should be created from
  43003. */
  43004. constructor(vrGamepad: any);
  43005. /**
  43006. * Fired when the trigger on this controller is modified
  43007. */
  43008. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43009. /**
  43010. * Fired when the menu button on this controller is modified
  43011. */
  43012. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43013. /**
  43014. * Fired when the grip button on this controller is modified
  43015. */
  43016. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43017. /**
  43018. * Fired when the thumbstick button on this controller is modified
  43019. */
  43020. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43021. /**
  43022. * Fired when the touchpad button on this controller is modified
  43023. */
  43024. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43025. /**
  43026. * Fired when the touchpad values on this controller are modified
  43027. */
  43028. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43029. private _updateTrackpad;
  43030. /**
  43031. * Called once per frame by the engine.
  43032. */
  43033. update(): void;
  43034. /**
  43035. * Called once for each button that changed state since the last frame
  43036. * @param buttonIdx Which button index changed
  43037. * @param state New state of the button
  43038. * @param changes Which properties on the state changed since last frame
  43039. */
  43040. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43041. /**
  43042. * Moves the buttons on the controller mesh based on their current state
  43043. * @param buttonName the name of the button to move
  43044. * @param buttonValue the value of the button which determines the buttons new position
  43045. */
  43046. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43047. /**
  43048. * Moves the axis on the controller mesh based on its current state
  43049. * @param axis the index of the axis
  43050. * @param axisValue the value of the axis which determines the meshes new position
  43051. * @hidden
  43052. */
  43053. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43054. /**
  43055. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43056. * @param scene scene in which to add meshes
  43057. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43058. */
  43059. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43060. /**
  43061. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43062. * can be transformed by button presses and axes values, based on this._mapping.
  43063. *
  43064. * @param scene scene in which the meshes exist
  43065. * @param meshes list of meshes that make up the controller model to process
  43066. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43067. */
  43068. private processModel;
  43069. private createMeshInfo;
  43070. /**
  43071. * Gets the ray of the controller in the direction the controller is pointing
  43072. * @param length the length the resulting ray should be
  43073. * @returns a ray in the direction the controller is pointing
  43074. */
  43075. getForwardRay(length?: number): Ray;
  43076. /**
  43077. * Disposes of the controller
  43078. */
  43079. dispose(): void;
  43080. }
  43081. }
  43082. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43083. import { Observable } from "babylonjs/Misc/observable";
  43084. import { Scene } from "babylonjs/scene";
  43085. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43086. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43087. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43088. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43089. /**
  43090. * Oculus Touch Controller
  43091. */
  43092. export class OculusTouchController extends WebVRController {
  43093. /**
  43094. * Base Url for the controller model.
  43095. */
  43096. static MODEL_BASE_URL: string;
  43097. /**
  43098. * File name for the left controller model.
  43099. */
  43100. static MODEL_LEFT_FILENAME: string;
  43101. /**
  43102. * File name for the right controller model.
  43103. */
  43104. static MODEL_RIGHT_FILENAME: string;
  43105. /**
  43106. * Base Url for the Quest controller model.
  43107. */
  43108. static QUEST_MODEL_BASE_URL: string;
  43109. /**
  43110. * @hidden
  43111. * If the controllers are running on a device that needs the updated Quest controller models
  43112. */
  43113. static _IsQuest: boolean;
  43114. /**
  43115. * Fired when the secondary trigger on this controller is modified
  43116. */
  43117. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43118. /**
  43119. * Fired when the thumb rest on this controller is modified
  43120. */
  43121. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43122. /**
  43123. * Creates a new OculusTouchController from a gamepad
  43124. * @param vrGamepad the gamepad that the controller should be created from
  43125. */
  43126. constructor(vrGamepad: any);
  43127. /**
  43128. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43129. * @param scene scene in which to add meshes
  43130. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43131. */
  43132. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43133. /**
  43134. * Fired when the A button on this controller is modified
  43135. */
  43136. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43137. /**
  43138. * Fired when the B button on this controller is modified
  43139. */
  43140. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43141. /**
  43142. * Fired when the X button on this controller is modified
  43143. */
  43144. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43145. /**
  43146. * Fired when the Y button on this controller is modified
  43147. */
  43148. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43149. /**
  43150. * Called once for each button that changed state since the last frame
  43151. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43152. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43153. * 2) secondary trigger (same)
  43154. * 3) A (right) X (left), touch, pressed = value
  43155. * 4) B / Y
  43156. * 5) thumb rest
  43157. * @param buttonIdx Which button index changed
  43158. * @param state New state of the button
  43159. * @param changes Which properties on the state changed since last frame
  43160. */
  43161. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43162. }
  43163. }
  43164. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43165. import { Scene } from "babylonjs/scene";
  43166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43167. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43168. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43169. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43170. import { Observable } from "babylonjs/Misc/observable";
  43171. /**
  43172. * Vive Controller
  43173. */
  43174. export class ViveController extends WebVRController {
  43175. /**
  43176. * Base Url for the controller model.
  43177. */
  43178. static MODEL_BASE_URL: string;
  43179. /**
  43180. * File name for the controller model.
  43181. */
  43182. static MODEL_FILENAME: string;
  43183. /**
  43184. * Creates a new ViveController from a gamepad
  43185. * @param vrGamepad the gamepad that the controller should be created from
  43186. */
  43187. constructor(vrGamepad: any);
  43188. /**
  43189. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43190. * @param scene scene in which to add meshes
  43191. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43192. */
  43193. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43194. /**
  43195. * Fired when the left button on this controller is modified
  43196. */
  43197. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43198. /**
  43199. * Fired when the right button on this controller is modified
  43200. */
  43201. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43202. /**
  43203. * Fired when the menu button on this controller is modified
  43204. */
  43205. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43206. /**
  43207. * Called once for each button that changed state since the last frame
  43208. * Vive mapping:
  43209. * 0: touchpad
  43210. * 1: trigger
  43211. * 2: left AND right buttons
  43212. * 3: menu button
  43213. * @param buttonIdx Which button index changed
  43214. * @param state New state of the button
  43215. * @param changes Which properties on the state changed since last frame
  43216. */
  43217. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43218. }
  43219. }
  43220. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43221. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43222. /**
  43223. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43224. */
  43225. export class WebXRControllerModelLoader {
  43226. /**
  43227. * Creates the WebXRControllerModelLoader
  43228. * @param input xr input that creates the controllers
  43229. */
  43230. constructor(input: WebXRInput);
  43231. }
  43232. }
  43233. declare module "babylonjs/Cameras/XR/index" {
  43234. export * from "babylonjs/Cameras/XR/webXRCamera";
  43235. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43236. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43237. export * from "babylonjs/Cameras/XR/webXRInput";
  43238. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43239. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43240. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43241. export * from "babylonjs/Cameras/XR/webXRController";
  43242. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43243. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43244. }
  43245. declare module "babylonjs/Cameras/RigModes/index" {
  43246. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43247. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43248. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43249. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43250. }
  43251. declare module "babylonjs/Cameras/index" {
  43252. export * from "babylonjs/Cameras/Inputs/index";
  43253. export * from "babylonjs/Cameras/cameraInputsManager";
  43254. export * from "babylonjs/Cameras/camera";
  43255. export * from "babylonjs/Cameras/targetCamera";
  43256. export * from "babylonjs/Cameras/freeCamera";
  43257. export * from "babylonjs/Cameras/freeCameraInputsManager";
  43258. export * from "babylonjs/Cameras/touchCamera";
  43259. export * from "babylonjs/Cameras/arcRotateCamera";
  43260. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43261. export * from "babylonjs/Cameras/deviceOrientationCamera";
  43262. export * from "babylonjs/Cameras/flyCamera";
  43263. export * from "babylonjs/Cameras/flyCameraInputsManager";
  43264. export * from "babylonjs/Cameras/followCamera";
  43265. export * from "babylonjs/Cameras/gamepadCamera";
  43266. export * from "babylonjs/Cameras/Stereoscopic/index";
  43267. export * from "babylonjs/Cameras/universalCamera";
  43268. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  43269. export * from "babylonjs/Cameras/VR/index";
  43270. export * from "babylonjs/Cameras/XR/index";
  43271. export * from "babylonjs/Cameras/RigModes/index";
  43272. }
  43273. declare module "babylonjs/Collisions/index" {
  43274. export * from "babylonjs/Collisions/collider";
  43275. export * from "babylonjs/Collisions/collisionCoordinator";
  43276. export * from "babylonjs/Collisions/pickingInfo";
  43277. export * from "babylonjs/Collisions/intersectionInfo";
  43278. export * from "babylonjs/Collisions/meshCollisionData";
  43279. }
  43280. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  43281. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  43282. import { Vector3 } from "babylonjs/Maths/math.vector";
  43283. import { Ray } from "babylonjs/Culling/ray";
  43284. import { Plane } from "babylonjs/Maths/math.plane";
  43285. /**
  43286. * Contains an array of blocks representing the octree
  43287. */
  43288. export interface IOctreeContainer<T> {
  43289. /**
  43290. * Blocks within the octree
  43291. */
  43292. blocks: Array<OctreeBlock<T>>;
  43293. }
  43294. /**
  43295. * Class used to store a cell in an octree
  43296. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43297. */
  43298. export class OctreeBlock<T> {
  43299. /**
  43300. * Gets the content of the current block
  43301. */
  43302. entries: T[];
  43303. /**
  43304. * Gets the list of block children
  43305. */
  43306. blocks: Array<OctreeBlock<T>>;
  43307. private _depth;
  43308. private _maxDepth;
  43309. private _capacity;
  43310. private _minPoint;
  43311. private _maxPoint;
  43312. private _boundingVectors;
  43313. private _creationFunc;
  43314. /**
  43315. * Creates a new block
  43316. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43317. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43318. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43319. * @param depth defines the current depth of this block in the octree
  43320. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43321. * @param creationFunc defines a callback to call when an element is added to the block
  43322. */
  43323. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43324. /**
  43325. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43326. */
  43327. readonly capacity: number;
  43328. /**
  43329. * Gets the minimum vector (in world space) of the block's bounding box
  43330. */
  43331. readonly minPoint: Vector3;
  43332. /**
  43333. * Gets the maximum vector (in world space) of the block's bounding box
  43334. */
  43335. readonly maxPoint: Vector3;
  43336. /**
  43337. * Add a new element to this block
  43338. * @param entry defines the element to add
  43339. */
  43340. addEntry(entry: T): void;
  43341. /**
  43342. * Remove an element from this block
  43343. * @param entry defines the element to remove
  43344. */
  43345. removeEntry(entry: T): void;
  43346. /**
  43347. * Add an array of elements to this block
  43348. * @param entries defines the array of elements to add
  43349. */
  43350. addEntries(entries: T[]): void;
  43351. /**
  43352. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43353. * @param frustumPlanes defines the frustum planes to test
  43354. * @param selection defines the array to store current content if selection is positive
  43355. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43356. */
  43357. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43358. /**
  43359. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43360. * @param sphereCenter defines the bounding sphere center
  43361. * @param sphereRadius defines the bounding sphere radius
  43362. * @param selection defines the array to store current content if selection is positive
  43363. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43364. */
  43365. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43366. /**
  43367. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43368. * @param ray defines the ray to test with
  43369. * @param selection defines the array to store current content if selection is positive
  43370. */
  43371. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43372. /**
  43373. * Subdivide the content into child blocks (this block will then be empty)
  43374. */
  43375. createInnerBlocks(): void;
  43376. /**
  43377. * @hidden
  43378. */
  43379. 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;
  43380. }
  43381. }
  43382. declare module "babylonjs/Culling/Octrees/octree" {
  43383. import { SmartArray } from "babylonjs/Misc/smartArray";
  43384. import { Vector3 } from "babylonjs/Maths/math.vector";
  43385. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43386. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43387. import { Ray } from "babylonjs/Culling/ray";
  43388. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  43389. import { Plane } from "babylonjs/Maths/math.plane";
  43390. /**
  43391. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43392. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43393. */
  43394. export class Octree<T> {
  43395. /** 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.) */
  43396. maxDepth: number;
  43397. /**
  43398. * Blocks within the octree containing objects
  43399. */
  43400. blocks: Array<OctreeBlock<T>>;
  43401. /**
  43402. * Content stored in the octree
  43403. */
  43404. dynamicContent: T[];
  43405. private _maxBlockCapacity;
  43406. private _selectionContent;
  43407. private _creationFunc;
  43408. /**
  43409. * Creates a octree
  43410. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43411. * @param creationFunc function to be used to instatiate the octree
  43412. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43413. * @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.)
  43414. */
  43415. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43416. /** 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.) */
  43417. maxDepth?: number);
  43418. /**
  43419. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43420. * @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);
  43421. * @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);
  43422. * @param entries meshes to be added to the octree blocks
  43423. */
  43424. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43425. /**
  43426. * Adds a mesh to the octree
  43427. * @param entry Mesh to add to the octree
  43428. */
  43429. addMesh(entry: T): void;
  43430. /**
  43431. * Remove an element from the octree
  43432. * @param entry defines the element to remove
  43433. */
  43434. removeMesh(entry: T): void;
  43435. /**
  43436. * Selects an array of meshes within the frustum
  43437. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43438. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43439. * @returns array of meshes within the frustum
  43440. */
  43441. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43442. /**
  43443. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43444. * @param sphereCenter defines the bounding sphere center
  43445. * @param sphereRadius defines the bounding sphere radius
  43446. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43447. * @returns an array of objects that intersect the sphere
  43448. */
  43449. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43450. /**
  43451. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43452. * @param ray defines the ray to test with
  43453. * @returns array of intersected objects
  43454. */
  43455. intersectsRay(ray: Ray): SmartArray<T>;
  43456. /**
  43457. * Adds a mesh into the octree block if it intersects the block
  43458. */
  43459. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43460. /**
  43461. * Adds a submesh into the octree block if it intersects the block
  43462. */
  43463. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43464. }
  43465. }
  43466. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  43467. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  43468. import { Scene } from "babylonjs/scene";
  43469. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43470. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43471. import { Ray } from "babylonjs/Culling/ray";
  43472. import { Octree } from "babylonjs/Culling/Octrees/octree";
  43473. import { Collider } from "babylonjs/Collisions/collider";
  43474. module "babylonjs/scene" {
  43475. interface Scene {
  43476. /**
  43477. * @hidden
  43478. * Backing Filed
  43479. */
  43480. _selectionOctree: Octree<AbstractMesh>;
  43481. /**
  43482. * Gets the octree used to boost mesh selection (picking)
  43483. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43484. */
  43485. selectionOctree: Octree<AbstractMesh>;
  43486. /**
  43487. * Creates or updates the octree used to boost selection (picking)
  43488. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43489. * @param maxCapacity defines the maximum capacity per leaf
  43490. * @param maxDepth defines the maximum depth of the octree
  43491. * @returns an octree of AbstractMesh
  43492. */
  43493. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  43494. }
  43495. }
  43496. module "babylonjs/Meshes/abstractMesh" {
  43497. interface AbstractMesh {
  43498. /**
  43499. * @hidden
  43500. * Backing Field
  43501. */
  43502. _submeshesOctree: Octree<SubMesh>;
  43503. /**
  43504. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  43505. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  43506. * @param maxCapacity defines the maximum size of each block (64 by default)
  43507. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  43508. * @returns the new octree
  43509. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  43510. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43511. */
  43512. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  43513. }
  43514. }
  43515. /**
  43516. * Defines the octree scene component responsible to manage any octrees
  43517. * in a given scene.
  43518. */
  43519. export class OctreeSceneComponent {
  43520. /**
  43521. * The component name help to identify the component in the list of scene components.
  43522. */
  43523. readonly name: string;
  43524. /**
  43525. * The scene the component belongs to.
  43526. */
  43527. scene: Scene;
  43528. /**
  43529. * Indicates if the meshes have been checked to make sure they are isEnabled()
  43530. */
  43531. readonly checksIsEnabled: boolean;
  43532. /**
  43533. * Creates a new instance of the component for the given scene
  43534. * @param scene Defines the scene to register the component in
  43535. */
  43536. constructor(scene: Scene);
  43537. /**
  43538. * Registers the component in a given scene
  43539. */
  43540. register(): void;
  43541. /**
  43542. * Return the list of active meshes
  43543. * @returns the list of active meshes
  43544. */
  43545. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43546. /**
  43547. * Return the list of active sub meshes
  43548. * @param mesh The mesh to get the candidates sub meshes from
  43549. * @returns the list of active sub meshes
  43550. */
  43551. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43552. private _tempRay;
  43553. /**
  43554. * Return the list of sub meshes intersecting with a given local ray
  43555. * @param mesh defines the mesh to find the submesh for
  43556. * @param localRay defines the ray in local space
  43557. * @returns the list of intersecting sub meshes
  43558. */
  43559. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  43560. /**
  43561. * Return the list of sub meshes colliding with a collider
  43562. * @param mesh defines the mesh to find the submesh for
  43563. * @param collider defines the collider to evaluate the collision against
  43564. * @returns the list of colliding sub meshes
  43565. */
  43566. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  43567. /**
  43568. * Rebuilds the elements related to this component in case of
  43569. * context lost for instance.
  43570. */
  43571. rebuild(): void;
  43572. /**
  43573. * Disposes the component and the associated ressources.
  43574. */
  43575. dispose(): void;
  43576. }
  43577. }
  43578. declare module "babylonjs/Culling/Octrees/index" {
  43579. export * from "babylonjs/Culling/Octrees/octree";
  43580. export * from "babylonjs/Culling/Octrees/octreeBlock";
  43581. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  43582. }
  43583. declare module "babylonjs/Culling/index" {
  43584. export * from "babylonjs/Culling/boundingBox";
  43585. export * from "babylonjs/Culling/boundingInfo";
  43586. export * from "babylonjs/Culling/boundingSphere";
  43587. export * from "babylonjs/Culling/Octrees/index";
  43588. export * from "babylonjs/Culling/ray";
  43589. }
  43590. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  43591. import { IDisposable, Scene } from "babylonjs/scene";
  43592. import { Nullable } from "babylonjs/types";
  43593. import { Observable } from "babylonjs/Misc/observable";
  43594. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43595. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  43596. import { Camera } from "babylonjs/Cameras/camera";
  43597. /**
  43598. * Renders a layer on top of an existing scene
  43599. */
  43600. export class UtilityLayerRenderer implements IDisposable {
  43601. /** the original scene that will be rendered on top of */
  43602. originalScene: Scene;
  43603. private _pointerCaptures;
  43604. private _lastPointerEvents;
  43605. private static _DefaultUtilityLayer;
  43606. private static _DefaultKeepDepthUtilityLayer;
  43607. private _sharedGizmoLight;
  43608. private _renderCamera;
  43609. /**
  43610. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  43611. * @returns the camera that is used when rendering the utility layer
  43612. */
  43613. getRenderCamera(): Nullable<Camera>;
  43614. /**
  43615. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  43616. * @param cam the camera that should be used when rendering the utility layer
  43617. */
  43618. setRenderCamera(cam: Nullable<Camera>): void;
  43619. /**
  43620. * @hidden
  43621. * Light which used by gizmos to get light shading
  43622. */
  43623. _getSharedGizmoLight(): HemisphericLight;
  43624. /**
  43625. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  43626. */
  43627. pickUtilitySceneFirst: boolean;
  43628. /**
  43629. * 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)
  43630. */
  43631. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  43632. /**
  43633. * 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)
  43634. */
  43635. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  43636. /**
  43637. * The scene that is rendered on top of the original scene
  43638. */
  43639. utilityLayerScene: Scene;
  43640. /**
  43641. * If the utility layer should automatically be rendered on top of existing scene
  43642. */
  43643. shouldRender: boolean;
  43644. /**
  43645. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  43646. */
  43647. onlyCheckPointerDownEvents: boolean;
  43648. /**
  43649. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  43650. */
  43651. processAllEvents: boolean;
  43652. /**
  43653. * Observable raised when the pointer move from the utility layer scene to the main scene
  43654. */
  43655. onPointerOutObservable: Observable<number>;
  43656. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  43657. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  43658. private _afterRenderObserver;
  43659. private _sceneDisposeObserver;
  43660. private _originalPointerObserver;
  43661. /**
  43662. * Instantiates a UtilityLayerRenderer
  43663. * @param originalScene the original scene that will be rendered on top of
  43664. * @param handleEvents boolean indicating if the utility layer should handle events
  43665. */
  43666. constructor(
  43667. /** the original scene that will be rendered on top of */
  43668. originalScene: Scene, handleEvents?: boolean);
  43669. private _notifyObservers;
  43670. /**
  43671. * Renders the utility layers scene on top of the original scene
  43672. */
  43673. render(): void;
  43674. /**
  43675. * Disposes of the renderer
  43676. */
  43677. dispose(): void;
  43678. private _updateCamera;
  43679. }
  43680. }
  43681. declare module "babylonjs/Gizmos/gizmo" {
  43682. import { Nullable } from "babylonjs/types";
  43683. import { IDisposable } from "babylonjs/scene";
  43684. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43685. import { Mesh } from "babylonjs/Meshes/mesh";
  43686. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43687. /**
  43688. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  43689. */
  43690. export class Gizmo implements IDisposable {
  43691. /** The utility layer the gizmo will be added to */
  43692. gizmoLayer: UtilityLayerRenderer;
  43693. /**
  43694. * The root mesh of the gizmo
  43695. */
  43696. _rootMesh: Mesh;
  43697. private _attachedMesh;
  43698. /**
  43699. * Ratio for the scale of the gizmo (Default: 1)
  43700. */
  43701. scaleRatio: number;
  43702. /**
  43703. * If a custom mesh has been set (Default: false)
  43704. */
  43705. protected _customMeshSet: boolean;
  43706. /**
  43707. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  43708. * * When set, interactions will be enabled
  43709. */
  43710. attachedMesh: Nullable<AbstractMesh>;
  43711. /**
  43712. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43713. * @param mesh The mesh to replace the default mesh of the gizmo
  43714. */
  43715. setCustomMesh(mesh: Mesh): void;
  43716. /**
  43717. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  43718. */
  43719. updateGizmoRotationToMatchAttachedMesh: boolean;
  43720. /**
  43721. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  43722. */
  43723. updateGizmoPositionToMatchAttachedMesh: boolean;
  43724. /**
  43725. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  43726. */
  43727. updateScale: boolean;
  43728. protected _interactionsEnabled: boolean;
  43729. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43730. private _beforeRenderObserver;
  43731. private _tempVector;
  43732. /**
  43733. * Creates a gizmo
  43734. * @param gizmoLayer The utility layer the gizmo will be added to
  43735. */
  43736. constructor(
  43737. /** The utility layer the gizmo will be added to */
  43738. gizmoLayer?: UtilityLayerRenderer);
  43739. /**
  43740. * Updates the gizmo to match the attached mesh's position/rotation
  43741. */
  43742. protected _update(): void;
  43743. /**
  43744. * Disposes of the gizmo
  43745. */
  43746. dispose(): void;
  43747. }
  43748. }
  43749. declare module "babylonjs/Gizmos/planeDragGizmo" {
  43750. import { Observable } from "babylonjs/Misc/observable";
  43751. import { Nullable } from "babylonjs/types";
  43752. import { Vector3 } from "babylonjs/Maths/math.vector";
  43753. import { Color3 } from "babylonjs/Maths/math.color";
  43754. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43755. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43756. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43757. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43758. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43759. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  43760. import { Scene } from "babylonjs/scene";
  43761. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43762. /**
  43763. * Single plane drag gizmo
  43764. */
  43765. export class PlaneDragGizmo extends Gizmo {
  43766. /**
  43767. * Drag behavior responsible for the gizmos dragging interactions
  43768. */
  43769. dragBehavior: PointerDragBehavior;
  43770. private _pointerObserver;
  43771. /**
  43772. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43773. */
  43774. snapDistance: number;
  43775. /**
  43776. * Event that fires each time the gizmo snaps to a new location.
  43777. * * snapDistance is the the change in distance
  43778. */
  43779. onSnapObservable: Observable<{
  43780. snapDistance: number;
  43781. }>;
  43782. private _plane;
  43783. private _coloredMaterial;
  43784. private _hoverMaterial;
  43785. private _isEnabled;
  43786. private _parent;
  43787. /** @hidden */
  43788. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  43789. /** @hidden */
  43790. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43791. /**
  43792. * Creates a PlaneDragGizmo
  43793. * @param gizmoLayer The utility layer the gizmo will be added to
  43794. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  43795. * @param color The color of the gizmo
  43796. */
  43797. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  43798. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43799. /**
  43800. * If the gizmo is enabled
  43801. */
  43802. isEnabled: boolean;
  43803. /**
  43804. * Disposes of the gizmo
  43805. */
  43806. dispose(): void;
  43807. }
  43808. }
  43809. declare module "babylonjs/Gizmos/positionGizmo" {
  43810. import { Observable } from "babylonjs/Misc/observable";
  43811. import { Nullable } from "babylonjs/types";
  43812. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43813. import { Mesh } from "babylonjs/Meshes/mesh";
  43814. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43815. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43816. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  43817. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43818. /**
  43819. * Gizmo that enables dragging a mesh along 3 axis
  43820. */
  43821. export class PositionGizmo extends Gizmo {
  43822. /**
  43823. * Internal gizmo used for interactions on the x axis
  43824. */
  43825. xGizmo: AxisDragGizmo;
  43826. /**
  43827. * Internal gizmo used for interactions on the y axis
  43828. */
  43829. yGizmo: AxisDragGizmo;
  43830. /**
  43831. * Internal gizmo used for interactions on the z axis
  43832. */
  43833. zGizmo: AxisDragGizmo;
  43834. /**
  43835. * Internal gizmo used for interactions on the yz plane
  43836. */
  43837. xPlaneGizmo: PlaneDragGizmo;
  43838. /**
  43839. * Internal gizmo used for interactions on the xz plane
  43840. */
  43841. yPlaneGizmo: PlaneDragGizmo;
  43842. /**
  43843. * Internal gizmo used for interactions on the xy plane
  43844. */
  43845. zPlaneGizmo: PlaneDragGizmo;
  43846. /**
  43847. * private variables
  43848. */
  43849. private _meshAttached;
  43850. private _updateGizmoRotationToMatchAttachedMesh;
  43851. private _snapDistance;
  43852. private _scaleRatio;
  43853. /** Fires an event when any of it's sub gizmos are dragged */
  43854. onDragStartObservable: Observable<unknown>;
  43855. /** Fires an event when any of it's sub gizmos are released from dragging */
  43856. onDragEndObservable: Observable<unknown>;
  43857. /**
  43858. * If set to true, planar drag is enabled
  43859. */
  43860. private _planarGizmoEnabled;
  43861. attachedMesh: Nullable<AbstractMesh>;
  43862. /**
  43863. * Creates a PositionGizmo
  43864. * @param gizmoLayer The utility layer the gizmo will be added to
  43865. */
  43866. constructor(gizmoLayer?: UtilityLayerRenderer);
  43867. /**
  43868. * If the planar drag gizmo is enabled
  43869. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  43870. */
  43871. planarGizmoEnabled: boolean;
  43872. updateGizmoRotationToMatchAttachedMesh: boolean;
  43873. /**
  43874. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43875. */
  43876. snapDistance: number;
  43877. /**
  43878. * Ratio for the scale of the gizmo (Default: 1)
  43879. */
  43880. scaleRatio: number;
  43881. /**
  43882. * Disposes of the gizmo
  43883. */
  43884. dispose(): void;
  43885. /**
  43886. * CustomMeshes are not supported by this gizmo
  43887. * @param mesh The mesh to replace the default mesh of the gizmo
  43888. */
  43889. setCustomMesh(mesh: Mesh): void;
  43890. }
  43891. }
  43892. declare module "babylonjs/Gizmos/axisDragGizmo" {
  43893. import { Observable } from "babylonjs/Misc/observable";
  43894. import { Nullable } from "babylonjs/types";
  43895. import { Vector3 } from "babylonjs/Maths/math.vector";
  43896. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43897. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43898. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43899. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43900. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43901. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  43902. import { Scene } from "babylonjs/scene";
  43903. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43904. import { Color3 } from "babylonjs/Maths/math.color";
  43905. /**
  43906. * Single axis drag gizmo
  43907. */
  43908. export class AxisDragGizmo extends Gizmo {
  43909. /**
  43910. * Drag behavior responsible for the gizmos dragging interactions
  43911. */
  43912. dragBehavior: PointerDragBehavior;
  43913. private _pointerObserver;
  43914. /**
  43915. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43916. */
  43917. snapDistance: number;
  43918. /**
  43919. * Event that fires each time the gizmo snaps to a new location.
  43920. * * snapDistance is the the change in distance
  43921. */
  43922. onSnapObservable: Observable<{
  43923. snapDistance: number;
  43924. }>;
  43925. private _isEnabled;
  43926. private _parent;
  43927. private _arrow;
  43928. private _coloredMaterial;
  43929. private _hoverMaterial;
  43930. /** @hidden */
  43931. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  43932. /** @hidden */
  43933. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43934. /**
  43935. * Creates an AxisDragGizmo
  43936. * @param gizmoLayer The utility layer the gizmo will be added to
  43937. * @param dragAxis The axis which the gizmo will be able to drag on
  43938. * @param color The color of the gizmo
  43939. */
  43940. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  43941. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43942. /**
  43943. * If the gizmo is enabled
  43944. */
  43945. isEnabled: boolean;
  43946. /**
  43947. * Disposes of the gizmo
  43948. */
  43949. dispose(): void;
  43950. }
  43951. }
  43952. declare module "babylonjs/Debug/axesViewer" {
  43953. import { Vector3 } from "babylonjs/Maths/math.vector";
  43954. import { Nullable } from "babylonjs/types";
  43955. import { Scene } from "babylonjs/scene";
  43956. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43957. /**
  43958. * The Axes viewer will show 3 axes in a specific point in space
  43959. */
  43960. export class AxesViewer {
  43961. private _xAxis;
  43962. private _yAxis;
  43963. private _zAxis;
  43964. private _scaleLinesFactor;
  43965. private _instanced;
  43966. /**
  43967. * Gets the hosting scene
  43968. */
  43969. scene: Scene;
  43970. /**
  43971. * Gets or sets a number used to scale line length
  43972. */
  43973. scaleLines: number;
  43974. /** Gets the node hierarchy used to render x-axis */
  43975. readonly xAxis: TransformNode;
  43976. /** Gets the node hierarchy used to render y-axis */
  43977. readonly yAxis: TransformNode;
  43978. /** Gets the node hierarchy used to render z-axis */
  43979. readonly zAxis: TransformNode;
  43980. /**
  43981. * Creates a new AxesViewer
  43982. * @param scene defines the hosting scene
  43983. * @param scaleLines defines a number used to scale line length (1 by default)
  43984. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  43985. * @param xAxis defines the node hierarchy used to render the x-axis
  43986. * @param yAxis defines the node hierarchy used to render the y-axis
  43987. * @param zAxis defines the node hierarchy used to render the z-axis
  43988. */
  43989. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  43990. /**
  43991. * Force the viewer to update
  43992. * @param position defines the position of the viewer
  43993. * @param xaxis defines the x axis of the viewer
  43994. * @param yaxis defines the y axis of the viewer
  43995. * @param zaxis defines the z axis of the viewer
  43996. */
  43997. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  43998. /**
  43999. * Creates an instance of this axes viewer.
  44000. * @returns a new axes viewer with instanced meshes
  44001. */
  44002. createInstance(): AxesViewer;
  44003. /** Releases resources */
  44004. dispose(): void;
  44005. private static _SetRenderingGroupId;
  44006. }
  44007. }
  44008. declare module "babylonjs/Debug/boneAxesViewer" {
  44009. import { Nullable } from "babylonjs/types";
  44010. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44011. import { Vector3 } from "babylonjs/Maths/math.vector";
  44012. import { Mesh } from "babylonjs/Meshes/mesh";
  44013. import { Bone } from "babylonjs/Bones/bone";
  44014. import { Scene } from "babylonjs/scene";
  44015. /**
  44016. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44017. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44018. */
  44019. export class BoneAxesViewer extends AxesViewer {
  44020. /**
  44021. * Gets or sets the target mesh where to display the axes viewer
  44022. */
  44023. mesh: Nullable<Mesh>;
  44024. /**
  44025. * Gets or sets the target bone where to display the axes viewer
  44026. */
  44027. bone: Nullable<Bone>;
  44028. /** Gets current position */
  44029. pos: Vector3;
  44030. /** Gets direction of X axis */
  44031. xaxis: Vector3;
  44032. /** Gets direction of Y axis */
  44033. yaxis: Vector3;
  44034. /** Gets direction of Z axis */
  44035. zaxis: Vector3;
  44036. /**
  44037. * Creates a new BoneAxesViewer
  44038. * @param scene defines the hosting scene
  44039. * @param bone defines the target bone
  44040. * @param mesh defines the target mesh
  44041. * @param scaleLines defines a scaling factor for line length (1 by default)
  44042. */
  44043. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44044. /**
  44045. * Force the viewer to update
  44046. */
  44047. update(): void;
  44048. /** Releases resources */
  44049. dispose(): void;
  44050. }
  44051. }
  44052. declare module "babylonjs/Debug/debugLayer" {
  44053. import { Scene } from "babylonjs/scene";
  44054. /**
  44055. * Interface used to define scene explorer extensibility option
  44056. */
  44057. export interface IExplorerExtensibilityOption {
  44058. /**
  44059. * Define the option label
  44060. */
  44061. label: string;
  44062. /**
  44063. * Defines the action to execute on click
  44064. */
  44065. action: (entity: any) => void;
  44066. }
  44067. /**
  44068. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44069. */
  44070. export interface IExplorerExtensibilityGroup {
  44071. /**
  44072. * Defines a predicate to test if a given type mut be extended
  44073. */
  44074. predicate: (entity: any) => boolean;
  44075. /**
  44076. * Gets the list of options added to a type
  44077. */
  44078. entries: IExplorerExtensibilityOption[];
  44079. }
  44080. /**
  44081. * Interface used to define the options to use to create the Inspector
  44082. */
  44083. export interface IInspectorOptions {
  44084. /**
  44085. * Display in overlay mode (default: false)
  44086. */
  44087. overlay?: boolean;
  44088. /**
  44089. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44090. */
  44091. globalRoot?: HTMLElement;
  44092. /**
  44093. * Display the Scene explorer
  44094. */
  44095. showExplorer?: boolean;
  44096. /**
  44097. * Display the property inspector
  44098. */
  44099. showInspector?: boolean;
  44100. /**
  44101. * Display in embed mode (both panes on the right)
  44102. */
  44103. embedMode?: boolean;
  44104. /**
  44105. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44106. */
  44107. handleResize?: boolean;
  44108. /**
  44109. * Allow the panes to popup (default: true)
  44110. */
  44111. enablePopup?: boolean;
  44112. /**
  44113. * Allow the panes to be closed by users (default: true)
  44114. */
  44115. enableClose?: boolean;
  44116. /**
  44117. * Optional list of extensibility entries
  44118. */
  44119. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44120. /**
  44121. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44122. */
  44123. inspectorURL?: string;
  44124. }
  44125. module "babylonjs/scene" {
  44126. interface Scene {
  44127. /**
  44128. * @hidden
  44129. * Backing field
  44130. */
  44131. _debugLayer: DebugLayer;
  44132. /**
  44133. * Gets the debug layer (aka Inspector) associated with the scene
  44134. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44135. */
  44136. debugLayer: DebugLayer;
  44137. }
  44138. }
  44139. /**
  44140. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44141. * what is happening in your scene
  44142. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44143. */
  44144. export class DebugLayer {
  44145. /**
  44146. * Define the url to get the inspector script from.
  44147. * By default it uses the babylonjs CDN.
  44148. * @ignoreNaming
  44149. */
  44150. static InspectorURL: string;
  44151. private _scene;
  44152. private BJSINSPECTOR;
  44153. private _onPropertyChangedObservable?;
  44154. /**
  44155. * Observable triggered when a property is changed through the inspector.
  44156. */
  44157. readonly onPropertyChangedObservable: any;
  44158. /**
  44159. * Instantiates a new debug layer.
  44160. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44161. * what is happening in your scene
  44162. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44163. * @param scene Defines the scene to inspect
  44164. */
  44165. constructor(scene: Scene);
  44166. /** Creates the inspector window. */
  44167. private _createInspector;
  44168. /**
  44169. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44170. * @param entity defines the entity to select
  44171. * @param lineContainerTitle defines the specific block to highlight
  44172. */
  44173. select(entity: any, lineContainerTitle?: string): void;
  44174. /** Get the inspector from bundle or global */
  44175. private _getGlobalInspector;
  44176. /**
  44177. * Get if the inspector is visible or not.
  44178. * @returns true if visible otherwise, false
  44179. */
  44180. isVisible(): boolean;
  44181. /**
  44182. * Hide the inspector and close its window.
  44183. */
  44184. hide(): void;
  44185. /**
  44186. * Launch the debugLayer.
  44187. * @param config Define the configuration of the inspector
  44188. * @return a promise fulfilled when the debug layer is visible
  44189. */
  44190. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44191. }
  44192. }
  44193. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44194. import { Nullable } from "babylonjs/types";
  44195. import { Scene } from "babylonjs/scene";
  44196. import { Vector4 } from "babylonjs/Maths/math.vector";
  44197. import { Color4 } from "babylonjs/Maths/math.color";
  44198. import { Mesh } from "babylonjs/Meshes/mesh";
  44199. /**
  44200. * Class containing static functions to help procedurally build meshes
  44201. */
  44202. export class BoxBuilder {
  44203. /**
  44204. * Creates a box mesh
  44205. * * The parameter `size` sets the size (float) of each box side (default 1)
  44206. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44207. * * 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)
  44208. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44209. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44210. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44211. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44212. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44213. * @param name defines the name of the mesh
  44214. * @param options defines the options used to create the mesh
  44215. * @param scene defines the hosting scene
  44216. * @returns the box mesh
  44217. */
  44218. static CreateBox(name: string, options: {
  44219. size?: number;
  44220. width?: number;
  44221. height?: number;
  44222. depth?: number;
  44223. faceUV?: Vector4[];
  44224. faceColors?: Color4[];
  44225. sideOrientation?: number;
  44226. frontUVs?: Vector4;
  44227. backUVs?: Vector4;
  44228. wrap?: boolean;
  44229. topBaseAt?: number;
  44230. bottomBaseAt?: number;
  44231. updatable?: boolean;
  44232. }, scene?: Nullable<Scene>): Mesh;
  44233. }
  44234. }
  44235. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44236. import { Vector4 } from "babylonjs/Maths/math.vector";
  44237. import { Mesh } from "babylonjs/Meshes/mesh";
  44238. /**
  44239. * Class containing static functions to help procedurally build meshes
  44240. */
  44241. export class SphereBuilder {
  44242. /**
  44243. * Creates a sphere mesh
  44244. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44245. * * 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`)
  44246. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44247. * * 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
  44248. * * 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)
  44249. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44250. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44252. * @param name defines the name of the mesh
  44253. * @param options defines the options used to create the mesh
  44254. * @param scene defines the hosting scene
  44255. * @returns the sphere mesh
  44256. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44257. */
  44258. static CreateSphere(name: string, options: {
  44259. segments?: number;
  44260. diameter?: number;
  44261. diameterX?: number;
  44262. diameterY?: number;
  44263. diameterZ?: number;
  44264. arc?: number;
  44265. slice?: number;
  44266. sideOrientation?: number;
  44267. frontUVs?: Vector4;
  44268. backUVs?: Vector4;
  44269. updatable?: boolean;
  44270. }, scene: any): Mesh;
  44271. }
  44272. }
  44273. declare module "babylonjs/Debug/physicsViewer" {
  44274. import { Nullable } from "babylonjs/types";
  44275. import { Scene } from "babylonjs/scene";
  44276. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44277. import { Mesh } from "babylonjs/Meshes/mesh";
  44278. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  44279. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  44280. /**
  44281. * Used to show the physics impostor around the specific mesh
  44282. */
  44283. export class PhysicsViewer {
  44284. /** @hidden */
  44285. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44286. /** @hidden */
  44287. protected _meshes: Array<Nullable<AbstractMesh>>;
  44288. /** @hidden */
  44289. protected _scene: Nullable<Scene>;
  44290. /** @hidden */
  44291. protected _numMeshes: number;
  44292. /** @hidden */
  44293. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44294. private _renderFunction;
  44295. private _utilityLayer;
  44296. private _debugBoxMesh;
  44297. private _debugSphereMesh;
  44298. private _debugCylinderMesh;
  44299. private _debugMaterial;
  44300. private _debugMeshMeshes;
  44301. /**
  44302. * Creates a new PhysicsViewer
  44303. * @param scene defines the hosting scene
  44304. */
  44305. constructor(scene: Scene);
  44306. /** @hidden */
  44307. protected _updateDebugMeshes(): void;
  44308. /**
  44309. * Renders a specified physic impostor
  44310. * @param impostor defines the impostor to render
  44311. * @param targetMesh defines the mesh represented by the impostor
  44312. * @returns the new debug mesh used to render the impostor
  44313. */
  44314. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  44315. /**
  44316. * Hides a specified physic impostor
  44317. * @param impostor defines the impostor to hide
  44318. */
  44319. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  44320. private _getDebugMaterial;
  44321. private _getDebugBoxMesh;
  44322. private _getDebugSphereMesh;
  44323. private _getDebugCylinderMesh;
  44324. private _getDebugMeshMesh;
  44325. private _getDebugMesh;
  44326. /** Releases all resources */
  44327. dispose(): void;
  44328. }
  44329. }
  44330. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  44331. import { Vector3 } from "babylonjs/Maths/math.vector";
  44332. import { Color4 } from "babylonjs/Maths/math.color";
  44333. import { Nullable } from "babylonjs/types";
  44334. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44335. import { Scene } from "babylonjs/scene";
  44336. /**
  44337. * Class containing static functions to help procedurally build meshes
  44338. */
  44339. export class LinesBuilder {
  44340. /**
  44341. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44342. * * 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
  44343. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44344. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44345. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44346. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44347. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44348. * * 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
  44349. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44351. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44352. * @param name defines the name of the new line system
  44353. * @param options defines the options used to create the line system
  44354. * @param scene defines the hosting scene
  44355. * @returns a new line system mesh
  44356. */
  44357. static CreateLineSystem(name: string, options: {
  44358. lines: Vector3[][];
  44359. updatable?: boolean;
  44360. instance?: Nullable<LinesMesh>;
  44361. colors?: Nullable<Color4[][]>;
  44362. useVertexAlpha?: boolean;
  44363. }, scene: Nullable<Scene>): LinesMesh;
  44364. /**
  44365. * Creates a line mesh
  44366. * 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
  44367. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44368. * * The parameter `points` is an array successive Vector3
  44369. * * 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
  44370. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44371. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44372. * * When updating an instance, remember that only point positions can change, not the number of points
  44373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44374. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44375. * @param name defines the name of the new line system
  44376. * @param options defines the options used to create the line system
  44377. * @param scene defines the hosting scene
  44378. * @returns a new line mesh
  44379. */
  44380. static CreateLines(name: string, options: {
  44381. points: Vector3[];
  44382. updatable?: boolean;
  44383. instance?: Nullable<LinesMesh>;
  44384. colors?: Color4[];
  44385. useVertexAlpha?: boolean;
  44386. }, scene?: Nullable<Scene>): LinesMesh;
  44387. /**
  44388. * Creates a dashed line mesh
  44389. * * 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
  44390. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44391. * * The parameter `points` is an array successive Vector3
  44392. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44393. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44394. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44395. * * 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
  44396. * * When updating an instance, remember that only point positions can change, not the number of points
  44397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44398. * @param name defines the name of the mesh
  44399. * @param options defines the options used to create the mesh
  44400. * @param scene defines the hosting scene
  44401. * @returns the dashed line mesh
  44402. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44403. */
  44404. static CreateDashedLines(name: string, options: {
  44405. points: Vector3[];
  44406. dashSize?: number;
  44407. gapSize?: number;
  44408. dashNb?: number;
  44409. updatable?: boolean;
  44410. instance?: LinesMesh;
  44411. }, scene?: Nullable<Scene>): LinesMesh;
  44412. }
  44413. }
  44414. declare module "babylonjs/Debug/rayHelper" {
  44415. import { Nullable } from "babylonjs/types";
  44416. import { Ray } from "babylonjs/Culling/ray";
  44417. import { Vector3 } from "babylonjs/Maths/math.vector";
  44418. import { Color3 } from "babylonjs/Maths/math.color";
  44419. import { Scene } from "babylonjs/scene";
  44420. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44421. import "babylonjs/Meshes/Builders/linesBuilder";
  44422. /**
  44423. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44424. * in order to better appreciate the issue one might have.
  44425. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44426. */
  44427. export class RayHelper {
  44428. /**
  44429. * Defines the ray we are currently tryin to visualize.
  44430. */
  44431. ray: Nullable<Ray>;
  44432. private _renderPoints;
  44433. private _renderLine;
  44434. private _renderFunction;
  44435. private _scene;
  44436. private _updateToMeshFunction;
  44437. private _attachedToMesh;
  44438. private _meshSpaceDirection;
  44439. private _meshSpaceOrigin;
  44440. /**
  44441. * Helper function to create a colored helper in a scene in one line.
  44442. * @param ray Defines the ray we are currently tryin to visualize
  44443. * @param scene Defines the scene the ray is used in
  44444. * @param color Defines the color we want to see the ray in
  44445. * @returns The newly created ray helper.
  44446. */
  44447. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  44448. /**
  44449. * Instantiate a new ray helper.
  44450. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44451. * in order to better appreciate the issue one might have.
  44452. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44453. * @param ray Defines the ray we are currently tryin to visualize
  44454. */
  44455. constructor(ray: Ray);
  44456. /**
  44457. * Shows the ray we are willing to debug.
  44458. * @param scene Defines the scene the ray needs to be rendered in
  44459. * @param color Defines the color the ray needs to be rendered in
  44460. */
  44461. show(scene: Scene, color?: Color3): void;
  44462. /**
  44463. * Hides the ray we are debugging.
  44464. */
  44465. hide(): void;
  44466. private _render;
  44467. /**
  44468. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  44469. * @param mesh Defines the mesh we want the helper attached to
  44470. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  44471. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  44472. * @param length Defines the length of the ray
  44473. */
  44474. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  44475. /**
  44476. * Detach the ray helper from the mesh it has previously been attached to.
  44477. */
  44478. detachFromMesh(): void;
  44479. private _updateToMesh;
  44480. /**
  44481. * Dispose the helper and release its associated resources.
  44482. */
  44483. dispose(): void;
  44484. }
  44485. }
  44486. declare module "babylonjs/Debug/skeletonViewer" {
  44487. import { Color3 } from "babylonjs/Maths/math.color";
  44488. import { Scene } from "babylonjs/scene";
  44489. import { Nullable } from "babylonjs/types";
  44490. import { Skeleton } from "babylonjs/Bones/skeleton";
  44491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44492. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44493. /**
  44494. * Class used to render a debug view of a given skeleton
  44495. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  44496. */
  44497. export class SkeletonViewer {
  44498. /** defines the skeleton to render */
  44499. skeleton: Skeleton;
  44500. /** defines the mesh attached to the skeleton */
  44501. mesh: AbstractMesh;
  44502. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44503. autoUpdateBonesMatrices: boolean;
  44504. /** defines the rendering group id to use with the viewer */
  44505. renderingGroupId: number;
  44506. /** Gets or sets the color used to render the skeleton */
  44507. color: Color3;
  44508. private _scene;
  44509. private _debugLines;
  44510. private _debugMesh;
  44511. private _isEnabled;
  44512. private _renderFunction;
  44513. private _utilityLayer;
  44514. /**
  44515. * Returns the mesh used to render the bones
  44516. */
  44517. readonly debugMesh: Nullable<LinesMesh>;
  44518. /**
  44519. * Creates a new SkeletonViewer
  44520. * @param skeleton defines the skeleton to render
  44521. * @param mesh defines the mesh attached to the skeleton
  44522. * @param scene defines the hosting scene
  44523. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  44524. * @param renderingGroupId defines the rendering group id to use with the viewer
  44525. */
  44526. constructor(
  44527. /** defines the skeleton to render */
  44528. skeleton: Skeleton,
  44529. /** defines the mesh attached to the skeleton */
  44530. mesh: AbstractMesh, scene: Scene,
  44531. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44532. autoUpdateBonesMatrices?: boolean,
  44533. /** defines the rendering group id to use with the viewer */
  44534. renderingGroupId?: number);
  44535. /** Gets or sets a boolean indicating if the viewer is enabled */
  44536. isEnabled: boolean;
  44537. private _getBonePosition;
  44538. private _getLinesForBonesWithLength;
  44539. private _getLinesForBonesNoLength;
  44540. /** Update the viewer to sync with current skeleton state */
  44541. update(): void;
  44542. /** Release associated resources */
  44543. dispose(): void;
  44544. }
  44545. }
  44546. declare module "babylonjs/Debug/index" {
  44547. export * from "babylonjs/Debug/axesViewer";
  44548. export * from "babylonjs/Debug/boneAxesViewer";
  44549. export * from "babylonjs/Debug/debugLayer";
  44550. export * from "babylonjs/Debug/physicsViewer";
  44551. export * from "babylonjs/Debug/rayHelper";
  44552. export * from "babylonjs/Debug/skeletonViewer";
  44553. }
  44554. declare module "babylonjs/Engines/nullEngine" {
  44555. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  44556. import { Scene } from "babylonjs/scene";
  44557. import { Engine } from "babylonjs/Engines/engine";
  44558. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  44559. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  44560. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  44561. import { Effect } from "babylonjs/Materials/effect";
  44562. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  44563. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  44564. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  44565. /**
  44566. * Options to create the null engine
  44567. */
  44568. export class NullEngineOptions {
  44569. /**
  44570. * Render width (Default: 512)
  44571. */
  44572. renderWidth: number;
  44573. /**
  44574. * Render height (Default: 256)
  44575. */
  44576. renderHeight: number;
  44577. /**
  44578. * Texture size (Default: 512)
  44579. */
  44580. textureSize: number;
  44581. /**
  44582. * If delta time between frames should be constant
  44583. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44584. */
  44585. deterministicLockstep: boolean;
  44586. /**
  44587. * Maximum about of steps between frames (Default: 4)
  44588. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44589. */
  44590. lockstepMaxSteps: number;
  44591. }
  44592. /**
  44593. * The null engine class provides support for headless version of babylon.js.
  44594. * This can be used in server side scenario or for testing purposes
  44595. */
  44596. export class NullEngine extends Engine {
  44597. private _options;
  44598. /**
  44599. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44600. */
  44601. isDeterministicLockStep(): boolean;
  44602. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  44603. getLockstepMaxSteps(): number;
  44604. /**
  44605. * Sets hardware scaling, used to save performance if needed
  44606. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  44607. */
  44608. getHardwareScalingLevel(): number;
  44609. constructor(options?: NullEngineOptions);
  44610. createVertexBuffer(vertices: FloatArray): DataBuffer;
  44611. createIndexBuffer(indices: IndicesArray): DataBuffer;
  44612. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44613. getRenderWidth(useScreen?: boolean): number;
  44614. getRenderHeight(useScreen?: boolean): number;
  44615. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  44616. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  44617. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  44618. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44619. bindSamplers(effect: Effect): void;
  44620. enableEffect(effect: Effect): void;
  44621. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44622. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44623. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44624. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44625. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44626. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44627. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44628. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44629. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44630. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44631. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44632. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44633. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44634. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44635. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44636. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44637. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44638. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44639. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44640. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44641. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44642. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44643. bindBuffers(vertexBuffers: {
  44644. [key: string]: VertexBuffer;
  44645. }, indexBuffer: DataBuffer, effect: Effect): void;
  44646. wipeCaches(bruteForce?: boolean): void;
  44647. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  44648. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44649. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44650. /** @hidden */
  44651. _createTexture(): WebGLTexture;
  44652. /** @hidden */
  44653. _releaseTexture(texture: InternalTexture): void;
  44654. 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;
  44655. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44656. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44657. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44658. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44659. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  44660. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  44661. areAllEffectsReady(): boolean;
  44662. /**
  44663. * @hidden
  44664. * Get the current error code of the webGL context
  44665. * @returns the error code
  44666. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  44667. */
  44668. getError(): number;
  44669. /** @hidden */
  44670. _getUnpackAlignement(): number;
  44671. /** @hidden */
  44672. _unpackFlipY(value: boolean): void;
  44673. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  44674. /**
  44675. * Updates a dynamic vertex buffer.
  44676. * @param vertexBuffer the vertex buffer to update
  44677. * @param data the data used to update the vertex buffer
  44678. * @param byteOffset the byte offset of the data (optional)
  44679. * @param byteLength the byte length of the data (optional)
  44680. */
  44681. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  44682. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  44683. /** @hidden */
  44684. _bindTexture(channel: number, texture: InternalTexture): void;
  44685. /** @hidden */
  44686. _releaseBuffer(buffer: DataBuffer): boolean;
  44687. releaseEffects(): void;
  44688. displayLoadingUI(): void;
  44689. hideLoadingUI(): void;
  44690. /** @hidden */
  44691. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44692. /** @hidden */
  44693. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44694. /** @hidden */
  44695. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44696. /** @hidden */
  44697. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44698. }
  44699. }
  44700. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  44701. import { Nullable, int } from "babylonjs/types";
  44702. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  44703. /** @hidden */
  44704. export class _OcclusionDataStorage {
  44705. /** @hidden */
  44706. occlusionInternalRetryCounter: number;
  44707. /** @hidden */
  44708. isOcclusionQueryInProgress: boolean;
  44709. /** @hidden */
  44710. isOccluded: boolean;
  44711. /** @hidden */
  44712. occlusionRetryCount: number;
  44713. /** @hidden */
  44714. occlusionType: number;
  44715. /** @hidden */
  44716. occlusionQueryAlgorithmType: number;
  44717. }
  44718. module "babylonjs/Engines/engine" {
  44719. interface Engine {
  44720. /**
  44721. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  44722. * @return the new query
  44723. */
  44724. createQuery(): WebGLQuery;
  44725. /**
  44726. * Delete and release a webGL query
  44727. * @param query defines the query to delete
  44728. * @return the current engine
  44729. */
  44730. deleteQuery(query: WebGLQuery): Engine;
  44731. /**
  44732. * Check if a given query has resolved and got its value
  44733. * @param query defines the query to check
  44734. * @returns true if the query got its value
  44735. */
  44736. isQueryResultAvailable(query: WebGLQuery): boolean;
  44737. /**
  44738. * Gets the value of a given query
  44739. * @param query defines the query to check
  44740. * @returns the value of the query
  44741. */
  44742. getQueryResult(query: WebGLQuery): number;
  44743. /**
  44744. * Initiates an occlusion query
  44745. * @param algorithmType defines the algorithm to use
  44746. * @param query defines the query to use
  44747. * @returns the current engine
  44748. * @see http://doc.babylonjs.com/features/occlusionquery
  44749. */
  44750. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  44751. /**
  44752. * Ends an occlusion query
  44753. * @see http://doc.babylonjs.com/features/occlusionquery
  44754. * @param algorithmType defines the algorithm to use
  44755. * @returns the current engine
  44756. */
  44757. endOcclusionQuery(algorithmType: number): Engine;
  44758. /**
  44759. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  44760. * Please note that only one query can be issued at a time
  44761. * @returns a time token used to track the time span
  44762. */
  44763. startTimeQuery(): Nullable<_TimeToken>;
  44764. /**
  44765. * Ends a time query
  44766. * @param token defines the token used to measure the time span
  44767. * @returns the time spent (in ns)
  44768. */
  44769. endTimeQuery(token: _TimeToken): int;
  44770. /** @hidden */
  44771. _currentNonTimestampToken: Nullable<_TimeToken>;
  44772. /** @hidden */
  44773. _createTimeQuery(): WebGLQuery;
  44774. /** @hidden */
  44775. _deleteTimeQuery(query: WebGLQuery): void;
  44776. /** @hidden */
  44777. _getGlAlgorithmType(algorithmType: number): number;
  44778. /** @hidden */
  44779. _getTimeQueryResult(query: WebGLQuery): any;
  44780. /** @hidden */
  44781. _getTimeQueryAvailability(query: WebGLQuery): any;
  44782. }
  44783. }
  44784. module "babylonjs/Meshes/abstractMesh" {
  44785. interface AbstractMesh {
  44786. /**
  44787. * Backing filed
  44788. * @hidden
  44789. */
  44790. __occlusionDataStorage: _OcclusionDataStorage;
  44791. /**
  44792. * Access property
  44793. * @hidden
  44794. */
  44795. _occlusionDataStorage: _OcclusionDataStorage;
  44796. /**
  44797. * 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.
  44798. * The default value is -1 which means don't break the query and wait till the result
  44799. * @see http://doc.babylonjs.com/features/occlusionquery
  44800. */
  44801. occlusionRetryCount: number;
  44802. /**
  44803. * 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:
  44804. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  44805. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  44806. * * 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.
  44807. * @see http://doc.babylonjs.com/features/occlusionquery
  44808. */
  44809. occlusionType: number;
  44810. /**
  44811. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  44812. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  44813. * * 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.
  44814. * @see http://doc.babylonjs.com/features/occlusionquery
  44815. */
  44816. occlusionQueryAlgorithmType: number;
  44817. /**
  44818. * 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
  44819. * @see http://doc.babylonjs.com/features/occlusionquery
  44820. */
  44821. isOccluded: boolean;
  44822. /**
  44823. * Flag to check the progress status of the query
  44824. * @see http://doc.babylonjs.com/features/occlusionquery
  44825. */
  44826. isOcclusionQueryInProgress: boolean;
  44827. }
  44828. }
  44829. }
  44830. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  44831. import { Nullable } from "babylonjs/types";
  44832. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  44833. /** @hidden */
  44834. export var _forceTransformFeedbackToBundle: boolean;
  44835. module "babylonjs/Engines/engine" {
  44836. interface Engine {
  44837. /**
  44838. * Creates a webGL transform feedback object
  44839. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  44840. * @returns the webGL transform feedback object
  44841. */
  44842. createTransformFeedback(): WebGLTransformFeedback;
  44843. /**
  44844. * Delete a webGL transform feedback object
  44845. * @param value defines the webGL transform feedback object to delete
  44846. */
  44847. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  44848. /**
  44849. * Bind a webGL transform feedback object to the webgl context
  44850. * @param value defines the webGL transform feedback object to bind
  44851. */
  44852. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  44853. /**
  44854. * Begins a transform feedback operation
  44855. * @param usePoints defines if points or triangles must be used
  44856. */
  44857. beginTransformFeedback(usePoints: boolean): void;
  44858. /**
  44859. * Ends a transform feedback operation
  44860. */
  44861. endTransformFeedback(): void;
  44862. /**
  44863. * Specify the varyings to use with transform feedback
  44864. * @param program defines the associated webGL program
  44865. * @param value defines the list of strings representing the varying names
  44866. */
  44867. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  44868. /**
  44869. * Bind a webGL buffer for a transform feedback operation
  44870. * @param value defines the webGL buffer to bind
  44871. */
  44872. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  44873. }
  44874. }
  44875. }
  44876. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  44877. import { Scene } from "babylonjs/scene";
  44878. import { Engine } from "babylonjs/Engines/engine";
  44879. import { Texture } from "babylonjs/Materials/Textures/texture";
  44880. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44881. import "babylonjs/Engines/Extensions/engine.multiRender";
  44882. /**
  44883. * Creation options of the multi render target texture.
  44884. */
  44885. export interface IMultiRenderTargetOptions {
  44886. /**
  44887. * Define if the texture needs to create mip maps after render.
  44888. */
  44889. generateMipMaps?: boolean;
  44890. /**
  44891. * Define the types of all the draw buffers we want to create
  44892. */
  44893. types?: number[];
  44894. /**
  44895. * Define the sampling modes of all the draw buffers we want to create
  44896. */
  44897. samplingModes?: number[];
  44898. /**
  44899. * Define if a depth buffer is required
  44900. */
  44901. generateDepthBuffer?: boolean;
  44902. /**
  44903. * Define if a stencil buffer is required
  44904. */
  44905. generateStencilBuffer?: boolean;
  44906. /**
  44907. * Define if a depth texture is required instead of a depth buffer
  44908. */
  44909. generateDepthTexture?: boolean;
  44910. /**
  44911. * Define the number of desired draw buffers
  44912. */
  44913. textureCount?: number;
  44914. /**
  44915. * Define if aspect ratio should be adapted to the texture or stay the scene one
  44916. */
  44917. doNotChangeAspectRatio?: boolean;
  44918. /**
  44919. * Define the default type of the buffers we are creating
  44920. */
  44921. defaultType?: number;
  44922. }
  44923. /**
  44924. * A multi render target, like a render target provides the ability to render to a texture.
  44925. * Unlike the render target, it can render to several draw buffers in one draw.
  44926. * This is specially interesting in deferred rendering or for any effects requiring more than
  44927. * just one color from a single pass.
  44928. */
  44929. export class MultiRenderTarget extends RenderTargetTexture {
  44930. private _internalTextures;
  44931. private _textures;
  44932. private _multiRenderTargetOptions;
  44933. /**
  44934. * Get if draw buffers are currently supported by the used hardware and browser.
  44935. */
  44936. readonly isSupported: boolean;
  44937. /**
  44938. * Get the list of textures generated by the multi render target.
  44939. */
  44940. readonly textures: Texture[];
  44941. /**
  44942. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  44943. */
  44944. readonly depthTexture: Texture;
  44945. /**
  44946. * Set the wrapping mode on U of all the textures we are rendering to.
  44947. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44948. */
  44949. wrapU: number;
  44950. /**
  44951. * Set the wrapping mode on V of all the textures we are rendering to.
  44952. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44953. */
  44954. wrapV: number;
  44955. /**
  44956. * Instantiate a new multi render target texture.
  44957. * A multi render target, like a render target provides the ability to render to a texture.
  44958. * Unlike the render target, it can render to several draw buffers in one draw.
  44959. * This is specially interesting in deferred rendering or for any effects requiring more than
  44960. * just one color from a single pass.
  44961. * @param name Define the name of the texture
  44962. * @param size Define the size of the buffers to render to
  44963. * @param count Define the number of target we are rendering into
  44964. * @param scene Define the scene the texture belongs to
  44965. * @param options Define the options used to create the multi render target
  44966. */
  44967. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  44968. /** @hidden */
  44969. _rebuild(): void;
  44970. private _createInternalTextures;
  44971. private _createTextures;
  44972. /**
  44973. * Define the number of samples used if MSAA is enabled.
  44974. */
  44975. samples: number;
  44976. /**
  44977. * Resize all the textures in the multi render target.
  44978. * Be carrefull as it will recreate all the data in the new texture.
  44979. * @param size Define the new size
  44980. */
  44981. resize(size: any): void;
  44982. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  44983. /**
  44984. * Dispose the render targets and their associated resources
  44985. */
  44986. dispose(): void;
  44987. /**
  44988. * Release all the underlying texture used as draw buffers.
  44989. */
  44990. releaseInternalTextures(): void;
  44991. }
  44992. }
  44993. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  44994. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  44995. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  44996. import { Nullable } from "babylonjs/types";
  44997. module "babylonjs/Engines/engine" {
  44998. interface Engine {
  44999. /**
  45000. * Unbind a list of render target textures from the webGL context
  45001. * This is used only when drawBuffer extension or webGL2 are active
  45002. * @param textures defines the render target textures to unbind
  45003. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45004. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45005. */
  45006. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45007. /**
  45008. * Create a multi render target texture
  45009. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45010. * @param size defines the size of the texture
  45011. * @param options defines the creation options
  45012. * @returns the cube texture as an InternalTexture
  45013. */
  45014. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45015. /**
  45016. * Update the sample count for a given multiple render target texture
  45017. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  45018. * @param textures defines the textures to update
  45019. * @param samples defines the sample count to set
  45020. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45021. */
  45022. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45023. }
  45024. }
  45025. }
  45026. declare module "babylonjs/Engines/Extensions/index" {
  45027. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  45028. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  45029. export * from "babylonjs/Engines/Extensions/engine.multiview";
  45030. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  45031. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  45032. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  45033. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  45034. export * from "babylonjs/Engines/Extensions/engine.webVR";
  45035. }
  45036. declare module "babylonjs/Engines/index" {
  45037. export * from "babylonjs/Engines/constants";
  45038. export * from "babylonjs/Engines/engine";
  45039. export * from "babylonjs/Engines/engineStore";
  45040. export * from "babylonjs/Engines/nullEngine";
  45041. export * from "babylonjs/Engines/Extensions/index";
  45042. export * from "babylonjs/Engines/IPipelineContext";
  45043. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  45044. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  45045. }
  45046. declare module "babylonjs/Events/clipboardEvents" {
  45047. /**
  45048. * Gather the list of clipboard event types as constants.
  45049. */
  45050. export class ClipboardEventTypes {
  45051. /**
  45052. * The clipboard event is fired when a copy command is active (pressed).
  45053. */
  45054. static readonly COPY: number;
  45055. /**
  45056. * The clipboard event is fired when a cut command is active (pressed).
  45057. */
  45058. static readonly CUT: number;
  45059. /**
  45060. * The clipboard event is fired when a paste command is active (pressed).
  45061. */
  45062. static readonly PASTE: number;
  45063. }
  45064. /**
  45065. * This class is used to store clipboard related info for the onClipboardObservable event.
  45066. */
  45067. export class ClipboardInfo {
  45068. /**
  45069. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45070. */
  45071. type: number;
  45072. /**
  45073. * Defines the related dom event
  45074. */
  45075. event: ClipboardEvent;
  45076. /**
  45077. *Creates an instance of ClipboardInfo.
  45078. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  45079. * @param event Defines the related dom event
  45080. */
  45081. constructor(
  45082. /**
  45083. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45084. */
  45085. type: number,
  45086. /**
  45087. * Defines the related dom event
  45088. */
  45089. event: ClipboardEvent);
  45090. /**
  45091. * Get the clipboard event's type from the keycode.
  45092. * @param keyCode Defines the keyCode for the current keyboard event.
  45093. * @return {number}
  45094. */
  45095. static GetTypeFromCharacter(keyCode: number): number;
  45096. }
  45097. }
  45098. declare module "babylonjs/Events/index" {
  45099. export * from "babylonjs/Events/keyboardEvents";
  45100. export * from "babylonjs/Events/pointerEvents";
  45101. export * from "babylonjs/Events/clipboardEvents";
  45102. }
  45103. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  45104. import { Scene } from "babylonjs/scene";
  45105. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45106. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  45107. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45108. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45109. /**
  45110. * Google Daydream controller
  45111. */
  45112. export class DaydreamController extends WebVRController {
  45113. /**
  45114. * Base Url for the controller model.
  45115. */
  45116. static MODEL_BASE_URL: string;
  45117. /**
  45118. * File name for the controller model.
  45119. */
  45120. static MODEL_FILENAME: string;
  45121. /**
  45122. * Gamepad Id prefix used to identify Daydream Controller.
  45123. */
  45124. static readonly GAMEPAD_ID_PREFIX: string;
  45125. /**
  45126. * Creates a new DaydreamController from a gamepad
  45127. * @param vrGamepad the gamepad that the controller should be created from
  45128. */
  45129. constructor(vrGamepad: any);
  45130. /**
  45131. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45132. * @param scene scene in which to add meshes
  45133. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45134. */
  45135. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45136. /**
  45137. * Called once for each button that changed state since the last frame
  45138. * @param buttonIdx Which button index changed
  45139. * @param state New state of the button
  45140. * @param changes Which properties on the state changed since last frame
  45141. */
  45142. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45143. }
  45144. }
  45145. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  45146. import { Scene } from "babylonjs/scene";
  45147. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45148. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  45149. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45150. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45151. /**
  45152. * Gear VR Controller
  45153. */
  45154. export class GearVRController extends WebVRController {
  45155. /**
  45156. * Base Url for the controller model.
  45157. */
  45158. static MODEL_BASE_URL: string;
  45159. /**
  45160. * File name for the controller model.
  45161. */
  45162. static MODEL_FILENAME: string;
  45163. /**
  45164. * Gamepad Id prefix used to identify this controller.
  45165. */
  45166. static readonly GAMEPAD_ID_PREFIX: string;
  45167. private readonly _buttonIndexToObservableNameMap;
  45168. /**
  45169. * Creates a new GearVRController from a gamepad
  45170. * @param vrGamepad the gamepad that the controller should be created from
  45171. */
  45172. constructor(vrGamepad: any);
  45173. /**
  45174. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45175. * @param scene scene in which to add meshes
  45176. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45177. */
  45178. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45179. /**
  45180. * Called once for each button that changed state since the last frame
  45181. * @param buttonIdx Which button index changed
  45182. * @param state New state of the button
  45183. * @param changes Which properties on the state changed since last frame
  45184. */
  45185. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45186. }
  45187. }
  45188. declare module "babylonjs/Gamepads/Controllers/index" {
  45189. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  45190. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  45191. export * from "babylonjs/Gamepads/Controllers/genericController";
  45192. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  45193. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45194. export * from "babylonjs/Gamepads/Controllers/viveController";
  45195. export * from "babylonjs/Gamepads/Controllers/webVRController";
  45196. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  45197. }
  45198. declare module "babylonjs/Gamepads/index" {
  45199. export * from "babylonjs/Gamepads/Controllers/index";
  45200. export * from "babylonjs/Gamepads/gamepad";
  45201. export * from "babylonjs/Gamepads/gamepadManager";
  45202. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  45203. export * from "babylonjs/Gamepads/xboxGamepad";
  45204. }
  45205. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  45206. import { Scene } from "babylonjs/scene";
  45207. import { Vector4 } from "babylonjs/Maths/math.vector";
  45208. import { Color4 } from "babylonjs/Maths/math.color";
  45209. import { Mesh } from "babylonjs/Meshes/mesh";
  45210. import { Nullable } from "babylonjs/types";
  45211. /**
  45212. * Class containing static functions to help procedurally build meshes
  45213. */
  45214. export class PolyhedronBuilder {
  45215. /**
  45216. * Creates a polyhedron mesh
  45217. * * 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
  45218. * * The parameter `size` (positive float, default 1) sets the polygon size
  45219. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  45220. * * 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`
  45221. * * 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
  45222. * * 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)`)
  45223. * * 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
  45224. * * 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
  45225. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45226. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45227. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45228. * @param name defines the name of the mesh
  45229. * @param options defines the options used to create the mesh
  45230. * @param scene defines the hosting scene
  45231. * @returns the polyhedron mesh
  45232. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  45233. */
  45234. static CreatePolyhedron(name: string, options: {
  45235. type?: number;
  45236. size?: number;
  45237. sizeX?: number;
  45238. sizeY?: number;
  45239. sizeZ?: number;
  45240. custom?: any;
  45241. faceUV?: Vector4[];
  45242. faceColors?: Color4[];
  45243. flat?: boolean;
  45244. updatable?: boolean;
  45245. sideOrientation?: number;
  45246. frontUVs?: Vector4;
  45247. backUVs?: Vector4;
  45248. }, scene?: Nullable<Scene>): Mesh;
  45249. }
  45250. }
  45251. declare module "babylonjs/Gizmos/scaleGizmo" {
  45252. import { Observable } from "babylonjs/Misc/observable";
  45253. import { Nullable } from "babylonjs/types";
  45254. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45255. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45256. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  45257. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45258. /**
  45259. * Gizmo that enables scaling a mesh along 3 axis
  45260. */
  45261. export class ScaleGizmo extends Gizmo {
  45262. /**
  45263. * Internal gizmo used for interactions on the x axis
  45264. */
  45265. xGizmo: AxisScaleGizmo;
  45266. /**
  45267. * Internal gizmo used for interactions on the y axis
  45268. */
  45269. yGizmo: AxisScaleGizmo;
  45270. /**
  45271. * Internal gizmo used for interactions on the z axis
  45272. */
  45273. zGizmo: AxisScaleGizmo;
  45274. /**
  45275. * Internal gizmo used to scale all axis equally
  45276. */
  45277. uniformScaleGizmo: AxisScaleGizmo;
  45278. private _meshAttached;
  45279. private _updateGizmoRotationToMatchAttachedMesh;
  45280. private _snapDistance;
  45281. private _scaleRatio;
  45282. private _uniformScalingMesh;
  45283. private _octahedron;
  45284. /** Fires an event when any of it's sub gizmos are dragged */
  45285. onDragStartObservable: Observable<unknown>;
  45286. /** Fires an event when any of it's sub gizmos are released from dragging */
  45287. onDragEndObservable: Observable<unknown>;
  45288. attachedMesh: Nullable<AbstractMesh>;
  45289. /**
  45290. * Creates a ScaleGizmo
  45291. * @param gizmoLayer The utility layer the gizmo will be added to
  45292. */
  45293. constructor(gizmoLayer?: UtilityLayerRenderer);
  45294. updateGizmoRotationToMatchAttachedMesh: boolean;
  45295. /**
  45296. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45297. */
  45298. snapDistance: number;
  45299. /**
  45300. * Ratio for the scale of the gizmo (Default: 1)
  45301. */
  45302. scaleRatio: number;
  45303. /**
  45304. * Disposes of the gizmo
  45305. */
  45306. dispose(): void;
  45307. }
  45308. }
  45309. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  45310. import { Observable } from "babylonjs/Misc/observable";
  45311. import { Nullable } from "babylonjs/types";
  45312. import { Vector3 } from "babylonjs/Maths/math.vector";
  45313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45314. import { Mesh } from "babylonjs/Meshes/mesh";
  45315. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45316. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45317. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45318. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45319. import { Color3 } from "babylonjs/Maths/math.color";
  45320. /**
  45321. * Single axis scale gizmo
  45322. */
  45323. export class AxisScaleGizmo extends Gizmo {
  45324. /**
  45325. * Drag behavior responsible for the gizmos dragging interactions
  45326. */
  45327. dragBehavior: PointerDragBehavior;
  45328. private _pointerObserver;
  45329. /**
  45330. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45331. */
  45332. snapDistance: number;
  45333. /**
  45334. * Event that fires each time the gizmo snaps to a new location.
  45335. * * snapDistance is the the change in distance
  45336. */
  45337. onSnapObservable: Observable<{
  45338. snapDistance: number;
  45339. }>;
  45340. /**
  45341. * If the scaling operation should be done on all axis (default: false)
  45342. */
  45343. uniformScaling: boolean;
  45344. private _isEnabled;
  45345. private _parent;
  45346. private _arrow;
  45347. private _coloredMaterial;
  45348. private _hoverMaterial;
  45349. /**
  45350. * Creates an AxisScaleGizmo
  45351. * @param gizmoLayer The utility layer the gizmo will be added to
  45352. * @param dragAxis The axis which the gizmo will be able to scale on
  45353. * @param color The color of the gizmo
  45354. */
  45355. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  45356. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45357. /**
  45358. * If the gizmo is enabled
  45359. */
  45360. isEnabled: boolean;
  45361. /**
  45362. * Disposes of the gizmo
  45363. */
  45364. dispose(): void;
  45365. /**
  45366. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45367. * @param mesh The mesh to replace the default mesh of the gizmo
  45368. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  45369. */
  45370. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  45371. }
  45372. }
  45373. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  45374. import { Observable } from "babylonjs/Misc/observable";
  45375. import { Nullable } from "babylonjs/types";
  45376. import { Vector3 } from "babylonjs/Maths/math.vector";
  45377. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45378. import { Mesh } from "babylonjs/Meshes/mesh";
  45379. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45380. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45381. import { Color3 } from "babylonjs/Maths/math.color";
  45382. import "babylonjs/Meshes/Builders/boxBuilder";
  45383. /**
  45384. * Bounding box gizmo
  45385. */
  45386. export class BoundingBoxGizmo extends Gizmo {
  45387. private _lineBoundingBox;
  45388. private _rotateSpheresParent;
  45389. private _scaleBoxesParent;
  45390. private _boundingDimensions;
  45391. private _renderObserver;
  45392. private _pointerObserver;
  45393. private _scaleDragSpeed;
  45394. private _tmpQuaternion;
  45395. private _tmpVector;
  45396. private _tmpRotationMatrix;
  45397. /**
  45398. * 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)
  45399. */
  45400. ignoreChildren: boolean;
  45401. /**
  45402. * 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)
  45403. */
  45404. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45405. /**
  45406. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45407. */
  45408. rotationSphereSize: number;
  45409. /**
  45410. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45411. */
  45412. scaleBoxSize: number;
  45413. /**
  45414. * 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)
  45415. */
  45416. fixedDragMeshScreenSize: boolean;
  45417. /**
  45418. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45419. */
  45420. fixedDragMeshScreenSizeDistanceFactor: number;
  45421. /**
  45422. * Fired when a rotation sphere or scale box is dragged
  45423. */
  45424. onDragStartObservable: Observable<{}>;
  45425. /**
  45426. * Fired when a scale box is dragged
  45427. */
  45428. onScaleBoxDragObservable: Observable<{}>;
  45429. /**
  45430. * Fired when a scale box drag is ended
  45431. */
  45432. onScaleBoxDragEndObservable: Observable<{}>;
  45433. /**
  45434. * Fired when a rotation sphere is dragged
  45435. */
  45436. onRotationSphereDragObservable: Observable<{}>;
  45437. /**
  45438. * Fired when a rotation sphere drag is ended
  45439. */
  45440. onRotationSphereDragEndObservable: Observable<{}>;
  45441. /**
  45442. * 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)
  45443. */
  45444. scalePivot: Nullable<Vector3>;
  45445. /**
  45446. * Mesh used as a pivot to rotate the attached mesh
  45447. */
  45448. private _anchorMesh;
  45449. private _existingMeshScale;
  45450. private _dragMesh;
  45451. private pointerDragBehavior;
  45452. private coloredMaterial;
  45453. private hoverColoredMaterial;
  45454. /**
  45455. * Sets the color of the bounding box gizmo
  45456. * @param color the color to set
  45457. */
  45458. setColor(color: Color3): void;
  45459. /**
  45460. * Creates an BoundingBoxGizmo
  45461. * @param gizmoLayer The utility layer the gizmo will be added to
  45462. * @param color The color of the gizmo
  45463. */
  45464. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45465. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45466. private _selectNode;
  45467. /**
  45468. * Updates the bounding box information for the Gizmo
  45469. */
  45470. updateBoundingBox(): void;
  45471. private _updateRotationSpheres;
  45472. private _updateScaleBoxes;
  45473. /**
  45474. * Enables rotation on the specified axis and disables rotation on the others
  45475. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45476. */
  45477. setEnabledRotationAxis(axis: string): void;
  45478. /**
  45479. * Enables/disables scaling
  45480. * @param enable if scaling should be enabled
  45481. */
  45482. setEnabledScaling(enable: boolean): void;
  45483. private _updateDummy;
  45484. /**
  45485. * Enables a pointer drag behavior on the bounding box of the gizmo
  45486. */
  45487. enableDragBehavior(): void;
  45488. /**
  45489. * Disposes of the gizmo
  45490. */
  45491. dispose(): void;
  45492. /**
  45493. * 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)
  45494. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45495. * @returns the bounding box mesh with the passed in mesh as a child
  45496. */
  45497. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45498. /**
  45499. * CustomMeshes are not supported by this gizmo
  45500. * @param mesh The mesh to replace the default mesh of the gizmo
  45501. */
  45502. setCustomMesh(mesh: Mesh): void;
  45503. }
  45504. }
  45505. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  45506. import { Observable } from "babylonjs/Misc/observable";
  45507. import { Nullable } from "babylonjs/types";
  45508. import { Vector3 } from "babylonjs/Maths/math.vector";
  45509. import { Color3 } from "babylonjs/Maths/math.color";
  45510. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45511. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45512. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45513. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45514. import "babylonjs/Meshes/Builders/linesBuilder";
  45515. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45516. /**
  45517. * Single plane rotation gizmo
  45518. */
  45519. export class PlaneRotationGizmo extends Gizmo {
  45520. /**
  45521. * Drag behavior responsible for the gizmos dragging interactions
  45522. */
  45523. dragBehavior: PointerDragBehavior;
  45524. private _pointerObserver;
  45525. /**
  45526. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45527. */
  45528. snapDistance: number;
  45529. /**
  45530. * Event that fires each time the gizmo snaps to a new location.
  45531. * * snapDistance is the the change in distance
  45532. */
  45533. onSnapObservable: Observable<{
  45534. snapDistance: number;
  45535. }>;
  45536. private _isEnabled;
  45537. private _parent;
  45538. /**
  45539. * Creates a PlaneRotationGizmo
  45540. * @param gizmoLayer The utility layer the gizmo will be added to
  45541. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45542. * @param color The color of the gizmo
  45543. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45544. */
  45545. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  45546. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45547. /**
  45548. * If the gizmo is enabled
  45549. */
  45550. isEnabled: boolean;
  45551. /**
  45552. * Disposes of the gizmo
  45553. */
  45554. dispose(): void;
  45555. }
  45556. }
  45557. declare module "babylonjs/Gizmos/rotationGizmo" {
  45558. import { Observable } from "babylonjs/Misc/observable";
  45559. import { Nullable } from "babylonjs/types";
  45560. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45561. import { Mesh } from "babylonjs/Meshes/mesh";
  45562. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45563. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  45564. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45565. /**
  45566. * Gizmo that enables rotating a mesh along 3 axis
  45567. */
  45568. export class RotationGizmo extends Gizmo {
  45569. /**
  45570. * Internal gizmo used for interactions on the x axis
  45571. */
  45572. xGizmo: PlaneRotationGizmo;
  45573. /**
  45574. * Internal gizmo used for interactions on the y axis
  45575. */
  45576. yGizmo: PlaneRotationGizmo;
  45577. /**
  45578. * Internal gizmo used for interactions on the z axis
  45579. */
  45580. zGizmo: PlaneRotationGizmo;
  45581. /** Fires an event when any of it's sub gizmos are dragged */
  45582. onDragStartObservable: Observable<unknown>;
  45583. /** Fires an event when any of it's sub gizmos are released from dragging */
  45584. onDragEndObservable: Observable<unknown>;
  45585. private _meshAttached;
  45586. attachedMesh: Nullable<AbstractMesh>;
  45587. /**
  45588. * Creates a RotationGizmo
  45589. * @param gizmoLayer The utility layer the gizmo will be added to
  45590. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45591. */
  45592. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  45593. updateGizmoRotationToMatchAttachedMesh: boolean;
  45594. /**
  45595. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45596. */
  45597. snapDistance: number;
  45598. /**
  45599. * Ratio for the scale of the gizmo (Default: 1)
  45600. */
  45601. scaleRatio: number;
  45602. /**
  45603. * Disposes of the gizmo
  45604. */
  45605. dispose(): void;
  45606. /**
  45607. * CustomMeshes are not supported by this gizmo
  45608. * @param mesh The mesh to replace the default mesh of the gizmo
  45609. */
  45610. setCustomMesh(mesh: Mesh): void;
  45611. }
  45612. }
  45613. declare module "babylonjs/Gizmos/gizmoManager" {
  45614. import { Observable } from "babylonjs/Misc/observable";
  45615. import { Nullable } from "babylonjs/types";
  45616. import { Scene, IDisposable } from "babylonjs/scene";
  45617. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45618. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45619. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45620. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45621. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45622. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45623. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  45624. /**
  45625. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45626. */
  45627. export class GizmoManager implements IDisposable {
  45628. private scene;
  45629. /**
  45630. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45631. */
  45632. gizmos: {
  45633. positionGizmo: Nullable<PositionGizmo>;
  45634. rotationGizmo: Nullable<RotationGizmo>;
  45635. scaleGizmo: Nullable<ScaleGizmo>;
  45636. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45637. };
  45638. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45639. clearGizmoOnEmptyPointerEvent: boolean;
  45640. /** Fires an event when the manager is attached to a mesh */
  45641. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45642. private _gizmosEnabled;
  45643. private _pointerObserver;
  45644. private _attachedMesh;
  45645. private _boundingBoxColor;
  45646. private _defaultUtilityLayer;
  45647. private _defaultKeepDepthUtilityLayer;
  45648. /**
  45649. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45650. */
  45651. boundingBoxDragBehavior: SixDofDragBehavior;
  45652. /**
  45653. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45654. */
  45655. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45656. /**
  45657. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45658. */
  45659. usePointerToAttachGizmos: boolean;
  45660. /**
  45661. * Utility layer that the bounding box gizmo belongs to
  45662. */
  45663. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45664. /**
  45665. * Utility layer that all gizmos besides bounding box belong to
  45666. */
  45667. readonly utilityLayer: UtilityLayerRenderer;
  45668. /**
  45669. * Instatiates a gizmo manager
  45670. * @param scene the scene to overlay the gizmos on top of
  45671. */
  45672. constructor(scene: Scene);
  45673. /**
  45674. * Attaches a set of gizmos to the specified mesh
  45675. * @param mesh The mesh the gizmo's should be attached to
  45676. */
  45677. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45678. /**
  45679. * If the position gizmo is enabled
  45680. */
  45681. positionGizmoEnabled: boolean;
  45682. /**
  45683. * If the rotation gizmo is enabled
  45684. */
  45685. rotationGizmoEnabled: boolean;
  45686. /**
  45687. * If the scale gizmo is enabled
  45688. */
  45689. scaleGizmoEnabled: boolean;
  45690. /**
  45691. * If the boundingBox gizmo is enabled
  45692. */
  45693. boundingBoxGizmoEnabled: boolean;
  45694. /**
  45695. * Disposes of the gizmo manager
  45696. */
  45697. dispose(): void;
  45698. }
  45699. }
  45700. declare module "babylonjs/Lights/directionalLight" {
  45701. import { Camera } from "babylonjs/Cameras/camera";
  45702. import { Scene } from "babylonjs/scene";
  45703. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  45704. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45705. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45706. import { Effect } from "babylonjs/Materials/effect";
  45707. /**
  45708. * A directional light is defined by a direction (what a surprise!).
  45709. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45710. * 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.
  45711. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45712. */
  45713. export class DirectionalLight extends ShadowLight {
  45714. private _shadowFrustumSize;
  45715. /**
  45716. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45717. */
  45718. /**
  45719. * Specifies a fix frustum size for the shadow generation.
  45720. */
  45721. shadowFrustumSize: number;
  45722. private _shadowOrthoScale;
  45723. /**
  45724. * Gets the shadow projection scale against the optimal computed one.
  45725. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45726. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45727. */
  45728. /**
  45729. * Sets the shadow projection scale against the optimal computed one.
  45730. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45731. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45732. */
  45733. shadowOrthoScale: number;
  45734. /**
  45735. * Automatically compute the projection matrix to best fit (including all the casters)
  45736. * on each frame.
  45737. */
  45738. autoUpdateExtends: boolean;
  45739. private _orthoLeft;
  45740. private _orthoRight;
  45741. private _orthoTop;
  45742. private _orthoBottom;
  45743. /**
  45744. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45745. * The directional light is emitted from everywhere in the given direction.
  45746. * It can cast shadows.
  45747. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45748. * @param name The friendly name of the light
  45749. * @param direction The direction of the light
  45750. * @param scene The scene the light belongs to
  45751. */
  45752. constructor(name: string, direction: Vector3, scene: Scene);
  45753. /**
  45754. * Returns the string "DirectionalLight".
  45755. * @return The class name
  45756. */
  45757. getClassName(): string;
  45758. /**
  45759. * Returns the integer 1.
  45760. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45761. */
  45762. getTypeID(): number;
  45763. /**
  45764. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45765. * Returns the DirectionalLight Shadow projection matrix.
  45766. */
  45767. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45768. /**
  45769. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45770. * Returns the DirectionalLight Shadow projection matrix.
  45771. */
  45772. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45773. /**
  45774. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45775. * Returns the DirectionalLight Shadow projection matrix.
  45776. */
  45777. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45778. protected _buildUniformLayout(): void;
  45779. /**
  45780. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45781. * @param effect The effect to update
  45782. * @param lightIndex The index of the light in the effect to update
  45783. * @returns The directional light
  45784. */
  45785. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45786. /**
  45787. * Gets the minZ used for shadow according to both the scene and the light.
  45788. *
  45789. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45790. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45791. * @param activeCamera The camera we are returning the min for
  45792. * @returns the depth min z
  45793. */
  45794. getDepthMinZ(activeCamera: Camera): number;
  45795. /**
  45796. * Gets the maxZ used for shadow according to both the scene and the light.
  45797. *
  45798. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45799. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45800. * @param activeCamera The camera we are returning the max for
  45801. * @returns the depth max z
  45802. */
  45803. getDepthMaxZ(activeCamera: Camera): number;
  45804. /**
  45805. * Prepares the list of defines specific to the light type.
  45806. * @param defines the list of defines
  45807. * @param lightIndex defines the index of the light for the effect
  45808. */
  45809. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45810. }
  45811. }
  45812. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  45813. import { Mesh } from "babylonjs/Meshes/mesh";
  45814. /**
  45815. * Class containing static functions to help procedurally build meshes
  45816. */
  45817. export class HemisphereBuilder {
  45818. /**
  45819. * Creates a hemisphere mesh
  45820. * @param name defines the name of the mesh
  45821. * @param options defines the options used to create the mesh
  45822. * @param scene defines the hosting scene
  45823. * @returns the hemisphere mesh
  45824. */
  45825. static CreateHemisphere(name: string, options: {
  45826. segments?: number;
  45827. diameter?: number;
  45828. sideOrientation?: number;
  45829. }, scene: any): Mesh;
  45830. }
  45831. }
  45832. declare module "babylonjs/Lights/spotLight" {
  45833. import { Nullable } from "babylonjs/types";
  45834. import { Scene } from "babylonjs/scene";
  45835. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  45836. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45837. import { Effect } from "babylonjs/Materials/effect";
  45838. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45839. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45840. /**
  45841. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45842. * These values define a cone of light starting from the position, emitting toward the direction.
  45843. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45844. * and the exponent defines the speed of the decay of the light with distance (reach).
  45845. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45846. */
  45847. export class SpotLight extends ShadowLight {
  45848. private _angle;
  45849. private _innerAngle;
  45850. private _cosHalfAngle;
  45851. private _lightAngleScale;
  45852. private _lightAngleOffset;
  45853. /**
  45854. * Gets the cone angle of the spot light in Radians.
  45855. */
  45856. /**
  45857. * Sets the cone angle of the spot light in Radians.
  45858. */
  45859. angle: number;
  45860. /**
  45861. * Only used in gltf falloff mode, this defines the angle where
  45862. * the directional falloff will start before cutting at angle which could be seen
  45863. * as outer angle.
  45864. */
  45865. /**
  45866. * Only used in gltf falloff mode, this defines the angle where
  45867. * the directional falloff will start before cutting at angle which could be seen
  45868. * as outer angle.
  45869. */
  45870. innerAngle: number;
  45871. private _shadowAngleScale;
  45872. /**
  45873. * Allows scaling the angle of the light for shadow generation only.
  45874. */
  45875. /**
  45876. * Allows scaling the angle of the light for shadow generation only.
  45877. */
  45878. shadowAngleScale: number;
  45879. /**
  45880. * The light decay speed with the distance from the emission spot.
  45881. */
  45882. exponent: number;
  45883. private _projectionTextureMatrix;
  45884. /**
  45885. * Allows reading the projecton texture
  45886. */
  45887. readonly projectionTextureMatrix: Matrix;
  45888. protected _projectionTextureLightNear: number;
  45889. /**
  45890. * Gets the near clip of the Spotlight for texture projection.
  45891. */
  45892. /**
  45893. * Sets the near clip of the Spotlight for texture projection.
  45894. */
  45895. projectionTextureLightNear: number;
  45896. protected _projectionTextureLightFar: number;
  45897. /**
  45898. * Gets the far clip of the Spotlight for texture projection.
  45899. */
  45900. /**
  45901. * Sets the far clip of the Spotlight for texture projection.
  45902. */
  45903. projectionTextureLightFar: number;
  45904. protected _projectionTextureUpDirection: Vector3;
  45905. /**
  45906. * Gets the Up vector of the Spotlight for texture projection.
  45907. */
  45908. /**
  45909. * Sets the Up vector of the Spotlight for texture projection.
  45910. */
  45911. projectionTextureUpDirection: Vector3;
  45912. private _projectionTexture;
  45913. /**
  45914. * Gets the projection texture of the light.
  45915. */
  45916. /**
  45917. * Sets the projection texture of the light.
  45918. */
  45919. projectionTexture: Nullable<BaseTexture>;
  45920. private _projectionTextureViewLightDirty;
  45921. private _projectionTextureProjectionLightDirty;
  45922. private _projectionTextureDirty;
  45923. private _projectionTextureViewTargetVector;
  45924. private _projectionTextureViewLightMatrix;
  45925. private _projectionTextureProjectionLightMatrix;
  45926. private _projectionTextureScalingMatrix;
  45927. /**
  45928. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45929. * It can cast shadows.
  45930. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45931. * @param name The light friendly name
  45932. * @param position The position of the spot light in the scene
  45933. * @param direction The direction of the light in the scene
  45934. * @param angle The cone angle of the light in Radians
  45935. * @param exponent The light decay speed with the distance from the emission spot
  45936. * @param scene The scene the lights belongs to
  45937. */
  45938. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45939. /**
  45940. * Returns the string "SpotLight".
  45941. * @returns the class name
  45942. */
  45943. getClassName(): string;
  45944. /**
  45945. * Returns the integer 2.
  45946. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45947. */
  45948. getTypeID(): number;
  45949. /**
  45950. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45951. */
  45952. protected _setDirection(value: Vector3): void;
  45953. /**
  45954. * Overrides the position setter to recompute the projection texture view light Matrix.
  45955. */
  45956. protected _setPosition(value: Vector3): void;
  45957. /**
  45958. * 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.
  45959. * Returns the SpotLight.
  45960. */
  45961. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45962. protected _computeProjectionTextureViewLightMatrix(): void;
  45963. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45964. /**
  45965. * Main function for light texture projection matrix computing.
  45966. */
  45967. protected _computeProjectionTextureMatrix(): void;
  45968. protected _buildUniformLayout(): void;
  45969. private _computeAngleValues;
  45970. /**
  45971. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45972. * @param effect The effect to update
  45973. * @param lightIndex The index of the light in the effect to update
  45974. * @returns The spot light
  45975. */
  45976. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45977. /**
  45978. * Disposes the light and the associated resources.
  45979. */
  45980. dispose(): void;
  45981. /**
  45982. * Prepares the list of defines specific to the light type.
  45983. * @param defines the list of defines
  45984. * @param lightIndex defines the index of the light for the effect
  45985. */
  45986. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45987. }
  45988. }
  45989. declare module "babylonjs/Gizmos/lightGizmo" {
  45990. import { Nullable } from "babylonjs/types";
  45991. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45992. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45993. import { Light } from "babylonjs/Lights/light";
  45994. /**
  45995. * Gizmo that enables viewing a light
  45996. */
  45997. export class LightGizmo extends Gizmo {
  45998. private _lightMesh;
  45999. private _material;
  46000. private cachedPosition;
  46001. private cachedForward;
  46002. /**
  46003. * Creates a LightGizmo
  46004. * @param gizmoLayer The utility layer the gizmo will be added to
  46005. */
  46006. constructor(gizmoLayer?: UtilityLayerRenderer);
  46007. private _light;
  46008. /**
  46009. * The light that the gizmo is attached to
  46010. */
  46011. light: Nullable<Light>;
  46012. /**
  46013. * @hidden
  46014. * Updates the gizmo to match the attached mesh's position/rotation
  46015. */
  46016. protected _update(): void;
  46017. private static _Scale;
  46018. /**
  46019. * Creates the lines for a light mesh
  46020. */
  46021. private static _createLightLines;
  46022. /**
  46023. * Disposes of the light gizmo
  46024. */
  46025. dispose(): void;
  46026. private static _CreateHemisphericLightMesh;
  46027. private static _CreatePointLightMesh;
  46028. private static _CreateSpotLightMesh;
  46029. private static _CreateDirectionalLightMesh;
  46030. }
  46031. }
  46032. declare module "babylonjs/Gizmos/index" {
  46033. export * from "babylonjs/Gizmos/axisDragGizmo";
  46034. export * from "babylonjs/Gizmos/axisScaleGizmo";
  46035. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  46036. export * from "babylonjs/Gizmos/gizmo";
  46037. export * from "babylonjs/Gizmos/gizmoManager";
  46038. export * from "babylonjs/Gizmos/planeRotationGizmo";
  46039. export * from "babylonjs/Gizmos/positionGizmo";
  46040. export * from "babylonjs/Gizmos/rotationGizmo";
  46041. export * from "babylonjs/Gizmos/scaleGizmo";
  46042. export * from "babylonjs/Gizmos/lightGizmo";
  46043. }
  46044. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  46045. /** @hidden */
  46046. export var backgroundFragmentDeclaration: {
  46047. name: string;
  46048. shader: string;
  46049. };
  46050. }
  46051. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  46052. /** @hidden */
  46053. export var backgroundUboDeclaration: {
  46054. name: string;
  46055. shader: string;
  46056. };
  46057. }
  46058. declare module "babylonjs/Shaders/background.fragment" {
  46059. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  46060. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  46061. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46062. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46063. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46064. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46065. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46066. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  46067. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46068. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46069. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46070. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46071. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46072. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46073. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46074. /** @hidden */
  46075. export var backgroundPixelShader: {
  46076. name: string;
  46077. shader: string;
  46078. };
  46079. }
  46080. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  46081. /** @hidden */
  46082. export var backgroundVertexDeclaration: {
  46083. name: string;
  46084. shader: string;
  46085. };
  46086. }
  46087. declare module "babylonjs/Shaders/background.vertex" {
  46088. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  46089. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  46090. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46091. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46092. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46093. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46094. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46095. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46096. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46097. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46098. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46099. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46100. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46101. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46102. /** @hidden */
  46103. export var backgroundVertexShader: {
  46104. name: string;
  46105. shader: string;
  46106. };
  46107. }
  46108. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  46109. import { Nullable, int, float } from "babylonjs/types";
  46110. import { Scene } from "babylonjs/scene";
  46111. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46112. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46114. import { Mesh } from "babylonjs/Meshes/mesh";
  46115. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46116. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  46117. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  46118. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46119. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  46120. import { Color3 } from "babylonjs/Maths/math.color";
  46121. import "babylonjs/Shaders/background.fragment";
  46122. import "babylonjs/Shaders/background.vertex";
  46123. /**
  46124. * Background material used to create an efficient environement around your scene.
  46125. */
  46126. export class BackgroundMaterial extends PushMaterial {
  46127. /**
  46128. * Standard reflectance value at parallel view angle.
  46129. */
  46130. static StandardReflectance0: number;
  46131. /**
  46132. * Standard reflectance value at grazing angle.
  46133. */
  46134. static StandardReflectance90: number;
  46135. protected _primaryColor: Color3;
  46136. /**
  46137. * Key light Color (multiply against the environement texture)
  46138. */
  46139. primaryColor: Color3;
  46140. protected __perceptualColor: Nullable<Color3>;
  46141. /**
  46142. * Experimental Internal Use Only.
  46143. *
  46144. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  46145. * This acts as a helper to set the primary color to a more "human friendly" value.
  46146. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  46147. * output color as close as possible from the chosen value.
  46148. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  46149. * part of lighting setup.)
  46150. */
  46151. _perceptualColor: Nullable<Color3>;
  46152. protected _primaryColorShadowLevel: float;
  46153. /**
  46154. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  46155. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  46156. */
  46157. primaryColorShadowLevel: float;
  46158. protected _primaryColorHighlightLevel: float;
  46159. /**
  46160. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  46161. * The primary color is used at the level chosen to define what the white area would look.
  46162. */
  46163. primaryColorHighlightLevel: float;
  46164. protected _reflectionTexture: Nullable<BaseTexture>;
  46165. /**
  46166. * Reflection Texture used in the material.
  46167. * Should be author in a specific way for the best result (refer to the documentation).
  46168. */
  46169. reflectionTexture: Nullable<BaseTexture>;
  46170. protected _reflectionBlur: float;
  46171. /**
  46172. * Reflection Texture level of blur.
  46173. *
  46174. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  46175. * texture twice.
  46176. */
  46177. reflectionBlur: float;
  46178. protected _diffuseTexture: Nullable<BaseTexture>;
  46179. /**
  46180. * Diffuse Texture used in the material.
  46181. * Should be author in a specific way for the best result (refer to the documentation).
  46182. */
  46183. diffuseTexture: Nullable<BaseTexture>;
  46184. protected _shadowLights: Nullable<IShadowLight[]>;
  46185. /**
  46186. * Specify the list of lights casting shadow on the material.
  46187. * All scene shadow lights will be included if null.
  46188. */
  46189. shadowLights: Nullable<IShadowLight[]>;
  46190. protected _shadowLevel: float;
  46191. /**
  46192. * Helps adjusting the shadow to a softer level if required.
  46193. * 0 means black shadows and 1 means no shadows.
  46194. */
  46195. shadowLevel: float;
  46196. protected _sceneCenter: Vector3;
  46197. /**
  46198. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  46199. * It is usually zero but might be interesting to modify according to your setup.
  46200. */
  46201. sceneCenter: Vector3;
  46202. protected _opacityFresnel: boolean;
  46203. /**
  46204. * This helps specifying that the material is falling off to the sky box at grazing angle.
  46205. * This helps ensuring a nice transition when the camera goes under the ground.
  46206. */
  46207. opacityFresnel: boolean;
  46208. protected _reflectionFresnel: boolean;
  46209. /**
  46210. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  46211. * This helps adding a mirror texture on the ground.
  46212. */
  46213. reflectionFresnel: boolean;
  46214. protected _reflectionFalloffDistance: number;
  46215. /**
  46216. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  46217. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  46218. */
  46219. reflectionFalloffDistance: number;
  46220. protected _reflectionAmount: number;
  46221. /**
  46222. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  46223. */
  46224. reflectionAmount: number;
  46225. protected _reflectionReflectance0: number;
  46226. /**
  46227. * This specifies the weight of the reflection at grazing angle.
  46228. */
  46229. reflectionReflectance0: number;
  46230. protected _reflectionReflectance90: number;
  46231. /**
  46232. * This specifies the weight of the reflection at a perpendicular point of view.
  46233. */
  46234. reflectionReflectance90: number;
  46235. /**
  46236. * Sets the reflection reflectance fresnel values according to the default standard
  46237. * empirically know to work well :-)
  46238. */
  46239. reflectionStandardFresnelWeight: number;
  46240. protected _useRGBColor: boolean;
  46241. /**
  46242. * Helps to directly use the maps channels instead of their level.
  46243. */
  46244. useRGBColor: boolean;
  46245. protected _enableNoise: boolean;
  46246. /**
  46247. * This helps reducing the banding effect that could occur on the background.
  46248. */
  46249. enableNoise: boolean;
  46250. /**
  46251. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46252. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  46253. * Recommended to be keep at 1.0 except for special cases.
  46254. */
  46255. fovMultiplier: number;
  46256. private _fovMultiplier;
  46257. /**
  46258. * Enable the FOV adjustment feature controlled by fovMultiplier.
  46259. */
  46260. useEquirectangularFOV: boolean;
  46261. private _maxSimultaneousLights;
  46262. /**
  46263. * Number of Simultaneous lights allowed on the material.
  46264. */
  46265. maxSimultaneousLights: int;
  46266. /**
  46267. * Default configuration related to image processing available in the Background Material.
  46268. */
  46269. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46270. /**
  46271. * Keep track of the image processing observer to allow dispose and replace.
  46272. */
  46273. private _imageProcessingObserver;
  46274. /**
  46275. * Attaches a new image processing configuration to the PBR Material.
  46276. * @param configuration (if null the scene configuration will be use)
  46277. */
  46278. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46279. /**
  46280. * Gets the image processing configuration used either in this material.
  46281. */
  46282. /**
  46283. * Sets the Default image processing configuration used either in the this material.
  46284. *
  46285. * If sets to null, the scene one is in use.
  46286. */
  46287. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  46288. /**
  46289. * Gets wether the color curves effect is enabled.
  46290. */
  46291. /**
  46292. * Sets wether the color curves effect is enabled.
  46293. */
  46294. cameraColorCurvesEnabled: boolean;
  46295. /**
  46296. * Gets wether the color grading effect is enabled.
  46297. */
  46298. /**
  46299. * Gets wether the color grading effect is enabled.
  46300. */
  46301. cameraColorGradingEnabled: boolean;
  46302. /**
  46303. * Gets wether tonemapping is enabled or not.
  46304. */
  46305. /**
  46306. * Sets wether tonemapping is enabled or not
  46307. */
  46308. cameraToneMappingEnabled: boolean;
  46309. /**
  46310. * The camera exposure used on this material.
  46311. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46312. * This corresponds to a photographic exposure.
  46313. */
  46314. /**
  46315. * The camera exposure used on this material.
  46316. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46317. * This corresponds to a photographic exposure.
  46318. */
  46319. cameraExposure: float;
  46320. /**
  46321. * Gets The camera contrast used on this material.
  46322. */
  46323. /**
  46324. * Sets The camera contrast used on this material.
  46325. */
  46326. cameraContrast: float;
  46327. /**
  46328. * Gets the Color Grading 2D Lookup Texture.
  46329. */
  46330. /**
  46331. * Sets the Color Grading 2D Lookup Texture.
  46332. */
  46333. cameraColorGradingTexture: Nullable<BaseTexture>;
  46334. /**
  46335. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46336. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46337. * 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;
  46338. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46339. */
  46340. /**
  46341. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46342. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46343. * 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;
  46344. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46345. */
  46346. cameraColorCurves: Nullable<ColorCurves>;
  46347. /**
  46348. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  46349. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  46350. */
  46351. switchToBGR: boolean;
  46352. private _renderTargets;
  46353. private _reflectionControls;
  46354. private _white;
  46355. private _primaryShadowColor;
  46356. private _primaryHighlightColor;
  46357. /**
  46358. * Instantiates a Background Material in the given scene
  46359. * @param name The friendly name of the material
  46360. * @param scene The scene to add the material to
  46361. */
  46362. constructor(name: string, scene: Scene);
  46363. /**
  46364. * Gets a boolean indicating that current material needs to register RTT
  46365. */
  46366. readonly hasRenderTargetTextures: boolean;
  46367. /**
  46368. * The entire material has been created in order to prevent overdraw.
  46369. * @returns false
  46370. */
  46371. needAlphaTesting(): boolean;
  46372. /**
  46373. * The entire material has been created in order to prevent overdraw.
  46374. * @returns true if blending is enable
  46375. */
  46376. needAlphaBlending(): boolean;
  46377. /**
  46378. * Checks wether the material is ready to be rendered for a given mesh.
  46379. * @param mesh The mesh to render
  46380. * @param subMesh The submesh to check against
  46381. * @param useInstances Specify wether or not the material is used with instances
  46382. * @returns true if all the dependencies are ready (Textures, Effects...)
  46383. */
  46384. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46385. /**
  46386. * Compute the primary color according to the chosen perceptual color.
  46387. */
  46388. private _computePrimaryColorFromPerceptualColor;
  46389. /**
  46390. * Compute the highlights and shadow colors according to their chosen levels.
  46391. */
  46392. private _computePrimaryColors;
  46393. /**
  46394. * Build the uniform buffer used in the material.
  46395. */
  46396. buildUniformLayout(): void;
  46397. /**
  46398. * Unbind the material.
  46399. */
  46400. unbind(): void;
  46401. /**
  46402. * Bind only the world matrix to the material.
  46403. * @param world The world matrix to bind.
  46404. */
  46405. bindOnlyWorldMatrix(world: Matrix): void;
  46406. /**
  46407. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  46408. * @param world The world matrix to bind.
  46409. * @param subMesh The submesh to bind for.
  46410. */
  46411. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46412. /**
  46413. * Dispose the material.
  46414. * @param forceDisposeEffect Force disposal of the associated effect.
  46415. * @param forceDisposeTextures Force disposal of the associated textures.
  46416. */
  46417. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46418. /**
  46419. * Clones the material.
  46420. * @param name The cloned name.
  46421. * @returns The cloned material.
  46422. */
  46423. clone(name: string): BackgroundMaterial;
  46424. /**
  46425. * Serializes the current material to its JSON representation.
  46426. * @returns The JSON representation.
  46427. */
  46428. serialize(): any;
  46429. /**
  46430. * Gets the class name of the material
  46431. * @returns "BackgroundMaterial"
  46432. */
  46433. getClassName(): string;
  46434. /**
  46435. * Parse a JSON input to create back a background material.
  46436. * @param source The JSON data to parse
  46437. * @param scene The scene to create the parsed material in
  46438. * @param rootUrl The root url of the assets the material depends upon
  46439. * @returns the instantiated BackgroundMaterial.
  46440. */
  46441. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  46442. }
  46443. }
  46444. declare module "babylonjs/Helpers/environmentHelper" {
  46445. import { Observable } from "babylonjs/Misc/observable";
  46446. import { Nullable } from "babylonjs/types";
  46447. import { Scene } from "babylonjs/scene";
  46448. import { Vector3 } from "babylonjs/Maths/math.vector";
  46449. import { Color3 } from "babylonjs/Maths/math.color";
  46450. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46451. import { Mesh } from "babylonjs/Meshes/mesh";
  46452. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46453. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  46454. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46455. import "babylonjs/Meshes/Builders/planeBuilder";
  46456. import "babylonjs/Meshes/Builders/boxBuilder";
  46457. /**
  46458. * Represents the different options available during the creation of
  46459. * a Environment helper.
  46460. *
  46461. * This can control the default ground, skybox and image processing setup of your scene.
  46462. */
  46463. export interface IEnvironmentHelperOptions {
  46464. /**
  46465. * Specifies wether or not to create a ground.
  46466. * True by default.
  46467. */
  46468. createGround: boolean;
  46469. /**
  46470. * Specifies the ground size.
  46471. * 15 by default.
  46472. */
  46473. groundSize: number;
  46474. /**
  46475. * The texture used on the ground for the main color.
  46476. * Comes from the BabylonJS CDN by default.
  46477. *
  46478. * Remarks: Can be either a texture or a url.
  46479. */
  46480. groundTexture: string | BaseTexture;
  46481. /**
  46482. * The color mixed in the ground texture by default.
  46483. * BabylonJS clearColor by default.
  46484. */
  46485. groundColor: Color3;
  46486. /**
  46487. * Specifies the ground opacity.
  46488. * 1 by default.
  46489. */
  46490. groundOpacity: number;
  46491. /**
  46492. * Enables the ground to receive shadows.
  46493. * True by default.
  46494. */
  46495. enableGroundShadow: boolean;
  46496. /**
  46497. * Helps preventing the shadow to be fully black on the ground.
  46498. * 0.5 by default.
  46499. */
  46500. groundShadowLevel: number;
  46501. /**
  46502. * Creates a mirror texture attach to the ground.
  46503. * false by default.
  46504. */
  46505. enableGroundMirror: boolean;
  46506. /**
  46507. * Specifies the ground mirror size ratio.
  46508. * 0.3 by default as the default kernel is 64.
  46509. */
  46510. groundMirrorSizeRatio: number;
  46511. /**
  46512. * Specifies the ground mirror blur kernel size.
  46513. * 64 by default.
  46514. */
  46515. groundMirrorBlurKernel: number;
  46516. /**
  46517. * Specifies the ground mirror visibility amount.
  46518. * 1 by default
  46519. */
  46520. groundMirrorAmount: number;
  46521. /**
  46522. * Specifies the ground mirror reflectance weight.
  46523. * This uses the standard weight of the background material to setup the fresnel effect
  46524. * of the mirror.
  46525. * 1 by default.
  46526. */
  46527. groundMirrorFresnelWeight: number;
  46528. /**
  46529. * Specifies the ground mirror Falloff distance.
  46530. * This can helps reducing the size of the reflection.
  46531. * 0 by Default.
  46532. */
  46533. groundMirrorFallOffDistance: number;
  46534. /**
  46535. * Specifies the ground mirror texture type.
  46536. * Unsigned Int by Default.
  46537. */
  46538. groundMirrorTextureType: number;
  46539. /**
  46540. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46541. * the shown objects.
  46542. */
  46543. groundYBias: number;
  46544. /**
  46545. * Specifies wether or not to create a skybox.
  46546. * True by default.
  46547. */
  46548. createSkybox: boolean;
  46549. /**
  46550. * Specifies the skybox size.
  46551. * 20 by default.
  46552. */
  46553. skyboxSize: number;
  46554. /**
  46555. * The texture used on the skybox for the main color.
  46556. * Comes from the BabylonJS CDN by default.
  46557. *
  46558. * Remarks: Can be either a texture or a url.
  46559. */
  46560. skyboxTexture: string | BaseTexture;
  46561. /**
  46562. * The color mixed in the skybox texture by default.
  46563. * BabylonJS clearColor by default.
  46564. */
  46565. skyboxColor: Color3;
  46566. /**
  46567. * The background rotation around the Y axis of the scene.
  46568. * This helps aligning the key lights of your scene with the background.
  46569. * 0 by default.
  46570. */
  46571. backgroundYRotation: number;
  46572. /**
  46573. * Compute automatically the size of the elements to best fit with the scene.
  46574. */
  46575. sizeAuto: boolean;
  46576. /**
  46577. * Default position of the rootMesh if autoSize is not true.
  46578. */
  46579. rootPosition: Vector3;
  46580. /**
  46581. * Sets up the image processing in the scene.
  46582. * true by default.
  46583. */
  46584. setupImageProcessing: boolean;
  46585. /**
  46586. * The texture used as your environment texture in the scene.
  46587. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46588. *
  46589. * Remarks: Can be either a texture or a url.
  46590. */
  46591. environmentTexture: string | BaseTexture;
  46592. /**
  46593. * The value of the exposure to apply to the scene.
  46594. * 0.6 by default if setupImageProcessing is true.
  46595. */
  46596. cameraExposure: number;
  46597. /**
  46598. * The value of the contrast to apply to the scene.
  46599. * 1.6 by default if setupImageProcessing is true.
  46600. */
  46601. cameraContrast: number;
  46602. /**
  46603. * Specifies wether or not tonemapping should be enabled in the scene.
  46604. * true by default if setupImageProcessing is true.
  46605. */
  46606. toneMappingEnabled: boolean;
  46607. }
  46608. /**
  46609. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  46610. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  46611. * It also helps with the default setup of your imageProcessing configuration.
  46612. */
  46613. export class EnvironmentHelper {
  46614. /**
  46615. * Default ground texture URL.
  46616. */
  46617. private static _groundTextureCDNUrl;
  46618. /**
  46619. * Default skybox texture URL.
  46620. */
  46621. private static _skyboxTextureCDNUrl;
  46622. /**
  46623. * Default environment texture URL.
  46624. */
  46625. private static _environmentTextureCDNUrl;
  46626. /**
  46627. * Creates the default options for the helper.
  46628. */
  46629. private static _getDefaultOptions;
  46630. private _rootMesh;
  46631. /**
  46632. * Gets the root mesh created by the helper.
  46633. */
  46634. readonly rootMesh: Mesh;
  46635. private _skybox;
  46636. /**
  46637. * Gets the skybox created by the helper.
  46638. */
  46639. readonly skybox: Nullable<Mesh>;
  46640. private _skyboxTexture;
  46641. /**
  46642. * Gets the skybox texture created by the helper.
  46643. */
  46644. readonly skyboxTexture: Nullable<BaseTexture>;
  46645. private _skyboxMaterial;
  46646. /**
  46647. * Gets the skybox material created by the helper.
  46648. */
  46649. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46650. private _ground;
  46651. /**
  46652. * Gets the ground mesh created by the helper.
  46653. */
  46654. readonly ground: Nullable<Mesh>;
  46655. private _groundTexture;
  46656. /**
  46657. * Gets the ground texture created by the helper.
  46658. */
  46659. readonly groundTexture: Nullable<BaseTexture>;
  46660. private _groundMirror;
  46661. /**
  46662. * Gets the ground mirror created by the helper.
  46663. */
  46664. readonly groundMirror: Nullable<MirrorTexture>;
  46665. /**
  46666. * Gets the ground mirror render list to helps pushing the meshes
  46667. * you wish in the ground reflection.
  46668. */
  46669. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46670. private _groundMaterial;
  46671. /**
  46672. * Gets the ground material created by the helper.
  46673. */
  46674. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46675. /**
  46676. * Stores the creation options.
  46677. */
  46678. private readonly _scene;
  46679. private _options;
  46680. /**
  46681. * This observable will be notified with any error during the creation of the environment,
  46682. * mainly texture creation errors.
  46683. */
  46684. onErrorObservable: Observable<{
  46685. message?: string;
  46686. exception?: any;
  46687. }>;
  46688. /**
  46689. * constructor
  46690. * @param options Defines the options we want to customize the helper
  46691. * @param scene The scene to add the material to
  46692. */
  46693. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46694. /**
  46695. * Updates the background according to the new options
  46696. * @param options
  46697. */
  46698. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46699. /**
  46700. * Sets the primary color of all the available elements.
  46701. * @param color the main color to affect to the ground and the background
  46702. */
  46703. setMainColor(color: Color3): void;
  46704. /**
  46705. * Setup the image processing according to the specified options.
  46706. */
  46707. private _setupImageProcessing;
  46708. /**
  46709. * Setup the environment texture according to the specified options.
  46710. */
  46711. private _setupEnvironmentTexture;
  46712. /**
  46713. * Setup the background according to the specified options.
  46714. */
  46715. private _setupBackground;
  46716. /**
  46717. * Get the scene sizes according to the setup.
  46718. */
  46719. private _getSceneSize;
  46720. /**
  46721. * Setup the ground according to the specified options.
  46722. */
  46723. private _setupGround;
  46724. /**
  46725. * Setup the ground material according to the specified options.
  46726. */
  46727. private _setupGroundMaterial;
  46728. /**
  46729. * Setup the ground diffuse texture according to the specified options.
  46730. */
  46731. private _setupGroundDiffuseTexture;
  46732. /**
  46733. * Setup the ground mirror texture according to the specified options.
  46734. */
  46735. private _setupGroundMirrorTexture;
  46736. /**
  46737. * Setup the ground to receive the mirror texture.
  46738. */
  46739. private _setupMirrorInGroundMaterial;
  46740. /**
  46741. * Setup the skybox according to the specified options.
  46742. */
  46743. private _setupSkybox;
  46744. /**
  46745. * Setup the skybox material according to the specified options.
  46746. */
  46747. private _setupSkyboxMaterial;
  46748. /**
  46749. * Setup the skybox reflection texture according to the specified options.
  46750. */
  46751. private _setupSkyboxReflectionTexture;
  46752. private _errorHandler;
  46753. /**
  46754. * Dispose all the elements created by the Helper.
  46755. */
  46756. dispose(): void;
  46757. }
  46758. }
  46759. declare module "babylonjs/Helpers/photoDome" {
  46760. import { Observable } from "babylonjs/Misc/observable";
  46761. import { Nullable } from "babylonjs/types";
  46762. import { Scene } from "babylonjs/scene";
  46763. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46764. import { Mesh } from "babylonjs/Meshes/mesh";
  46765. import { Texture } from "babylonjs/Materials/Textures/texture";
  46766. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46767. import "babylonjs/Meshes/Builders/sphereBuilder";
  46768. /**
  46769. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46770. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46771. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46772. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46773. */
  46774. export class PhotoDome extends TransformNode {
  46775. /**
  46776. * Define the image as a Monoscopic panoramic 360 image.
  46777. */
  46778. static readonly MODE_MONOSCOPIC: number;
  46779. /**
  46780. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46781. */
  46782. static readonly MODE_TOPBOTTOM: number;
  46783. /**
  46784. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46785. */
  46786. static readonly MODE_SIDEBYSIDE: number;
  46787. private _useDirectMapping;
  46788. /**
  46789. * The texture being displayed on the sphere
  46790. */
  46791. protected _photoTexture: Texture;
  46792. /**
  46793. * Gets or sets the texture being displayed on the sphere
  46794. */
  46795. photoTexture: Texture;
  46796. /**
  46797. * Observable raised when an error occured while loading the 360 image
  46798. */
  46799. onLoadErrorObservable: Observable<string>;
  46800. /**
  46801. * The skybox material
  46802. */
  46803. protected _material: BackgroundMaterial;
  46804. /**
  46805. * The surface used for the skybox
  46806. */
  46807. protected _mesh: Mesh;
  46808. /**
  46809. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46810. * Also see the options.resolution property.
  46811. */
  46812. fovMultiplier: number;
  46813. private _imageMode;
  46814. /**
  46815. * Gets or set the current video mode for the video. It can be:
  46816. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46817. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46818. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46819. */
  46820. imageMode: number;
  46821. /**
  46822. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46823. * @param name Element's name, child elements will append suffixes for their own names.
  46824. * @param urlsOfPhoto defines the url of the photo to display
  46825. * @param options defines an object containing optional or exposed sub element properties
  46826. * @param onError defines a callback called when an error occured while loading the texture
  46827. */
  46828. constructor(name: string, urlOfPhoto: string, options: {
  46829. resolution?: number;
  46830. size?: number;
  46831. useDirectMapping?: boolean;
  46832. faceForward?: boolean;
  46833. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46834. private _onBeforeCameraRenderObserver;
  46835. private _changeImageMode;
  46836. /**
  46837. * Releases resources associated with this node.
  46838. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46839. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46840. */
  46841. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46842. }
  46843. }
  46844. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46845. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46846. /** @hidden */
  46847. export var rgbdDecodePixelShader: {
  46848. name: string;
  46849. shader: string;
  46850. };
  46851. }
  46852. declare module "babylonjs/Misc/brdfTextureTools" {
  46853. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46854. import { Scene } from "babylonjs/scene";
  46855. import "babylonjs/Shaders/rgbdDecode.fragment";
  46856. /**
  46857. * Class used to host texture specific utilities
  46858. */
  46859. export class BRDFTextureTools {
  46860. /**
  46861. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  46862. * @param texture the texture to expand.
  46863. */
  46864. private static _ExpandDefaultBRDFTexture;
  46865. /**
  46866. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46867. * @param scene defines the hosting scene
  46868. * @returns the environment BRDF texture
  46869. */
  46870. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46871. private static _environmentBRDFBase64Texture;
  46872. }
  46873. }
  46874. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  46875. import { Nullable } from "babylonjs/types";
  46876. import { Color3 } from "babylonjs/Maths/math.color";
  46877. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46878. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46879. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46880. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  46881. import { Engine } from "babylonjs/Engines/engine";
  46882. import { Scene } from "babylonjs/scene";
  46883. /**
  46884. * @hidden
  46885. */
  46886. export interface IMaterialClearCoatDefines {
  46887. CLEARCOAT: boolean;
  46888. CLEARCOAT_DEFAULTIOR: boolean;
  46889. CLEARCOAT_TEXTURE: boolean;
  46890. CLEARCOAT_TEXTUREDIRECTUV: number;
  46891. CLEARCOAT_BUMP: boolean;
  46892. CLEARCOAT_BUMPDIRECTUV: number;
  46893. CLEARCOAT_TINT: boolean;
  46894. CLEARCOAT_TINT_TEXTURE: boolean;
  46895. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46896. /** @hidden */
  46897. _areTexturesDirty: boolean;
  46898. }
  46899. /**
  46900. * Define the code related to the clear coat parameters of the pbr material.
  46901. */
  46902. export class PBRClearCoatConfiguration {
  46903. /**
  46904. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46905. * The default fits with a polyurethane material.
  46906. */
  46907. private static readonly _DefaultIndexOfRefraction;
  46908. private _isEnabled;
  46909. /**
  46910. * Defines if the clear coat is enabled in the material.
  46911. */
  46912. isEnabled: boolean;
  46913. /**
  46914. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46915. */
  46916. intensity: number;
  46917. /**
  46918. * Defines the clear coat layer roughness.
  46919. */
  46920. roughness: number;
  46921. private _indexOfRefraction;
  46922. /**
  46923. * Defines the index of refraction of the clear coat.
  46924. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46925. * The default fits with a polyurethane material.
  46926. * Changing the default value is more performance intensive.
  46927. */
  46928. indexOfRefraction: number;
  46929. private _texture;
  46930. /**
  46931. * Stores the clear coat values in a texture.
  46932. */
  46933. texture: Nullable<BaseTexture>;
  46934. private _bumpTexture;
  46935. /**
  46936. * Define the clear coat specific bump texture.
  46937. */
  46938. bumpTexture: Nullable<BaseTexture>;
  46939. private _isTintEnabled;
  46940. /**
  46941. * Defines if the clear coat tint is enabled in the material.
  46942. */
  46943. isTintEnabled: boolean;
  46944. /**
  46945. * Defines the clear coat tint of the material.
  46946. * This is only use if tint is enabled
  46947. */
  46948. tintColor: Color3;
  46949. /**
  46950. * Defines the distance at which the tint color should be found in the
  46951. * clear coat media.
  46952. * This is only use if tint is enabled
  46953. */
  46954. tintColorAtDistance: number;
  46955. /**
  46956. * Defines the clear coat layer thickness.
  46957. * This is only use if tint is enabled
  46958. */
  46959. tintThickness: number;
  46960. private _tintTexture;
  46961. /**
  46962. * Stores the clear tint values in a texture.
  46963. * rgb is tint
  46964. * a is a thickness factor
  46965. */
  46966. tintTexture: Nullable<BaseTexture>;
  46967. /** @hidden */
  46968. private _internalMarkAllSubMeshesAsTexturesDirty;
  46969. /** @hidden */
  46970. _markAllSubMeshesAsTexturesDirty(): void;
  46971. /**
  46972. * Instantiate a new istance of clear coat configuration.
  46973. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46974. */
  46975. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46976. /**
  46977. * Gets wehter the submesh is ready to be used or not.
  46978. * @param defines the list of "defines" to update.
  46979. * @param scene defines the scene the material belongs to.
  46980. * @param engine defines the engine the material belongs to.
  46981. * @param disableBumpMap defines wether the material disables bump or not.
  46982. * @returns - boolean indicating that the submesh is ready or not.
  46983. */
  46984. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46985. /**
  46986. * Checks to see if a texture is used in the material.
  46987. * @param defines the list of "defines" to update.
  46988. * @param scene defines the scene to the material belongs to.
  46989. */
  46990. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46991. /**
  46992. * Binds the material data.
  46993. * @param uniformBuffer defines the Uniform buffer to fill in.
  46994. * @param scene defines the scene the material belongs to.
  46995. * @param engine defines the engine the material belongs to.
  46996. * @param disableBumpMap defines wether the material disables bump or not.
  46997. * @param isFrozen defines wether the material is frozen or not.
  46998. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46999. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47000. */
  47001. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  47002. /**
  47003. * Checks to see if a texture is used in the material.
  47004. * @param texture - Base texture to use.
  47005. * @returns - Boolean specifying if a texture is used in the material.
  47006. */
  47007. hasTexture(texture: BaseTexture): boolean;
  47008. /**
  47009. * Returns an array of the actively used textures.
  47010. * @param activeTextures Array of BaseTextures
  47011. */
  47012. getActiveTextures(activeTextures: BaseTexture[]): void;
  47013. /**
  47014. * Returns the animatable textures.
  47015. * @param animatables Array of animatable textures.
  47016. */
  47017. getAnimatables(animatables: IAnimatable[]): void;
  47018. /**
  47019. * Disposes the resources of the material.
  47020. * @param forceDisposeTextures - Forces the disposal of all textures.
  47021. */
  47022. dispose(forceDisposeTextures?: boolean): void;
  47023. /**
  47024. * Get the current class name of the texture useful for serialization or dynamic coding.
  47025. * @returns "PBRClearCoatConfiguration"
  47026. */
  47027. getClassName(): string;
  47028. /**
  47029. * Add fallbacks to the effect fallbacks list.
  47030. * @param defines defines the Base texture to use.
  47031. * @param fallbacks defines the current fallback list.
  47032. * @param currentRank defines the current fallback rank.
  47033. * @returns the new fallback rank.
  47034. */
  47035. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47036. /**
  47037. * Add the required uniforms to the current list.
  47038. * @param uniforms defines the current uniform list.
  47039. */
  47040. static AddUniforms(uniforms: string[]): void;
  47041. /**
  47042. * Add the required samplers to the current list.
  47043. * @param samplers defines the current sampler list.
  47044. */
  47045. static AddSamplers(samplers: string[]): void;
  47046. /**
  47047. * Add the required uniforms to the current buffer.
  47048. * @param uniformBuffer defines the current uniform buffer.
  47049. */
  47050. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47051. /**
  47052. * Makes a duplicate of the current configuration into another one.
  47053. * @param clearCoatConfiguration define the config where to copy the info
  47054. */
  47055. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  47056. /**
  47057. * Serializes this clear coat configuration.
  47058. * @returns - An object with the serialized config.
  47059. */
  47060. serialize(): any;
  47061. /**
  47062. * Parses a anisotropy Configuration from a serialized object.
  47063. * @param source - Serialized object.
  47064. * @param scene Defines the scene we are parsing for
  47065. * @param rootUrl Defines the rootUrl to load from
  47066. */
  47067. parse(source: any, scene: Scene, rootUrl: string): void;
  47068. }
  47069. }
  47070. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  47071. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47072. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47074. import { Vector2 } from "babylonjs/Maths/math.vector";
  47075. import { Scene } from "babylonjs/scene";
  47076. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47077. import { Nullable } from "babylonjs/types";
  47078. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47079. /**
  47080. * @hidden
  47081. */
  47082. export interface IMaterialAnisotropicDefines {
  47083. ANISOTROPIC: boolean;
  47084. ANISOTROPIC_TEXTURE: boolean;
  47085. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47086. MAINUV1: boolean;
  47087. _areTexturesDirty: boolean;
  47088. _needUVs: boolean;
  47089. }
  47090. /**
  47091. * Define the code related to the anisotropic parameters of the pbr material.
  47092. */
  47093. export class PBRAnisotropicConfiguration {
  47094. private _isEnabled;
  47095. /**
  47096. * Defines if the anisotropy is enabled in the material.
  47097. */
  47098. isEnabled: boolean;
  47099. /**
  47100. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  47101. */
  47102. intensity: number;
  47103. /**
  47104. * Defines if the effect is along the tangents, bitangents or in between.
  47105. * By default, the effect is "strectching" the highlights along the tangents.
  47106. */
  47107. direction: Vector2;
  47108. private _texture;
  47109. /**
  47110. * Stores the anisotropy values in a texture.
  47111. * rg is direction (like normal from -1 to 1)
  47112. * b is a intensity
  47113. */
  47114. texture: Nullable<BaseTexture>;
  47115. /** @hidden */
  47116. private _internalMarkAllSubMeshesAsTexturesDirty;
  47117. /** @hidden */
  47118. _markAllSubMeshesAsTexturesDirty(): void;
  47119. /**
  47120. * Instantiate a new istance of anisotropy configuration.
  47121. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47122. */
  47123. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47124. /**
  47125. * Specifies that the submesh is ready to be used.
  47126. * @param defines the list of "defines" to update.
  47127. * @param scene defines the scene the material belongs to.
  47128. * @returns - boolean indicating that the submesh is ready or not.
  47129. */
  47130. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  47131. /**
  47132. * Checks to see if a texture is used in the material.
  47133. * @param defines the list of "defines" to update.
  47134. * @param mesh the mesh we are preparing the defines for.
  47135. * @param scene defines the scene the material belongs to.
  47136. */
  47137. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  47138. /**
  47139. * Binds the material data.
  47140. * @param uniformBuffer defines the Uniform buffer to fill in.
  47141. * @param scene defines the scene the material belongs to.
  47142. * @param isFrozen defines wether the material is frozen or not.
  47143. */
  47144. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47145. /**
  47146. * Checks to see if a texture is used in the material.
  47147. * @param texture - Base texture to use.
  47148. * @returns - Boolean specifying if a texture is used in the material.
  47149. */
  47150. hasTexture(texture: BaseTexture): boolean;
  47151. /**
  47152. * Returns an array of the actively used textures.
  47153. * @param activeTextures Array of BaseTextures
  47154. */
  47155. getActiveTextures(activeTextures: BaseTexture[]): void;
  47156. /**
  47157. * Returns the animatable textures.
  47158. * @param animatables Array of animatable textures.
  47159. */
  47160. getAnimatables(animatables: IAnimatable[]): void;
  47161. /**
  47162. * Disposes the resources of the material.
  47163. * @param forceDisposeTextures - Forces the disposal of all textures.
  47164. */
  47165. dispose(forceDisposeTextures?: boolean): void;
  47166. /**
  47167. * Get the current class name of the texture useful for serialization or dynamic coding.
  47168. * @returns "PBRAnisotropicConfiguration"
  47169. */
  47170. getClassName(): string;
  47171. /**
  47172. * Add fallbacks to the effect fallbacks list.
  47173. * @param defines defines the Base texture to use.
  47174. * @param fallbacks defines the current fallback list.
  47175. * @param currentRank defines the current fallback rank.
  47176. * @returns the new fallback rank.
  47177. */
  47178. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47179. /**
  47180. * Add the required uniforms to the current list.
  47181. * @param uniforms defines the current uniform list.
  47182. */
  47183. static AddUniforms(uniforms: string[]): void;
  47184. /**
  47185. * Add the required uniforms to the current buffer.
  47186. * @param uniformBuffer defines the current uniform buffer.
  47187. */
  47188. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47189. /**
  47190. * Add the required samplers to the current list.
  47191. * @param samplers defines the current sampler list.
  47192. */
  47193. static AddSamplers(samplers: string[]): void;
  47194. /**
  47195. * Makes a duplicate of the current configuration into another one.
  47196. * @param anisotropicConfiguration define the config where to copy the info
  47197. */
  47198. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  47199. /**
  47200. * Serializes this anisotropy configuration.
  47201. * @returns - An object with the serialized config.
  47202. */
  47203. serialize(): any;
  47204. /**
  47205. * Parses a anisotropy Configuration from a serialized object.
  47206. * @param source - Serialized object.
  47207. * @param scene Defines the scene we are parsing for
  47208. * @param rootUrl Defines the rootUrl to load from
  47209. */
  47210. parse(source: any, scene: Scene, rootUrl: string): void;
  47211. }
  47212. }
  47213. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  47214. import { Scene } from "babylonjs/scene";
  47215. /**
  47216. * @hidden
  47217. */
  47218. export interface IMaterialBRDFDefines {
  47219. BRDF_V_HEIGHT_CORRELATED: boolean;
  47220. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47221. SPHERICAL_HARMONICS: boolean;
  47222. /** @hidden */
  47223. _areMiscDirty: boolean;
  47224. }
  47225. /**
  47226. * Define the code related to the BRDF parameters of the pbr material.
  47227. */
  47228. export class PBRBRDFConfiguration {
  47229. /**
  47230. * Default value used for the energy conservation.
  47231. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47232. */
  47233. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  47234. /**
  47235. * Default value used for the Smith Visibility Height Correlated mode.
  47236. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47237. */
  47238. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  47239. /**
  47240. * Default value used for the IBL diffuse part.
  47241. * This can help switching back to the polynomials mode globally which is a tiny bit
  47242. * less GPU intensive at the drawback of a lower quality.
  47243. */
  47244. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  47245. private _useEnergyConservation;
  47246. /**
  47247. * Defines if the material uses energy conservation.
  47248. */
  47249. useEnergyConservation: boolean;
  47250. private _useSmithVisibilityHeightCorrelated;
  47251. /**
  47252. * LEGACY Mode set to false
  47253. * Defines if the material uses height smith correlated visibility term.
  47254. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  47255. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47256. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  47257. * Not relying on height correlated will also disable energy conservation.
  47258. */
  47259. useSmithVisibilityHeightCorrelated: boolean;
  47260. private _useSphericalHarmonics;
  47261. /**
  47262. * LEGACY Mode set to false
  47263. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  47264. * diffuse part of the IBL.
  47265. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  47266. * to the ground truth.
  47267. */
  47268. useSphericalHarmonics: boolean;
  47269. /** @hidden */
  47270. private _internalMarkAllSubMeshesAsMiscDirty;
  47271. /** @hidden */
  47272. _markAllSubMeshesAsMiscDirty(): void;
  47273. /**
  47274. * Instantiate a new istance of clear coat configuration.
  47275. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  47276. */
  47277. constructor(markAllSubMeshesAsMiscDirty: () => void);
  47278. /**
  47279. * Checks to see if a texture is used in the material.
  47280. * @param defines the list of "defines" to update.
  47281. */
  47282. prepareDefines(defines: IMaterialBRDFDefines): void;
  47283. /**
  47284. * Get the current class name of the texture useful for serialization or dynamic coding.
  47285. * @returns "PBRClearCoatConfiguration"
  47286. */
  47287. getClassName(): string;
  47288. /**
  47289. * Makes a duplicate of the current configuration into another one.
  47290. * @param brdfConfiguration define the config where to copy the info
  47291. */
  47292. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  47293. /**
  47294. * Serializes this BRDF configuration.
  47295. * @returns - An object with the serialized config.
  47296. */
  47297. serialize(): any;
  47298. /**
  47299. * Parses a anisotropy Configuration from a serialized object.
  47300. * @param source - Serialized object.
  47301. * @param scene Defines the scene we are parsing for
  47302. * @param rootUrl Defines the rootUrl to load from
  47303. */
  47304. parse(source: any, scene: Scene, rootUrl: string): void;
  47305. }
  47306. }
  47307. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  47308. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47309. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47310. import { Color3 } from "babylonjs/Maths/math.color";
  47311. import { Scene } from "babylonjs/scene";
  47312. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47313. import { Nullable } from "babylonjs/types";
  47314. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47315. /**
  47316. * @hidden
  47317. */
  47318. export interface IMaterialSheenDefines {
  47319. SHEEN: boolean;
  47320. SHEEN_TEXTURE: boolean;
  47321. SHEEN_TEXTUREDIRECTUV: number;
  47322. SHEEN_LINKWITHALBEDO: boolean;
  47323. /** @hidden */
  47324. _areTexturesDirty: boolean;
  47325. }
  47326. /**
  47327. * Define the code related to the Sheen parameters of the pbr material.
  47328. */
  47329. export class PBRSheenConfiguration {
  47330. private _isEnabled;
  47331. /**
  47332. * Defines if the material uses sheen.
  47333. */
  47334. isEnabled: boolean;
  47335. private _linkSheenWithAlbedo;
  47336. /**
  47337. * Defines if the sheen is linked to the sheen color.
  47338. */
  47339. linkSheenWithAlbedo: boolean;
  47340. /**
  47341. * Defines the sheen intensity.
  47342. */
  47343. intensity: number;
  47344. /**
  47345. * Defines the sheen color.
  47346. */
  47347. color: Color3;
  47348. private _texture;
  47349. /**
  47350. * Stores the sheen tint values in a texture.
  47351. * rgb is tint
  47352. * a is a intensity
  47353. */
  47354. texture: Nullable<BaseTexture>;
  47355. /** @hidden */
  47356. private _internalMarkAllSubMeshesAsTexturesDirty;
  47357. /** @hidden */
  47358. _markAllSubMeshesAsTexturesDirty(): void;
  47359. /**
  47360. * Instantiate a new istance of clear coat configuration.
  47361. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47362. */
  47363. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47364. /**
  47365. * Specifies that the submesh is ready to be used.
  47366. * @param defines the list of "defines" to update.
  47367. * @param scene defines the scene the material belongs to.
  47368. * @returns - boolean indicating that the submesh is ready or not.
  47369. */
  47370. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  47371. /**
  47372. * Checks to see if a texture is used in the material.
  47373. * @param defines the list of "defines" to update.
  47374. * @param scene defines the scene the material belongs to.
  47375. */
  47376. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  47377. /**
  47378. * Binds the material data.
  47379. * @param uniformBuffer defines the Uniform buffer to fill in.
  47380. * @param scene defines the scene the material belongs to.
  47381. * @param isFrozen defines wether the material is frozen or not.
  47382. */
  47383. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47384. /**
  47385. * Checks to see if a texture is used in the material.
  47386. * @param texture - Base texture to use.
  47387. * @returns - Boolean specifying if a texture is used in the material.
  47388. */
  47389. hasTexture(texture: BaseTexture): boolean;
  47390. /**
  47391. * Returns an array of the actively used textures.
  47392. * @param activeTextures Array of BaseTextures
  47393. */
  47394. getActiveTextures(activeTextures: BaseTexture[]): void;
  47395. /**
  47396. * Returns the animatable textures.
  47397. * @param animatables Array of animatable textures.
  47398. */
  47399. getAnimatables(animatables: IAnimatable[]): void;
  47400. /**
  47401. * Disposes the resources of the material.
  47402. * @param forceDisposeTextures - Forces the disposal of all textures.
  47403. */
  47404. dispose(forceDisposeTextures?: boolean): void;
  47405. /**
  47406. * Get the current class name of the texture useful for serialization or dynamic coding.
  47407. * @returns "PBRSheenConfiguration"
  47408. */
  47409. getClassName(): string;
  47410. /**
  47411. * Add fallbacks to the effect fallbacks list.
  47412. * @param defines defines the Base texture to use.
  47413. * @param fallbacks defines the current fallback list.
  47414. * @param currentRank defines the current fallback rank.
  47415. * @returns the new fallback rank.
  47416. */
  47417. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47418. /**
  47419. * Add the required uniforms to the current list.
  47420. * @param uniforms defines the current uniform list.
  47421. */
  47422. static AddUniforms(uniforms: string[]): void;
  47423. /**
  47424. * Add the required uniforms to the current buffer.
  47425. * @param uniformBuffer defines the current uniform buffer.
  47426. */
  47427. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47428. /**
  47429. * Add the required samplers to the current list.
  47430. * @param samplers defines the current sampler list.
  47431. */
  47432. static AddSamplers(samplers: string[]): void;
  47433. /**
  47434. * Makes a duplicate of the current configuration into another one.
  47435. * @param sheenConfiguration define the config where to copy the info
  47436. */
  47437. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  47438. /**
  47439. * Serializes this BRDF configuration.
  47440. * @returns - An object with the serialized config.
  47441. */
  47442. serialize(): any;
  47443. /**
  47444. * Parses a anisotropy Configuration from a serialized object.
  47445. * @param source - Serialized object.
  47446. * @param scene Defines the scene we are parsing for
  47447. * @param rootUrl Defines the rootUrl to load from
  47448. */
  47449. parse(source: any, scene: Scene, rootUrl: string): void;
  47450. }
  47451. }
  47452. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  47453. import { Nullable } from "babylonjs/types";
  47454. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47455. import { Color3 } from "babylonjs/Maths/math.color";
  47456. import { SmartArray } from "babylonjs/Misc/smartArray";
  47457. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47458. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47459. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  47460. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47461. import { Engine } from "babylonjs/Engines/engine";
  47462. import { Scene } from "babylonjs/scene";
  47463. /**
  47464. * @hidden
  47465. */
  47466. export interface IMaterialSubSurfaceDefines {
  47467. SUBSURFACE: boolean;
  47468. SS_REFRACTION: boolean;
  47469. SS_TRANSLUCENCY: boolean;
  47470. SS_SCATERRING: boolean;
  47471. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47472. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47473. SS_REFRACTIONMAP_3D: boolean;
  47474. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47475. SS_LODINREFRACTIONALPHA: boolean;
  47476. SS_GAMMAREFRACTION: boolean;
  47477. SS_RGBDREFRACTION: boolean;
  47478. SS_LINEARSPECULARREFRACTION: boolean;
  47479. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47480. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47481. /** @hidden */
  47482. _areTexturesDirty: boolean;
  47483. }
  47484. /**
  47485. * Define the code related to the sub surface parameters of the pbr material.
  47486. */
  47487. export class PBRSubSurfaceConfiguration {
  47488. private _isRefractionEnabled;
  47489. /**
  47490. * Defines if the refraction is enabled in the material.
  47491. */
  47492. isRefractionEnabled: boolean;
  47493. private _isTranslucencyEnabled;
  47494. /**
  47495. * Defines if the translucency is enabled in the material.
  47496. */
  47497. isTranslucencyEnabled: boolean;
  47498. private _isScatteringEnabled;
  47499. /**
  47500. * Defines the refraction intensity of the material.
  47501. * The refraction when enabled replaces the Diffuse part of the material.
  47502. * The intensity helps transitionning between diffuse and refraction.
  47503. */
  47504. refractionIntensity: number;
  47505. /**
  47506. * Defines the translucency intensity of the material.
  47507. * When translucency has been enabled, this defines how much of the "translucency"
  47508. * is addded to the diffuse part of the material.
  47509. */
  47510. translucencyIntensity: number;
  47511. /**
  47512. * Defines the scattering intensity of the material.
  47513. * When scattering has been enabled, this defines how much of the "scattered light"
  47514. * is addded to the diffuse part of the material.
  47515. */
  47516. scatteringIntensity: number;
  47517. private _thicknessTexture;
  47518. /**
  47519. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47520. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47521. * 0 would mean minimumThickness
  47522. * 1 would mean maximumThickness
  47523. * The other channels might be use as a mask to vary the different effects intensity.
  47524. */
  47525. thicknessTexture: Nullable<BaseTexture>;
  47526. private _refractionTexture;
  47527. /**
  47528. * Defines the texture to use for refraction.
  47529. */
  47530. refractionTexture: Nullable<BaseTexture>;
  47531. private _indexOfRefraction;
  47532. /**
  47533. * Defines the index of refraction used in the material.
  47534. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47535. */
  47536. indexOfRefraction: number;
  47537. private _invertRefractionY;
  47538. /**
  47539. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47540. */
  47541. invertRefractionY: boolean;
  47542. private _linkRefractionWithTransparency;
  47543. /**
  47544. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47545. * Materials half opaque for instance using refraction could benefit from this control.
  47546. */
  47547. linkRefractionWithTransparency: boolean;
  47548. /**
  47549. * Defines the minimum thickness stored in the thickness map.
  47550. * If no thickness map is defined, this value will be used to simulate thickness.
  47551. */
  47552. minimumThickness: number;
  47553. /**
  47554. * Defines the maximum thickness stored in the thickness map.
  47555. */
  47556. maximumThickness: number;
  47557. /**
  47558. * Defines the volume tint of the material.
  47559. * This is used for both translucency and scattering.
  47560. */
  47561. tintColor: Color3;
  47562. /**
  47563. * Defines the distance at which the tint color should be found in the media.
  47564. * This is used for refraction only.
  47565. */
  47566. tintColorAtDistance: number;
  47567. /**
  47568. * Defines how far each channel transmit through the media.
  47569. * It is defined as a color to simplify it selection.
  47570. */
  47571. diffusionDistance: Color3;
  47572. private _useMaskFromThicknessTexture;
  47573. /**
  47574. * Stores the intensity of the different subsurface effects in the thickness texture.
  47575. * * the green channel is the translucency intensity.
  47576. * * the blue channel is the scattering intensity.
  47577. * * the alpha channel is the refraction intensity.
  47578. */
  47579. useMaskFromThicknessTexture: boolean;
  47580. /** @hidden */
  47581. private _internalMarkAllSubMeshesAsTexturesDirty;
  47582. /** @hidden */
  47583. _markAllSubMeshesAsTexturesDirty(): void;
  47584. /**
  47585. * Instantiate a new istance of sub surface configuration.
  47586. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47587. */
  47588. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47589. /**
  47590. * Gets wehter the submesh is ready to be used or not.
  47591. * @param defines the list of "defines" to update.
  47592. * @param scene defines the scene the material belongs to.
  47593. * @returns - boolean indicating that the submesh is ready or not.
  47594. */
  47595. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  47596. /**
  47597. * Checks to see if a texture is used in the material.
  47598. * @param defines the list of "defines" to update.
  47599. * @param scene defines the scene to the material belongs to.
  47600. */
  47601. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  47602. /**
  47603. * Binds the material data.
  47604. * @param uniformBuffer defines the Uniform buffer to fill in.
  47605. * @param scene defines the scene the material belongs to.
  47606. * @param engine defines the engine the material belongs to.
  47607. * @param isFrozen defines wether the material is frozen or not.
  47608. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  47609. */
  47610. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  47611. /**
  47612. * Unbinds the material from the mesh.
  47613. * @param activeEffect defines the effect that should be unbound from.
  47614. * @returns true if unbound, otherwise false
  47615. */
  47616. unbind(activeEffect: Effect): boolean;
  47617. /**
  47618. * Returns the texture used for refraction or null if none is used.
  47619. * @param scene defines the scene the material belongs to.
  47620. * @returns - Refraction texture if present. If no refraction texture and refraction
  47621. * is linked with transparency, returns environment texture. Otherwise, returns null.
  47622. */
  47623. private _getRefractionTexture;
  47624. /**
  47625. * Returns true if alpha blending should be disabled.
  47626. */
  47627. readonly disableAlphaBlending: boolean;
  47628. /**
  47629. * Fills the list of render target textures.
  47630. * @param renderTargets the list of render targets to update
  47631. */
  47632. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47633. /**
  47634. * Checks to see if a texture is used in the material.
  47635. * @param texture - Base texture to use.
  47636. * @returns - Boolean specifying if a texture is used in the material.
  47637. */
  47638. hasTexture(texture: BaseTexture): boolean;
  47639. /**
  47640. * Gets a boolean indicating that current material needs to register RTT
  47641. * @returns true if this uses a render target otherwise false.
  47642. */
  47643. hasRenderTargetTextures(): boolean;
  47644. /**
  47645. * Returns an array of the actively used textures.
  47646. * @param activeTextures Array of BaseTextures
  47647. */
  47648. getActiveTextures(activeTextures: BaseTexture[]): void;
  47649. /**
  47650. * Returns the animatable textures.
  47651. * @param animatables Array of animatable textures.
  47652. */
  47653. getAnimatables(animatables: IAnimatable[]): void;
  47654. /**
  47655. * Disposes the resources of the material.
  47656. * @param forceDisposeTextures - Forces the disposal of all textures.
  47657. */
  47658. dispose(forceDisposeTextures?: boolean): void;
  47659. /**
  47660. * Get the current class name of the texture useful for serialization or dynamic coding.
  47661. * @returns "PBRSubSurfaceConfiguration"
  47662. */
  47663. getClassName(): string;
  47664. /**
  47665. * Add fallbacks to the effect fallbacks list.
  47666. * @param defines defines the Base texture to use.
  47667. * @param fallbacks defines the current fallback list.
  47668. * @param currentRank defines the current fallback rank.
  47669. * @returns the new fallback rank.
  47670. */
  47671. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47672. /**
  47673. * Add the required uniforms to the current list.
  47674. * @param uniforms defines the current uniform list.
  47675. */
  47676. static AddUniforms(uniforms: string[]): void;
  47677. /**
  47678. * Add the required samplers to the current list.
  47679. * @param samplers defines the current sampler list.
  47680. */
  47681. static AddSamplers(samplers: string[]): void;
  47682. /**
  47683. * Add the required uniforms to the current buffer.
  47684. * @param uniformBuffer defines the current uniform buffer.
  47685. */
  47686. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47687. /**
  47688. * Makes a duplicate of the current configuration into another one.
  47689. * @param configuration define the config where to copy the info
  47690. */
  47691. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47692. /**
  47693. * Serializes this Sub Surface configuration.
  47694. * @returns - An object with the serialized config.
  47695. */
  47696. serialize(): any;
  47697. /**
  47698. * Parses a anisotropy Configuration from a serialized object.
  47699. * @param source - Serialized object.
  47700. * @param scene Defines the scene we are parsing for
  47701. * @param rootUrl Defines the rootUrl to load from
  47702. */
  47703. parse(source: any, scene: Scene, rootUrl: string): void;
  47704. }
  47705. }
  47706. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  47707. /** @hidden */
  47708. export var pbrFragmentDeclaration: {
  47709. name: string;
  47710. shader: string;
  47711. };
  47712. }
  47713. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  47714. /** @hidden */
  47715. export var pbrUboDeclaration: {
  47716. name: string;
  47717. shader: string;
  47718. };
  47719. }
  47720. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  47721. /** @hidden */
  47722. export var pbrFragmentExtraDeclaration: {
  47723. name: string;
  47724. shader: string;
  47725. };
  47726. }
  47727. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  47728. /** @hidden */
  47729. export var pbrFragmentSamplersDeclaration: {
  47730. name: string;
  47731. shader: string;
  47732. };
  47733. }
  47734. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  47735. /** @hidden */
  47736. export var pbrHelperFunctions: {
  47737. name: string;
  47738. shader: string;
  47739. };
  47740. }
  47741. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  47742. /** @hidden */
  47743. export var harmonicsFunctions: {
  47744. name: string;
  47745. shader: string;
  47746. };
  47747. }
  47748. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  47749. /** @hidden */
  47750. export var pbrDirectLightingSetupFunctions: {
  47751. name: string;
  47752. shader: string;
  47753. };
  47754. }
  47755. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  47756. /** @hidden */
  47757. export var pbrDirectLightingFalloffFunctions: {
  47758. name: string;
  47759. shader: string;
  47760. };
  47761. }
  47762. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  47763. /** @hidden */
  47764. export var pbrBRDFFunctions: {
  47765. name: string;
  47766. shader: string;
  47767. };
  47768. }
  47769. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  47770. /** @hidden */
  47771. export var pbrDirectLightingFunctions: {
  47772. name: string;
  47773. shader: string;
  47774. };
  47775. }
  47776. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  47777. /** @hidden */
  47778. export var pbrIBLFunctions: {
  47779. name: string;
  47780. shader: string;
  47781. };
  47782. }
  47783. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  47784. /** @hidden */
  47785. export var pbrDebug: {
  47786. name: string;
  47787. shader: string;
  47788. };
  47789. }
  47790. declare module "babylonjs/Shaders/pbr.fragment" {
  47791. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  47792. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47793. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  47794. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47795. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47796. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  47797. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47798. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47799. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47800. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47801. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47802. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  47803. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47804. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47805. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47806. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  47807. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  47808. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  47809. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  47810. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  47811. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  47812. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47813. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47814. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  47815. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  47816. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47817. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  47818. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47819. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  47820. /** @hidden */
  47821. export var pbrPixelShader: {
  47822. name: string;
  47823. shader: string;
  47824. };
  47825. }
  47826. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  47827. /** @hidden */
  47828. export var pbrVertexDeclaration: {
  47829. name: string;
  47830. shader: string;
  47831. };
  47832. }
  47833. declare module "babylonjs/Shaders/pbr.vertex" {
  47834. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  47835. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47836. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47837. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47838. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47839. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47840. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  47841. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47842. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47843. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47844. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47845. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  47846. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  47847. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47848. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  47849. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47850. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47851. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  47852. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47853. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47854. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47855. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  47856. /** @hidden */
  47857. export var pbrVertexShader: {
  47858. name: string;
  47859. shader: string;
  47860. };
  47861. }
  47862. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  47863. import { Nullable } from "babylonjs/types";
  47864. import { Scene } from "babylonjs/scene";
  47865. import { Matrix } from "babylonjs/Maths/math.vector";
  47866. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47867. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47868. import { Mesh } from "babylonjs/Meshes/mesh";
  47869. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  47870. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  47871. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  47872. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  47873. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  47874. import { Color3 } from "babylonjs/Maths/math.color";
  47875. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  47876. import { Material } from "babylonjs/Materials/material";
  47877. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  47878. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47879. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47880. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47881. import "babylonjs/Shaders/pbr.fragment";
  47882. import "babylonjs/Shaders/pbr.vertex";
  47883. /**
  47884. * Manages the defines for the PBR Material.
  47885. * @hidden
  47886. */
  47887. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47888. PBR: boolean;
  47889. MAINUV1: boolean;
  47890. MAINUV2: boolean;
  47891. UV1: boolean;
  47892. UV2: boolean;
  47893. ALBEDO: boolean;
  47894. ALBEDODIRECTUV: number;
  47895. VERTEXCOLOR: boolean;
  47896. AMBIENT: boolean;
  47897. AMBIENTDIRECTUV: number;
  47898. AMBIENTINGRAYSCALE: boolean;
  47899. OPACITY: boolean;
  47900. VERTEXALPHA: boolean;
  47901. OPACITYDIRECTUV: number;
  47902. OPACITYRGB: boolean;
  47903. ALPHATEST: boolean;
  47904. DEPTHPREPASS: boolean;
  47905. ALPHABLEND: boolean;
  47906. ALPHAFROMALBEDO: boolean;
  47907. ALPHATESTVALUE: string;
  47908. SPECULAROVERALPHA: boolean;
  47909. RADIANCEOVERALPHA: boolean;
  47910. ALPHAFRESNEL: boolean;
  47911. LINEARALPHAFRESNEL: boolean;
  47912. PREMULTIPLYALPHA: boolean;
  47913. EMISSIVE: boolean;
  47914. EMISSIVEDIRECTUV: number;
  47915. REFLECTIVITY: boolean;
  47916. REFLECTIVITYDIRECTUV: number;
  47917. SPECULARTERM: boolean;
  47918. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47919. MICROSURFACEAUTOMATIC: boolean;
  47920. LODBASEDMICROSFURACE: boolean;
  47921. MICROSURFACEMAP: boolean;
  47922. MICROSURFACEMAPDIRECTUV: number;
  47923. METALLICWORKFLOW: boolean;
  47924. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47925. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47926. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47927. AOSTOREINMETALMAPRED: boolean;
  47928. ENVIRONMENTBRDF: boolean;
  47929. ENVIRONMENTBRDF_RGBD: boolean;
  47930. NORMAL: boolean;
  47931. TANGENT: boolean;
  47932. BUMP: boolean;
  47933. BUMPDIRECTUV: number;
  47934. OBJECTSPACE_NORMALMAP: boolean;
  47935. PARALLAX: boolean;
  47936. PARALLAXOCCLUSION: boolean;
  47937. NORMALXYSCALE: boolean;
  47938. LIGHTMAP: boolean;
  47939. LIGHTMAPDIRECTUV: number;
  47940. USELIGHTMAPASSHADOWMAP: boolean;
  47941. GAMMALIGHTMAP: boolean;
  47942. REFLECTION: boolean;
  47943. REFLECTIONMAP_3D: boolean;
  47944. REFLECTIONMAP_SPHERICAL: boolean;
  47945. REFLECTIONMAP_PLANAR: boolean;
  47946. REFLECTIONMAP_CUBIC: boolean;
  47947. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  47948. REFLECTIONMAP_PROJECTION: boolean;
  47949. REFLECTIONMAP_SKYBOX: boolean;
  47950. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  47951. REFLECTIONMAP_EXPLICIT: boolean;
  47952. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  47953. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  47954. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  47955. INVERTCUBICMAP: boolean;
  47956. USESPHERICALFROMREFLECTIONMAP: boolean;
  47957. USEIRRADIANCEMAP: boolean;
  47958. SPHERICAL_HARMONICS: boolean;
  47959. USESPHERICALINVERTEX: boolean;
  47960. REFLECTIONMAP_OPPOSITEZ: boolean;
  47961. LODINREFLECTIONALPHA: boolean;
  47962. GAMMAREFLECTION: boolean;
  47963. RGBDREFLECTION: boolean;
  47964. LINEARSPECULARREFLECTION: boolean;
  47965. RADIANCEOCCLUSION: boolean;
  47966. HORIZONOCCLUSION: boolean;
  47967. INSTANCES: boolean;
  47968. NUM_BONE_INFLUENCERS: number;
  47969. BonesPerMesh: number;
  47970. BONETEXTURE: boolean;
  47971. NONUNIFORMSCALING: boolean;
  47972. MORPHTARGETS: boolean;
  47973. MORPHTARGETS_NORMAL: boolean;
  47974. MORPHTARGETS_TANGENT: boolean;
  47975. MORPHTARGETS_UV: boolean;
  47976. NUM_MORPH_INFLUENCERS: number;
  47977. IMAGEPROCESSING: boolean;
  47978. VIGNETTE: boolean;
  47979. VIGNETTEBLENDMODEMULTIPLY: boolean;
  47980. VIGNETTEBLENDMODEOPAQUE: boolean;
  47981. TONEMAPPING: boolean;
  47982. TONEMAPPING_ACES: boolean;
  47983. CONTRAST: boolean;
  47984. COLORCURVES: boolean;
  47985. COLORGRADING: boolean;
  47986. COLORGRADING3D: boolean;
  47987. SAMPLER3DGREENDEPTH: boolean;
  47988. SAMPLER3DBGRMAP: boolean;
  47989. IMAGEPROCESSINGPOSTPROCESS: boolean;
  47990. EXPOSURE: boolean;
  47991. MULTIVIEW: boolean;
  47992. USEPHYSICALLIGHTFALLOFF: boolean;
  47993. USEGLTFLIGHTFALLOFF: boolean;
  47994. TWOSIDEDLIGHTING: boolean;
  47995. SHADOWFLOAT: boolean;
  47996. CLIPPLANE: boolean;
  47997. CLIPPLANE2: boolean;
  47998. CLIPPLANE3: boolean;
  47999. CLIPPLANE4: boolean;
  48000. POINTSIZE: boolean;
  48001. FOG: boolean;
  48002. LOGARITHMICDEPTH: boolean;
  48003. FORCENORMALFORWARD: boolean;
  48004. SPECULARAA: boolean;
  48005. CLEARCOAT: boolean;
  48006. CLEARCOAT_DEFAULTIOR: boolean;
  48007. CLEARCOAT_TEXTURE: boolean;
  48008. CLEARCOAT_TEXTUREDIRECTUV: number;
  48009. CLEARCOAT_BUMP: boolean;
  48010. CLEARCOAT_BUMPDIRECTUV: number;
  48011. CLEARCOAT_TINT: boolean;
  48012. CLEARCOAT_TINT_TEXTURE: boolean;
  48013. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48014. ANISOTROPIC: boolean;
  48015. ANISOTROPIC_TEXTURE: boolean;
  48016. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48017. BRDF_V_HEIGHT_CORRELATED: boolean;
  48018. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48019. SHEEN: boolean;
  48020. SHEEN_TEXTURE: boolean;
  48021. SHEEN_TEXTUREDIRECTUV: number;
  48022. SHEEN_LINKWITHALBEDO: boolean;
  48023. SUBSURFACE: boolean;
  48024. SS_REFRACTION: boolean;
  48025. SS_TRANSLUCENCY: boolean;
  48026. SS_SCATERRING: boolean;
  48027. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48028. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48029. SS_REFRACTIONMAP_3D: boolean;
  48030. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48031. SS_LODINREFRACTIONALPHA: boolean;
  48032. SS_GAMMAREFRACTION: boolean;
  48033. SS_RGBDREFRACTION: boolean;
  48034. SS_LINEARSPECULARREFRACTION: boolean;
  48035. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48036. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48037. UNLIT: boolean;
  48038. DEBUGMODE: number;
  48039. /**
  48040. * Initializes the PBR Material defines.
  48041. */
  48042. constructor();
  48043. /**
  48044. * Resets the PBR Material defines.
  48045. */
  48046. reset(): void;
  48047. }
  48048. /**
  48049. * The Physically based material base class of BJS.
  48050. *
  48051. * This offers the main features of a standard PBR material.
  48052. * For more information, please refer to the documentation :
  48053. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48054. */
  48055. export abstract class PBRBaseMaterial extends PushMaterial {
  48056. /**
  48057. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48058. */
  48059. static readonly PBRMATERIAL_OPAQUE: number;
  48060. /**
  48061. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48062. */
  48063. static readonly PBRMATERIAL_ALPHATEST: number;
  48064. /**
  48065. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48066. */
  48067. static readonly PBRMATERIAL_ALPHABLEND: number;
  48068. /**
  48069. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48070. * They are also discarded below the alpha cutoff threshold to improve performances.
  48071. */
  48072. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48073. /**
  48074. * Defines the default value of how much AO map is occluding the analytical lights
  48075. * (point spot...).
  48076. */
  48077. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48078. /**
  48079. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  48080. */
  48081. static readonly LIGHTFALLOFF_PHYSICAL: number;
  48082. /**
  48083. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  48084. * to enhance interoperability with other engines.
  48085. */
  48086. static readonly LIGHTFALLOFF_GLTF: number;
  48087. /**
  48088. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  48089. * to enhance interoperability with other materials.
  48090. */
  48091. static readonly LIGHTFALLOFF_STANDARD: number;
  48092. /**
  48093. * Intensity of the direct lights e.g. the four lights available in your scene.
  48094. * This impacts both the direct diffuse and specular highlights.
  48095. */
  48096. protected _directIntensity: number;
  48097. /**
  48098. * Intensity of the emissive part of the material.
  48099. * This helps controlling the emissive effect without modifying the emissive color.
  48100. */
  48101. protected _emissiveIntensity: number;
  48102. /**
  48103. * Intensity of the environment e.g. how much the environment will light the object
  48104. * either through harmonics for rough material or through the refelction for shiny ones.
  48105. */
  48106. protected _environmentIntensity: number;
  48107. /**
  48108. * This is a special control allowing the reduction of the specular highlights coming from the
  48109. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48110. */
  48111. protected _specularIntensity: number;
  48112. /**
  48113. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  48114. */
  48115. private _lightingInfos;
  48116. /**
  48117. * Debug Control allowing disabling the bump map on this material.
  48118. */
  48119. protected _disableBumpMap: boolean;
  48120. /**
  48121. * AKA Diffuse Texture in standard nomenclature.
  48122. */
  48123. protected _albedoTexture: Nullable<BaseTexture>;
  48124. /**
  48125. * AKA Occlusion Texture in other nomenclature.
  48126. */
  48127. protected _ambientTexture: Nullable<BaseTexture>;
  48128. /**
  48129. * AKA Occlusion Texture Intensity in other nomenclature.
  48130. */
  48131. protected _ambientTextureStrength: number;
  48132. /**
  48133. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48134. * 1 means it completely occludes it
  48135. * 0 mean it has no impact
  48136. */
  48137. protected _ambientTextureImpactOnAnalyticalLights: number;
  48138. /**
  48139. * Stores the alpha values in a texture.
  48140. */
  48141. protected _opacityTexture: Nullable<BaseTexture>;
  48142. /**
  48143. * Stores the reflection values in a texture.
  48144. */
  48145. protected _reflectionTexture: Nullable<BaseTexture>;
  48146. /**
  48147. * Stores the emissive values in a texture.
  48148. */
  48149. protected _emissiveTexture: Nullable<BaseTexture>;
  48150. /**
  48151. * AKA Specular texture in other nomenclature.
  48152. */
  48153. protected _reflectivityTexture: Nullable<BaseTexture>;
  48154. /**
  48155. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48156. */
  48157. protected _metallicTexture: Nullable<BaseTexture>;
  48158. /**
  48159. * Specifies the metallic scalar of the metallic/roughness workflow.
  48160. * Can also be used to scale the metalness values of the metallic texture.
  48161. */
  48162. protected _metallic: Nullable<number>;
  48163. /**
  48164. * Specifies the roughness scalar of the metallic/roughness workflow.
  48165. * Can also be used to scale the roughness values of the metallic texture.
  48166. */
  48167. protected _roughness: Nullable<number>;
  48168. /**
  48169. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48170. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48171. */
  48172. protected _microSurfaceTexture: Nullable<BaseTexture>;
  48173. /**
  48174. * Stores surface normal data used to displace a mesh in a texture.
  48175. */
  48176. protected _bumpTexture: Nullable<BaseTexture>;
  48177. /**
  48178. * Stores the pre-calculated light information of a mesh in a texture.
  48179. */
  48180. protected _lightmapTexture: Nullable<BaseTexture>;
  48181. /**
  48182. * The color of a material in ambient lighting.
  48183. */
  48184. protected _ambientColor: Color3;
  48185. /**
  48186. * AKA Diffuse Color in other nomenclature.
  48187. */
  48188. protected _albedoColor: Color3;
  48189. /**
  48190. * AKA Specular Color in other nomenclature.
  48191. */
  48192. protected _reflectivityColor: Color3;
  48193. /**
  48194. * The color applied when light is reflected from a material.
  48195. */
  48196. protected _reflectionColor: Color3;
  48197. /**
  48198. * The color applied when light is emitted from a material.
  48199. */
  48200. protected _emissiveColor: Color3;
  48201. /**
  48202. * AKA Glossiness in other nomenclature.
  48203. */
  48204. protected _microSurface: number;
  48205. /**
  48206. * Specifies that the material will use the light map as a show map.
  48207. */
  48208. protected _useLightmapAsShadowmap: boolean;
  48209. /**
  48210. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48211. * makes the reflect vector face the model (under horizon).
  48212. */
  48213. protected _useHorizonOcclusion: boolean;
  48214. /**
  48215. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48216. * too much the area relying on ambient texture to define their ambient occlusion.
  48217. */
  48218. protected _useRadianceOcclusion: boolean;
  48219. /**
  48220. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48221. */
  48222. protected _useAlphaFromAlbedoTexture: boolean;
  48223. /**
  48224. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  48225. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48226. */
  48227. protected _useSpecularOverAlpha: boolean;
  48228. /**
  48229. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48230. */
  48231. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48232. /**
  48233. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48234. */
  48235. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  48236. /**
  48237. * Specifies if the metallic texture contains the roughness information in its green channel.
  48238. */
  48239. protected _useRoughnessFromMetallicTextureGreen: boolean;
  48240. /**
  48241. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48242. */
  48243. protected _useMetallnessFromMetallicTextureBlue: boolean;
  48244. /**
  48245. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48246. */
  48247. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  48248. /**
  48249. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48250. */
  48251. protected _useAmbientInGrayScale: boolean;
  48252. /**
  48253. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48254. * The material will try to infer what glossiness each pixel should be.
  48255. */
  48256. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  48257. /**
  48258. * Defines the falloff type used in this material.
  48259. * It by default is Physical.
  48260. */
  48261. protected _lightFalloff: number;
  48262. /**
  48263. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48264. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48265. */
  48266. protected _useRadianceOverAlpha: boolean;
  48267. /**
  48268. * Allows using an object space normal map (instead of tangent space).
  48269. */
  48270. protected _useObjectSpaceNormalMap: boolean;
  48271. /**
  48272. * Allows using the bump map in parallax mode.
  48273. */
  48274. protected _useParallax: boolean;
  48275. /**
  48276. * Allows using the bump map in parallax occlusion mode.
  48277. */
  48278. protected _useParallaxOcclusion: boolean;
  48279. /**
  48280. * Controls the scale bias of the parallax mode.
  48281. */
  48282. protected _parallaxScaleBias: number;
  48283. /**
  48284. * If sets to true, disables all the lights affecting the material.
  48285. */
  48286. protected _disableLighting: boolean;
  48287. /**
  48288. * Number of Simultaneous lights allowed on the material.
  48289. */
  48290. protected _maxSimultaneousLights: number;
  48291. /**
  48292. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48293. */
  48294. protected _invertNormalMapX: boolean;
  48295. /**
  48296. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48297. */
  48298. protected _invertNormalMapY: boolean;
  48299. /**
  48300. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48301. */
  48302. protected _twoSidedLighting: boolean;
  48303. /**
  48304. * Defines the alpha limits in alpha test mode.
  48305. */
  48306. protected _alphaCutOff: number;
  48307. /**
  48308. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48309. */
  48310. protected _forceAlphaTest: boolean;
  48311. /**
  48312. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48313. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48314. */
  48315. protected _useAlphaFresnel: boolean;
  48316. /**
  48317. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48318. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48319. */
  48320. protected _useLinearAlphaFresnel: boolean;
  48321. /**
  48322. * The transparency mode of the material.
  48323. */
  48324. protected _transparencyMode: Nullable<number>;
  48325. /**
  48326. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  48327. * from cos thetav and roughness:
  48328. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  48329. */
  48330. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  48331. /**
  48332. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48333. */
  48334. protected _forceIrradianceInFragment: boolean;
  48335. /**
  48336. * Force normal to face away from face.
  48337. */
  48338. protected _forceNormalForward: boolean;
  48339. /**
  48340. * Enables specular anti aliasing in the PBR shader.
  48341. * It will both interacts on the Geometry for analytical and IBL lighting.
  48342. * It also prefilter the roughness map based on the bump values.
  48343. */
  48344. protected _enableSpecularAntiAliasing: boolean;
  48345. /**
  48346. * Default configuration related to image processing available in the PBR Material.
  48347. */
  48348. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48349. /**
  48350. * Keep track of the image processing observer to allow dispose and replace.
  48351. */
  48352. private _imageProcessingObserver;
  48353. /**
  48354. * Attaches a new image processing configuration to the PBR Material.
  48355. * @param configuration
  48356. */
  48357. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48358. /**
  48359. * Stores the available render targets.
  48360. */
  48361. private _renderTargets;
  48362. /**
  48363. * Sets the global ambient color for the material used in lighting calculations.
  48364. */
  48365. private _globalAmbientColor;
  48366. /**
  48367. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  48368. */
  48369. private _useLogarithmicDepth;
  48370. /**
  48371. * If set to true, no lighting calculations will be applied.
  48372. */
  48373. private _unlit;
  48374. private _debugMode;
  48375. /**
  48376. * @hidden
  48377. * This is reserved for the inspector.
  48378. * Defines the material debug mode.
  48379. * It helps seeing only some components of the material while troubleshooting.
  48380. */
  48381. debugMode: number;
  48382. /**
  48383. * @hidden
  48384. * This is reserved for the inspector.
  48385. * Specify from where on screen the debug mode should start.
  48386. * The value goes from -1 (full screen) to 1 (not visible)
  48387. * It helps with side by side comparison against the final render
  48388. * This defaults to -1
  48389. */
  48390. private debugLimit;
  48391. /**
  48392. * @hidden
  48393. * This is reserved for the inspector.
  48394. * As the default viewing range might not be enough (if the ambient is really small for instance)
  48395. * You can use the factor to better multiply the final value.
  48396. */
  48397. private debugFactor;
  48398. /**
  48399. * Defines the clear coat layer parameters for the material.
  48400. */
  48401. readonly clearCoat: PBRClearCoatConfiguration;
  48402. /**
  48403. * Defines the anisotropic parameters for the material.
  48404. */
  48405. readonly anisotropy: PBRAnisotropicConfiguration;
  48406. /**
  48407. * Defines the BRDF parameters for the material.
  48408. */
  48409. readonly brdf: PBRBRDFConfiguration;
  48410. /**
  48411. * Defines the Sheen parameters for the material.
  48412. */
  48413. readonly sheen: PBRSheenConfiguration;
  48414. /**
  48415. * Defines the SubSurface parameters for the material.
  48416. */
  48417. readonly subSurface: PBRSubSurfaceConfiguration;
  48418. /**
  48419. * Custom callback helping to override the default shader used in the material.
  48420. */
  48421. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  48422. /**
  48423. * Instantiates a new PBRMaterial instance.
  48424. *
  48425. * @param name The material name
  48426. * @param scene The scene the material will be use in.
  48427. */
  48428. constructor(name: string, scene: Scene);
  48429. /**
  48430. * Gets a boolean indicating that current material needs to register RTT
  48431. */
  48432. readonly hasRenderTargetTextures: boolean;
  48433. /**
  48434. * Gets the name of the material class.
  48435. */
  48436. getClassName(): string;
  48437. /**
  48438. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48439. */
  48440. /**
  48441. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48442. */
  48443. useLogarithmicDepth: boolean;
  48444. /**
  48445. * Gets the current transparency mode.
  48446. */
  48447. /**
  48448. * Sets the transparency mode of the material.
  48449. *
  48450. * | Value | Type | Description |
  48451. * | ----- | ----------------------------------- | ----------- |
  48452. * | 0 | OPAQUE | |
  48453. * | 1 | ALPHATEST | |
  48454. * | 2 | ALPHABLEND | |
  48455. * | 3 | ALPHATESTANDBLEND | |
  48456. *
  48457. */
  48458. transparencyMode: Nullable<number>;
  48459. /**
  48460. * Returns true if alpha blending should be disabled.
  48461. */
  48462. private readonly _disableAlphaBlending;
  48463. /**
  48464. * Specifies whether or not this material should be rendered in alpha blend mode.
  48465. */
  48466. needAlphaBlending(): boolean;
  48467. /**
  48468. * Specifies if the mesh will require alpha blending.
  48469. * @param mesh - BJS mesh.
  48470. */
  48471. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  48472. /**
  48473. * Specifies whether or not this material should be rendered in alpha test mode.
  48474. */
  48475. needAlphaTesting(): boolean;
  48476. /**
  48477. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  48478. */
  48479. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  48480. /**
  48481. * Gets the texture used for the alpha test.
  48482. */
  48483. getAlphaTestTexture(): Nullable<BaseTexture>;
  48484. /**
  48485. * Specifies that the submesh is ready to be used.
  48486. * @param mesh - BJS mesh.
  48487. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  48488. * @param useInstances - Specifies that instances should be used.
  48489. * @returns - boolean indicating that the submesh is ready or not.
  48490. */
  48491. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48492. /**
  48493. * Specifies if the material uses metallic roughness workflow.
  48494. * @returns boolean specifiying if the material uses metallic roughness workflow.
  48495. */
  48496. isMetallicWorkflow(): boolean;
  48497. private _prepareEffect;
  48498. private _prepareDefines;
  48499. /**
  48500. * Force shader compilation
  48501. */
  48502. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  48503. clipPlane: boolean;
  48504. }>): void;
  48505. /**
  48506. * Initializes the uniform buffer layout for the shader.
  48507. */
  48508. buildUniformLayout(): void;
  48509. /**
  48510. * Unbinds the material from the mesh
  48511. */
  48512. unbind(): void;
  48513. /**
  48514. * Binds the submesh data.
  48515. * @param world - The world matrix.
  48516. * @param mesh - The BJS mesh.
  48517. * @param subMesh - A submesh of the BJS mesh.
  48518. */
  48519. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48520. /**
  48521. * Returns the animatable textures.
  48522. * @returns - Array of animatable textures.
  48523. */
  48524. getAnimatables(): IAnimatable[];
  48525. /**
  48526. * Returns the texture used for reflections.
  48527. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  48528. */
  48529. private _getReflectionTexture;
  48530. /**
  48531. * Returns an array of the actively used textures.
  48532. * @returns - Array of BaseTextures
  48533. */
  48534. getActiveTextures(): BaseTexture[];
  48535. /**
  48536. * Checks to see if a texture is used in the material.
  48537. * @param texture - Base texture to use.
  48538. * @returns - Boolean specifying if a texture is used in the material.
  48539. */
  48540. hasTexture(texture: BaseTexture): boolean;
  48541. /**
  48542. * Disposes the resources of the material.
  48543. * @param forceDisposeEffect - Forces the disposal of effects.
  48544. * @param forceDisposeTextures - Forces the disposal of all textures.
  48545. */
  48546. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48547. }
  48548. }
  48549. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  48550. import { Nullable } from "babylonjs/types";
  48551. import { Scene } from "babylonjs/scene";
  48552. import { Color3 } from "babylonjs/Maths/math.color";
  48553. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48554. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48555. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48556. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48557. /**
  48558. * The Physically based material of BJS.
  48559. *
  48560. * This offers the main features of a standard PBR material.
  48561. * For more information, please refer to the documentation :
  48562. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48563. */
  48564. export class PBRMaterial extends PBRBaseMaterial {
  48565. /**
  48566. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48567. */
  48568. static readonly PBRMATERIAL_OPAQUE: number;
  48569. /**
  48570. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48571. */
  48572. static readonly PBRMATERIAL_ALPHATEST: number;
  48573. /**
  48574. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48575. */
  48576. static readonly PBRMATERIAL_ALPHABLEND: number;
  48577. /**
  48578. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48579. * They are also discarded below the alpha cutoff threshold to improve performances.
  48580. */
  48581. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48582. /**
  48583. * Defines the default value of how much AO map is occluding the analytical lights
  48584. * (point spot...).
  48585. */
  48586. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48587. /**
  48588. * Intensity of the direct lights e.g. the four lights available in your scene.
  48589. * This impacts both the direct diffuse and specular highlights.
  48590. */
  48591. directIntensity: number;
  48592. /**
  48593. * Intensity of the emissive part of the material.
  48594. * This helps controlling the emissive effect without modifying the emissive color.
  48595. */
  48596. emissiveIntensity: number;
  48597. /**
  48598. * Intensity of the environment e.g. how much the environment will light the object
  48599. * either through harmonics for rough material or through the refelction for shiny ones.
  48600. */
  48601. environmentIntensity: number;
  48602. /**
  48603. * This is a special control allowing the reduction of the specular highlights coming from the
  48604. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48605. */
  48606. specularIntensity: number;
  48607. /**
  48608. * Debug Control allowing disabling the bump map on this material.
  48609. */
  48610. disableBumpMap: boolean;
  48611. /**
  48612. * AKA Diffuse Texture in standard nomenclature.
  48613. */
  48614. albedoTexture: BaseTexture;
  48615. /**
  48616. * AKA Occlusion Texture in other nomenclature.
  48617. */
  48618. ambientTexture: BaseTexture;
  48619. /**
  48620. * AKA Occlusion Texture Intensity in other nomenclature.
  48621. */
  48622. ambientTextureStrength: number;
  48623. /**
  48624. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48625. * 1 means it completely occludes it
  48626. * 0 mean it has no impact
  48627. */
  48628. ambientTextureImpactOnAnalyticalLights: number;
  48629. /**
  48630. * Stores the alpha values in a texture.
  48631. */
  48632. opacityTexture: BaseTexture;
  48633. /**
  48634. * Stores the reflection values in a texture.
  48635. */
  48636. reflectionTexture: Nullable<BaseTexture>;
  48637. /**
  48638. * Stores the emissive values in a texture.
  48639. */
  48640. emissiveTexture: BaseTexture;
  48641. /**
  48642. * AKA Specular texture in other nomenclature.
  48643. */
  48644. reflectivityTexture: BaseTexture;
  48645. /**
  48646. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48647. */
  48648. metallicTexture: BaseTexture;
  48649. /**
  48650. * Specifies the metallic scalar of the metallic/roughness workflow.
  48651. * Can also be used to scale the metalness values of the metallic texture.
  48652. */
  48653. metallic: Nullable<number>;
  48654. /**
  48655. * Specifies the roughness scalar of the metallic/roughness workflow.
  48656. * Can also be used to scale the roughness values of the metallic texture.
  48657. */
  48658. roughness: Nullable<number>;
  48659. /**
  48660. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48661. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48662. */
  48663. microSurfaceTexture: BaseTexture;
  48664. /**
  48665. * Stores surface normal data used to displace a mesh in a texture.
  48666. */
  48667. bumpTexture: BaseTexture;
  48668. /**
  48669. * Stores the pre-calculated light information of a mesh in a texture.
  48670. */
  48671. lightmapTexture: BaseTexture;
  48672. /**
  48673. * Stores the refracted light information in a texture.
  48674. */
  48675. refractionTexture: Nullable<BaseTexture>;
  48676. /**
  48677. * The color of a material in ambient lighting.
  48678. */
  48679. ambientColor: Color3;
  48680. /**
  48681. * AKA Diffuse Color in other nomenclature.
  48682. */
  48683. albedoColor: Color3;
  48684. /**
  48685. * AKA Specular Color in other nomenclature.
  48686. */
  48687. reflectivityColor: Color3;
  48688. /**
  48689. * The color reflected from the material.
  48690. */
  48691. reflectionColor: Color3;
  48692. /**
  48693. * The color emitted from the material.
  48694. */
  48695. emissiveColor: Color3;
  48696. /**
  48697. * AKA Glossiness in other nomenclature.
  48698. */
  48699. microSurface: number;
  48700. /**
  48701. * source material index of refraction (IOR)' / 'destination material IOR.
  48702. */
  48703. indexOfRefraction: number;
  48704. /**
  48705. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48706. */
  48707. invertRefractionY: boolean;
  48708. /**
  48709. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48710. * Materials half opaque for instance using refraction could benefit from this control.
  48711. */
  48712. linkRefractionWithTransparency: boolean;
  48713. /**
  48714. * If true, the light map contains occlusion information instead of lighting info.
  48715. */
  48716. useLightmapAsShadowmap: boolean;
  48717. /**
  48718. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48719. */
  48720. useAlphaFromAlbedoTexture: boolean;
  48721. /**
  48722. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48723. */
  48724. forceAlphaTest: boolean;
  48725. /**
  48726. * Defines the alpha limits in alpha test mode.
  48727. */
  48728. alphaCutOff: number;
  48729. /**
  48730. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48731. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48732. */
  48733. useSpecularOverAlpha: boolean;
  48734. /**
  48735. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48736. */
  48737. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48738. /**
  48739. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48740. */
  48741. useRoughnessFromMetallicTextureAlpha: boolean;
  48742. /**
  48743. * Specifies if the metallic texture contains the roughness information in its green channel.
  48744. */
  48745. useRoughnessFromMetallicTextureGreen: boolean;
  48746. /**
  48747. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48748. */
  48749. useMetallnessFromMetallicTextureBlue: boolean;
  48750. /**
  48751. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48752. */
  48753. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48754. /**
  48755. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48756. */
  48757. useAmbientInGrayScale: boolean;
  48758. /**
  48759. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48760. * The material will try to infer what glossiness each pixel should be.
  48761. */
  48762. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48763. /**
  48764. * BJS is using an harcoded light falloff based on a manually sets up range.
  48765. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48766. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48767. */
  48768. /**
  48769. * BJS is using an harcoded light falloff based on a manually sets up range.
  48770. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48771. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48772. */
  48773. usePhysicalLightFalloff: boolean;
  48774. /**
  48775. * In order to support the falloff compatibility with gltf, a special mode has been added
  48776. * to reproduce the gltf light falloff.
  48777. */
  48778. /**
  48779. * In order to support the falloff compatibility with gltf, a special mode has been added
  48780. * to reproduce the gltf light falloff.
  48781. */
  48782. useGLTFLightFalloff: boolean;
  48783. /**
  48784. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48785. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48786. */
  48787. useRadianceOverAlpha: boolean;
  48788. /**
  48789. * Allows using an object space normal map (instead of tangent space).
  48790. */
  48791. useObjectSpaceNormalMap: boolean;
  48792. /**
  48793. * Allows using the bump map in parallax mode.
  48794. */
  48795. useParallax: boolean;
  48796. /**
  48797. * Allows using the bump map in parallax occlusion mode.
  48798. */
  48799. useParallaxOcclusion: boolean;
  48800. /**
  48801. * Controls the scale bias of the parallax mode.
  48802. */
  48803. parallaxScaleBias: number;
  48804. /**
  48805. * If sets to true, disables all the lights affecting the material.
  48806. */
  48807. disableLighting: boolean;
  48808. /**
  48809. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48810. */
  48811. forceIrradianceInFragment: boolean;
  48812. /**
  48813. * Number of Simultaneous lights allowed on the material.
  48814. */
  48815. maxSimultaneousLights: number;
  48816. /**
  48817. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48818. */
  48819. invertNormalMapX: boolean;
  48820. /**
  48821. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48822. */
  48823. invertNormalMapY: boolean;
  48824. /**
  48825. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48826. */
  48827. twoSidedLighting: boolean;
  48828. /**
  48829. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48830. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48831. */
  48832. useAlphaFresnel: boolean;
  48833. /**
  48834. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48835. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48836. */
  48837. useLinearAlphaFresnel: boolean;
  48838. /**
  48839. * Let user defines the brdf lookup texture used for IBL.
  48840. * A default 8bit version is embedded but you could point at :
  48841. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  48842. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48843. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  48844. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48845. */
  48846. environmentBRDFTexture: Nullable<BaseTexture>;
  48847. /**
  48848. * Force normal to face away from face.
  48849. */
  48850. forceNormalForward: boolean;
  48851. /**
  48852. * Enables specular anti aliasing in the PBR shader.
  48853. * It will both interacts on the Geometry for analytical and IBL lighting.
  48854. * It also prefilter the roughness map based on the bump values.
  48855. */
  48856. enableSpecularAntiAliasing: boolean;
  48857. /**
  48858. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48859. * makes the reflect vector face the model (under horizon).
  48860. */
  48861. useHorizonOcclusion: boolean;
  48862. /**
  48863. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48864. * too much the area relying on ambient texture to define their ambient occlusion.
  48865. */
  48866. useRadianceOcclusion: boolean;
  48867. /**
  48868. * If set to true, no lighting calculations will be applied.
  48869. */
  48870. unlit: boolean;
  48871. /**
  48872. * Gets the image processing configuration used either in this material.
  48873. */
  48874. /**
  48875. * Sets the Default image processing configuration used either in the this material.
  48876. *
  48877. * If sets to null, the scene one is in use.
  48878. */
  48879. imageProcessingConfiguration: ImageProcessingConfiguration;
  48880. /**
  48881. * Gets wether the color curves effect is enabled.
  48882. */
  48883. /**
  48884. * Sets wether the color curves effect is enabled.
  48885. */
  48886. cameraColorCurvesEnabled: boolean;
  48887. /**
  48888. * Gets wether the color grading effect is enabled.
  48889. */
  48890. /**
  48891. * Gets wether the color grading effect is enabled.
  48892. */
  48893. cameraColorGradingEnabled: boolean;
  48894. /**
  48895. * Gets wether tonemapping is enabled or not.
  48896. */
  48897. /**
  48898. * Sets wether tonemapping is enabled or not
  48899. */
  48900. cameraToneMappingEnabled: boolean;
  48901. /**
  48902. * The camera exposure used on this material.
  48903. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48904. * This corresponds to a photographic exposure.
  48905. */
  48906. /**
  48907. * The camera exposure used on this material.
  48908. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48909. * This corresponds to a photographic exposure.
  48910. */
  48911. cameraExposure: number;
  48912. /**
  48913. * Gets The camera contrast used on this material.
  48914. */
  48915. /**
  48916. * Sets The camera contrast used on this material.
  48917. */
  48918. cameraContrast: number;
  48919. /**
  48920. * Gets the Color Grading 2D Lookup Texture.
  48921. */
  48922. /**
  48923. * Sets the Color Grading 2D Lookup Texture.
  48924. */
  48925. cameraColorGradingTexture: Nullable<BaseTexture>;
  48926. /**
  48927. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48928. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48929. * 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;
  48930. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48931. */
  48932. /**
  48933. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48934. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48935. * 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;
  48936. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48937. */
  48938. cameraColorCurves: Nullable<ColorCurves>;
  48939. /**
  48940. * Instantiates a new PBRMaterial instance.
  48941. *
  48942. * @param name The material name
  48943. * @param scene The scene the material will be use in.
  48944. */
  48945. constructor(name: string, scene: Scene);
  48946. /**
  48947. * Returns the name of this material class.
  48948. */
  48949. getClassName(): string;
  48950. /**
  48951. * Makes a duplicate of the current material.
  48952. * @param name - name to use for the new material.
  48953. */
  48954. clone(name: string): PBRMaterial;
  48955. /**
  48956. * Serializes this PBR Material.
  48957. * @returns - An object with the serialized material.
  48958. */
  48959. serialize(): any;
  48960. /**
  48961. * Parses a PBR Material from a serialized object.
  48962. * @param source - Serialized object.
  48963. * @param scene - BJS scene instance.
  48964. * @param rootUrl - url for the scene object
  48965. * @returns - PBRMaterial
  48966. */
  48967. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  48968. }
  48969. }
  48970. declare module "babylonjs/Misc/dds" {
  48971. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48972. import { Engine } from "babylonjs/Engines/engine";
  48973. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48974. import { Nullable } from "babylonjs/types";
  48975. import { Scene } from "babylonjs/scene";
  48976. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  48977. /**
  48978. * Direct draw surface info
  48979. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48980. */
  48981. export interface DDSInfo {
  48982. /**
  48983. * Width of the texture
  48984. */
  48985. width: number;
  48986. /**
  48987. * Width of the texture
  48988. */
  48989. height: number;
  48990. /**
  48991. * Number of Mipmaps for the texture
  48992. * @see https://en.wikipedia.org/wiki/Mipmap
  48993. */
  48994. mipmapCount: number;
  48995. /**
  48996. * If the textures format is a known fourCC format
  48997. * @see https://www.fourcc.org/
  48998. */
  48999. isFourCC: boolean;
  49000. /**
  49001. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  49002. */
  49003. isRGB: boolean;
  49004. /**
  49005. * If the texture is a lumincance format
  49006. */
  49007. isLuminance: boolean;
  49008. /**
  49009. * If this is a cube texture
  49010. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  49011. */
  49012. isCube: boolean;
  49013. /**
  49014. * If the texture is a compressed format eg. FOURCC_DXT1
  49015. */
  49016. isCompressed: boolean;
  49017. /**
  49018. * The dxgiFormat of the texture
  49019. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  49020. */
  49021. dxgiFormat: number;
  49022. /**
  49023. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  49024. */
  49025. textureType: number;
  49026. /**
  49027. * Sphericle polynomial created for the dds texture
  49028. */
  49029. sphericalPolynomial?: SphericalPolynomial;
  49030. }
  49031. /**
  49032. * Class used to provide DDS decompression tools
  49033. */
  49034. export class DDSTools {
  49035. /**
  49036. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  49037. */
  49038. static StoreLODInAlphaChannel: boolean;
  49039. /**
  49040. * Gets DDS information from an array buffer
  49041. * @param arrayBuffer defines the array buffer to read data from
  49042. * @returns the DDS information
  49043. */
  49044. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  49045. private static _FloatView;
  49046. private static _Int32View;
  49047. private static _ToHalfFloat;
  49048. private static _FromHalfFloat;
  49049. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  49050. private static _GetHalfFloatRGBAArrayBuffer;
  49051. private static _GetFloatRGBAArrayBuffer;
  49052. private static _GetFloatAsUIntRGBAArrayBuffer;
  49053. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  49054. private static _GetRGBAArrayBuffer;
  49055. private static _ExtractLongWordOrder;
  49056. private static _GetRGBArrayBuffer;
  49057. private static _GetLuminanceArrayBuffer;
  49058. /**
  49059. * Uploads DDS Levels to a Babylon Texture
  49060. * @hidden
  49061. */
  49062. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  49063. }
  49064. module "babylonjs/Engines/engine" {
  49065. interface Engine {
  49066. /**
  49067. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  49068. * @param rootUrl defines the url where the file to load is located
  49069. * @param scene defines the current scene
  49070. * @param lodScale defines scale to apply to the mip map selection
  49071. * @param lodOffset defines offset to apply to the mip map selection
  49072. * @param onLoad defines an optional callback raised when the texture is loaded
  49073. * @param onError defines an optional callback raised if there is an issue to load the texture
  49074. * @param format defines the format of the data
  49075. * @param forcedExtension defines the extension to use to pick the right loader
  49076. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  49077. * @returns the cube texture as an InternalTexture
  49078. */
  49079. 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;
  49080. }
  49081. }
  49082. }
  49083. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  49084. import { Nullable } from "babylonjs/types";
  49085. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49086. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49087. /**
  49088. * Implementation of the DDS Texture Loader.
  49089. * @hidden
  49090. */
  49091. export class _DDSTextureLoader implements IInternalTextureLoader {
  49092. /**
  49093. * Defines wether the loader supports cascade loading the different faces.
  49094. */
  49095. readonly supportCascades: boolean;
  49096. /**
  49097. * This returns if the loader support the current file information.
  49098. * @param extension defines the file extension of the file being loaded
  49099. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49100. * @param fallback defines the fallback internal texture if any
  49101. * @param isBase64 defines whether the texture is encoded as a base64
  49102. * @param isBuffer defines whether the texture data are stored as a buffer
  49103. * @returns true if the loader can load the specified file
  49104. */
  49105. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49106. /**
  49107. * Transform the url before loading if required.
  49108. * @param rootUrl the url of the texture
  49109. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49110. * @returns the transformed texture
  49111. */
  49112. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49113. /**
  49114. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49115. * @param rootUrl the url of the texture
  49116. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49117. * @returns the fallback texture
  49118. */
  49119. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49120. /**
  49121. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49122. * @param data contains the texture data
  49123. * @param texture defines the BabylonJS internal texture
  49124. * @param createPolynomials will be true if polynomials have been requested
  49125. * @param onLoad defines the callback to trigger once the texture is ready
  49126. * @param onError defines the callback to trigger in case of error
  49127. */
  49128. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49129. /**
  49130. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49131. * @param data contains the texture data
  49132. * @param texture defines the BabylonJS internal texture
  49133. * @param callback defines the method to call once ready to upload
  49134. */
  49135. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49136. }
  49137. }
  49138. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49139. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49140. /** @hidden */
  49141. export var rgbdEncodePixelShader: {
  49142. name: string;
  49143. shader: string;
  49144. };
  49145. }
  49146. declare module "babylonjs/Misc/environmentTextureTools" {
  49147. import { Nullable } from "babylonjs/types";
  49148. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49149. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49150. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49151. import "babylonjs/Engines/Extensions/engine.renderTarget";
  49152. import "babylonjs/Shaders/rgbdEncode.fragment";
  49153. import "babylonjs/Shaders/rgbdDecode.fragment";
  49154. /**
  49155. * Raw texture data and descriptor sufficient for WebGL texture upload
  49156. */
  49157. export interface EnvironmentTextureInfo {
  49158. /**
  49159. * Version of the environment map
  49160. */
  49161. version: number;
  49162. /**
  49163. * Width of image
  49164. */
  49165. width: number;
  49166. /**
  49167. * Irradiance information stored in the file.
  49168. */
  49169. irradiance: any;
  49170. /**
  49171. * Specular information stored in the file.
  49172. */
  49173. specular: any;
  49174. }
  49175. /**
  49176. * Sets of helpers addressing the serialization and deserialization of environment texture
  49177. * stored in a BabylonJS env file.
  49178. * Those files are usually stored as .env files.
  49179. */
  49180. export class EnvironmentTextureTools {
  49181. /**
  49182. * Magic number identifying the env file.
  49183. */
  49184. private static _MagicBytes;
  49185. /**
  49186. * Gets the environment info from an env file.
  49187. * @param data The array buffer containing the .env bytes.
  49188. * @returns the environment file info (the json header) if successfully parsed.
  49189. */
  49190. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  49191. /**
  49192. * Creates an environment texture from a loaded cube texture.
  49193. * @param texture defines the cube texture to convert in env file
  49194. * @return a promise containing the environment data if succesfull.
  49195. */
  49196. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49197. /**
  49198. * Creates a JSON representation of the spherical data.
  49199. * @param texture defines the texture containing the polynomials
  49200. * @return the JSON representation of the spherical info
  49201. */
  49202. private static _CreateEnvTextureIrradiance;
  49203. /**
  49204. * Uploads the texture info contained in the env file to the GPU.
  49205. * @param texture defines the internal texture to upload to
  49206. * @param arrayBuffer defines the buffer cotaining the data to load
  49207. * @param info defines the texture info retrieved through the GetEnvInfo method
  49208. * @returns a promise
  49209. */
  49210. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  49211. /**
  49212. * Uploads the levels of image data to the GPU.
  49213. * @param texture defines the internal texture to upload to
  49214. * @param imageData defines the array buffer views of image data [mipmap][face]
  49215. * @returns a promise
  49216. */
  49217. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49218. /**
  49219. * Uploads spherical polynomials information to the texture.
  49220. * @param texture defines the texture we are trying to upload the information to
  49221. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49222. */
  49223. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49224. /** @hidden */
  49225. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49226. }
  49227. }
  49228. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  49229. import { Nullable } from "babylonjs/types";
  49230. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49231. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49232. /**
  49233. * Implementation of the ENV Texture Loader.
  49234. * @hidden
  49235. */
  49236. export class _ENVTextureLoader implements IInternalTextureLoader {
  49237. /**
  49238. * Defines wether the loader supports cascade loading the different faces.
  49239. */
  49240. readonly supportCascades: boolean;
  49241. /**
  49242. * This returns if the loader support the current file information.
  49243. * @param extension defines the file extension of the file being loaded
  49244. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49245. * @param fallback defines the fallback internal texture if any
  49246. * @param isBase64 defines whether the texture is encoded as a base64
  49247. * @param isBuffer defines whether the texture data are stored as a buffer
  49248. * @returns true if the loader can load the specified file
  49249. */
  49250. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49251. /**
  49252. * Transform the url before loading if required.
  49253. * @param rootUrl the url of the texture
  49254. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49255. * @returns the transformed texture
  49256. */
  49257. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49258. /**
  49259. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49260. * @param rootUrl the url of the texture
  49261. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49262. * @returns the fallback texture
  49263. */
  49264. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49265. /**
  49266. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49267. * @param data contains the texture data
  49268. * @param texture defines the BabylonJS internal texture
  49269. * @param createPolynomials will be true if polynomials have been requested
  49270. * @param onLoad defines the callback to trigger once the texture is ready
  49271. * @param onError defines the callback to trigger in case of error
  49272. */
  49273. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49274. /**
  49275. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49276. * @param data contains the texture data
  49277. * @param texture defines the BabylonJS internal texture
  49278. * @param callback defines the method to call once ready to upload
  49279. */
  49280. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49281. }
  49282. }
  49283. declare module "babylonjs/Misc/khronosTextureContainer" {
  49284. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49285. /**
  49286. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49287. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49288. */
  49289. export class KhronosTextureContainer {
  49290. /** contents of the KTX container file */
  49291. arrayBuffer: any;
  49292. private static HEADER_LEN;
  49293. private static COMPRESSED_2D;
  49294. private static COMPRESSED_3D;
  49295. private static TEX_2D;
  49296. private static TEX_3D;
  49297. /**
  49298. * Gets the openGL type
  49299. */
  49300. glType: number;
  49301. /**
  49302. * Gets the openGL type size
  49303. */
  49304. glTypeSize: number;
  49305. /**
  49306. * Gets the openGL format
  49307. */
  49308. glFormat: number;
  49309. /**
  49310. * Gets the openGL internal format
  49311. */
  49312. glInternalFormat: number;
  49313. /**
  49314. * Gets the base internal format
  49315. */
  49316. glBaseInternalFormat: number;
  49317. /**
  49318. * Gets image width in pixel
  49319. */
  49320. pixelWidth: number;
  49321. /**
  49322. * Gets image height in pixel
  49323. */
  49324. pixelHeight: number;
  49325. /**
  49326. * Gets image depth in pixels
  49327. */
  49328. pixelDepth: number;
  49329. /**
  49330. * Gets the number of array elements
  49331. */
  49332. numberOfArrayElements: number;
  49333. /**
  49334. * Gets the number of faces
  49335. */
  49336. numberOfFaces: number;
  49337. /**
  49338. * Gets the number of mipmap levels
  49339. */
  49340. numberOfMipmapLevels: number;
  49341. /**
  49342. * Gets the bytes of key value data
  49343. */
  49344. bytesOfKeyValueData: number;
  49345. /**
  49346. * Gets the load type
  49347. */
  49348. loadType: number;
  49349. /**
  49350. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  49351. */
  49352. isInvalid: boolean;
  49353. /**
  49354. * Creates a new KhronosTextureContainer
  49355. * @param arrayBuffer contents of the KTX container file
  49356. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  49357. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  49358. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  49359. */
  49360. constructor(
  49361. /** contents of the KTX container file */
  49362. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  49363. /**
  49364. * Uploads KTX content to a Babylon Texture.
  49365. * It is assumed that the texture has already been created & is currently bound
  49366. * @hidden
  49367. */
  49368. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  49369. private _upload2DCompressedLevels;
  49370. }
  49371. }
  49372. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  49373. import { Nullable } from "babylonjs/types";
  49374. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49375. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49376. /**
  49377. * Implementation of the KTX Texture Loader.
  49378. * @hidden
  49379. */
  49380. export class _KTXTextureLoader implements IInternalTextureLoader {
  49381. /**
  49382. * Defines wether the loader supports cascade loading the different faces.
  49383. */
  49384. readonly supportCascades: boolean;
  49385. /**
  49386. * This returns if the loader support the current file information.
  49387. * @param extension defines the file extension of the file being loaded
  49388. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49389. * @param fallback defines the fallback internal texture if any
  49390. * @param isBase64 defines whether the texture is encoded as a base64
  49391. * @param isBuffer defines whether the texture data are stored as a buffer
  49392. * @returns true if the loader can load the specified file
  49393. */
  49394. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49395. /**
  49396. * Transform the url before loading if required.
  49397. * @param rootUrl the url of the texture
  49398. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49399. * @returns the transformed texture
  49400. */
  49401. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49402. /**
  49403. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49404. * @param rootUrl the url of the texture
  49405. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49406. * @returns the fallback texture
  49407. */
  49408. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49409. /**
  49410. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49411. * @param data contains the texture data
  49412. * @param texture defines the BabylonJS internal texture
  49413. * @param createPolynomials will be true if polynomials have been requested
  49414. * @param onLoad defines the callback to trigger once the texture is ready
  49415. * @param onError defines the callback to trigger in case of error
  49416. */
  49417. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49418. /**
  49419. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49420. * @param data contains the texture data
  49421. * @param texture defines the BabylonJS internal texture
  49422. * @param callback defines the method to call once ready to upload
  49423. */
  49424. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  49425. }
  49426. }
  49427. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  49428. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  49429. import { Scene } from "babylonjs/scene";
  49430. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  49431. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  49432. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  49433. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  49434. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  49435. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  49436. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49437. /**
  49438. * Options for the default xr helper
  49439. */
  49440. export class WebXRDefaultExperienceOptions {
  49441. /**
  49442. * Floor meshes that should be used for teleporting
  49443. */
  49444. floorMeshes: Array<AbstractMesh>;
  49445. }
  49446. /**
  49447. * Default experience which provides a similar setup to the previous webVRExperience
  49448. */
  49449. export class WebXRDefaultExperience {
  49450. /**
  49451. * Base experience
  49452. */
  49453. baseExperience: WebXRExperienceHelper;
  49454. /**
  49455. * Input experience extension
  49456. */
  49457. input: WebXRInput;
  49458. /**
  49459. * Loads the controller models
  49460. */
  49461. controllerModelLoader: WebXRControllerModelLoader;
  49462. /**
  49463. * Enables laser pointer and selection
  49464. */
  49465. pointerSelection: WebXRControllerPointerSelection;
  49466. /**
  49467. * Enables teleportation
  49468. */
  49469. teleportation: WebXRControllerTeleportation;
  49470. /**
  49471. * Enables ui for enetering/exiting xr
  49472. */
  49473. enterExitUI: WebXREnterExitUI;
  49474. /**
  49475. * Default output canvas xr should render to
  49476. */
  49477. outputCanvas: WebXRManagedOutputCanvas;
  49478. /**
  49479. * Creates the default xr experience
  49480. * @param scene scene
  49481. * @param options options for basic configuration
  49482. * @returns resulting WebXRDefaultExperience
  49483. */
  49484. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49485. private constructor();
  49486. /**
  49487. * DIsposes of the experience helper
  49488. */
  49489. dispose(): void;
  49490. }
  49491. }
  49492. declare module "babylonjs/Helpers/sceneHelpers" {
  49493. import { Nullable } from "babylonjs/types";
  49494. import { Mesh } from "babylonjs/Meshes/mesh";
  49495. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49496. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  49497. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  49498. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49499. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49500. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49501. import "babylonjs/Meshes/Builders/boxBuilder";
  49502. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  49503. /** @hidden */
  49504. export var _forceSceneHelpersToBundle: boolean;
  49505. module "babylonjs/scene" {
  49506. interface Scene {
  49507. /**
  49508. * Creates a default light for the scene.
  49509. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  49510. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  49511. */
  49512. createDefaultLight(replace?: boolean): void;
  49513. /**
  49514. * Creates a default camera for the scene.
  49515. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  49516. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49517. * @param replace has default false, when true replaces the active camera in the scene
  49518. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  49519. */
  49520. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49521. /**
  49522. * Creates a default camera and a default light.
  49523. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  49524. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49525. * @param replace has the default false, when true replaces the active camera/light in the scene
  49526. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  49527. */
  49528. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49529. /**
  49530. * Creates a new sky box
  49531. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  49532. * @param environmentTexture defines the texture to use as environment texture
  49533. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  49534. * @param scale defines the overall scale of the skybox
  49535. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  49536. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  49537. * @returns a new mesh holding the sky box
  49538. */
  49539. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  49540. /**
  49541. * Creates a new environment
  49542. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  49543. * @param options defines the options you can use to configure the environment
  49544. * @returns the new EnvironmentHelper
  49545. */
  49546. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  49547. /**
  49548. * Creates a new VREXperienceHelper
  49549. * @see http://doc.babylonjs.com/how_to/webvr_helper
  49550. * @param webVROptions defines the options used to create the new VREXperienceHelper
  49551. * @returns a new VREXperienceHelper
  49552. */
  49553. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  49554. /**
  49555. * Creates a new WebXRDefaultExperience
  49556. * @see http://doc.babylonjs.com/how_to/webxr
  49557. * @param options experience options
  49558. * @returns a promise for a new WebXRDefaultExperience
  49559. */
  49560. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49561. }
  49562. }
  49563. }
  49564. declare module "babylonjs/Helpers/videoDome" {
  49565. import { Scene } from "babylonjs/scene";
  49566. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49567. import { Mesh } from "babylonjs/Meshes/mesh";
  49568. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  49569. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49570. import "babylonjs/Meshes/Builders/sphereBuilder";
  49571. /**
  49572. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  49573. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  49574. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  49575. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49576. */
  49577. export class VideoDome extends TransformNode {
  49578. /**
  49579. * Define the video source as a Monoscopic panoramic 360 video.
  49580. */
  49581. static readonly MODE_MONOSCOPIC: number;
  49582. /**
  49583. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49584. */
  49585. static readonly MODE_TOPBOTTOM: number;
  49586. /**
  49587. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49588. */
  49589. static readonly MODE_SIDEBYSIDE: number;
  49590. private _useDirectMapping;
  49591. /**
  49592. * The video texture being displayed on the sphere
  49593. */
  49594. protected _videoTexture: VideoTexture;
  49595. /**
  49596. * Gets the video texture being displayed on the sphere
  49597. */
  49598. readonly videoTexture: VideoTexture;
  49599. /**
  49600. * The skybox material
  49601. */
  49602. protected _material: BackgroundMaterial;
  49603. /**
  49604. * The surface used for the skybox
  49605. */
  49606. protected _mesh: Mesh;
  49607. /**
  49608. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49609. * Also see the options.resolution property.
  49610. */
  49611. fovMultiplier: number;
  49612. private _videoMode;
  49613. /**
  49614. * Gets or set the current video mode for the video. It can be:
  49615. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  49616. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49617. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49618. */
  49619. videoMode: number;
  49620. /**
  49621. * Oberserver used in Stereoscopic VR Mode.
  49622. */
  49623. private _onBeforeCameraRenderObserver;
  49624. /**
  49625. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  49626. * @param name Element's name, child elements will append suffixes for their own names.
  49627. * @param urlsOrVideo defines the url(s) or the video element to use
  49628. * @param options An object containing optional or exposed sub element properties
  49629. */
  49630. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  49631. resolution?: number;
  49632. clickToPlay?: boolean;
  49633. autoPlay?: boolean;
  49634. loop?: boolean;
  49635. size?: number;
  49636. poster?: string;
  49637. faceForward?: boolean;
  49638. useDirectMapping?: boolean;
  49639. }, scene: Scene);
  49640. private _changeVideoMode;
  49641. /**
  49642. * Releases resources associated with this node.
  49643. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49644. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49645. */
  49646. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49647. }
  49648. }
  49649. declare module "babylonjs/Helpers/index" {
  49650. export * from "babylonjs/Helpers/environmentHelper";
  49651. export * from "babylonjs/Helpers/photoDome";
  49652. export * from "babylonjs/Helpers/sceneHelpers";
  49653. export * from "babylonjs/Helpers/videoDome";
  49654. }
  49655. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  49656. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  49657. import { IDisposable } from "babylonjs/scene";
  49658. import { Engine } from "babylonjs/Engines/engine";
  49659. /**
  49660. * This class can be used to get instrumentation data from a Babylon engine
  49661. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49662. */
  49663. export class EngineInstrumentation implements IDisposable {
  49664. /**
  49665. * Define the instrumented engine.
  49666. */
  49667. engine: Engine;
  49668. private _captureGPUFrameTime;
  49669. private _gpuFrameTimeToken;
  49670. private _gpuFrameTime;
  49671. private _captureShaderCompilationTime;
  49672. private _shaderCompilationTime;
  49673. private _onBeginFrameObserver;
  49674. private _onEndFrameObserver;
  49675. private _onBeforeShaderCompilationObserver;
  49676. private _onAfterShaderCompilationObserver;
  49677. /**
  49678. * Gets the perf counter used for GPU frame time
  49679. */
  49680. readonly gpuFrameTimeCounter: PerfCounter;
  49681. /**
  49682. * Gets the GPU frame time capture status
  49683. */
  49684. /**
  49685. * Enable or disable the GPU frame time capture
  49686. */
  49687. captureGPUFrameTime: boolean;
  49688. /**
  49689. * Gets the perf counter used for shader compilation time
  49690. */
  49691. readonly shaderCompilationTimeCounter: PerfCounter;
  49692. /**
  49693. * Gets the shader compilation time capture status
  49694. */
  49695. /**
  49696. * Enable or disable the shader compilation time capture
  49697. */
  49698. captureShaderCompilationTime: boolean;
  49699. /**
  49700. * Instantiates a new engine instrumentation.
  49701. * This class can be used to get instrumentation data from a Babylon engine
  49702. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49703. * @param engine Defines the engine to instrument
  49704. */
  49705. constructor(
  49706. /**
  49707. * Define the instrumented engine.
  49708. */
  49709. engine: Engine);
  49710. /**
  49711. * Dispose and release associated resources.
  49712. */
  49713. dispose(): void;
  49714. }
  49715. }
  49716. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  49717. import { Scene, IDisposable } from "babylonjs/scene";
  49718. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  49719. /**
  49720. * This class can be used to get instrumentation data from a Babylon engine
  49721. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49722. */
  49723. export class SceneInstrumentation implements IDisposable {
  49724. /**
  49725. * Defines the scene to instrument
  49726. */
  49727. scene: Scene;
  49728. private _captureActiveMeshesEvaluationTime;
  49729. private _activeMeshesEvaluationTime;
  49730. private _captureRenderTargetsRenderTime;
  49731. private _renderTargetsRenderTime;
  49732. private _captureFrameTime;
  49733. private _frameTime;
  49734. private _captureRenderTime;
  49735. private _renderTime;
  49736. private _captureInterFrameTime;
  49737. private _interFrameTime;
  49738. private _captureParticlesRenderTime;
  49739. private _particlesRenderTime;
  49740. private _captureSpritesRenderTime;
  49741. private _spritesRenderTime;
  49742. private _capturePhysicsTime;
  49743. private _physicsTime;
  49744. private _captureAnimationsTime;
  49745. private _animationsTime;
  49746. private _captureCameraRenderTime;
  49747. private _cameraRenderTime;
  49748. private _onBeforeActiveMeshesEvaluationObserver;
  49749. private _onAfterActiveMeshesEvaluationObserver;
  49750. private _onBeforeRenderTargetsRenderObserver;
  49751. private _onAfterRenderTargetsRenderObserver;
  49752. private _onAfterRenderObserver;
  49753. private _onBeforeDrawPhaseObserver;
  49754. private _onAfterDrawPhaseObserver;
  49755. private _onBeforeAnimationsObserver;
  49756. private _onBeforeParticlesRenderingObserver;
  49757. private _onAfterParticlesRenderingObserver;
  49758. private _onBeforeSpritesRenderingObserver;
  49759. private _onAfterSpritesRenderingObserver;
  49760. private _onBeforePhysicsObserver;
  49761. private _onAfterPhysicsObserver;
  49762. private _onAfterAnimationsObserver;
  49763. private _onBeforeCameraRenderObserver;
  49764. private _onAfterCameraRenderObserver;
  49765. /**
  49766. * Gets the perf counter used for active meshes evaluation time
  49767. */
  49768. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49769. /**
  49770. * Gets the active meshes evaluation time capture status
  49771. */
  49772. /**
  49773. * Enable or disable the active meshes evaluation time capture
  49774. */
  49775. captureActiveMeshesEvaluationTime: boolean;
  49776. /**
  49777. * Gets the perf counter used for render targets render time
  49778. */
  49779. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49780. /**
  49781. * Gets the render targets render time capture status
  49782. */
  49783. /**
  49784. * Enable or disable the render targets render time capture
  49785. */
  49786. captureRenderTargetsRenderTime: boolean;
  49787. /**
  49788. * Gets the perf counter used for particles render time
  49789. */
  49790. readonly particlesRenderTimeCounter: PerfCounter;
  49791. /**
  49792. * Gets the particles render time capture status
  49793. */
  49794. /**
  49795. * Enable or disable the particles render time capture
  49796. */
  49797. captureParticlesRenderTime: boolean;
  49798. /**
  49799. * Gets the perf counter used for sprites render time
  49800. */
  49801. readonly spritesRenderTimeCounter: PerfCounter;
  49802. /**
  49803. * Gets the sprites render time capture status
  49804. */
  49805. /**
  49806. * Enable or disable the sprites render time capture
  49807. */
  49808. captureSpritesRenderTime: boolean;
  49809. /**
  49810. * Gets the perf counter used for physics time
  49811. */
  49812. readonly physicsTimeCounter: PerfCounter;
  49813. /**
  49814. * Gets the physics time capture status
  49815. */
  49816. /**
  49817. * Enable or disable the physics time capture
  49818. */
  49819. capturePhysicsTime: boolean;
  49820. /**
  49821. * Gets the perf counter used for animations time
  49822. */
  49823. readonly animationsTimeCounter: PerfCounter;
  49824. /**
  49825. * Gets the animations time capture status
  49826. */
  49827. /**
  49828. * Enable or disable the animations time capture
  49829. */
  49830. captureAnimationsTime: boolean;
  49831. /**
  49832. * Gets the perf counter used for frame time capture
  49833. */
  49834. readonly frameTimeCounter: PerfCounter;
  49835. /**
  49836. * Gets the frame time capture status
  49837. */
  49838. /**
  49839. * Enable or disable the frame time capture
  49840. */
  49841. captureFrameTime: boolean;
  49842. /**
  49843. * Gets the perf counter used for inter-frames time capture
  49844. */
  49845. readonly interFrameTimeCounter: PerfCounter;
  49846. /**
  49847. * Gets the inter-frames time capture status
  49848. */
  49849. /**
  49850. * Enable or disable the inter-frames time capture
  49851. */
  49852. captureInterFrameTime: boolean;
  49853. /**
  49854. * Gets the perf counter used for render time capture
  49855. */
  49856. readonly renderTimeCounter: PerfCounter;
  49857. /**
  49858. * Gets the render time capture status
  49859. */
  49860. /**
  49861. * Enable or disable the render time capture
  49862. */
  49863. captureRenderTime: boolean;
  49864. /**
  49865. * Gets the perf counter used for camera render time capture
  49866. */
  49867. readonly cameraRenderTimeCounter: PerfCounter;
  49868. /**
  49869. * Gets the camera render time capture status
  49870. */
  49871. /**
  49872. * Enable or disable the camera render time capture
  49873. */
  49874. captureCameraRenderTime: boolean;
  49875. /**
  49876. * Gets the perf counter used for draw calls
  49877. */
  49878. readonly drawCallsCounter: PerfCounter;
  49879. /**
  49880. * Instantiates a new scene instrumentation.
  49881. * This class can be used to get instrumentation data from a Babylon engine
  49882. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49883. * @param scene Defines the scene to instrument
  49884. */
  49885. constructor(
  49886. /**
  49887. * Defines the scene to instrument
  49888. */
  49889. scene: Scene);
  49890. /**
  49891. * Dispose and release associated resources.
  49892. */
  49893. dispose(): void;
  49894. }
  49895. }
  49896. declare module "babylonjs/Instrumentation/index" {
  49897. export * from "babylonjs/Instrumentation/engineInstrumentation";
  49898. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  49899. export * from "babylonjs/Instrumentation/timeToken";
  49900. }
  49901. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  49902. /** @hidden */
  49903. export var glowMapGenerationPixelShader: {
  49904. name: string;
  49905. shader: string;
  49906. };
  49907. }
  49908. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  49909. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49910. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49911. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49912. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49913. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49914. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49915. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49916. /** @hidden */
  49917. export var glowMapGenerationVertexShader: {
  49918. name: string;
  49919. shader: string;
  49920. };
  49921. }
  49922. declare module "babylonjs/Layers/effectLayer" {
  49923. import { Observable } from "babylonjs/Misc/observable";
  49924. import { Nullable } from "babylonjs/types";
  49925. import { Camera } from "babylonjs/Cameras/camera";
  49926. import { Scene } from "babylonjs/scene";
  49927. import { ISize } from "babylonjs/Maths/math.size";
  49928. import { Color4 } from "babylonjs/Maths/math.color";
  49929. import { Engine } from "babylonjs/Engines/engine";
  49930. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49931. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49932. import { Mesh } from "babylonjs/Meshes/mesh";
  49933. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  49934. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49935. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49936. import { Effect } from "babylonjs/Materials/effect";
  49937. import { Material } from "babylonjs/Materials/material";
  49938. import "babylonjs/Shaders/glowMapGeneration.fragment";
  49939. import "babylonjs/Shaders/glowMapGeneration.vertex";
  49940. /**
  49941. * Effect layer options. This helps customizing the behaviour
  49942. * of the effect layer.
  49943. */
  49944. export interface IEffectLayerOptions {
  49945. /**
  49946. * Multiplication factor apply to the canvas size to compute the render target size
  49947. * used to generated the objects (the smaller the faster).
  49948. */
  49949. mainTextureRatio: number;
  49950. /**
  49951. * Enforces a fixed size texture to ensure effect stability across devices.
  49952. */
  49953. mainTextureFixedSize?: number;
  49954. /**
  49955. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  49956. */
  49957. alphaBlendingMode: number;
  49958. /**
  49959. * The camera attached to the layer.
  49960. */
  49961. camera: Nullable<Camera>;
  49962. /**
  49963. * The rendering group to draw the layer in.
  49964. */
  49965. renderingGroupId: number;
  49966. }
  49967. /**
  49968. * The effect layer Helps adding post process effect blended with the main pass.
  49969. *
  49970. * This can be for instance use to generate glow or higlight effects on the scene.
  49971. *
  49972. * The effect layer class can not be used directly and is intented to inherited from to be
  49973. * customized per effects.
  49974. */
  49975. export abstract class EffectLayer {
  49976. private _vertexBuffers;
  49977. private _indexBuffer;
  49978. private _cachedDefines;
  49979. private _effectLayerMapGenerationEffect;
  49980. private _effectLayerOptions;
  49981. private _mergeEffect;
  49982. protected _scene: Scene;
  49983. protected _engine: Engine;
  49984. protected _maxSize: number;
  49985. protected _mainTextureDesiredSize: ISize;
  49986. protected _mainTexture: RenderTargetTexture;
  49987. protected _shouldRender: boolean;
  49988. protected _postProcesses: PostProcess[];
  49989. protected _textures: BaseTexture[];
  49990. protected _emissiveTextureAndColor: {
  49991. texture: Nullable<BaseTexture>;
  49992. color: Color4;
  49993. };
  49994. /**
  49995. * The name of the layer
  49996. */
  49997. name: string;
  49998. /**
  49999. * The clear color of the texture used to generate the glow map.
  50000. */
  50001. neutralColor: Color4;
  50002. /**
  50003. * Specifies wether the highlight layer is enabled or not.
  50004. */
  50005. isEnabled: boolean;
  50006. /**
  50007. * Gets the camera attached to the layer.
  50008. */
  50009. readonly camera: Nullable<Camera>;
  50010. /**
  50011. * Gets the rendering group id the layer should render in.
  50012. */
  50013. renderingGroupId: number;
  50014. /**
  50015. * An event triggered when the effect layer has been disposed.
  50016. */
  50017. onDisposeObservable: Observable<EffectLayer>;
  50018. /**
  50019. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  50020. */
  50021. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  50022. /**
  50023. * An event triggered when the generated texture is being merged in the scene.
  50024. */
  50025. onBeforeComposeObservable: Observable<EffectLayer>;
  50026. /**
  50027. * An event triggered when the generated texture has been merged in the scene.
  50028. */
  50029. onAfterComposeObservable: Observable<EffectLayer>;
  50030. /**
  50031. * An event triggered when the efffect layer changes its size.
  50032. */
  50033. onSizeChangedObservable: Observable<EffectLayer>;
  50034. /** @hidden */
  50035. static _SceneComponentInitialization: (scene: Scene) => void;
  50036. /**
  50037. * Instantiates a new effect Layer and references it in the scene.
  50038. * @param name The name of the layer
  50039. * @param scene The scene to use the layer in
  50040. */
  50041. constructor(
  50042. /** The Friendly of the effect in the scene */
  50043. name: string, scene: Scene);
  50044. /**
  50045. * Get the effect name of the layer.
  50046. * @return The effect name
  50047. */
  50048. abstract getEffectName(): string;
  50049. /**
  50050. * Checks for the readiness of the element composing the layer.
  50051. * @param subMesh the mesh to check for
  50052. * @param useInstances specify wether or not to use instances to render the mesh
  50053. * @return true if ready otherwise, false
  50054. */
  50055. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50056. /**
  50057. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50058. * @returns true if the effect requires stencil during the main canvas render pass.
  50059. */
  50060. abstract needStencil(): boolean;
  50061. /**
  50062. * Create the merge effect. This is the shader use to blit the information back
  50063. * to the main canvas at the end of the scene rendering.
  50064. * @returns The effect containing the shader used to merge the effect on the main canvas
  50065. */
  50066. protected abstract _createMergeEffect(): Effect;
  50067. /**
  50068. * Creates the render target textures and post processes used in the effect layer.
  50069. */
  50070. protected abstract _createTextureAndPostProcesses(): void;
  50071. /**
  50072. * Implementation specific of rendering the generating effect on the main canvas.
  50073. * @param effect The effect used to render through
  50074. */
  50075. protected abstract _internalRender(effect: Effect): void;
  50076. /**
  50077. * Sets the required values for both the emissive texture and and the main color.
  50078. */
  50079. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50080. /**
  50081. * Free any resources and references associated to a mesh.
  50082. * Internal use
  50083. * @param mesh The mesh to free.
  50084. */
  50085. abstract _disposeMesh(mesh: Mesh): void;
  50086. /**
  50087. * Serializes this layer (Glow or Highlight for example)
  50088. * @returns a serialized layer object
  50089. */
  50090. abstract serialize?(): any;
  50091. /**
  50092. * Initializes the effect layer with the required options.
  50093. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  50094. */
  50095. protected _init(options: Partial<IEffectLayerOptions>): void;
  50096. /**
  50097. * Generates the index buffer of the full screen quad blending to the main canvas.
  50098. */
  50099. private _generateIndexBuffer;
  50100. /**
  50101. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  50102. */
  50103. private _generateVertexBuffer;
  50104. /**
  50105. * Sets the main texture desired size which is the closest power of two
  50106. * of the engine canvas size.
  50107. */
  50108. private _setMainTextureSize;
  50109. /**
  50110. * Creates the main texture for the effect layer.
  50111. */
  50112. protected _createMainTexture(): void;
  50113. /**
  50114. * Adds specific effects defines.
  50115. * @param defines The defines to add specifics to.
  50116. */
  50117. protected _addCustomEffectDefines(defines: string[]): void;
  50118. /**
  50119. * Checks for the readiness of the element composing the layer.
  50120. * @param subMesh the mesh to check for
  50121. * @param useInstances specify wether or not to use instances to render the mesh
  50122. * @param emissiveTexture the associated emissive texture used to generate the glow
  50123. * @return true if ready otherwise, false
  50124. */
  50125. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  50126. /**
  50127. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  50128. */
  50129. render(): void;
  50130. /**
  50131. * Determine if a given mesh will be used in the current effect.
  50132. * @param mesh mesh to test
  50133. * @returns true if the mesh will be used
  50134. */
  50135. hasMesh(mesh: AbstractMesh): boolean;
  50136. /**
  50137. * Returns true if the layer contains information to display, otherwise false.
  50138. * @returns true if the glow layer should be rendered
  50139. */
  50140. shouldRender(): boolean;
  50141. /**
  50142. * Returns true if the mesh should render, otherwise false.
  50143. * @param mesh The mesh to render
  50144. * @returns true if it should render otherwise false
  50145. */
  50146. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  50147. /**
  50148. * Returns true if the mesh can be rendered, otherwise false.
  50149. * @param mesh The mesh to render
  50150. * @param material The material used on the mesh
  50151. * @returns true if it can be rendered otherwise false
  50152. */
  50153. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50154. /**
  50155. * Returns true if the mesh should render, otherwise false.
  50156. * @param mesh The mesh to render
  50157. * @returns true if it should render otherwise false
  50158. */
  50159. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  50160. /**
  50161. * Renders the submesh passed in parameter to the generation map.
  50162. */
  50163. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  50164. /**
  50165. * Rebuild the required buffers.
  50166. * @hidden Internal use only.
  50167. */
  50168. _rebuild(): void;
  50169. /**
  50170. * Dispose only the render target textures and post process.
  50171. */
  50172. private _disposeTextureAndPostProcesses;
  50173. /**
  50174. * Dispose the highlight layer and free resources.
  50175. */
  50176. dispose(): void;
  50177. /**
  50178. * Gets the class name of the effect layer
  50179. * @returns the string with the class name of the effect layer
  50180. */
  50181. getClassName(): string;
  50182. /**
  50183. * Creates an effect layer from parsed effect layer data
  50184. * @param parsedEffectLayer defines effect layer data
  50185. * @param scene defines the current scene
  50186. * @param rootUrl defines the root URL containing the effect layer information
  50187. * @returns a parsed effect Layer
  50188. */
  50189. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  50190. }
  50191. }
  50192. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  50193. import { Scene } from "babylonjs/scene";
  50194. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50195. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50196. import { AbstractScene } from "babylonjs/abstractScene";
  50197. module "babylonjs/abstractScene" {
  50198. interface AbstractScene {
  50199. /**
  50200. * The list of effect layers (highlights/glow) added to the scene
  50201. * @see http://doc.babylonjs.com/how_to/highlight_layer
  50202. * @see http://doc.babylonjs.com/how_to/glow_layer
  50203. */
  50204. effectLayers: Array<EffectLayer>;
  50205. /**
  50206. * Removes the given effect layer from this scene.
  50207. * @param toRemove defines the effect layer to remove
  50208. * @returns the index of the removed effect layer
  50209. */
  50210. removeEffectLayer(toRemove: EffectLayer): number;
  50211. /**
  50212. * Adds the given effect layer to this scene
  50213. * @param newEffectLayer defines the effect layer to add
  50214. */
  50215. addEffectLayer(newEffectLayer: EffectLayer): void;
  50216. }
  50217. }
  50218. /**
  50219. * Defines the layer scene component responsible to manage any effect layers
  50220. * in a given scene.
  50221. */
  50222. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  50223. /**
  50224. * The component name helpfull to identify the component in the list of scene components.
  50225. */
  50226. readonly name: string;
  50227. /**
  50228. * The scene the component belongs to.
  50229. */
  50230. scene: Scene;
  50231. private _engine;
  50232. private _renderEffects;
  50233. private _needStencil;
  50234. private _previousStencilState;
  50235. /**
  50236. * Creates a new instance of the component for the given scene
  50237. * @param scene Defines the scene to register the component in
  50238. */
  50239. constructor(scene: Scene);
  50240. /**
  50241. * Registers the component in a given scene
  50242. */
  50243. register(): void;
  50244. /**
  50245. * Rebuilds the elements related to this component in case of
  50246. * context lost for instance.
  50247. */
  50248. rebuild(): void;
  50249. /**
  50250. * Serializes the component data to the specified json object
  50251. * @param serializationObject The object to serialize to
  50252. */
  50253. serialize(serializationObject: any): void;
  50254. /**
  50255. * Adds all the elements from the container to the scene
  50256. * @param container the container holding the elements
  50257. */
  50258. addFromContainer(container: AbstractScene): void;
  50259. /**
  50260. * Removes all the elements in the container from the scene
  50261. * @param container contains the elements to remove
  50262. * @param dispose if the removed element should be disposed (default: false)
  50263. */
  50264. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50265. /**
  50266. * Disposes the component and the associated ressources.
  50267. */
  50268. dispose(): void;
  50269. private _isReadyForMesh;
  50270. private _renderMainTexture;
  50271. private _setStencil;
  50272. private _setStencilBack;
  50273. private _draw;
  50274. private _drawCamera;
  50275. private _drawRenderingGroup;
  50276. }
  50277. }
  50278. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  50279. /** @hidden */
  50280. export var glowMapMergePixelShader: {
  50281. name: string;
  50282. shader: string;
  50283. };
  50284. }
  50285. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  50286. /** @hidden */
  50287. export var glowMapMergeVertexShader: {
  50288. name: string;
  50289. shader: string;
  50290. };
  50291. }
  50292. declare module "babylonjs/Layers/glowLayer" {
  50293. import { Nullable } from "babylonjs/types";
  50294. import { Camera } from "babylonjs/Cameras/camera";
  50295. import { Scene } from "babylonjs/scene";
  50296. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50298. import { Mesh } from "babylonjs/Meshes/mesh";
  50299. import { Texture } from "babylonjs/Materials/Textures/texture";
  50300. import { Effect } from "babylonjs/Materials/effect";
  50301. import { Material } from "babylonjs/Materials/material";
  50302. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50303. import { Color4 } from "babylonjs/Maths/math.color";
  50304. import "babylonjs/Shaders/glowMapMerge.fragment";
  50305. import "babylonjs/Shaders/glowMapMerge.vertex";
  50306. import "babylonjs/Layers/effectLayerSceneComponent";
  50307. module "babylonjs/abstractScene" {
  50308. interface AbstractScene {
  50309. /**
  50310. * Return a the first highlight layer of the scene with a given name.
  50311. * @param name The name of the highlight layer to look for.
  50312. * @return The highlight layer if found otherwise null.
  50313. */
  50314. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  50315. }
  50316. }
  50317. /**
  50318. * Glow layer options. This helps customizing the behaviour
  50319. * of the glow layer.
  50320. */
  50321. export interface IGlowLayerOptions {
  50322. /**
  50323. * Multiplication factor apply to the canvas size to compute the render target size
  50324. * used to generated the glowing objects (the smaller the faster).
  50325. */
  50326. mainTextureRatio: number;
  50327. /**
  50328. * Enforces a fixed size texture to ensure resize independant blur.
  50329. */
  50330. mainTextureFixedSize?: number;
  50331. /**
  50332. * How big is the kernel of the blur texture.
  50333. */
  50334. blurKernelSize: number;
  50335. /**
  50336. * The camera attached to the layer.
  50337. */
  50338. camera: Nullable<Camera>;
  50339. /**
  50340. * Enable MSAA by chosing the number of samples.
  50341. */
  50342. mainTextureSamples?: number;
  50343. /**
  50344. * The rendering group to draw the layer in.
  50345. */
  50346. renderingGroupId: number;
  50347. }
  50348. /**
  50349. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  50350. *
  50351. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  50352. * glowy meshes to your scene.
  50353. *
  50354. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  50355. */
  50356. export class GlowLayer extends EffectLayer {
  50357. /**
  50358. * Effect Name of the layer.
  50359. */
  50360. static readonly EffectName: string;
  50361. /**
  50362. * The default blur kernel size used for the glow.
  50363. */
  50364. static DefaultBlurKernelSize: number;
  50365. /**
  50366. * The default texture size ratio used for the glow.
  50367. */
  50368. static DefaultTextureRatio: number;
  50369. /**
  50370. * Sets the kernel size of the blur.
  50371. */
  50372. /**
  50373. * Gets the kernel size of the blur.
  50374. */
  50375. blurKernelSize: number;
  50376. /**
  50377. * Sets the glow intensity.
  50378. */
  50379. /**
  50380. * Gets the glow intensity.
  50381. */
  50382. intensity: number;
  50383. private _options;
  50384. private _intensity;
  50385. private _horizontalBlurPostprocess1;
  50386. private _verticalBlurPostprocess1;
  50387. private _horizontalBlurPostprocess2;
  50388. private _verticalBlurPostprocess2;
  50389. private _blurTexture1;
  50390. private _blurTexture2;
  50391. private _postProcesses1;
  50392. private _postProcesses2;
  50393. private _includedOnlyMeshes;
  50394. private _excludedMeshes;
  50395. /**
  50396. * Callback used to let the user override the color selection on a per mesh basis
  50397. */
  50398. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  50399. /**
  50400. * Callback used to let the user override the texture selection on a per mesh basis
  50401. */
  50402. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  50403. /**
  50404. * Instantiates a new glow Layer and references it to the scene.
  50405. * @param name The name of the layer
  50406. * @param scene The scene to use the layer in
  50407. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  50408. */
  50409. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  50410. /**
  50411. * Get the effect name of the layer.
  50412. * @return The effect name
  50413. */
  50414. getEffectName(): string;
  50415. /**
  50416. * Create the merge effect. This is the shader use to blit the information back
  50417. * to the main canvas at the end of the scene rendering.
  50418. */
  50419. protected _createMergeEffect(): Effect;
  50420. /**
  50421. * Creates the render target textures and post processes used in the glow layer.
  50422. */
  50423. protected _createTextureAndPostProcesses(): void;
  50424. /**
  50425. * Checks for the readiness of the element composing the layer.
  50426. * @param subMesh the mesh to check for
  50427. * @param useInstances specify wether or not to use instances to render the mesh
  50428. * @param emissiveTexture the associated emissive texture used to generate the glow
  50429. * @return true if ready otherwise, false
  50430. */
  50431. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50432. /**
  50433. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50434. */
  50435. needStencil(): boolean;
  50436. /**
  50437. * Returns true if the mesh can be rendered, otherwise false.
  50438. * @param mesh The mesh to render
  50439. * @param material The material used on the mesh
  50440. * @returns true if it can be rendered otherwise false
  50441. */
  50442. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50443. /**
  50444. * Implementation specific of rendering the generating effect on the main canvas.
  50445. * @param effect The effect used to render through
  50446. */
  50447. protected _internalRender(effect: Effect): void;
  50448. /**
  50449. * Sets the required values for both the emissive texture and and the main color.
  50450. */
  50451. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50452. /**
  50453. * Returns true if the mesh should render, otherwise false.
  50454. * @param mesh The mesh to render
  50455. * @returns true if it should render otherwise false
  50456. */
  50457. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50458. /**
  50459. * Adds specific effects defines.
  50460. * @param defines The defines to add specifics to.
  50461. */
  50462. protected _addCustomEffectDefines(defines: string[]): void;
  50463. /**
  50464. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  50465. * @param mesh The mesh to exclude from the glow layer
  50466. */
  50467. addExcludedMesh(mesh: Mesh): void;
  50468. /**
  50469. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  50470. * @param mesh The mesh to remove
  50471. */
  50472. removeExcludedMesh(mesh: Mesh): void;
  50473. /**
  50474. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  50475. * @param mesh The mesh to include in the glow layer
  50476. */
  50477. addIncludedOnlyMesh(mesh: Mesh): void;
  50478. /**
  50479. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  50480. * @param mesh The mesh to remove
  50481. */
  50482. removeIncludedOnlyMesh(mesh: Mesh): void;
  50483. /**
  50484. * Determine if a given mesh will be used in the glow layer
  50485. * @param mesh The mesh to test
  50486. * @returns true if the mesh will be highlighted by the current glow layer
  50487. */
  50488. hasMesh(mesh: AbstractMesh): boolean;
  50489. /**
  50490. * Free any resources and references associated to a mesh.
  50491. * Internal use
  50492. * @param mesh The mesh to free.
  50493. * @hidden
  50494. */
  50495. _disposeMesh(mesh: Mesh): void;
  50496. /**
  50497. * Gets the class name of the effect layer
  50498. * @returns the string with the class name of the effect layer
  50499. */
  50500. getClassName(): string;
  50501. /**
  50502. * Serializes this glow layer
  50503. * @returns a serialized glow layer object
  50504. */
  50505. serialize(): any;
  50506. /**
  50507. * Creates a Glow Layer from parsed glow layer data
  50508. * @param parsedGlowLayer defines glow layer data
  50509. * @param scene defines the current scene
  50510. * @param rootUrl defines the root URL containing the glow layer information
  50511. * @returns a parsed Glow Layer
  50512. */
  50513. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  50514. }
  50515. }
  50516. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  50517. /** @hidden */
  50518. export var glowBlurPostProcessPixelShader: {
  50519. name: string;
  50520. shader: string;
  50521. };
  50522. }
  50523. declare module "babylonjs/Layers/highlightLayer" {
  50524. import { Observable } from "babylonjs/Misc/observable";
  50525. import { Nullable } from "babylonjs/types";
  50526. import { Camera } from "babylonjs/Cameras/camera";
  50527. import { Scene } from "babylonjs/scene";
  50528. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50530. import { Mesh } from "babylonjs/Meshes/mesh";
  50531. import { Effect } from "babylonjs/Materials/effect";
  50532. import { Material } from "babylonjs/Materials/material";
  50533. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50534. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  50535. import "babylonjs/Shaders/glowMapMerge.fragment";
  50536. import "babylonjs/Shaders/glowMapMerge.vertex";
  50537. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  50538. module "babylonjs/abstractScene" {
  50539. interface AbstractScene {
  50540. /**
  50541. * Return a the first highlight layer of the scene with a given name.
  50542. * @param name The name of the highlight layer to look for.
  50543. * @return The highlight layer if found otherwise null.
  50544. */
  50545. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  50546. }
  50547. }
  50548. /**
  50549. * Highlight layer options. This helps customizing the behaviour
  50550. * of the highlight layer.
  50551. */
  50552. export interface IHighlightLayerOptions {
  50553. /**
  50554. * Multiplication factor apply to the canvas size to compute the render target size
  50555. * used to generated the glowing objects (the smaller the faster).
  50556. */
  50557. mainTextureRatio: number;
  50558. /**
  50559. * Enforces a fixed size texture to ensure resize independant blur.
  50560. */
  50561. mainTextureFixedSize?: number;
  50562. /**
  50563. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  50564. * of the picture to blur (the smaller the faster).
  50565. */
  50566. blurTextureSizeRatio: number;
  50567. /**
  50568. * How big in texel of the blur texture is the vertical blur.
  50569. */
  50570. blurVerticalSize: number;
  50571. /**
  50572. * How big in texel of the blur texture is the horizontal blur.
  50573. */
  50574. blurHorizontalSize: number;
  50575. /**
  50576. * Alpha blending mode used to apply the blur. Default is combine.
  50577. */
  50578. alphaBlendingMode: number;
  50579. /**
  50580. * The camera attached to the layer.
  50581. */
  50582. camera: Nullable<Camera>;
  50583. /**
  50584. * Should we display highlight as a solid stroke?
  50585. */
  50586. isStroke?: boolean;
  50587. /**
  50588. * The rendering group to draw the layer in.
  50589. */
  50590. renderingGroupId: number;
  50591. }
  50592. /**
  50593. * The highlight layer Helps adding a glow effect around a mesh.
  50594. *
  50595. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  50596. * glowy meshes to your scene.
  50597. *
  50598. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  50599. */
  50600. export class HighlightLayer extends EffectLayer {
  50601. name: string;
  50602. /**
  50603. * Effect Name of the highlight layer.
  50604. */
  50605. static readonly EffectName: string;
  50606. /**
  50607. * The neutral color used during the preparation of the glow effect.
  50608. * This is black by default as the blend operation is a blend operation.
  50609. */
  50610. static NeutralColor: Color4;
  50611. /**
  50612. * Stencil value used for glowing meshes.
  50613. */
  50614. static GlowingMeshStencilReference: number;
  50615. /**
  50616. * Stencil value used for the other meshes in the scene.
  50617. */
  50618. static NormalMeshStencilReference: number;
  50619. /**
  50620. * Specifies whether or not the inner glow is ACTIVE in the layer.
  50621. */
  50622. innerGlow: boolean;
  50623. /**
  50624. * Specifies whether or not the outer glow is ACTIVE in the layer.
  50625. */
  50626. outerGlow: boolean;
  50627. /**
  50628. * Specifies the horizontal size of the blur.
  50629. */
  50630. /**
  50631. * Gets the horizontal size of the blur.
  50632. */
  50633. blurHorizontalSize: number;
  50634. /**
  50635. * Specifies the vertical size of the blur.
  50636. */
  50637. /**
  50638. * Gets the vertical size of the blur.
  50639. */
  50640. blurVerticalSize: number;
  50641. /**
  50642. * An event triggered when the highlight layer is being blurred.
  50643. */
  50644. onBeforeBlurObservable: Observable<HighlightLayer>;
  50645. /**
  50646. * An event triggered when the highlight layer has been blurred.
  50647. */
  50648. onAfterBlurObservable: Observable<HighlightLayer>;
  50649. private _instanceGlowingMeshStencilReference;
  50650. private _options;
  50651. private _downSamplePostprocess;
  50652. private _horizontalBlurPostprocess;
  50653. private _verticalBlurPostprocess;
  50654. private _blurTexture;
  50655. private _meshes;
  50656. private _excludedMeshes;
  50657. /**
  50658. * Instantiates a new highlight Layer and references it to the scene..
  50659. * @param name The name of the layer
  50660. * @param scene The scene to use the layer in
  50661. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  50662. */
  50663. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  50664. /**
  50665. * Get the effect name of the layer.
  50666. * @return The effect name
  50667. */
  50668. getEffectName(): string;
  50669. /**
  50670. * Create the merge effect. This is the shader use to blit the information back
  50671. * to the main canvas at the end of the scene rendering.
  50672. */
  50673. protected _createMergeEffect(): Effect;
  50674. /**
  50675. * Creates the render target textures and post processes used in the highlight layer.
  50676. */
  50677. protected _createTextureAndPostProcesses(): void;
  50678. /**
  50679. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50680. */
  50681. needStencil(): boolean;
  50682. /**
  50683. * Checks for the readiness of the element composing the layer.
  50684. * @param subMesh the mesh to check for
  50685. * @param useInstances specify wether or not to use instances to render the mesh
  50686. * @param emissiveTexture the associated emissive texture used to generate the glow
  50687. * @return true if ready otherwise, false
  50688. */
  50689. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50690. /**
  50691. * Implementation specific of rendering the generating effect on the main canvas.
  50692. * @param effect The effect used to render through
  50693. */
  50694. protected _internalRender(effect: Effect): void;
  50695. /**
  50696. * Returns true if the layer contains information to display, otherwise false.
  50697. */
  50698. shouldRender(): boolean;
  50699. /**
  50700. * Returns true if the mesh should render, otherwise false.
  50701. * @param mesh The mesh to render
  50702. * @returns true if it should render otherwise false
  50703. */
  50704. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50705. /**
  50706. * Sets the required values for both the emissive texture and and the main color.
  50707. */
  50708. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50709. /**
  50710. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  50711. * @param mesh The mesh to exclude from the highlight layer
  50712. */
  50713. addExcludedMesh(mesh: Mesh): void;
  50714. /**
  50715. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  50716. * @param mesh The mesh to highlight
  50717. */
  50718. removeExcludedMesh(mesh: Mesh): void;
  50719. /**
  50720. * Determine if a given mesh will be highlighted by the current HighlightLayer
  50721. * @param mesh mesh to test
  50722. * @returns true if the mesh will be highlighted by the current HighlightLayer
  50723. */
  50724. hasMesh(mesh: AbstractMesh): boolean;
  50725. /**
  50726. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  50727. * @param mesh The mesh to highlight
  50728. * @param color The color of the highlight
  50729. * @param glowEmissiveOnly Extract the glow from the emissive texture
  50730. */
  50731. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  50732. /**
  50733. * Remove a mesh from the highlight layer in order to make it stop glowing.
  50734. * @param mesh The mesh to highlight
  50735. */
  50736. removeMesh(mesh: Mesh): void;
  50737. /**
  50738. * Force the stencil to the normal expected value for none glowing parts
  50739. */
  50740. private _defaultStencilReference;
  50741. /**
  50742. * Free any resources and references associated to a mesh.
  50743. * Internal use
  50744. * @param mesh The mesh to free.
  50745. * @hidden
  50746. */
  50747. _disposeMesh(mesh: Mesh): void;
  50748. /**
  50749. * Dispose the highlight layer and free resources.
  50750. */
  50751. dispose(): void;
  50752. /**
  50753. * Gets the class name of the effect layer
  50754. * @returns the string with the class name of the effect layer
  50755. */
  50756. getClassName(): string;
  50757. /**
  50758. * Serializes this Highlight layer
  50759. * @returns a serialized Highlight layer object
  50760. */
  50761. serialize(): any;
  50762. /**
  50763. * Creates a Highlight layer from parsed Highlight layer data
  50764. * @param parsedHightlightLayer defines the Highlight layer data
  50765. * @param scene defines the current scene
  50766. * @param rootUrl defines the root URL containing the Highlight layer information
  50767. * @returns a parsed Highlight layer
  50768. */
  50769. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  50770. }
  50771. }
  50772. declare module "babylonjs/Layers/layerSceneComponent" {
  50773. import { Scene } from "babylonjs/scene";
  50774. import { ISceneComponent } from "babylonjs/sceneComponent";
  50775. import { Layer } from "babylonjs/Layers/layer";
  50776. import { AbstractScene } from "babylonjs/abstractScene";
  50777. module "babylonjs/abstractScene" {
  50778. interface AbstractScene {
  50779. /**
  50780. * The list of layers (background and foreground) of the scene
  50781. */
  50782. layers: Array<Layer>;
  50783. }
  50784. }
  50785. /**
  50786. * Defines the layer scene component responsible to manage any layers
  50787. * in a given scene.
  50788. */
  50789. export class LayerSceneComponent implements ISceneComponent {
  50790. /**
  50791. * The component name helpfull to identify the component in the list of scene components.
  50792. */
  50793. readonly name: string;
  50794. /**
  50795. * The scene the component belongs to.
  50796. */
  50797. scene: Scene;
  50798. private _engine;
  50799. /**
  50800. * Creates a new instance of the component for the given scene
  50801. * @param scene Defines the scene to register the component in
  50802. */
  50803. constructor(scene: Scene);
  50804. /**
  50805. * Registers the component in a given scene
  50806. */
  50807. register(): void;
  50808. /**
  50809. * Rebuilds the elements related to this component in case of
  50810. * context lost for instance.
  50811. */
  50812. rebuild(): void;
  50813. /**
  50814. * Disposes the component and the associated ressources.
  50815. */
  50816. dispose(): void;
  50817. private _draw;
  50818. private _drawCameraPredicate;
  50819. private _drawCameraBackground;
  50820. private _drawCameraForeground;
  50821. private _drawRenderTargetPredicate;
  50822. private _drawRenderTargetBackground;
  50823. private _drawRenderTargetForeground;
  50824. /**
  50825. * Adds all the elements from the container to the scene
  50826. * @param container the container holding the elements
  50827. */
  50828. addFromContainer(container: AbstractScene): void;
  50829. /**
  50830. * Removes all the elements in the container from the scene
  50831. * @param container contains the elements to remove
  50832. * @param dispose if the removed element should be disposed (default: false)
  50833. */
  50834. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50835. }
  50836. }
  50837. declare module "babylonjs/Shaders/layer.fragment" {
  50838. /** @hidden */
  50839. export var layerPixelShader: {
  50840. name: string;
  50841. shader: string;
  50842. };
  50843. }
  50844. declare module "babylonjs/Shaders/layer.vertex" {
  50845. /** @hidden */
  50846. export var layerVertexShader: {
  50847. name: string;
  50848. shader: string;
  50849. };
  50850. }
  50851. declare module "babylonjs/Layers/layer" {
  50852. import { Observable } from "babylonjs/Misc/observable";
  50853. import { Nullable } from "babylonjs/types";
  50854. import { Scene } from "babylonjs/scene";
  50855. import { Vector2 } from "babylonjs/Maths/math.vector";
  50856. import { Color4 } from "babylonjs/Maths/math.color";
  50857. import { Texture } from "babylonjs/Materials/Textures/texture";
  50858. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50859. import "babylonjs/Shaders/layer.fragment";
  50860. import "babylonjs/Shaders/layer.vertex";
  50861. /**
  50862. * This represents a full screen 2d layer.
  50863. * This can be useful to display a picture in the background of your scene for instance.
  50864. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50865. */
  50866. export class Layer {
  50867. /**
  50868. * Define the name of the layer.
  50869. */
  50870. name: string;
  50871. /**
  50872. * Define the texture the layer should display.
  50873. */
  50874. texture: Nullable<Texture>;
  50875. /**
  50876. * Is the layer in background or foreground.
  50877. */
  50878. isBackground: boolean;
  50879. /**
  50880. * Define the color of the layer (instead of texture).
  50881. */
  50882. color: Color4;
  50883. /**
  50884. * Define the scale of the layer in order to zoom in out of the texture.
  50885. */
  50886. scale: Vector2;
  50887. /**
  50888. * Define an offset for the layer in order to shift the texture.
  50889. */
  50890. offset: Vector2;
  50891. /**
  50892. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50893. */
  50894. alphaBlendingMode: number;
  50895. /**
  50896. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50897. * Alpha test will not mix with the background color in case of transparency.
  50898. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50899. */
  50900. alphaTest: boolean;
  50901. /**
  50902. * Define a mask to restrict the layer to only some of the scene cameras.
  50903. */
  50904. layerMask: number;
  50905. /**
  50906. * Define the list of render target the layer is visible into.
  50907. */
  50908. renderTargetTextures: RenderTargetTexture[];
  50909. /**
  50910. * Define if the layer is only used in renderTarget or if it also
  50911. * renders in the main frame buffer of the canvas.
  50912. */
  50913. renderOnlyInRenderTargetTextures: boolean;
  50914. private _scene;
  50915. private _vertexBuffers;
  50916. private _indexBuffer;
  50917. private _effect;
  50918. private _alphaTestEffect;
  50919. /**
  50920. * An event triggered when the layer is disposed.
  50921. */
  50922. onDisposeObservable: Observable<Layer>;
  50923. private _onDisposeObserver;
  50924. /**
  50925. * Back compatibility with callback before the onDisposeObservable existed.
  50926. * The set callback will be triggered when the layer has been disposed.
  50927. */
  50928. onDispose: () => void;
  50929. /**
  50930. * An event triggered before rendering the scene
  50931. */
  50932. onBeforeRenderObservable: Observable<Layer>;
  50933. private _onBeforeRenderObserver;
  50934. /**
  50935. * Back compatibility with callback before the onBeforeRenderObservable existed.
  50936. * The set callback will be triggered just before rendering the layer.
  50937. */
  50938. onBeforeRender: () => void;
  50939. /**
  50940. * An event triggered after rendering the scene
  50941. */
  50942. onAfterRenderObservable: Observable<Layer>;
  50943. private _onAfterRenderObserver;
  50944. /**
  50945. * Back compatibility with callback before the onAfterRenderObservable existed.
  50946. * The set callback will be triggered just after rendering the layer.
  50947. */
  50948. onAfterRender: () => void;
  50949. /**
  50950. * Instantiates a new layer.
  50951. * This represents a full screen 2d layer.
  50952. * This can be useful to display a picture in the background of your scene for instance.
  50953. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50954. * @param name Define the name of the layer in the scene
  50955. * @param imgUrl Define the url of the texture to display in the layer
  50956. * @param scene Define the scene the layer belongs to
  50957. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  50958. * @param color Defines a color for the layer
  50959. */
  50960. constructor(
  50961. /**
  50962. * Define the name of the layer.
  50963. */
  50964. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  50965. private _createIndexBuffer;
  50966. /** @hidden */
  50967. _rebuild(): void;
  50968. /**
  50969. * Renders the layer in the scene.
  50970. */
  50971. render(): void;
  50972. /**
  50973. * Disposes and releases the associated ressources.
  50974. */
  50975. dispose(): void;
  50976. }
  50977. }
  50978. declare module "babylonjs/Layers/index" {
  50979. export * from "babylonjs/Layers/effectLayer";
  50980. export * from "babylonjs/Layers/effectLayerSceneComponent";
  50981. export * from "babylonjs/Layers/glowLayer";
  50982. export * from "babylonjs/Layers/highlightLayer";
  50983. export * from "babylonjs/Layers/layer";
  50984. export * from "babylonjs/Layers/layerSceneComponent";
  50985. }
  50986. declare module "babylonjs/Shaders/lensFlare.fragment" {
  50987. /** @hidden */
  50988. export var lensFlarePixelShader: {
  50989. name: string;
  50990. shader: string;
  50991. };
  50992. }
  50993. declare module "babylonjs/Shaders/lensFlare.vertex" {
  50994. /** @hidden */
  50995. export var lensFlareVertexShader: {
  50996. name: string;
  50997. shader: string;
  50998. };
  50999. }
  51000. declare module "babylonjs/LensFlares/lensFlareSystem" {
  51001. import { Scene } from "babylonjs/scene";
  51002. import { Vector3 } from "babylonjs/Maths/math.vector";
  51003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51004. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  51005. import "babylonjs/Shaders/lensFlare.fragment";
  51006. import "babylonjs/Shaders/lensFlare.vertex";
  51007. import { Viewport } from "babylonjs/Maths/math.viewport";
  51008. /**
  51009. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51010. * It is usually composed of several `lensFlare`.
  51011. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51012. */
  51013. export class LensFlareSystem {
  51014. /**
  51015. * Define the name of the lens flare system
  51016. */
  51017. name: string;
  51018. /**
  51019. * List of lens flares used in this system.
  51020. */
  51021. lensFlares: LensFlare[];
  51022. /**
  51023. * Define a limit from the border the lens flare can be visible.
  51024. */
  51025. borderLimit: number;
  51026. /**
  51027. * Define a viewport border we do not want to see the lens flare in.
  51028. */
  51029. viewportBorder: number;
  51030. /**
  51031. * Define a predicate which could limit the list of meshes able to occlude the effect.
  51032. */
  51033. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51034. /**
  51035. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  51036. */
  51037. layerMask: number;
  51038. /**
  51039. * Define the id of the lens flare system in the scene.
  51040. * (equal to name by default)
  51041. */
  51042. id: string;
  51043. private _scene;
  51044. private _emitter;
  51045. private _vertexBuffers;
  51046. private _indexBuffer;
  51047. private _effect;
  51048. private _positionX;
  51049. private _positionY;
  51050. private _isEnabled;
  51051. /** @hidden */
  51052. static _SceneComponentInitialization: (scene: Scene) => void;
  51053. /**
  51054. * Instantiates a lens flare system.
  51055. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51056. * It is usually composed of several `lensFlare`.
  51057. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51058. * @param name Define the name of the lens flare system in the scene
  51059. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  51060. * @param scene Define the scene the lens flare system belongs to
  51061. */
  51062. constructor(
  51063. /**
  51064. * Define the name of the lens flare system
  51065. */
  51066. name: string, emitter: any, scene: Scene);
  51067. /**
  51068. * Define if the lens flare system is enabled.
  51069. */
  51070. isEnabled: boolean;
  51071. /**
  51072. * Get the scene the effects belongs to.
  51073. * @returns the scene holding the lens flare system
  51074. */
  51075. getScene(): Scene;
  51076. /**
  51077. * Get the emitter of the lens flare system.
  51078. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51079. * @returns the emitter of the lens flare system
  51080. */
  51081. getEmitter(): any;
  51082. /**
  51083. * Set the emitter of the lens flare system.
  51084. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51085. * @param newEmitter Define the new emitter of the system
  51086. */
  51087. setEmitter(newEmitter: any): void;
  51088. /**
  51089. * Get the lens flare system emitter position.
  51090. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  51091. * @returns the position
  51092. */
  51093. getEmitterPosition(): Vector3;
  51094. /**
  51095. * @hidden
  51096. */
  51097. computeEffectivePosition(globalViewport: Viewport): boolean;
  51098. /** @hidden */
  51099. _isVisible(): boolean;
  51100. /**
  51101. * @hidden
  51102. */
  51103. render(): boolean;
  51104. /**
  51105. * Dispose and release the lens flare with its associated resources.
  51106. */
  51107. dispose(): void;
  51108. /**
  51109. * Parse a lens flare system from a JSON repressentation
  51110. * @param parsedLensFlareSystem Define the JSON to parse
  51111. * @param scene Define the scene the parsed system should be instantiated in
  51112. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  51113. * @returns the parsed system
  51114. */
  51115. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  51116. /**
  51117. * Serialize the current Lens Flare System into a JSON representation.
  51118. * @returns the serialized JSON
  51119. */
  51120. serialize(): any;
  51121. }
  51122. }
  51123. declare module "babylonjs/LensFlares/lensFlare" {
  51124. import { Nullable } from "babylonjs/types";
  51125. import { Color3 } from "babylonjs/Maths/math.color";
  51126. import { Texture } from "babylonjs/Materials/Textures/texture";
  51127. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  51128. /**
  51129. * This represents one of the lens effect in a `lensFlareSystem`.
  51130. * It controls one of the indiviual texture used in the effect.
  51131. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51132. */
  51133. export class LensFlare {
  51134. /**
  51135. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51136. */
  51137. size: number;
  51138. /**
  51139. * 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.
  51140. */
  51141. position: number;
  51142. /**
  51143. * Define the lens color.
  51144. */
  51145. color: Color3;
  51146. /**
  51147. * Define the lens texture.
  51148. */
  51149. texture: Nullable<Texture>;
  51150. /**
  51151. * Define the alpha mode to render this particular lens.
  51152. */
  51153. alphaMode: number;
  51154. private _system;
  51155. /**
  51156. * Creates a new Lens Flare.
  51157. * This represents one of the lens effect in a `lensFlareSystem`.
  51158. * It controls one of the indiviual texture used in the effect.
  51159. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51160. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  51161. * @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.
  51162. * @param color Define the lens color
  51163. * @param imgUrl Define the lens texture url
  51164. * @param system Define the `lensFlareSystem` this flare is part of
  51165. * @returns The newly created Lens Flare
  51166. */
  51167. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  51168. /**
  51169. * Instantiates a new Lens Flare.
  51170. * This represents one of the lens effect in a `lensFlareSystem`.
  51171. * It controls one of the indiviual texture used in the effect.
  51172. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51173. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  51174. * @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.
  51175. * @param color Define the lens color
  51176. * @param imgUrl Define the lens texture url
  51177. * @param system Define the `lensFlareSystem` this flare is part of
  51178. */
  51179. constructor(
  51180. /**
  51181. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51182. */
  51183. size: number,
  51184. /**
  51185. * 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.
  51186. */
  51187. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  51188. /**
  51189. * Dispose and release the lens flare with its associated resources.
  51190. */
  51191. dispose(): void;
  51192. }
  51193. }
  51194. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  51195. import { Nullable } from "babylonjs/types";
  51196. import { Scene } from "babylonjs/scene";
  51197. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51198. import { AbstractScene } from "babylonjs/abstractScene";
  51199. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  51200. module "babylonjs/abstractScene" {
  51201. interface AbstractScene {
  51202. /**
  51203. * The list of lens flare system added to the scene
  51204. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51205. */
  51206. lensFlareSystems: Array<LensFlareSystem>;
  51207. /**
  51208. * Removes the given lens flare system from this scene.
  51209. * @param toRemove The lens flare system to remove
  51210. * @returns The index of the removed lens flare system
  51211. */
  51212. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  51213. /**
  51214. * Adds the given lens flare system to this scene
  51215. * @param newLensFlareSystem The lens flare system to add
  51216. */
  51217. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  51218. /**
  51219. * Gets a lens flare system using its name
  51220. * @param name defines the name to look for
  51221. * @returns the lens flare system or null if not found
  51222. */
  51223. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  51224. /**
  51225. * Gets a lens flare system using its id
  51226. * @param id defines the id to look for
  51227. * @returns the lens flare system or null if not found
  51228. */
  51229. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  51230. }
  51231. }
  51232. /**
  51233. * Defines the lens flare scene component responsible to manage any lens flares
  51234. * in a given scene.
  51235. */
  51236. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  51237. /**
  51238. * The component name helpfull to identify the component in the list of scene components.
  51239. */
  51240. readonly name: string;
  51241. /**
  51242. * The scene the component belongs to.
  51243. */
  51244. scene: Scene;
  51245. /**
  51246. * Creates a new instance of the component for the given scene
  51247. * @param scene Defines the scene to register the component in
  51248. */
  51249. constructor(scene: Scene);
  51250. /**
  51251. * Registers the component in a given scene
  51252. */
  51253. register(): void;
  51254. /**
  51255. * Rebuilds the elements related to this component in case of
  51256. * context lost for instance.
  51257. */
  51258. rebuild(): void;
  51259. /**
  51260. * Adds all the elements from the container to the scene
  51261. * @param container the container holding the elements
  51262. */
  51263. addFromContainer(container: AbstractScene): void;
  51264. /**
  51265. * Removes all the elements in the container from the scene
  51266. * @param container contains the elements to remove
  51267. * @param dispose if the removed element should be disposed (default: false)
  51268. */
  51269. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51270. /**
  51271. * Serializes the component data to the specified json object
  51272. * @param serializationObject The object to serialize to
  51273. */
  51274. serialize(serializationObject: any): void;
  51275. /**
  51276. * Disposes the component and the associated ressources.
  51277. */
  51278. dispose(): void;
  51279. private _draw;
  51280. }
  51281. }
  51282. declare module "babylonjs/LensFlares/index" {
  51283. export * from "babylonjs/LensFlares/lensFlare";
  51284. export * from "babylonjs/LensFlares/lensFlareSystem";
  51285. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  51286. }
  51287. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  51288. import { Scene } from "babylonjs/scene";
  51289. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51290. import { AbstractScene } from "babylonjs/abstractScene";
  51291. /**
  51292. * Defines the shadow generator component responsible to manage any shadow generators
  51293. * in a given scene.
  51294. */
  51295. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  51296. /**
  51297. * The component name helpfull to identify the component in the list of scene components.
  51298. */
  51299. readonly name: string;
  51300. /**
  51301. * The scene the component belongs to.
  51302. */
  51303. scene: Scene;
  51304. /**
  51305. * Creates a new instance of the component for the given scene
  51306. * @param scene Defines the scene to register the component in
  51307. */
  51308. constructor(scene: Scene);
  51309. /**
  51310. * Registers the component in a given scene
  51311. */
  51312. register(): void;
  51313. /**
  51314. * Rebuilds the elements related to this component in case of
  51315. * context lost for instance.
  51316. */
  51317. rebuild(): void;
  51318. /**
  51319. * Serializes the component data to the specified json object
  51320. * @param serializationObject The object to serialize to
  51321. */
  51322. serialize(serializationObject: any): void;
  51323. /**
  51324. * Adds all the elements from the container to the scene
  51325. * @param container the container holding the elements
  51326. */
  51327. addFromContainer(container: AbstractScene): void;
  51328. /**
  51329. * Removes all the elements in the container from the scene
  51330. * @param container contains the elements to remove
  51331. * @param dispose if the removed element should be disposed (default: false)
  51332. */
  51333. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51334. /**
  51335. * Rebuilds the elements related to this component in case of
  51336. * context lost for instance.
  51337. */
  51338. dispose(): void;
  51339. private _gatherRenderTargets;
  51340. }
  51341. }
  51342. declare module "babylonjs/Lights/Shadows/index" {
  51343. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  51344. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  51345. }
  51346. declare module "babylonjs/Lights/pointLight" {
  51347. import { Scene } from "babylonjs/scene";
  51348. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51350. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51351. import { Effect } from "babylonjs/Materials/effect";
  51352. /**
  51353. * A point light is a light defined by an unique point in world space.
  51354. * The light is emitted in every direction from this point.
  51355. * A good example of a point light is a standard light bulb.
  51356. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51357. */
  51358. export class PointLight extends ShadowLight {
  51359. private _shadowAngle;
  51360. /**
  51361. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51362. * This specifies what angle the shadow will use to be created.
  51363. *
  51364. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51365. */
  51366. /**
  51367. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51368. * This specifies what angle the shadow will use to be created.
  51369. *
  51370. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51371. */
  51372. shadowAngle: number;
  51373. /**
  51374. * Gets the direction if it has been set.
  51375. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51376. */
  51377. /**
  51378. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51379. */
  51380. direction: Vector3;
  51381. /**
  51382. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  51383. * A PointLight emits the light in every direction.
  51384. * It can cast shadows.
  51385. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  51386. * ```javascript
  51387. * var pointLight = new PointLight("pl", camera.position, scene);
  51388. * ```
  51389. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51390. * @param name The light friendly name
  51391. * @param position The position of the point light in the scene
  51392. * @param scene The scene the lights belongs to
  51393. */
  51394. constructor(name: string, position: Vector3, scene: Scene);
  51395. /**
  51396. * Returns the string "PointLight"
  51397. * @returns the class name
  51398. */
  51399. getClassName(): string;
  51400. /**
  51401. * Returns the integer 0.
  51402. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51403. */
  51404. getTypeID(): number;
  51405. /**
  51406. * Specifies wether or not the shadowmap should be a cube texture.
  51407. * @returns true if the shadowmap needs to be a cube texture.
  51408. */
  51409. needCube(): boolean;
  51410. /**
  51411. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  51412. * @param faceIndex The index of the face we are computed the direction to generate shadow
  51413. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  51414. */
  51415. getShadowDirection(faceIndex?: number): Vector3;
  51416. /**
  51417. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  51418. * - fov = PI / 2
  51419. * - aspect ratio : 1.0
  51420. * - z-near and far equal to the active camera minZ and maxZ.
  51421. * Returns the PointLight.
  51422. */
  51423. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51424. protected _buildUniformLayout(): void;
  51425. /**
  51426. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  51427. * @param effect The effect to update
  51428. * @param lightIndex The index of the light in the effect to update
  51429. * @returns The point light
  51430. */
  51431. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  51432. /**
  51433. * Prepares the list of defines specific to the light type.
  51434. * @param defines the list of defines
  51435. * @param lightIndex defines the index of the light for the effect
  51436. */
  51437. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51438. }
  51439. }
  51440. declare module "babylonjs/Lights/index" {
  51441. export * from "babylonjs/Lights/light";
  51442. export * from "babylonjs/Lights/shadowLight";
  51443. export * from "babylonjs/Lights/Shadows/index";
  51444. export * from "babylonjs/Lights/directionalLight";
  51445. export * from "babylonjs/Lights/hemisphericLight";
  51446. export * from "babylonjs/Lights/pointLight";
  51447. export * from "babylonjs/Lights/spotLight";
  51448. }
  51449. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  51450. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  51451. /**
  51452. * Header information of HDR texture files.
  51453. */
  51454. export interface HDRInfo {
  51455. /**
  51456. * The height of the texture in pixels.
  51457. */
  51458. height: number;
  51459. /**
  51460. * The width of the texture in pixels.
  51461. */
  51462. width: number;
  51463. /**
  51464. * The index of the beginning of the data in the binary file.
  51465. */
  51466. dataPosition: number;
  51467. }
  51468. /**
  51469. * This groups tools to convert HDR texture to native colors array.
  51470. */
  51471. export class HDRTools {
  51472. private static Ldexp;
  51473. private static Rgbe2float;
  51474. private static readStringLine;
  51475. /**
  51476. * Reads header information from an RGBE texture stored in a native array.
  51477. * More information on this format are available here:
  51478. * https://en.wikipedia.org/wiki/RGBE_image_format
  51479. *
  51480. * @param uint8array The binary file stored in native array.
  51481. * @return The header information.
  51482. */
  51483. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  51484. /**
  51485. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  51486. * This RGBE texture needs to store the information as a panorama.
  51487. *
  51488. * More information on this format are available here:
  51489. * https://en.wikipedia.org/wiki/RGBE_image_format
  51490. *
  51491. * @param buffer The binary file stored in an array buffer.
  51492. * @param size The expected size of the extracted cubemap.
  51493. * @return The Cube Map information.
  51494. */
  51495. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  51496. /**
  51497. * Returns the pixels data extracted from an RGBE texture.
  51498. * This pixels will be stored left to right up to down in the R G B order in one array.
  51499. *
  51500. * More information on this format are available here:
  51501. * https://en.wikipedia.org/wiki/RGBE_image_format
  51502. *
  51503. * @param uint8array The binary file stored in an array buffer.
  51504. * @param hdrInfo The header information of the file.
  51505. * @return The pixels data in RGB right to left up to down order.
  51506. */
  51507. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  51508. private static RGBE_ReadPixels_RLE;
  51509. }
  51510. }
  51511. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  51512. import { Nullable } from "babylonjs/types";
  51513. import { Scene } from "babylonjs/scene";
  51514. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51515. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51516. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51517. /**
  51518. * This represents a texture coming from an HDR input.
  51519. *
  51520. * The only supported format is currently panorama picture stored in RGBE format.
  51521. * Example of such files can be found on HDRLib: http://hdrlib.com/
  51522. */
  51523. export class HDRCubeTexture extends BaseTexture {
  51524. private static _facesMapping;
  51525. private _generateHarmonics;
  51526. private _noMipmap;
  51527. private _textureMatrix;
  51528. private _size;
  51529. private _onLoad;
  51530. private _onError;
  51531. /**
  51532. * The texture URL.
  51533. */
  51534. url: string;
  51535. /**
  51536. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  51537. */
  51538. coordinatesMode: number;
  51539. protected _isBlocking: boolean;
  51540. /**
  51541. * Sets wether or not the texture is blocking during loading.
  51542. */
  51543. /**
  51544. * Gets wether or not the texture is blocking during loading.
  51545. */
  51546. isBlocking: boolean;
  51547. protected _rotationY: number;
  51548. /**
  51549. * Sets texture matrix rotation angle around Y axis in radians.
  51550. */
  51551. /**
  51552. * Gets texture matrix rotation angle around Y axis radians.
  51553. */
  51554. rotationY: number;
  51555. /**
  51556. * Gets or sets the center of the bounding box associated with the cube texture
  51557. * It must define where the camera used to render the texture was set
  51558. */
  51559. boundingBoxPosition: Vector3;
  51560. private _boundingBoxSize;
  51561. /**
  51562. * Gets or sets the size of the bounding box associated with the cube texture
  51563. * When defined, the cubemap will switch to local mode
  51564. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  51565. * @example https://www.babylonjs-playground.com/#RNASML
  51566. */
  51567. boundingBoxSize: Vector3;
  51568. /**
  51569. * Instantiates an HDRTexture from the following parameters.
  51570. *
  51571. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  51572. * @param scene The scene the texture will be used in
  51573. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51574. * @param noMipmap Forces to not generate the mipmap if true
  51575. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  51576. * @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)
  51577. * @param reserved Reserved flag for internal use.
  51578. */
  51579. 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>);
  51580. /**
  51581. * Get the current class name of the texture useful for serialization or dynamic coding.
  51582. * @returns "HDRCubeTexture"
  51583. */
  51584. getClassName(): string;
  51585. /**
  51586. * Occurs when the file is raw .hdr file.
  51587. */
  51588. private loadTexture;
  51589. clone(): HDRCubeTexture;
  51590. delayLoad(): void;
  51591. /**
  51592. * Get the texture reflection matrix used to rotate/transform the reflection.
  51593. * @returns the reflection matrix
  51594. */
  51595. getReflectionTextureMatrix(): Matrix;
  51596. /**
  51597. * Set the texture reflection matrix used to rotate/transform the reflection.
  51598. * @param value Define the reflection matrix to set
  51599. */
  51600. setReflectionTextureMatrix(value: Matrix): void;
  51601. /**
  51602. * Parses a JSON representation of an HDR Texture in order to create the texture
  51603. * @param parsedTexture Define the JSON representation
  51604. * @param scene Define the scene the texture should be created in
  51605. * @param rootUrl Define the root url in case we need to load relative dependencies
  51606. * @returns the newly created texture after parsing
  51607. */
  51608. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  51609. serialize(): any;
  51610. }
  51611. }
  51612. declare module "babylonjs/Physics/physicsEngine" {
  51613. import { Nullable } from "babylonjs/types";
  51614. import { Vector3 } from "babylonjs/Maths/math.vector";
  51615. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51616. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  51617. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  51618. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51619. /**
  51620. * Class used to control physics engine
  51621. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51622. */
  51623. export class PhysicsEngine implements IPhysicsEngine {
  51624. private _physicsPlugin;
  51625. /**
  51626. * Global value used to control the smallest number supported by the simulation
  51627. */
  51628. static Epsilon: number;
  51629. private _impostors;
  51630. private _joints;
  51631. /**
  51632. * Gets the gravity vector used by the simulation
  51633. */
  51634. gravity: Vector3;
  51635. /**
  51636. * Factory used to create the default physics plugin.
  51637. * @returns The default physics plugin
  51638. */
  51639. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  51640. /**
  51641. * Creates a new Physics Engine
  51642. * @param gravity defines the gravity vector used by the simulation
  51643. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  51644. */
  51645. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  51646. /**
  51647. * Sets the gravity vector used by the simulation
  51648. * @param gravity defines the gravity vector to use
  51649. */
  51650. setGravity(gravity: Vector3): void;
  51651. /**
  51652. * Set the time step of the physics engine.
  51653. * Default is 1/60.
  51654. * To slow it down, enter 1/600 for example.
  51655. * To speed it up, 1/30
  51656. * @param newTimeStep defines the new timestep to apply to this world.
  51657. */
  51658. setTimeStep(newTimeStep?: number): void;
  51659. /**
  51660. * Get the time step of the physics engine.
  51661. * @returns the current time step
  51662. */
  51663. getTimeStep(): number;
  51664. /**
  51665. * Release all resources
  51666. */
  51667. dispose(): void;
  51668. /**
  51669. * Gets the name of the current physics plugin
  51670. * @returns the name of the plugin
  51671. */
  51672. getPhysicsPluginName(): string;
  51673. /**
  51674. * Adding a new impostor for the impostor tracking.
  51675. * This will be done by the impostor itself.
  51676. * @param impostor the impostor to add
  51677. */
  51678. addImpostor(impostor: PhysicsImpostor): void;
  51679. /**
  51680. * Remove an impostor from the engine.
  51681. * This impostor and its mesh will not longer be updated by the physics engine.
  51682. * @param impostor the impostor to remove
  51683. */
  51684. removeImpostor(impostor: PhysicsImpostor): void;
  51685. /**
  51686. * Add a joint to the physics engine
  51687. * @param mainImpostor defines the main impostor to which the joint is added.
  51688. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  51689. * @param joint defines the joint that will connect both impostors.
  51690. */
  51691. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51692. /**
  51693. * Removes a joint from the simulation
  51694. * @param mainImpostor defines the impostor used with the joint
  51695. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  51696. * @param joint defines the joint to remove
  51697. */
  51698. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51699. /**
  51700. * Called by the scene. No need to call it.
  51701. * @param delta defines the timespam between frames
  51702. */
  51703. _step(delta: number): void;
  51704. /**
  51705. * Gets the current plugin used to run the simulation
  51706. * @returns current plugin
  51707. */
  51708. getPhysicsPlugin(): IPhysicsEnginePlugin;
  51709. /**
  51710. * Gets the list of physic impostors
  51711. * @returns an array of PhysicsImpostor
  51712. */
  51713. getImpostors(): Array<PhysicsImpostor>;
  51714. /**
  51715. * Gets the impostor for a physics enabled object
  51716. * @param object defines the object impersonated by the impostor
  51717. * @returns the PhysicsImpostor or null if not found
  51718. */
  51719. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  51720. /**
  51721. * Gets the impostor for a physics body object
  51722. * @param body defines physics body used by the impostor
  51723. * @returns the PhysicsImpostor or null if not found
  51724. */
  51725. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  51726. /**
  51727. * Does a raycast in the physics world
  51728. * @param from when should the ray start?
  51729. * @param to when should the ray end?
  51730. * @returns PhysicsRaycastResult
  51731. */
  51732. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51733. }
  51734. }
  51735. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  51736. import { Nullable } from "babylonjs/types";
  51737. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  51738. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51739. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51740. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51741. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51742. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51743. /** @hidden */
  51744. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  51745. private _useDeltaForWorldStep;
  51746. world: any;
  51747. name: string;
  51748. private _physicsMaterials;
  51749. private _fixedTimeStep;
  51750. private _cannonRaycastResult;
  51751. private _raycastResult;
  51752. private _physicsBodysToRemoveAfterStep;
  51753. BJSCANNON: any;
  51754. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  51755. setGravity(gravity: Vector3): void;
  51756. setTimeStep(timeStep: number): void;
  51757. getTimeStep(): number;
  51758. executeStep(delta: number): void;
  51759. private _removeMarkedPhysicsBodiesFromWorld;
  51760. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51761. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51762. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51763. private _processChildMeshes;
  51764. removePhysicsBody(impostor: PhysicsImpostor): void;
  51765. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51766. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51767. private _addMaterial;
  51768. private _checkWithEpsilon;
  51769. private _createShape;
  51770. private _createHeightmap;
  51771. private _minus90X;
  51772. private _plus90X;
  51773. private _tmpPosition;
  51774. private _tmpDeltaPosition;
  51775. private _tmpUnityRotation;
  51776. private _updatePhysicsBodyTransformation;
  51777. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51778. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51779. isSupported(): boolean;
  51780. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51781. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51782. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51783. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51784. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51785. getBodyMass(impostor: PhysicsImpostor): number;
  51786. getBodyFriction(impostor: PhysicsImpostor): number;
  51787. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51788. getBodyRestitution(impostor: PhysicsImpostor): number;
  51789. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51790. sleepBody(impostor: PhysicsImpostor): void;
  51791. wakeUpBody(impostor: PhysicsImpostor): void;
  51792. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  51793. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51794. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51795. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51796. getRadius(impostor: PhysicsImpostor): number;
  51797. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51798. dispose(): void;
  51799. private _extendNamespace;
  51800. /**
  51801. * Does a raycast in the physics world
  51802. * @param from when should the ray start?
  51803. * @param to when should the ray end?
  51804. * @returns PhysicsRaycastResult
  51805. */
  51806. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51807. }
  51808. }
  51809. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  51810. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51811. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51812. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51813. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51814. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  51815. import { Nullable } from "babylonjs/types";
  51816. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51817. /** @hidden */
  51818. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  51819. world: any;
  51820. name: string;
  51821. BJSOIMO: any;
  51822. private _raycastResult;
  51823. constructor(iterations?: number, oimoInjection?: any);
  51824. setGravity(gravity: Vector3): void;
  51825. setTimeStep(timeStep: number): void;
  51826. getTimeStep(): number;
  51827. private _tmpImpostorsArray;
  51828. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51829. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51830. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51831. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51832. private _tmpPositionVector;
  51833. removePhysicsBody(impostor: PhysicsImpostor): void;
  51834. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51835. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51836. isSupported(): boolean;
  51837. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51838. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51839. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51840. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51841. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51842. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51843. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51844. getBodyMass(impostor: PhysicsImpostor): number;
  51845. getBodyFriction(impostor: PhysicsImpostor): number;
  51846. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51847. getBodyRestitution(impostor: PhysicsImpostor): number;
  51848. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51849. sleepBody(impostor: PhysicsImpostor): void;
  51850. wakeUpBody(impostor: PhysicsImpostor): void;
  51851. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51852. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51853. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51854. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51855. getRadius(impostor: PhysicsImpostor): number;
  51856. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51857. dispose(): void;
  51858. /**
  51859. * Does a raycast in the physics world
  51860. * @param from when should the ray start?
  51861. * @param to when should the ray end?
  51862. * @returns PhysicsRaycastResult
  51863. */
  51864. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51865. }
  51866. }
  51867. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  51868. import { Nullable } from "babylonjs/types";
  51869. import { Scene } from "babylonjs/scene";
  51870. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  51871. import { Color4 } from "babylonjs/Maths/math.color";
  51872. import { Mesh } from "babylonjs/Meshes/mesh";
  51873. /**
  51874. * Class containing static functions to help procedurally build meshes
  51875. */
  51876. export class RibbonBuilder {
  51877. /**
  51878. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51879. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51880. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51881. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51882. * * 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
  51883. * * 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
  51884. * * 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
  51885. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51886. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51887. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51888. * * 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
  51889. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51890. * * 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
  51891. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51893. * @param name defines the name of the mesh
  51894. * @param options defines the options used to create the mesh
  51895. * @param scene defines the hosting scene
  51896. * @returns the ribbon mesh
  51897. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51898. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51899. */
  51900. static CreateRibbon(name: string, options: {
  51901. pathArray: Vector3[][];
  51902. closeArray?: boolean;
  51903. closePath?: boolean;
  51904. offset?: number;
  51905. updatable?: boolean;
  51906. sideOrientation?: number;
  51907. frontUVs?: Vector4;
  51908. backUVs?: Vector4;
  51909. instance?: Mesh;
  51910. invertUV?: boolean;
  51911. uvs?: Vector2[];
  51912. colors?: Color4[];
  51913. }, scene?: Nullable<Scene>): Mesh;
  51914. }
  51915. }
  51916. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  51917. import { Nullable } from "babylonjs/types";
  51918. import { Scene } from "babylonjs/scene";
  51919. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  51920. import { Mesh } from "babylonjs/Meshes/mesh";
  51921. /**
  51922. * Class containing static functions to help procedurally build meshes
  51923. */
  51924. export class ShapeBuilder {
  51925. /**
  51926. * 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.
  51927. * * 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.
  51928. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51929. * * 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.
  51930. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51931. * * 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
  51932. * * 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
  51933. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51934. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51935. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51936. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51937. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51938. * @param name defines the name of the mesh
  51939. * @param options defines the options used to create the mesh
  51940. * @param scene defines the hosting scene
  51941. * @returns the extruded shape mesh
  51942. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51943. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51944. */
  51945. static ExtrudeShape(name: string, options: {
  51946. shape: Vector3[];
  51947. path: Vector3[];
  51948. scale?: number;
  51949. rotation?: number;
  51950. cap?: number;
  51951. updatable?: boolean;
  51952. sideOrientation?: number;
  51953. frontUVs?: Vector4;
  51954. backUVs?: Vector4;
  51955. instance?: Mesh;
  51956. invertUV?: boolean;
  51957. }, scene?: Nullable<Scene>): Mesh;
  51958. /**
  51959. * Creates an custom extruded shape mesh.
  51960. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51961. * * 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.
  51962. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51963. * * 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
  51964. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51965. * * 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
  51966. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51967. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51968. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51969. * * 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
  51970. * * 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
  51971. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51972. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51973. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51974. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51975. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51976. * @param name defines the name of the mesh
  51977. * @param options defines the options used to create the mesh
  51978. * @param scene defines the hosting scene
  51979. * @returns the custom extruded shape mesh
  51980. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51981. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51982. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51983. */
  51984. static ExtrudeShapeCustom(name: string, options: {
  51985. shape: Vector3[];
  51986. path: Vector3[];
  51987. scaleFunction?: any;
  51988. rotationFunction?: any;
  51989. ribbonCloseArray?: boolean;
  51990. ribbonClosePath?: boolean;
  51991. cap?: number;
  51992. updatable?: boolean;
  51993. sideOrientation?: number;
  51994. frontUVs?: Vector4;
  51995. backUVs?: Vector4;
  51996. instance?: Mesh;
  51997. invertUV?: boolean;
  51998. }, scene?: Nullable<Scene>): Mesh;
  51999. private static _ExtrudeShapeGeneric;
  52000. }
  52001. }
  52002. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52003. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  52004. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52005. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52006. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52007. import { Nullable } from "babylonjs/types";
  52008. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52009. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52010. /**
  52011. * AmmoJS Physics plugin
  52012. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52013. * @see https://github.com/kripken/ammo.js/
  52014. */
  52015. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52016. private _useDeltaForWorldStep;
  52017. /**
  52018. * Reference to the Ammo library
  52019. */
  52020. bjsAMMO: any;
  52021. /**
  52022. * Created ammoJS world which physics bodies are added to
  52023. */
  52024. world: any;
  52025. /**
  52026. * Name of the plugin
  52027. */
  52028. name: string;
  52029. private _timeStep;
  52030. private _fixedTimeStep;
  52031. private _maxSteps;
  52032. private _tmpQuaternion;
  52033. private _tmpAmmoTransform;
  52034. private _tmpAmmoQuaternion;
  52035. private _tmpAmmoConcreteContactResultCallback;
  52036. private _collisionConfiguration;
  52037. private _dispatcher;
  52038. private _overlappingPairCache;
  52039. private _solver;
  52040. private _softBodySolver;
  52041. private _tmpAmmoVectorA;
  52042. private _tmpAmmoVectorB;
  52043. private _tmpAmmoVectorC;
  52044. private _tmpAmmoVectorD;
  52045. private _tmpContactCallbackResult;
  52046. private _tmpAmmoVectorRCA;
  52047. private _tmpAmmoVectorRCB;
  52048. private _raycastResult;
  52049. private static readonly DISABLE_COLLISION_FLAG;
  52050. private static readonly KINEMATIC_FLAG;
  52051. private static readonly DISABLE_DEACTIVATION_FLAG;
  52052. /**
  52053. * Initializes the ammoJS plugin
  52054. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52055. * @param ammoInjection can be used to inject your own ammo reference
  52056. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  52057. */
  52058. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  52059. /**
  52060. * Sets the gravity of the physics world (m/(s^2))
  52061. * @param gravity Gravity to set
  52062. */
  52063. setGravity(gravity: Vector3): void;
  52064. /**
  52065. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52066. * @param timeStep timestep to use in seconds
  52067. */
  52068. setTimeStep(timeStep: number): void;
  52069. /**
  52070. * 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)
  52071. * @param fixedTimeStep fixedTimeStep to use in seconds
  52072. */
  52073. setFixedTimeStep(fixedTimeStep: number): void;
  52074. /**
  52075. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52076. * @param maxSteps the maximum number of steps by the physics engine per frame
  52077. */
  52078. setMaxSteps(maxSteps: number): void;
  52079. /**
  52080. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52081. * @returns the current timestep in seconds
  52082. */
  52083. getTimeStep(): number;
  52084. private _isImpostorInContact;
  52085. private _isImpostorPairInContact;
  52086. private _stepSimulation;
  52087. /**
  52088. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52089. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52090. * After the step the babylon meshes are set to the position of the physics imposters
  52091. * @param delta amount of time to step forward
  52092. * @param impostors array of imposters to update before/after the step
  52093. */
  52094. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52095. /**
  52096. * Update babylon mesh to match physics world object
  52097. * @param impostor imposter to match
  52098. */
  52099. private _afterSoftStep;
  52100. /**
  52101. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52102. * @param impostor imposter to match
  52103. */
  52104. private _ropeStep;
  52105. /**
  52106. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52107. * @param impostor imposter to match
  52108. */
  52109. private _softbodyOrClothStep;
  52110. private _tmpVector;
  52111. private _tmpMatrix;
  52112. /**
  52113. * Applies an impulse on the imposter
  52114. * @param impostor imposter to apply impulse to
  52115. * @param force amount of force to be applied to the imposter
  52116. * @param contactPoint the location to apply the impulse on the imposter
  52117. */
  52118. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52119. /**
  52120. * Applies a force on the imposter
  52121. * @param impostor imposter to apply force
  52122. * @param force amount of force to be applied to the imposter
  52123. * @param contactPoint the location to apply the force on the imposter
  52124. */
  52125. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52126. /**
  52127. * Creates a physics body using the plugin
  52128. * @param impostor the imposter to create the physics body on
  52129. */
  52130. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52131. /**
  52132. * Removes the physics body from the imposter and disposes of the body's memory
  52133. * @param impostor imposter to remove the physics body from
  52134. */
  52135. removePhysicsBody(impostor: PhysicsImpostor): void;
  52136. /**
  52137. * Generates a joint
  52138. * @param impostorJoint the imposter joint to create the joint with
  52139. */
  52140. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52141. /**
  52142. * Removes a joint
  52143. * @param impostorJoint the imposter joint to remove the joint from
  52144. */
  52145. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52146. private _addMeshVerts;
  52147. /**
  52148. * Initialise the soft body vertices to match its object's (mesh) vertices
  52149. * Softbody vertices (nodes) are in world space and to match this
  52150. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  52151. * @param impostor to create the softbody for
  52152. */
  52153. private _softVertexData;
  52154. /**
  52155. * Create an impostor's soft body
  52156. * @param impostor to create the softbody for
  52157. */
  52158. private _createSoftbody;
  52159. /**
  52160. * Create cloth for an impostor
  52161. * @param impostor to create the softbody for
  52162. */
  52163. private _createCloth;
  52164. /**
  52165. * Create rope for an impostor
  52166. * @param impostor to create the softbody for
  52167. */
  52168. private _createRope;
  52169. private _addHullVerts;
  52170. private _createShape;
  52171. /**
  52172. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  52173. * @param impostor imposter containing the physics body and babylon object
  52174. */
  52175. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52176. /**
  52177. * Sets the babylon object's position/rotation from the physics body's position/rotation
  52178. * @param impostor imposter containing the physics body and babylon object
  52179. * @param newPosition new position
  52180. * @param newRotation new rotation
  52181. */
  52182. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52183. /**
  52184. * If this plugin is supported
  52185. * @returns true if its supported
  52186. */
  52187. isSupported(): boolean;
  52188. /**
  52189. * Sets the linear velocity of the physics body
  52190. * @param impostor imposter to set the velocity on
  52191. * @param velocity velocity to set
  52192. */
  52193. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52194. /**
  52195. * Sets the angular velocity of the physics body
  52196. * @param impostor imposter to set the velocity on
  52197. * @param velocity velocity to set
  52198. */
  52199. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52200. /**
  52201. * gets the linear velocity
  52202. * @param impostor imposter to get linear velocity from
  52203. * @returns linear velocity
  52204. */
  52205. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52206. /**
  52207. * gets the angular velocity
  52208. * @param impostor imposter to get angular velocity from
  52209. * @returns angular velocity
  52210. */
  52211. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52212. /**
  52213. * Sets the mass of physics body
  52214. * @param impostor imposter to set the mass on
  52215. * @param mass mass to set
  52216. */
  52217. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52218. /**
  52219. * Gets the mass of the physics body
  52220. * @param impostor imposter to get the mass from
  52221. * @returns mass
  52222. */
  52223. getBodyMass(impostor: PhysicsImpostor): number;
  52224. /**
  52225. * Gets friction of the impostor
  52226. * @param impostor impostor to get friction from
  52227. * @returns friction value
  52228. */
  52229. getBodyFriction(impostor: PhysicsImpostor): number;
  52230. /**
  52231. * Sets friction of the impostor
  52232. * @param impostor impostor to set friction on
  52233. * @param friction friction value
  52234. */
  52235. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52236. /**
  52237. * Gets restitution of the impostor
  52238. * @param impostor impostor to get restitution from
  52239. * @returns restitution value
  52240. */
  52241. getBodyRestitution(impostor: PhysicsImpostor): number;
  52242. /**
  52243. * Sets resitution of the impostor
  52244. * @param impostor impostor to set resitution on
  52245. * @param restitution resitution value
  52246. */
  52247. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52248. /**
  52249. * Gets pressure inside the impostor
  52250. * @param impostor impostor to get pressure from
  52251. * @returns pressure value
  52252. */
  52253. getBodyPressure(impostor: PhysicsImpostor): number;
  52254. /**
  52255. * Sets pressure inside a soft body impostor
  52256. * Cloth and rope must remain 0 pressure
  52257. * @param impostor impostor to set pressure on
  52258. * @param pressure pressure value
  52259. */
  52260. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  52261. /**
  52262. * Gets stiffness of the impostor
  52263. * @param impostor impostor to get stiffness from
  52264. * @returns pressure value
  52265. */
  52266. getBodyStiffness(impostor: PhysicsImpostor): number;
  52267. /**
  52268. * Sets stiffness of the impostor
  52269. * @param impostor impostor to set stiffness on
  52270. * @param stiffness stiffness value from 0 to 1
  52271. */
  52272. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  52273. /**
  52274. * Gets velocityIterations of the impostor
  52275. * @param impostor impostor to get velocity iterations from
  52276. * @returns velocityIterations value
  52277. */
  52278. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  52279. /**
  52280. * Sets velocityIterations of the impostor
  52281. * @param impostor impostor to set velocity iterations on
  52282. * @param velocityIterations velocityIterations value
  52283. */
  52284. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  52285. /**
  52286. * Gets positionIterations of the impostor
  52287. * @param impostor impostor to get position iterations from
  52288. * @returns positionIterations value
  52289. */
  52290. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  52291. /**
  52292. * Sets positionIterations of the impostor
  52293. * @param impostor impostor to set position on
  52294. * @param positionIterations positionIterations value
  52295. */
  52296. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  52297. /**
  52298. * Append an anchor to a cloth object
  52299. * @param impostor is the cloth impostor to add anchor to
  52300. * @param otherImpostor is the rigid impostor to anchor to
  52301. * @param width ratio across width from 0 to 1
  52302. * @param height ratio up height from 0 to 1
  52303. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  52304. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52305. */
  52306. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52307. /**
  52308. * Append an hook to a rope object
  52309. * @param impostor is the rope impostor to add hook to
  52310. * @param otherImpostor is the rigid impostor to hook to
  52311. * @param length ratio along the rope from 0 to 1
  52312. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  52313. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52314. */
  52315. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52316. /**
  52317. * Sleeps the physics body and stops it from being active
  52318. * @param impostor impostor to sleep
  52319. */
  52320. sleepBody(impostor: PhysicsImpostor): void;
  52321. /**
  52322. * Activates the physics body
  52323. * @param impostor impostor to activate
  52324. */
  52325. wakeUpBody(impostor: PhysicsImpostor): void;
  52326. /**
  52327. * Updates the distance parameters of the joint
  52328. * @param joint joint to update
  52329. * @param maxDistance maximum distance of the joint
  52330. * @param minDistance minimum distance of the joint
  52331. */
  52332. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52333. /**
  52334. * Sets a motor on the joint
  52335. * @param joint joint to set motor on
  52336. * @param speed speed of the motor
  52337. * @param maxForce maximum force of the motor
  52338. * @param motorIndex index of the motor
  52339. */
  52340. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52341. /**
  52342. * Sets the motors limit
  52343. * @param joint joint to set limit on
  52344. * @param upperLimit upper limit
  52345. * @param lowerLimit lower limit
  52346. */
  52347. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52348. /**
  52349. * Syncs the position and rotation of a mesh with the impostor
  52350. * @param mesh mesh to sync
  52351. * @param impostor impostor to update the mesh with
  52352. */
  52353. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52354. /**
  52355. * Gets the radius of the impostor
  52356. * @param impostor impostor to get radius from
  52357. * @returns the radius
  52358. */
  52359. getRadius(impostor: PhysicsImpostor): number;
  52360. /**
  52361. * Gets the box size of the impostor
  52362. * @param impostor impostor to get box size from
  52363. * @param result the resulting box size
  52364. */
  52365. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52366. /**
  52367. * Disposes of the impostor
  52368. */
  52369. dispose(): void;
  52370. /**
  52371. * Does a raycast in the physics world
  52372. * @param from when should the ray start?
  52373. * @param to when should the ray end?
  52374. * @returns PhysicsRaycastResult
  52375. */
  52376. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52377. }
  52378. }
  52379. declare module "babylonjs/Probes/reflectionProbe" {
  52380. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52381. import { Vector3 } from "babylonjs/Maths/math.vector";
  52382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52383. import { Nullable } from "babylonjs/types";
  52384. import { Scene } from "babylonjs/scene";
  52385. module "babylonjs/abstractScene" {
  52386. interface AbstractScene {
  52387. /**
  52388. * The list of reflection probes added to the scene
  52389. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52390. */
  52391. reflectionProbes: Array<ReflectionProbe>;
  52392. /**
  52393. * Removes the given reflection probe from this scene.
  52394. * @param toRemove The reflection probe to remove
  52395. * @returns The index of the removed reflection probe
  52396. */
  52397. removeReflectionProbe(toRemove: ReflectionProbe): number;
  52398. /**
  52399. * Adds the given reflection probe to this scene.
  52400. * @param newReflectionProbe The reflection probe to add
  52401. */
  52402. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  52403. }
  52404. }
  52405. /**
  52406. * Class used to generate realtime reflection / refraction cube textures
  52407. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52408. */
  52409. export class ReflectionProbe {
  52410. /** defines the name of the probe */
  52411. name: string;
  52412. private _scene;
  52413. private _renderTargetTexture;
  52414. private _projectionMatrix;
  52415. private _viewMatrix;
  52416. private _target;
  52417. private _add;
  52418. private _attachedMesh;
  52419. private _invertYAxis;
  52420. /** Gets or sets probe position (center of the cube map) */
  52421. position: Vector3;
  52422. /**
  52423. * Creates a new reflection probe
  52424. * @param name defines the name of the probe
  52425. * @param size defines the texture resolution (for each face)
  52426. * @param scene defines the hosting scene
  52427. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  52428. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  52429. */
  52430. constructor(
  52431. /** defines the name of the probe */
  52432. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  52433. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  52434. samples: number;
  52435. /** Gets or sets the refresh rate to use (on every frame by default) */
  52436. refreshRate: number;
  52437. /**
  52438. * Gets the hosting scene
  52439. * @returns a Scene
  52440. */
  52441. getScene(): Scene;
  52442. /** Gets the internal CubeTexture used to render to */
  52443. readonly cubeTexture: RenderTargetTexture;
  52444. /** Gets the list of meshes to render */
  52445. readonly renderList: Nullable<AbstractMesh[]>;
  52446. /**
  52447. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  52448. * @param mesh defines the mesh to attach to
  52449. */
  52450. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52451. /**
  52452. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  52453. * @param renderingGroupId The rendering group id corresponding to its index
  52454. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  52455. */
  52456. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  52457. /**
  52458. * Clean all associated resources
  52459. */
  52460. dispose(): void;
  52461. /**
  52462. * Converts the reflection probe information to a readable string for debug purpose.
  52463. * @param fullDetails Supports for multiple levels of logging within scene loading
  52464. * @returns the human readable reflection probe info
  52465. */
  52466. toString(fullDetails?: boolean): string;
  52467. /**
  52468. * Get the class name of the relfection probe.
  52469. * @returns "ReflectionProbe"
  52470. */
  52471. getClassName(): string;
  52472. /**
  52473. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  52474. * @returns The JSON representation of the texture
  52475. */
  52476. serialize(): any;
  52477. /**
  52478. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  52479. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  52480. * @param scene Define the scene the parsed reflection probe should be instantiated in
  52481. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  52482. * @returns The parsed reflection probe if successful
  52483. */
  52484. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  52485. }
  52486. }
  52487. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  52488. /** @hidden */
  52489. export var _BabylonLoaderRegistered: boolean;
  52490. }
  52491. declare module "babylonjs/Loading/Plugins/index" {
  52492. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  52493. }
  52494. declare module "babylonjs/Loading/index" {
  52495. export * from "babylonjs/Loading/loadingScreen";
  52496. export * from "babylonjs/Loading/Plugins/index";
  52497. export * from "babylonjs/Loading/sceneLoader";
  52498. export * from "babylonjs/Loading/sceneLoaderFlags";
  52499. }
  52500. declare module "babylonjs/Materials/Background/index" {
  52501. export * from "babylonjs/Materials/Background/backgroundMaterial";
  52502. }
  52503. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  52504. import { Scene } from "babylonjs/scene";
  52505. import { Color3 } from "babylonjs/Maths/math.color";
  52506. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52507. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52508. /**
  52509. * The Physically based simple base material of BJS.
  52510. *
  52511. * This enables better naming and convention enforcements on top of the pbrMaterial.
  52512. * It is used as the base class for both the specGloss and metalRough conventions.
  52513. */
  52514. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  52515. /**
  52516. * Number of Simultaneous lights allowed on the material.
  52517. */
  52518. maxSimultaneousLights: number;
  52519. /**
  52520. * If sets to true, disables all the lights affecting the material.
  52521. */
  52522. disableLighting: boolean;
  52523. /**
  52524. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  52525. */
  52526. environmentTexture: BaseTexture;
  52527. /**
  52528. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52529. */
  52530. invertNormalMapX: boolean;
  52531. /**
  52532. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52533. */
  52534. invertNormalMapY: boolean;
  52535. /**
  52536. * Normal map used in the model.
  52537. */
  52538. normalTexture: BaseTexture;
  52539. /**
  52540. * Emissivie color used to self-illuminate the model.
  52541. */
  52542. emissiveColor: Color3;
  52543. /**
  52544. * Emissivie texture used to self-illuminate the model.
  52545. */
  52546. emissiveTexture: BaseTexture;
  52547. /**
  52548. * Occlusion Channel Strenght.
  52549. */
  52550. occlusionStrength: number;
  52551. /**
  52552. * Occlusion Texture of the material (adding extra occlusion effects).
  52553. */
  52554. occlusionTexture: BaseTexture;
  52555. /**
  52556. * Defines the alpha limits in alpha test mode.
  52557. */
  52558. alphaCutOff: number;
  52559. /**
  52560. * Gets the current double sided mode.
  52561. */
  52562. /**
  52563. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52564. */
  52565. doubleSided: boolean;
  52566. /**
  52567. * Stores the pre-calculated light information of a mesh in a texture.
  52568. */
  52569. lightmapTexture: BaseTexture;
  52570. /**
  52571. * If true, the light map contains occlusion information instead of lighting info.
  52572. */
  52573. useLightmapAsShadowmap: boolean;
  52574. /**
  52575. * Instantiates a new PBRMaterial instance.
  52576. *
  52577. * @param name The material name
  52578. * @param scene The scene the material will be use in.
  52579. */
  52580. constructor(name: string, scene: Scene);
  52581. getClassName(): string;
  52582. }
  52583. }
  52584. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  52585. import { Scene } from "babylonjs/scene";
  52586. import { Color3 } from "babylonjs/Maths/math.color";
  52587. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52588. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52589. /**
  52590. * The PBR material of BJS following the metal roughness convention.
  52591. *
  52592. * This fits to the PBR convention in the GLTF definition:
  52593. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  52594. */
  52595. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  52596. /**
  52597. * The base color has two different interpretations depending on the value of metalness.
  52598. * When the material is a metal, the base color is the specific measured reflectance value
  52599. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  52600. * of the material.
  52601. */
  52602. baseColor: Color3;
  52603. /**
  52604. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  52605. * well as opacity information in the alpha channel.
  52606. */
  52607. baseTexture: BaseTexture;
  52608. /**
  52609. * Specifies the metallic scalar value of the material.
  52610. * Can also be used to scale the metalness values of the metallic texture.
  52611. */
  52612. metallic: number;
  52613. /**
  52614. * Specifies the roughness scalar value of the material.
  52615. * Can also be used to scale the roughness values of the metallic texture.
  52616. */
  52617. roughness: number;
  52618. /**
  52619. * Texture containing both the metallic value in the B channel and the
  52620. * roughness value in the G channel to keep better precision.
  52621. */
  52622. metallicRoughnessTexture: BaseTexture;
  52623. /**
  52624. * Instantiates a new PBRMetalRoughnessMaterial instance.
  52625. *
  52626. * @param name The material name
  52627. * @param scene The scene the material will be use in.
  52628. */
  52629. constructor(name: string, scene: Scene);
  52630. /**
  52631. * Return the currrent class name of the material.
  52632. */
  52633. getClassName(): string;
  52634. /**
  52635. * Makes a duplicate of the current material.
  52636. * @param name - name to use for the new material.
  52637. */
  52638. clone(name: string): PBRMetallicRoughnessMaterial;
  52639. /**
  52640. * Serialize the material to a parsable JSON object.
  52641. */
  52642. serialize(): any;
  52643. /**
  52644. * Parses a JSON object correponding to the serialize function.
  52645. */
  52646. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  52647. }
  52648. }
  52649. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  52650. import { Scene } from "babylonjs/scene";
  52651. import { Color3 } from "babylonjs/Maths/math.color";
  52652. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52653. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52654. /**
  52655. * The PBR material of BJS following the specular glossiness convention.
  52656. *
  52657. * This fits to the PBR convention in the GLTF definition:
  52658. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  52659. */
  52660. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  52661. /**
  52662. * Specifies the diffuse color of the material.
  52663. */
  52664. diffuseColor: Color3;
  52665. /**
  52666. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  52667. * channel.
  52668. */
  52669. diffuseTexture: BaseTexture;
  52670. /**
  52671. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  52672. */
  52673. specularColor: Color3;
  52674. /**
  52675. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  52676. */
  52677. glossiness: number;
  52678. /**
  52679. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  52680. */
  52681. specularGlossinessTexture: BaseTexture;
  52682. /**
  52683. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  52684. *
  52685. * @param name The material name
  52686. * @param scene The scene the material will be use in.
  52687. */
  52688. constructor(name: string, scene: Scene);
  52689. /**
  52690. * Return the currrent class name of the material.
  52691. */
  52692. getClassName(): string;
  52693. /**
  52694. * Makes a duplicate of the current material.
  52695. * @param name - name to use for the new material.
  52696. */
  52697. clone(name: string): PBRSpecularGlossinessMaterial;
  52698. /**
  52699. * Serialize the material to a parsable JSON object.
  52700. */
  52701. serialize(): any;
  52702. /**
  52703. * Parses a JSON object correponding to the serialize function.
  52704. */
  52705. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  52706. }
  52707. }
  52708. declare module "babylonjs/Materials/PBR/index" {
  52709. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52710. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52711. export * from "babylonjs/Materials/PBR/pbrMaterial";
  52712. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  52713. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  52714. }
  52715. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  52716. import { Nullable } from "babylonjs/types";
  52717. import { Scene } from "babylonjs/scene";
  52718. import { Matrix } from "babylonjs/Maths/math.vector";
  52719. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52720. /**
  52721. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  52722. * It can help converting any input color in a desired output one. This can then be used to create effects
  52723. * from sepia, black and white to sixties or futuristic rendering...
  52724. *
  52725. * The only supported format is currently 3dl.
  52726. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  52727. */
  52728. export class ColorGradingTexture extends BaseTexture {
  52729. /**
  52730. * The current texture matrix. (will always be identity in color grading texture)
  52731. */
  52732. private _textureMatrix;
  52733. /**
  52734. * The texture URL.
  52735. */
  52736. url: string;
  52737. /**
  52738. * Empty line regex stored for GC.
  52739. */
  52740. private static _noneEmptyLineRegex;
  52741. private _engine;
  52742. /**
  52743. * Instantiates a ColorGradingTexture from the following parameters.
  52744. *
  52745. * @param url The location of the color gradind data (currently only supporting 3dl)
  52746. * @param scene The scene the texture will be used in
  52747. */
  52748. constructor(url: string, scene: Scene);
  52749. /**
  52750. * Returns the texture matrix used in most of the material.
  52751. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  52752. */
  52753. getTextureMatrix(): Matrix;
  52754. /**
  52755. * Occurs when the file being loaded is a .3dl LUT file.
  52756. */
  52757. private load3dlTexture;
  52758. /**
  52759. * Starts the loading process of the texture.
  52760. */
  52761. private loadTexture;
  52762. /**
  52763. * Clones the color gradind texture.
  52764. */
  52765. clone(): ColorGradingTexture;
  52766. /**
  52767. * Called during delayed load for textures.
  52768. */
  52769. delayLoad(): void;
  52770. /**
  52771. * Parses a color grading texture serialized by Babylon.
  52772. * @param parsedTexture The texture information being parsedTexture
  52773. * @param scene The scene to load the texture in
  52774. * @param rootUrl The root url of the data assets to load
  52775. * @return A color gradind texture
  52776. */
  52777. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  52778. /**
  52779. * Serializes the LUT texture to json format.
  52780. */
  52781. serialize(): any;
  52782. }
  52783. }
  52784. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  52785. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52786. import { Scene } from "babylonjs/scene";
  52787. import { Nullable } from "babylonjs/types";
  52788. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52789. /**
  52790. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  52791. */
  52792. export class EquiRectangularCubeTexture extends BaseTexture {
  52793. /** The six faces of the cube. */
  52794. private static _FacesMapping;
  52795. private _noMipmap;
  52796. private _onLoad;
  52797. private _onError;
  52798. /** The size of the cubemap. */
  52799. private _size;
  52800. /** The buffer of the image. */
  52801. private _buffer;
  52802. /** The width of the input image. */
  52803. private _width;
  52804. /** The height of the input image. */
  52805. private _height;
  52806. /** The URL to the image. */
  52807. url: string;
  52808. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  52809. coordinatesMode: number;
  52810. /**
  52811. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  52812. * @param url The location of the image
  52813. * @param scene The scene the texture will be used in
  52814. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52815. * @param noMipmap Forces to not generate the mipmap if true
  52816. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  52817. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  52818. * @param onLoad — defines a callback called when texture is loaded
  52819. * @param onError — defines a callback called if there is an error
  52820. */
  52821. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52822. /**
  52823. * Load the image data, by putting the image on a canvas and extracting its buffer.
  52824. */
  52825. private loadImage;
  52826. /**
  52827. * Convert the image buffer into a cubemap and create a CubeTexture.
  52828. */
  52829. private loadTexture;
  52830. /**
  52831. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  52832. * @param buffer The ArrayBuffer that should be converted.
  52833. * @returns The buffer as Float32Array.
  52834. */
  52835. private getFloat32ArrayFromArrayBuffer;
  52836. /**
  52837. * Get the current class name of the texture useful for serialization or dynamic coding.
  52838. * @returns "EquiRectangularCubeTexture"
  52839. */
  52840. getClassName(): string;
  52841. /**
  52842. * Create a clone of the current EquiRectangularCubeTexture and return it.
  52843. * @returns A clone of the current EquiRectangularCubeTexture.
  52844. */
  52845. clone(): EquiRectangularCubeTexture;
  52846. }
  52847. }
  52848. declare module "babylonjs/Misc/tga" {
  52849. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52850. /**
  52851. * Based on jsTGALoader - Javascript loader for TGA file
  52852. * By Vincent Thibault
  52853. * @see http://blog.robrowser.com/javascript-tga-loader.html
  52854. */
  52855. export class TGATools {
  52856. private static _TYPE_INDEXED;
  52857. private static _TYPE_RGB;
  52858. private static _TYPE_GREY;
  52859. private static _TYPE_RLE_INDEXED;
  52860. private static _TYPE_RLE_RGB;
  52861. private static _TYPE_RLE_GREY;
  52862. private static _ORIGIN_MASK;
  52863. private static _ORIGIN_SHIFT;
  52864. private static _ORIGIN_BL;
  52865. private static _ORIGIN_BR;
  52866. private static _ORIGIN_UL;
  52867. private static _ORIGIN_UR;
  52868. /**
  52869. * Gets the header of a TGA file
  52870. * @param data defines the TGA data
  52871. * @returns the header
  52872. */
  52873. static GetTGAHeader(data: Uint8Array): any;
  52874. /**
  52875. * Uploads TGA content to a Babylon Texture
  52876. * @hidden
  52877. */
  52878. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  52879. /** @hidden */
  52880. 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;
  52881. /** @hidden */
  52882. 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;
  52883. /** @hidden */
  52884. 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;
  52885. /** @hidden */
  52886. 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;
  52887. /** @hidden */
  52888. 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;
  52889. /** @hidden */
  52890. 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;
  52891. }
  52892. }
  52893. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  52894. import { Nullable } from "babylonjs/types";
  52895. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52896. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52897. /**
  52898. * Implementation of the TGA Texture Loader.
  52899. * @hidden
  52900. */
  52901. export class _TGATextureLoader implements IInternalTextureLoader {
  52902. /**
  52903. * Defines wether the loader supports cascade loading the different faces.
  52904. */
  52905. readonly supportCascades: boolean;
  52906. /**
  52907. * This returns if the loader support the current file information.
  52908. * @param extension defines the file extension of the file being loaded
  52909. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52910. * @param fallback defines the fallback internal texture if any
  52911. * @param isBase64 defines whether the texture is encoded as a base64
  52912. * @param isBuffer defines whether the texture data are stored as a buffer
  52913. * @returns true if the loader can load the specified file
  52914. */
  52915. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52916. /**
  52917. * Transform the url before loading if required.
  52918. * @param rootUrl the url of the texture
  52919. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52920. * @returns the transformed texture
  52921. */
  52922. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52923. /**
  52924. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52925. * @param rootUrl the url of the texture
  52926. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52927. * @returns the fallback texture
  52928. */
  52929. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52930. /**
  52931. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52932. * @param data contains the texture data
  52933. * @param texture defines the BabylonJS internal texture
  52934. * @param createPolynomials will be true if polynomials have been requested
  52935. * @param onLoad defines the callback to trigger once the texture is ready
  52936. * @param onError defines the callback to trigger in case of error
  52937. */
  52938. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52939. /**
  52940. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52941. * @param data contains the texture data
  52942. * @param texture defines the BabylonJS internal texture
  52943. * @param callback defines the method to call once ready to upload
  52944. */
  52945. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52946. }
  52947. }
  52948. declare module "babylonjs/Misc/basis" {
  52949. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52950. /**
  52951. * Info about the .basis files
  52952. */
  52953. class BasisFileInfo {
  52954. /**
  52955. * If the file has alpha
  52956. */
  52957. hasAlpha: boolean;
  52958. /**
  52959. * Info about each image of the basis file
  52960. */
  52961. images: Array<{
  52962. levels: Array<{
  52963. width: number;
  52964. height: number;
  52965. transcodedPixels: ArrayBufferView;
  52966. }>;
  52967. }>;
  52968. }
  52969. /**
  52970. * Result of transcoding a basis file
  52971. */
  52972. class TranscodeResult {
  52973. /**
  52974. * Info about the .basis file
  52975. */
  52976. fileInfo: BasisFileInfo;
  52977. /**
  52978. * Format to use when loading the file
  52979. */
  52980. format: number;
  52981. }
  52982. /**
  52983. * Configuration options for the Basis transcoder
  52984. */
  52985. export class BasisTranscodeConfiguration {
  52986. /**
  52987. * Supported compression formats used to determine the supported output format of the transcoder
  52988. */
  52989. supportedCompressionFormats?: {
  52990. /**
  52991. * etc1 compression format
  52992. */
  52993. etc1?: boolean;
  52994. /**
  52995. * s3tc compression format
  52996. */
  52997. s3tc?: boolean;
  52998. /**
  52999. * pvrtc compression format
  53000. */
  53001. pvrtc?: boolean;
  53002. /**
  53003. * etc2 compression format
  53004. */
  53005. etc2?: boolean;
  53006. };
  53007. /**
  53008. * If mipmap levels should be loaded for transcoded images (Default: true)
  53009. */
  53010. loadMipmapLevels?: boolean;
  53011. /**
  53012. * Index of a single image to load (Default: all images)
  53013. */
  53014. loadSingleImage?: number;
  53015. }
  53016. /**
  53017. * Used to load .Basis files
  53018. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  53019. */
  53020. export class BasisTools {
  53021. private static _IgnoreSupportedFormats;
  53022. /**
  53023. * URL to use when loading the basis transcoder
  53024. */
  53025. static JSModuleURL: string;
  53026. /**
  53027. * URL to use when loading the wasm module for the transcoder
  53028. */
  53029. static WasmModuleURL: string;
  53030. /**
  53031. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  53032. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  53033. * @returns internal format corresponding to the Basis format
  53034. */
  53035. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  53036. private static _WorkerPromise;
  53037. private static _Worker;
  53038. private static _actionId;
  53039. private static _CreateWorkerAsync;
  53040. /**
  53041. * Transcodes a loaded image file to compressed pixel data
  53042. * @param imageData image data to transcode
  53043. * @param config configuration options for the transcoding
  53044. * @returns a promise resulting in the transcoded image
  53045. */
  53046. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  53047. /**
  53048. * Loads a texture from the transcode result
  53049. * @param texture texture load to
  53050. * @param transcodeResult the result of transcoding the basis file to load from
  53051. */
  53052. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  53053. }
  53054. }
  53055. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  53056. import { Nullable } from "babylonjs/types";
  53057. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53058. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53059. /**
  53060. * Loader for .basis file format
  53061. */
  53062. export class _BasisTextureLoader implements IInternalTextureLoader {
  53063. /**
  53064. * Defines whether the loader supports cascade loading the different faces.
  53065. */
  53066. readonly supportCascades: boolean;
  53067. /**
  53068. * This returns if the loader support the current file information.
  53069. * @param extension defines the file extension of the file being loaded
  53070. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53071. * @param fallback defines the fallback internal texture if any
  53072. * @param isBase64 defines whether the texture is encoded as a base64
  53073. * @param isBuffer defines whether the texture data are stored as a buffer
  53074. * @returns true if the loader can load the specified file
  53075. */
  53076. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53077. /**
  53078. * Transform the url before loading if required.
  53079. * @param rootUrl the url of the texture
  53080. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53081. * @returns the transformed texture
  53082. */
  53083. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53084. /**
  53085. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53086. * @param rootUrl the url of the texture
  53087. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53088. * @returns the fallback texture
  53089. */
  53090. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53091. /**
  53092. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  53093. * @param data contains the texture data
  53094. * @param texture defines the BabylonJS internal texture
  53095. * @param createPolynomials will be true if polynomials have been requested
  53096. * @param onLoad defines the callback to trigger once the texture is ready
  53097. * @param onError defines the callback to trigger in case of error
  53098. */
  53099. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53100. /**
  53101. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53102. * @param data contains the texture data
  53103. * @param texture defines the BabylonJS internal texture
  53104. * @param callback defines the method to call once ready to upload
  53105. */
  53106. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53107. }
  53108. }
  53109. declare module "babylonjs/Materials/Textures/Loaders/index" {
  53110. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  53111. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  53112. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  53113. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  53114. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  53115. }
  53116. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  53117. import { Scene } from "babylonjs/scene";
  53118. import { Texture } from "babylonjs/Materials/Textures/texture";
  53119. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53120. /**
  53121. * 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.
  53122. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53123. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53124. */
  53125. export class CustomProceduralTexture extends ProceduralTexture {
  53126. private _animate;
  53127. private _time;
  53128. private _config;
  53129. private _texturePath;
  53130. /**
  53131. * Instantiates a new Custom Procedural Texture.
  53132. * 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.
  53133. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53134. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53135. * @param name Define the name of the texture
  53136. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  53137. * @param size Define the size of the texture to create
  53138. * @param scene Define the scene the texture belongs to
  53139. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  53140. * @param generateMipMaps Define if the texture should creates mip maps or not
  53141. */
  53142. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53143. private _loadJson;
  53144. /**
  53145. * Is the texture ready to be used ? (rendered at least once)
  53146. * @returns true if ready, otherwise, false.
  53147. */
  53148. isReady(): boolean;
  53149. /**
  53150. * Render the texture to its associated render target.
  53151. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  53152. */
  53153. render(useCameraPostProcess?: boolean): void;
  53154. /**
  53155. * Update the list of dependant textures samplers in the shader.
  53156. */
  53157. updateTextures(): void;
  53158. /**
  53159. * Update the uniform values of the procedural texture in the shader.
  53160. */
  53161. updateShaderUniforms(): void;
  53162. /**
  53163. * Define if the texture animates or not.
  53164. */
  53165. animate: boolean;
  53166. }
  53167. }
  53168. declare module "babylonjs/Shaders/noise.fragment" {
  53169. /** @hidden */
  53170. export var noisePixelShader: {
  53171. name: string;
  53172. shader: string;
  53173. };
  53174. }
  53175. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  53176. import { Nullable } from "babylonjs/types";
  53177. import { Scene } from "babylonjs/scene";
  53178. import { Texture } from "babylonjs/Materials/Textures/texture";
  53179. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53180. import "babylonjs/Shaders/noise.fragment";
  53181. /**
  53182. * Class used to generate noise procedural textures
  53183. */
  53184. export class NoiseProceduralTexture extends ProceduralTexture {
  53185. private _time;
  53186. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  53187. brightness: number;
  53188. /** Defines the number of octaves to process */
  53189. octaves: number;
  53190. /** Defines the level of persistence (0.8 by default) */
  53191. persistence: number;
  53192. /** Gets or sets animation speed factor (default is 1) */
  53193. animationSpeedFactor: number;
  53194. /**
  53195. * Creates a new NoiseProceduralTexture
  53196. * @param name defines the name fo the texture
  53197. * @param size defines the size of the texture (default is 256)
  53198. * @param scene defines the hosting scene
  53199. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  53200. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  53201. */
  53202. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53203. private _updateShaderUniforms;
  53204. protected _getDefines(): string;
  53205. /** Generate the current state of the procedural texture */
  53206. render(useCameraPostProcess?: boolean): void;
  53207. /**
  53208. * Serializes this noise procedural texture
  53209. * @returns a serialized noise procedural texture object
  53210. */
  53211. serialize(): any;
  53212. /**
  53213. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  53214. * @param parsedTexture defines parsed texture data
  53215. * @param scene defines the current scene
  53216. * @param rootUrl defines the root URL containing noise procedural texture information
  53217. * @returns a parsed NoiseProceduralTexture
  53218. */
  53219. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  53220. }
  53221. }
  53222. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  53223. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  53224. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  53225. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53226. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  53227. }
  53228. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  53229. import { Nullable } from "babylonjs/types";
  53230. import { Scene } from "babylonjs/scene";
  53231. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53232. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53233. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  53234. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53235. /**
  53236. * Raw cube texture where the raw buffers are passed in
  53237. */
  53238. export class RawCubeTexture extends CubeTexture {
  53239. /**
  53240. * Creates a cube texture where the raw buffers are passed in.
  53241. * @param scene defines the scene the texture is attached to
  53242. * @param data defines the array of data to use to create each face
  53243. * @param size defines the size of the textures
  53244. * @param format defines the format of the data
  53245. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  53246. * @param generateMipMaps defines if the engine should generate the mip levels
  53247. * @param invertY defines if data must be stored with Y axis inverted
  53248. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  53249. * @param compression defines the compression used (null by default)
  53250. */
  53251. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  53252. /**
  53253. * Updates the raw cube texture.
  53254. * @param data defines the data to store
  53255. * @param format defines the data format
  53256. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53257. * @param invertY defines if data must be stored with Y axis inverted
  53258. * @param compression defines the compression used (null by default)
  53259. * @param level defines which level of the texture to update
  53260. */
  53261. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  53262. /**
  53263. * Updates a raw cube texture with RGBD encoded data.
  53264. * @param data defines the array of data [mipmap][face] to use to create each face
  53265. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  53266. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53267. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53268. * @returns a promsie that resolves when the operation is complete
  53269. */
  53270. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  53271. /**
  53272. * Clones the raw cube texture.
  53273. * @return a new cube texture
  53274. */
  53275. clone(): CubeTexture;
  53276. /** @hidden */
  53277. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53278. }
  53279. }
  53280. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  53281. import { Scene } from "babylonjs/scene";
  53282. import { Texture } from "babylonjs/Materials/Textures/texture";
  53283. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53284. /**
  53285. * Class used to store 3D textures containing user data
  53286. */
  53287. export class RawTexture3D extends Texture {
  53288. /** Gets or sets the texture format to use */
  53289. format: number;
  53290. private _engine;
  53291. /**
  53292. * Create a new RawTexture3D
  53293. * @param data defines the data of the texture
  53294. * @param width defines the width of the texture
  53295. * @param height defines the height of the texture
  53296. * @param depth defines the depth of the texture
  53297. * @param format defines the texture format to use
  53298. * @param scene defines the hosting scene
  53299. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  53300. * @param invertY defines if texture must be stored with Y axis inverted
  53301. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  53302. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  53303. */
  53304. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  53305. /** Gets or sets the texture format to use */
  53306. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  53307. /**
  53308. * Update the texture with new data
  53309. * @param data defines the data to store in the texture
  53310. */
  53311. update(data: ArrayBufferView): void;
  53312. }
  53313. }
  53314. declare module "babylonjs/Materials/Textures/refractionTexture" {
  53315. import { Scene } from "babylonjs/scene";
  53316. import { Plane } from "babylonjs/Maths/math.plane";
  53317. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53318. /**
  53319. * Creates a refraction texture used by refraction channel of the standard material.
  53320. * It is like a mirror but to see through a material.
  53321. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53322. */
  53323. export class RefractionTexture extends RenderTargetTexture {
  53324. /**
  53325. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  53326. * 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.
  53327. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53328. */
  53329. refractionPlane: Plane;
  53330. /**
  53331. * Define how deep under the surface we should see.
  53332. */
  53333. depth: number;
  53334. /**
  53335. * Creates a refraction texture used by refraction channel of the standard material.
  53336. * It is like a mirror but to see through a material.
  53337. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53338. * @param name Define the texture name
  53339. * @param size Define the size of the underlying texture
  53340. * @param scene Define the scene the refraction belongs to
  53341. * @param generateMipMaps Define if we need to generate mips level for the refraction
  53342. */
  53343. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  53344. /**
  53345. * Clone the refraction texture.
  53346. * @returns the cloned texture
  53347. */
  53348. clone(): RefractionTexture;
  53349. /**
  53350. * Serialize the texture to a JSON representation you could use in Parse later on
  53351. * @returns the serialized JSON representation
  53352. */
  53353. serialize(): any;
  53354. }
  53355. }
  53356. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  53357. import { Nullable } from "babylonjs/types";
  53358. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53359. import { Matrix } from "babylonjs/Maths/math.vector";
  53360. import { Engine } from "babylonjs/Engines/engine";
  53361. import { Scene } from "babylonjs/scene";
  53362. /**
  53363. * Defines the options related to the creation of an HtmlElementTexture
  53364. */
  53365. export interface IHtmlElementTextureOptions {
  53366. /**
  53367. * Defines wether mip maps should be created or not.
  53368. */
  53369. generateMipMaps?: boolean;
  53370. /**
  53371. * Defines the sampling mode of the texture.
  53372. */
  53373. samplingMode?: number;
  53374. /**
  53375. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  53376. */
  53377. engine: Nullable<Engine>;
  53378. /**
  53379. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  53380. */
  53381. scene: Nullable<Scene>;
  53382. }
  53383. /**
  53384. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  53385. * To be as efficient as possible depending on your constraints nothing aside the first upload
  53386. * is automatically managed.
  53387. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  53388. * in your application.
  53389. *
  53390. * As the update is not automatic, you need to call them manually.
  53391. */
  53392. export class HtmlElementTexture extends BaseTexture {
  53393. /**
  53394. * The texture URL.
  53395. */
  53396. element: HTMLVideoElement | HTMLCanvasElement;
  53397. private static readonly DefaultOptions;
  53398. private _textureMatrix;
  53399. private _engine;
  53400. private _isVideo;
  53401. private _generateMipMaps;
  53402. private _samplingMode;
  53403. /**
  53404. * Instantiates a HtmlElementTexture from the following parameters.
  53405. *
  53406. * @param name Defines the name of the texture
  53407. * @param element Defines the video or canvas the texture is filled with
  53408. * @param options Defines the other none mandatory texture creation options
  53409. */
  53410. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  53411. private _createInternalTexture;
  53412. /**
  53413. * Returns the texture matrix used in most of the material.
  53414. */
  53415. getTextureMatrix(): Matrix;
  53416. /**
  53417. * Updates the content of the texture.
  53418. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  53419. */
  53420. update(invertY?: Nullable<boolean>): void;
  53421. }
  53422. }
  53423. declare module "babylonjs/Materials/Textures/index" {
  53424. export * from "babylonjs/Materials/Textures/baseTexture";
  53425. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  53426. export * from "babylonjs/Materials/Textures/cubeTexture";
  53427. export * from "babylonjs/Materials/Textures/dynamicTexture";
  53428. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  53429. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  53430. export * from "babylonjs/Materials/Textures/internalTexture";
  53431. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  53432. export * from "babylonjs/Materials/Textures/Loaders/index";
  53433. export * from "babylonjs/Materials/Textures/mirrorTexture";
  53434. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  53435. export * from "babylonjs/Materials/Textures/Procedurals/index";
  53436. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  53437. export * from "babylonjs/Materials/Textures/rawTexture";
  53438. export * from "babylonjs/Materials/Textures/rawTexture3D";
  53439. export * from "babylonjs/Materials/Textures/refractionTexture";
  53440. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  53441. export * from "babylonjs/Materials/Textures/texture";
  53442. export * from "babylonjs/Materials/Textures/videoTexture";
  53443. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  53444. }
  53445. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  53446. /**
  53447. * Enum used to define the target of a block
  53448. */
  53449. export enum NodeMaterialBlockTargets {
  53450. /** Vertex shader */
  53451. Vertex = 1,
  53452. /** Fragment shader */
  53453. Fragment = 2,
  53454. /** Neutral */
  53455. Neutral = 4,
  53456. /** Vertex and Fragment */
  53457. VertexAndFragment = 3
  53458. }
  53459. }
  53460. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  53461. /**
  53462. * Defines the kind of connection point for node based material
  53463. */
  53464. export enum NodeMaterialBlockConnectionPointTypes {
  53465. /** Float */
  53466. Float = 1,
  53467. /** Int */
  53468. Int = 2,
  53469. /** Vector2 */
  53470. Vector2 = 4,
  53471. /** Vector3 */
  53472. Vector3 = 8,
  53473. /** Vector4 */
  53474. Vector4 = 16,
  53475. /** Color3 */
  53476. Color3 = 32,
  53477. /** Color4 */
  53478. Color4 = 64,
  53479. /** Matrix */
  53480. Matrix = 128,
  53481. /** Vector3 or Color3 */
  53482. Vector3OrColor3 = 40,
  53483. /** Vector3 or Vector4 */
  53484. Vector3OrVector4 = 24,
  53485. /** Vector4 or Color4 */
  53486. Vector4OrColor4 = 80,
  53487. /** Color3 or Color4 */
  53488. Color3OrColor4 = 96,
  53489. /** Vector2 or Color3 or Color4 */
  53490. Vector2OrColor3OrColor4 = 100,
  53491. /** Vector3 or Color3 or Color4 or Vector4 */
  53492. Vector3OrColor3OrVector4OrColor4 = 120,
  53493. /** Vector2 or Vector3 or Color3 or Color4 or Vector4 */
  53494. Vector2OrVector3OrColor3OrVector4OrColor4 = 124,
  53495. /** Detect type based on connection */
  53496. AutoDetect = 1024,
  53497. /** Output type that will be defined by input type */
  53498. BasedOnInput = 2048
  53499. }
  53500. }
  53501. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  53502. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53503. /**
  53504. * Root class for all node material optimizers
  53505. */
  53506. export class NodeMaterialOptimizer {
  53507. /**
  53508. * Function used to optimize a NodeMaterial graph
  53509. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  53510. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  53511. */
  53512. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  53513. }
  53514. }
  53515. declare module "babylonjs/Materials/Node/Blocks/vector4TransformBlock" {
  53516. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53517. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53518. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53519. /**
  53520. * Block used to transform a vector4 with a matrix
  53521. */
  53522. export class Vector4TransformBlock extends NodeMaterialBlock {
  53523. /**
  53524. * Defines the value to use to complement Vector3 to transform it to a Vector4
  53525. */
  53526. complementW: number;
  53527. /**
  53528. * Creates a new Vector4TransformBlock
  53529. * @param name defines the block name
  53530. */
  53531. constructor(name: string);
  53532. /**
  53533. * Gets the current class name
  53534. * @returns the class name
  53535. */
  53536. getClassName(): string;
  53537. /**
  53538. * Gets the vector input
  53539. */
  53540. readonly vector: NodeMaterialConnectionPoint;
  53541. /**
  53542. * Gets the output component
  53543. */
  53544. readonly output: NodeMaterialConnectionPoint;
  53545. /**
  53546. * Gets the matrix transform input
  53547. */
  53548. readonly transform: NodeMaterialConnectionPoint;
  53549. protected _buildBlock(state: NodeMaterialBuildState): this;
  53550. }
  53551. }
  53552. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  53553. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53554. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53555. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53556. /**
  53557. * Block used to output the vertex position
  53558. */
  53559. export class VertexOutputBlock extends NodeMaterialBlock {
  53560. /**
  53561. * Creates a new VertexOutputBlock
  53562. * @param name defines the block name
  53563. */
  53564. constructor(name: string);
  53565. /**
  53566. * Gets the current class name
  53567. * @returns the class name
  53568. */
  53569. getClassName(): string;
  53570. /**
  53571. * Gets the vector input component
  53572. */
  53573. readonly vector: NodeMaterialConnectionPoint;
  53574. protected _buildBlock(state: NodeMaterialBuildState): this;
  53575. }
  53576. }
  53577. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  53578. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53579. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53580. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53581. /**
  53582. * Block used to output the final color
  53583. */
  53584. export class FragmentOutputBlock extends NodeMaterialBlock {
  53585. /**
  53586. * Gets or sets a boolean indicating if this block will output an alpha value
  53587. */
  53588. alphaBlendingEnabled: boolean;
  53589. /**
  53590. * Create a new FragmentOutputBlock
  53591. * @param name defines the block name
  53592. */
  53593. constructor(name: string);
  53594. /**
  53595. * Gets the current class name
  53596. * @returns the class name
  53597. */
  53598. getClassName(): string;
  53599. /**
  53600. * Gets the color input component
  53601. */
  53602. readonly color: NodeMaterialConnectionPoint;
  53603. protected _buildBlock(state: NodeMaterialBuildState): this;
  53604. }
  53605. }
  53606. declare module "babylonjs/Materials/Node/nodeMaterial" {
  53607. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53608. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53609. import { Scene } from "babylonjs/scene";
  53610. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53611. import { Matrix } from "babylonjs/Maths/math.vector";
  53612. import { Mesh } from "babylonjs/Meshes/mesh";
  53613. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53614. import { Observable } from "babylonjs/Misc/observable";
  53615. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53616. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53617. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  53618. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53619. import { Nullable } from "babylonjs/types";
  53620. /**
  53621. * Interface used to configure the node material editor
  53622. */
  53623. export interface INodeMaterialEditorOptions {
  53624. /** Define the URl to load node editor script */
  53625. editorURL?: string;
  53626. }
  53627. /** @hidden */
  53628. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  53629. /** BONES */
  53630. NUM_BONE_INFLUENCERS: number;
  53631. BonesPerMesh: number;
  53632. BONETEXTURE: boolean;
  53633. /** MORPH TARGETS */
  53634. MORPHTARGETS: boolean;
  53635. MORPHTARGETS_NORMAL: boolean;
  53636. MORPHTARGETS_TANGENT: boolean;
  53637. MORPHTARGETS_UV: boolean;
  53638. NUM_MORPH_INFLUENCERS: number;
  53639. /** IMAGE PROCESSING */
  53640. IMAGEPROCESSING: boolean;
  53641. VIGNETTE: boolean;
  53642. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53643. VIGNETTEBLENDMODEOPAQUE: boolean;
  53644. TONEMAPPING: boolean;
  53645. TONEMAPPING_ACES: boolean;
  53646. CONTRAST: boolean;
  53647. EXPOSURE: boolean;
  53648. COLORCURVES: boolean;
  53649. COLORGRADING: boolean;
  53650. COLORGRADING3D: boolean;
  53651. SAMPLER3DGREENDEPTH: boolean;
  53652. SAMPLER3DBGRMAP: boolean;
  53653. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53654. constructor();
  53655. setValue(name: string, value: boolean): void;
  53656. }
  53657. /**
  53658. * Class used to configure NodeMaterial
  53659. */
  53660. export interface INodeMaterialOptions {
  53661. /**
  53662. * Defines if blocks should emit comments
  53663. */
  53664. emitComments: boolean;
  53665. }
  53666. /**
  53667. * Class used to create a node based material built by assembling shader blocks
  53668. */
  53669. export class NodeMaterial extends PushMaterial {
  53670. private _options;
  53671. private _vertexCompilationState;
  53672. private _fragmentCompilationState;
  53673. private _sharedData;
  53674. private _buildId;
  53675. private _buildWasSuccessful;
  53676. private _cachedWorldViewMatrix;
  53677. private _cachedWorldViewProjectionMatrix;
  53678. private _optimizers;
  53679. /** Define the URl to load node editor script */
  53680. static EditorURL: string;
  53681. private BJSNODEMATERIALEDITOR;
  53682. /** Get the inspector from bundle or global */
  53683. private _getGlobalNodeMaterialEditor;
  53684. /**
  53685. * Defines the maximum number of lights that can be used in the material
  53686. */
  53687. maxSimultaneousLights: number;
  53688. /**
  53689. * Observable raised when the material is built
  53690. */
  53691. onBuildObservable: Observable<NodeMaterial>;
  53692. /**
  53693. * Gets or sets the root nodes of the material vertex shader
  53694. */
  53695. _vertexOutputNodes: NodeMaterialBlock[];
  53696. /**
  53697. * Gets or sets the root nodes of the material fragment (pixel) shader
  53698. */
  53699. _fragmentOutputNodes: NodeMaterialBlock[];
  53700. /** Gets or sets options to control the node material overall behavior */
  53701. options: INodeMaterialOptions;
  53702. /**
  53703. * Default configuration related to image processing available in the standard Material.
  53704. */
  53705. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53706. /**
  53707. * Gets the image processing configuration used either in this material.
  53708. */
  53709. /**
  53710. * Sets the Default image processing configuration used either in the this material.
  53711. *
  53712. * If sets to null, the scene one is in use.
  53713. */
  53714. imageProcessingConfiguration: ImageProcessingConfiguration;
  53715. /**
  53716. * Create a new node based material
  53717. * @param name defines the material name
  53718. * @param scene defines the hosting scene
  53719. * @param options defines creation option
  53720. */
  53721. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  53722. /**
  53723. * Gets the current class name of the material e.g. "NodeMaterial"
  53724. * @returns the class name
  53725. */
  53726. getClassName(): string;
  53727. /**
  53728. * Keep track of the image processing observer to allow dispose and replace.
  53729. */
  53730. private _imageProcessingObserver;
  53731. /**
  53732. * Attaches a new image processing configuration to the Standard Material.
  53733. * @param configuration
  53734. */
  53735. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53736. /**
  53737. * Adds a new optimizer to the list of optimizers
  53738. * @param optimizer defines the optimizers to add
  53739. * @returns the current material
  53740. */
  53741. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53742. /**
  53743. * Remove an optimizer from the list of optimizers
  53744. * @param optimizer defines the optimizers to remove
  53745. * @returns the current material
  53746. */
  53747. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53748. /**
  53749. * Add a new block to the list of output nodes
  53750. * @param node defines the node to add
  53751. * @returns the current material
  53752. */
  53753. addOutputNode(node: NodeMaterialBlock): this;
  53754. /**
  53755. * Remove a block from the list of root nodes
  53756. * @param node defines the node to remove
  53757. * @returns the current material
  53758. */
  53759. removeOutputNode(node: NodeMaterialBlock): this;
  53760. private _addVertexOutputNode;
  53761. private _removeVertexOutputNode;
  53762. private _addFragmentOutputNode;
  53763. private _removeFragmentOutputNode;
  53764. /**
  53765. * Specifies if the material will require alpha blending
  53766. * @returns a boolean specifying if alpha blending is needed
  53767. */
  53768. needAlphaBlending(): boolean;
  53769. /**
  53770. * Specifies if this material should be rendered in alpha test mode
  53771. * @returns a boolean specifying if an alpha test is needed.
  53772. */
  53773. needAlphaTesting(): boolean;
  53774. private _initializeBlock;
  53775. private _resetDualBlocks;
  53776. /**
  53777. * Build the material and generates the inner effect
  53778. * @param verbose defines if the build should log activity
  53779. */
  53780. build(verbose?: boolean): void;
  53781. /**
  53782. * Runs an otpimization phase to try to improve the shader code
  53783. */
  53784. optimize(): void;
  53785. private _prepareDefinesForAttributes;
  53786. /**
  53787. * Get if the submesh is ready to be used and all its information available.
  53788. * Child classes can use it to update shaders
  53789. * @param mesh defines the mesh to check
  53790. * @param subMesh defines which submesh to check
  53791. * @param useInstances specifies that instances should be used
  53792. * @returns a boolean indicating that the submesh is ready or not
  53793. */
  53794. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53795. /**
  53796. * Binds the world matrix to the material
  53797. * @param world defines the world transformation matrix
  53798. */
  53799. bindOnlyWorldMatrix(world: Matrix): void;
  53800. /**
  53801. * Binds the submesh to this material by preparing the effect and shader to draw
  53802. * @param world defines the world transformation matrix
  53803. * @param mesh defines the mesh containing the submesh
  53804. * @param subMesh defines the submesh to bind the material to
  53805. */
  53806. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53807. /**
  53808. * Gets the active textures from the material
  53809. * @returns an array of textures
  53810. */
  53811. getActiveTextures(): BaseTexture[];
  53812. /**
  53813. * Specifies if the material uses a texture
  53814. * @param texture defines the texture to check against the material
  53815. * @returns a boolean specifying if the material uses the texture
  53816. */
  53817. hasTexture(texture: BaseTexture): boolean;
  53818. /**
  53819. * Disposes the material
  53820. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  53821. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  53822. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  53823. */
  53824. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  53825. /** Creates the node editor window. */
  53826. private _createNodeEditor;
  53827. /**
  53828. * Launch the node material editor
  53829. * @param config Define the configuration of the editor
  53830. * @return a promise fulfilled when the node editor is visible
  53831. */
  53832. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  53833. /**
  53834. * Clear the current material
  53835. */
  53836. clear(): void;
  53837. /**
  53838. * Clear the current material and set it to a default state
  53839. */
  53840. setToDefault(): void;
  53841. }
  53842. }
  53843. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  53844. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53845. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53846. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53847. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53848. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53849. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53850. import { Effect } from "babylonjs/Materials/effect";
  53851. import { Mesh } from "babylonjs/Meshes/mesh";
  53852. import { Nullable } from "babylonjs/types";
  53853. /**
  53854. * Block used to read a texture from a sampler
  53855. */
  53856. export class TextureBlock extends NodeMaterialBlock {
  53857. private _defineName;
  53858. private _samplerName;
  53859. private _transformedUVName;
  53860. private _textureTransformName;
  53861. private _textureInfoName;
  53862. private _mainUVName;
  53863. private _mainUVDefineName;
  53864. /**
  53865. * Gets or sets the texture associated with the node
  53866. */
  53867. texture: Nullable<BaseTexture>;
  53868. /**
  53869. * Create a new TextureBlock
  53870. * @param name defines the block name
  53871. */
  53872. constructor(name: string);
  53873. /**
  53874. * Gets the current class name
  53875. * @returns the class name
  53876. */
  53877. getClassName(): string;
  53878. /**
  53879. * Gets the uv input component
  53880. */
  53881. readonly uv: NodeMaterialConnectionPoint;
  53882. /**
  53883. * Gets the output component
  53884. */
  53885. readonly output: NodeMaterialConnectionPoint;
  53886. autoConfigure(): void;
  53887. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53888. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53889. isReady(): boolean;
  53890. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53891. private _injectVertexCode;
  53892. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53893. }
  53894. }
  53895. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  53896. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53897. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53898. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  53899. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  53900. /**
  53901. * Class used to store shared data between 2 NodeMaterialBuildState
  53902. */
  53903. export class NodeMaterialBuildStateSharedData {
  53904. /**
  53905. * Gets the list of emitted varyings
  53906. */
  53907. varyings: string[];
  53908. /**
  53909. * Gets the varying declaration string
  53910. */
  53911. varyingDeclaration: string;
  53912. /**
  53913. * Input blocks
  53914. */
  53915. inputBlocks: InputBlock[];
  53916. /**
  53917. * Input blocks
  53918. */
  53919. textureBlocks: TextureBlock[];
  53920. /**
  53921. * Bindable blocks (Blocks that need to set data to the effect)
  53922. */
  53923. bindableBlocks: NodeMaterialBlock[];
  53924. /**
  53925. * List of blocks that can provide a compilation fallback
  53926. */
  53927. blocksWithFallbacks: NodeMaterialBlock[];
  53928. /**
  53929. * List of blocks that can provide a define update
  53930. */
  53931. blocksWithDefines: NodeMaterialBlock[];
  53932. /**
  53933. * List of blocks that can provide a repeatable content
  53934. */
  53935. repeatableContentBlocks: NodeMaterialBlock[];
  53936. /**
  53937. * List of blocks that can provide a dynamic list of uniforms
  53938. */
  53939. dynamicUniformBlocks: NodeMaterialBlock[];
  53940. /**
  53941. * List of blocks that can block the isReady function for the material
  53942. */
  53943. blockingBlocks: NodeMaterialBlock[];
  53944. /**
  53945. * Build Id used to avoid multiple recompilations
  53946. */
  53947. buildId: number;
  53948. /** List of emitted variables */
  53949. variableNames: {
  53950. [key: string]: number;
  53951. };
  53952. /** List of emitted defines */
  53953. defineNames: {
  53954. [key: string]: number;
  53955. };
  53956. /** Should emit comments? */
  53957. emitComments: boolean;
  53958. /** Emit build activity */
  53959. verbose: boolean;
  53960. /**
  53961. * Gets the compilation hints emitted at compilation time
  53962. */
  53963. hints: {
  53964. needWorldViewMatrix: boolean;
  53965. needWorldViewProjectionMatrix: boolean;
  53966. needAlphaBlending: boolean;
  53967. needAlphaTesting: boolean;
  53968. };
  53969. /**
  53970. * List of compilation checks
  53971. */
  53972. checks: {
  53973. emitVertex: boolean;
  53974. emitFragment: boolean;
  53975. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  53976. };
  53977. /** Creates a new shared data */
  53978. constructor();
  53979. /**
  53980. * Emits console errors and exceptions if there is a failing check
  53981. */
  53982. emitErrors(): void;
  53983. }
  53984. }
  53985. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  53986. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53987. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53988. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  53989. /**
  53990. * Class used to store node based material build state
  53991. */
  53992. export class NodeMaterialBuildState {
  53993. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  53994. supportUniformBuffers: boolean;
  53995. /**
  53996. * Gets the list of emitted attributes
  53997. */
  53998. attributes: string[];
  53999. /**
  54000. * Gets the list of emitted uniforms
  54001. */
  54002. uniforms: string[];
  54003. /**
  54004. * Gets the list of emitted uniform buffers
  54005. */
  54006. uniformBuffers: string[];
  54007. /**
  54008. * Gets the list of emitted samplers
  54009. */
  54010. samplers: string[];
  54011. /**
  54012. * Gets the list of emitted functions
  54013. */
  54014. functions: {
  54015. [key: string]: string;
  54016. };
  54017. /**
  54018. * Gets the target of the compilation state
  54019. */
  54020. target: NodeMaterialBlockTargets;
  54021. /**
  54022. * Gets the list of emitted counters
  54023. */
  54024. counters: {
  54025. [key: string]: number;
  54026. };
  54027. /**
  54028. * Shared data between multiple NodeMaterialBuildState instances
  54029. */
  54030. sharedData: NodeMaterialBuildStateSharedData;
  54031. /** @hidden */
  54032. _vertexState: NodeMaterialBuildState;
  54033. /** @hidden */
  54034. _attributeDeclaration: string;
  54035. /** @hidden */
  54036. _uniformDeclaration: string;
  54037. /** @hidden */
  54038. _samplerDeclaration: string;
  54039. /** @hidden */
  54040. _varyingTransfer: string;
  54041. private _repeatableContentAnchorIndex;
  54042. /** @hidden */
  54043. _builtCompilationString: string;
  54044. /**
  54045. * Gets the emitted compilation strings
  54046. */
  54047. compilationString: string;
  54048. /**
  54049. * Finalize the compilation strings
  54050. * @param state defines the current compilation state
  54051. */
  54052. finalize(state: NodeMaterialBuildState): void;
  54053. /** @hidden */
  54054. readonly _repeatableContentAnchor: string;
  54055. /** @hidden */
  54056. _getFreeVariableName(prefix: string): string;
  54057. /** @hidden */
  54058. _getFreeDefineName(prefix: string): string;
  54059. /** @hidden */
  54060. _excludeVariableName(name: string): void;
  54061. /** @hidden */
  54062. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  54063. /** @hidden */
  54064. _emitFunction(name: string, code: string, comments: string): void;
  54065. /** @hidden */
  54066. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  54067. replaceStrings?: {
  54068. search: RegExp;
  54069. replace: string;
  54070. }[];
  54071. repeatKey?: string;
  54072. }): string;
  54073. /** @hidden */
  54074. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  54075. repeatKey?: string;
  54076. removeAttributes?: boolean;
  54077. removeUniforms?: boolean;
  54078. removeVaryings?: boolean;
  54079. removeIfDef?: boolean;
  54080. replaceStrings?: {
  54081. search: RegExp;
  54082. replace: string;
  54083. }[];
  54084. }, storeKey?: string): void;
  54085. /** @hidden */
  54086. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  54087. /** @hidden */
  54088. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  54089. }
  54090. }
  54091. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  54092. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54093. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54094. import { Nullable } from "babylonjs/types";
  54095. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54096. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54097. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  54098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54099. import { Mesh } from "babylonjs/Meshes/mesh";
  54100. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54101. /**
  54102. * Defines a block that can be used inside a node based material
  54103. */
  54104. export class NodeMaterialBlock {
  54105. private _buildId;
  54106. private _buildTarget;
  54107. private _target;
  54108. private _isFinalMerger;
  54109. private _isInput;
  54110. /** @hidden */
  54111. _inputs: NodeMaterialConnectionPoint[];
  54112. /** @hidden */
  54113. _outputs: NodeMaterialConnectionPoint[];
  54114. /**
  54115. * Gets or sets the name of the block
  54116. */
  54117. name: string;
  54118. /**
  54119. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  54120. */
  54121. readonly isFinalMerger: boolean;
  54122. /**
  54123. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  54124. */
  54125. readonly isInput: boolean;
  54126. /**
  54127. * Gets or sets the build Id
  54128. */
  54129. buildId: number;
  54130. /**
  54131. * Gets or sets the target of the block
  54132. */
  54133. target: NodeMaterialBlockTargets;
  54134. /**
  54135. * Gets the list of input points
  54136. */
  54137. readonly inputs: NodeMaterialConnectionPoint[];
  54138. /** Gets the list of output points */
  54139. readonly outputs: NodeMaterialConnectionPoint[];
  54140. /**
  54141. * Find an input by its name
  54142. * @param name defines the name of the input to look for
  54143. * @returns the input or null if not found
  54144. */
  54145. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54146. /**
  54147. * Find an output by its name
  54148. * @param name defines the name of the outputto look for
  54149. * @returns the output or null if not found
  54150. */
  54151. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54152. /**
  54153. * Creates a new NodeMaterialBlock
  54154. * @param name defines the block name
  54155. * @param target defines the target of that block (Vertex by default)
  54156. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  54157. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  54158. */
  54159. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  54160. /**
  54161. * Initialize the block and prepare the context for build
  54162. * @param state defines the state that will be used for the build
  54163. */
  54164. initialize(state: NodeMaterialBuildState): void;
  54165. /**
  54166. * Bind data to effect. Will only be called for blocks with isBindable === true
  54167. * @param effect defines the effect to bind data to
  54168. * @param nodeMaterial defines the hosting NodeMaterial
  54169. * @param mesh defines the mesh that will be rendered
  54170. */
  54171. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54172. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  54173. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  54174. protected _writeFloat(value: number): string;
  54175. /**
  54176. * Gets the current class name e.g. "NodeMaterialBlock"
  54177. * @returns the class name
  54178. */
  54179. getClassName(): string;
  54180. /**
  54181. * Register a new input. Must be called inside a block constructor
  54182. * @param name defines the connection point name
  54183. * @param type defines the connection point type
  54184. * @param isOptional defines a boolean indicating that this input can be omitted
  54185. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  54186. * @returns the current block
  54187. */
  54188. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  54189. /**
  54190. * Register a new output. Must be called inside a block constructor
  54191. * @param name defines the connection point name
  54192. * @param type defines the connection point type
  54193. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  54194. * @returns the current block
  54195. */
  54196. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  54197. /**
  54198. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  54199. * @param forOutput defines an optional connection point to check compatibility with
  54200. * @returns the first available input or null
  54201. */
  54202. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  54203. /**
  54204. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  54205. * @param forBlock defines an optional block to check compatibility with
  54206. * @returns the first available input or null
  54207. */
  54208. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  54209. /**
  54210. * Connect current block with another block
  54211. * @param other defines the block to connect with
  54212. * @param options define the various options to help pick the right connections
  54213. * @returns the current block
  54214. */
  54215. connectTo(other: NodeMaterialBlock, options?: {
  54216. input?: string;
  54217. output?: string;
  54218. outputSwizzle?: string;
  54219. }): this | undefined;
  54220. protected _buildBlock(state: NodeMaterialBuildState): void;
  54221. /**
  54222. * Add uniforms, samplers and uniform buffers at compilation time
  54223. * @param state defines the state to update
  54224. * @param nodeMaterial defines the node material requesting the update
  54225. * @param defines defines the material defines to update
  54226. */
  54227. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54228. /**
  54229. * Add potential fallbacks if shader compilation fails
  54230. * @param mesh defines the mesh to be rendered
  54231. * @param fallbacks defines the current prioritized list of fallbacks
  54232. */
  54233. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54234. /**
  54235. * Update defines for shader compilation
  54236. * @param mesh defines the mesh to be rendered
  54237. * @param nodeMaterial defines the node material requesting the update
  54238. * @param defines defines the material defines to update
  54239. * @param useInstances specifies that instances should be used
  54240. */
  54241. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54242. /**
  54243. * Initialize defines for shader compilation
  54244. * @param mesh defines the mesh to be rendered
  54245. * @param nodeMaterial defines the node material requesting the update
  54246. * @param defines defines the material defines to be prepared
  54247. * @param useInstances specifies that instances should be used
  54248. */
  54249. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54250. /**
  54251. * Lets the block try to connect some inputs automatically
  54252. */
  54253. autoConfigure(): void;
  54254. /**
  54255. * Function called when a block is declared as repeatable content generator
  54256. * @param vertexShaderState defines the current compilation state for the vertex shader
  54257. * @param fragmentShaderState defines the current compilation state for the fragment shader
  54258. * @param mesh defines the mesh to be rendered
  54259. * @param defines defines the material defines to update
  54260. */
  54261. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54262. /**
  54263. * Checks if the block is ready
  54264. * @param mesh defines the mesh to be rendered
  54265. * @param nodeMaterial defines the node material requesting the update
  54266. * @param defines defines the material defines to update
  54267. * @param useInstances specifies that instances should be used
  54268. * @returns true if the block is ready
  54269. */
  54270. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  54271. private _processBuild;
  54272. /**
  54273. * Compile the current node and generate the shader code
  54274. * @param state defines the current compilation state (uniforms, samplers, current string)
  54275. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  54276. * @returns true if already built
  54277. */
  54278. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  54279. }
  54280. }
  54281. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  54282. /**
  54283. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  54284. */
  54285. export enum NodeMaterialBlockConnectionPointMode {
  54286. /** Value is an uniform */
  54287. Uniform = 0,
  54288. /** Value is a mesh attribute */
  54289. Attribute = 1,
  54290. /** Value is a varying between vertex and fragment shaders */
  54291. Varying = 2,
  54292. /** Mode is undefined */
  54293. Undefined = 3
  54294. }
  54295. }
  54296. declare module "babylonjs/Materials/Node/nodeMaterialWellKnownValues" {
  54297. /**
  54298. * Enum used to define well known values e.g. values automatically provided by the system
  54299. */
  54300. export enum NodeMaterialWellKnownValues {
  54301. /** World */
  54302. World = 1,
  54303. /** View */
  54304. View = 2,
  54305. /** Projection */
  54306. Projection = 3,
  54307. /** ViewProjection */
  54308. ViewProjection = 4,
  54309. /** WorldView */
  54310. WorldView = 5,
  54311. /** WorldViewProjection */
  54312. WorldViewProjection = 6,
  54313. /** CameraPosition */
  54314. CameraPosition = 7,
  54315. /** Fog Color */
  54316. FogColor = 8
  54317. }
  54318. }
  54319. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  54320. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54321. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54322. import { NodeMaterialWellKnownValues } from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  54323. import { Nullable } from "babylonjs/types";
  54324. import { Effect } from "babylonjs/Materials/effect";
  54325. import { Matrix } from "babylonjs/Maths/math.vector";
  54326. import { Scene } from "babylonjs/scene";
  54327. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54328. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54329. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54330. /**
  54331. * Block used to expose an input value
  54332. */
  54333. export class InputBlock extends NodeMaterialBlock {
  54334. private _mode;
  54335. private _associatedVariableName;
  54336. private _storedValue;
  54337. private _valueCallback;
  54338. private _type;
  54339. /** @hidden */
  54340. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  54341. /**
  54342. * Gets or sets the connection point type (default is float)
  54343. */
  54344. readonly type: NodeMaterialBlockConnectionPointTypes;
  54345. /**
  54346. * Creates a new InputBlock
  54347. * @param name defines the block name
  54348. * @param target defines the target of that block (Vertex by default)
  54349. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  54350. */
  54351. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  54352. /**
  54353. * Gets the output component
  54354. */
  54355. readonly output: NodeMaterialConnectionPoint;
  54356. /**
  54357. * Set the source of this connection point to a vertex attribute
  54358. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  54359. * @returns the current connection point
  54360. */
  54361. setAsAttribute(attributeName?: string): InputBlock;
  54362. /**
  54363. * Set the source of this connection point to a well known value
  54364. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  54365. * @returns the current connection point
  54366. */
  54367. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  54368. /**
  54369. * Gets or sets the value of that point.
  54370. * Please note that this value will be ignored if valueCallback is defined
  54371. */
  54372. value: any;
  54373. /**
  54374. * Gets or sets a callback used to get the value of that point.
  54375. * Please note that setting this value will force the connection point to ignore the value property
  54376. */
  54377. valueCallback: () => any;
  54378. /**
  54379. * Gets or sets the associated variable name in the shader
  54380. */
  54381. associatedVariableName: string;
  54382. /**
  54383. * Gets a boolean indicating that this connection point not defined yet
  54384. */
  54385. readonly isUndefined: boolean;
  54386. /**
  54387. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  54388. * In this case the connection point name must be the name of the uniform to use.
  54389. * Can only be set on inputs
  54390. */
  54391. isUniform: boolean;
  54392. /**
  54393. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  54394. * In this case the connection point name must be the name of the attribute to use
  54395. * Can only be set on inputs
  54396. */
  54397. isAttribute: boolean;
  54398. /**
  54399. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  54400. * Can only be set on exit points
  54401. */
  54402. isVarying: boolean;
  54403. /**
  54404. * Gets a boolean indicating that the current connection point is a well known value
  54405. */
  54406. readonly isWellKnownValue: boolean;
  54407. /**
  54408. * Gets or sets the current well known value or null if not defined as well know value
  54409. */
  54410. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  54411. /**
  54412. * Gets the current class name
  54413. * @returns the class name
  54414. */
  54415. getClassName(): string;
  54416. private _emitDefine;
  54417. /**
  54418. * Set the input block to its default value (based on its type)
  54419. */
  54420. setDefaultValue(): void;
  54421. private _emit;
  54422. /** @hidden */
  54423. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  54424. /** @hidden */
  54425. _transmit(effect: Effect, scene: Scene): void;
  54426. protected _buildBlock(state: NodeMaterialBuildState): void;
  54427. }
  54428. }
  54429. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  54430. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54431. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54432. import { Nullable } from "babylonjs/types";
  54433. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54434. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54435. /**
  54436. * Defines a connection point for a block
  54437. */
  54438. export class NodeMaterialConnectionPoint {
  54439. /** @hidden */
  54440. _ownerBlock: NodeMaterialBlock;
  54441. /** @hidden */
  54442. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  54443. private _endpoints;
  54444. private _associatedVariableName;
  54445. /** @hidden */
  54446. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  54447. private _type;
  54448. /** @hidden */
  54449. _enforceAssociatedVariableName: boolean;
  54450. /**
  54451. * Gets or sets the associated variable name in the shader
  54452. */
  54453. associatedVariableName: string;
  54454. /**
  54455. * Gets or sets the connection point type (default is float)
  54456. */
  54457. type: NodeMaterialBlockConnectionPointTypes;
  54458. /**
  54459. * Gets or sets the connection point name
  54460. */
  54461. name: string;
  54462. /**
  54463. * Gets or sets the swizzle to apply to this connection point when reading or writing
  54464. */
  54465. swizzle: string;
  54466. /**
  54467. * Gets or sets a boolean indicating that this connection point can be omitted
  54468. */
  54469. isOptional: boolean;
  54470. /**
  54471. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  54472. */
  54473. define: string;
  54474. /** Gets or sets the target of that connection point */
  54475. target: NodeMaterialBlockTargets;
  54476. /**
  54477. * Gets a boolean indicating that the current point is connected
  54478. */
  54479. readonly isConnected: boolean;
  54480. /**
  54481. * Gets a boolean indicating that the current point is connected to an input block
  54482. */
  54483. readonly isConnectedToInput: boolean;
  54484. /**
  54485. * Gets a the connected input block (if any)
  54486. */
  54487. readonly connectInputBlock: Nullable<InputBlock>;
  54488. /** Get the other side of the connection (if any) */
  54489. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  54490. /** Get the block that owns this connection point */
  54491. readonly ownerBlock: NodeMaterialBlock;
  54492. /** Get the block connected on the other side of this connection (if any) */
  54493. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  54494. /** Get the block connected on the endpoints of this connection (if any) */
  54495. readonly connectedBlocks: Array<NodeMaterialBlock>;
  54496. /** Gets the list of connected endpoints */
  54497. readonly endpoints: NodeMaterialConnectionPoint[];
  54498. /**
  54499. * Creates a new connection point
  54500. * @param name defines the connection point name
  54501. * @param ownerBlock defines the block hosting this connection point
  54502. */
  54503. constructor(name: string, ownerBlock: NodeMaterialBlock);
  54504. /**
  54505. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  54506. * @returns the class name
  54507. */
  54508. getClassName(): string;
  54509. private _getTypeLength;
  54510. /**
  54511. * Gets an boolean indicating if the current point can be connected to another point
  54512. * @param connectionPoint defines the other connection point
  54513. * @returns true if the connection is possible
  54514. */
  54515. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  54516. /**
  54517. * Connect this point to another connection point
  54518. * @param connectionPoint defines the other connection point
  54519. * @returns the current connection point
  54520. */
  54521. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  54522. /**
  54523. * Disconnect this point from one of his endpoint
  54524. * @param endpoint defines the other connection point
  54525. * @returns the current connection point
  54526. */
  54527. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  54528. }
  54529. }
  54530. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  54531. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54532. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54533. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54534. import { Mesh } from "babylonjs/Meshes/mesh";
  54535. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  54536. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54537. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54538. /**
  54539. * Block used to add support for vertex skinning (bones)
  54540. */
  54541. export class BonesBlock extends NodeMaterialBlock {
  54542. /**
  54543. * Creates a new BonesBlock
  54544. * @param name defines the block name
  54545. */
  54546. constructor(name: string);
  54547. /**
  54548. * Initialize the block and prepare the context for build
  54549. * @param state defines the state that will be used for the build
  54550. */
  54551. initialize(state: NodeMaterialBuildState): void;
  54552. /**
  54553. * Gets the current class name
  54554. * @returns the class name
  54555. */
  54556. getClassName(): string;
  54557. /**
  54558. * Gets the matrix indices input component
  54559. */
  54560. readonly matricesIndices: NodeMaterialConnectionPoint;
  54561. /**
  54562. * Gets the matrix weights input component
  54563. */
  54564. readonly matricesWeights: NodeMaterialConnectionPoint;
  54565. /**
  54566. * Gets the extra matrix indices input component
  54567. */
  54568. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  54569. /**
  54570. * Gets the extra matrix weights input component
  54571. */
  54572. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  54573. /**
  54574. * Gets the world input component
  54575. */
  54576. readonly world: NodeMaterialConnectionPoint;
  54577. /**
  54578. * Gets the output component
  54579. */
  54580. readonly output: NodeMaterialConnectionPoint;
  54581. autoConfigure(): void;
  54582. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54583. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54584. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54585. protected _buildBlock(state: NodeMaterialBuildState): this;
  54586. }
  54587. }
  54588. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  54589. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54590. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54591. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54592. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54593. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54594. /**
  54595. * Block used to add support for instances
  54596. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  54597. */
  54598. export class InstancesBlock extends NodeMaterialBlock {
  54599. /**
  54600. * Creates a new InstancesBlock
  54601. * @param name defines the block name
  54602. */
  54603. constructor(name: string);
  54604. /**
  54605. * Gets the current class name
  54606. * @returns the class name
  54607. */
  54608. getClassName(): string;
  54609. /**
  54610. * Gets the first world row input component
  54611. */
  54612. readonly world0: NodeMaterialConnectionPoint;
  54613. /**
  54614. * Gets the second world row input component
  54615. */
  54616. readonly world1: NodeMaterialConnectionPoint;
  54617. /**
  54618. * Gets the third world row input component
  54619. */
  54620. readonly world2: NodeMaterialConnectionPoint;
  54621. /**
  54622. * Gets the forth world row input component
  54623. */
  54624. readonly world3: NodeMaterialConnectionPoint;
  54625. /**
  54626. * Gets the world input component
  54627. */
  54628. readonly world: NodeMaterialConnectionPoint;
  54629. /**
  54630. * Gets the output component
  54631. */
  54632. readonly output: NodeMaterialConnectionPoint;
  54633. autoConfigure(): void;
  54634. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54635. protected _buildBlock(state: NodeMaterialBuildState): this;
  54636. }
  54637. }
  54638. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  54639. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54640. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54641. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54642. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54643. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54644. import { Effect } from "babylonjs/Materials/effect";
  54645. import { Mesh } from "babylonjs/Meshes/mesh";
  54646. /**
  54647. * Block used to add morph targets support to vertex shader
  54648. */
  54649. export class MorphTargetsBlock extends NodeMaterialBlock {
  54650. private _repeatableContentAnchor;
  54651. private _repeatebleContentGenerated;
  54652. /**
  54653. * Create a new MorphTargetsBlock
  54654. * @param name defines the block name
  54655. */
  54656. constructor(name: string);
  54657. /**
  54658. * Gets the current class name
  54659. * @returns the class name
  54660. */
  54661. getClassName(): string;
  54662. /**
  54663. * Gets the position input component
  54664. */
  54665. readonly position: NodeMaterialConnectionPoint;
  54666. /**
  54667. * Gets the normal input component
  54668. */
  54669. readonly normal: NodeMaterialConnectionPoint;
  54670. /**
  54671. * Gets the tangent input component
  54672. */
  54673. readonly tangent: NodeMaterialConnectionPoint;
  54674. /**
  54675. * Gets the tangent input component
  54676. */
  54677. readonly uv: NodeMaterialConnectionPoint;
  54678. /**
  54679. * Gets the position output component
  54680. */
  54681. readonly positionOutput: NodeMaterialConnectionPoint;
  54682. /**
  54683. * Gets the normal output component
  54684. */
  54685. readonly normalOutput: NodeMaterialConnectionPoint;
  54686. /**
  54687. * Gets the tangent output component
  54688. */
  54689. readonly tangentOutput: NodeMaterialConnectionPoint;
  54690. /**
  54691. * Gets the tangent output component
  54692. */
  54693. readonly uvOutput: NodeMaterialConnectionPoint;
  54694. initialize(state: NodeMaterialBuildState): void;
  54695. autoConfigure(): void;
  54696. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54697. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54698. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54699. protected _buildBlock(state: NodeMaterialBuildState): this;
  54700. }
  54701. }
  54702. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  54703. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  54704. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  54705. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  54706. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  54707. }
  54708. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  54709. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54710. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54711. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54712. /**
  54713. * Block used to add an alpha test in the fragment shader
  54714. */
  54715. export class AlphaTestBlock extends NodeMaterialBlock {
  54716. /**
  54717. * Gets or sets the alpha value where alpha testing happens
  54718. */
  54719. alphaCutOff: number;
  54720. /**
  54721. * Create a new AlphaTestBlock
  54722. * @param name defines the block name
  54723. */
  54724. constructor(name: string);
  54725. /**
  54726. * Gets the current class name
  54727. * @returns the class name
  54728. */
  54729. getClassName(): string;
  54730. /**
  54731. * Gets the color input component
  54732. */
  54733. readonly color: NodeMaterialConnectionPoint;
  54734. protected _buildBlock(state: NodeMaterialBuildState): this;
  54735. }
  54736. }
  54737. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock" {
  54738. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54739. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54740. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54741. /**
  54742. * Block used to create a Color4 out of 4 inputs (one for each component)
  54743. */
  54744. export class RGBAMergerBlock extends NodeMaterialBlock {
  54745. /**
  54746. * Create a new RGBAMergerBlock
  54747. * @param name defines the block name
  54748. */
  54749. constructor(name: string);
  54750. /**
  54751. * Gets the current class name
  54752. * @returns the class name
  54753. */
  54754. getClassName(): string;
  54755. /**
  54756. * Gets the R input component
  54757. */
  54758. readonly r: NodeMaterialConnectionPoint;
  54759. /**
  54760. * Gets the G input component
  54761. */
  54762. readonly g: NodeMaterialConnectionPoint;
  54763. /**
  54764. * Gets the B input component
  54765. */
  54766. readonly b: NodeMaterialConnectionPoint;
  54767. /**
  54768. * Gets the RGB input component
  54769. */
  54770. readonly rgb: NodeMaterialConnectionPoint;
  54771. /**
  54772. * Gets the R input component
  54773. */
  54774. readonly a: NodeMaterialConnectionPoint;
  54775. /**
  54776. * Gets the output component
  54777. */
  54778. readonly output: NodeMaterialConnectionPoint;
  54779. protected _buildBlock(state: NodeMaterialBuildState): this;
  54780. }
  54781. }
  54782. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock" {
  54783. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54784. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54785. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54786. /**
  54787. * Block used to create a Color3 out of 3 inputs (one for each component)
  54788. */
  54789. export class RGBMergerBlock extends NodeMaterialBlock {
  54790. /**
  54791. * Create a new RGBMergerBlock
  54792. * @param name defines the block name
  54793. */
  54794. constructor(name: string);
  54795. /**
  54796. * Gets the current class name
  54797. * @returns the class name
  54798. */
  54799. getClassName(): string;
  54800. /**
  54801. * Gets the R component input
  54802. */
  54803. readonly r: NodeMaterialConnectionPoint;
  54804. /**
  54805. * Gets the G component input
  54806. */
  54807. readonly g: NodeMaterialConnectionPoint;
  54808. /**
  54809. * Gets the B component input
  54810. */
  54811. readonly b: NodeMaterialConnectionPoint;
  54812. /**
  54813. * Gets the output component
  54814. */
  54815. readonly output: NodeMaterialConnectionPoint;
  54816. protected _buildBlock(state: NodeMaterialBuildState): this;
  54817. }
  54818. }
  54819. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock" {
  54820. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54821. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54822. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54823. /**
  54824. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  54825. */
  54826. export class RGBASplitterBlock extends NodeMaterialBlock {
  54827. /**
  54828. * Create a new RGBASplitterBlock
  54829. * @param name defines the block name
  54830. */
  54831. constructor(name: string);
  54832. /**
  54833. * Gets the current class name
  54834. * @returns the class name
  54835. */
  54836. getClassName(): string;
  54837. /**
  54838. * Gets the input component
  54839. */
  54840. readonly input: NodeMaterialConnectionPoint;
  54841. protected _buildBlock(state: NodeMaterialBuildState): this;
  54842. }
  54843. }
  54844. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock" {
  54845. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54846. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54847. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54848. /**
  54849. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  54850. */
  54851. export class RGBSplitterBlock extends NodeMaterialBlock {
  54852. /**
  54853. * Create a new RGBSplitterBlock
  54854. * @param name defines the block name
  54855. */
  54856. constructor(name: string);
  54857. /**
  54858. * Gets the current class name
  54859. * @returns the class name
  54860. */
  54861. getClassName(): string;
  54862. /**
  54863. * Gets the input component
  54864. */
  54865. readonly input: NodeMaterialConnectionPoint;
  54866. protected _buildBlock(state: NodeMaterialBuildState): this;
  54867. }
  54868. }
  54869. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  54870. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54871. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54872. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54873. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54874. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54875. import { Effect } from "babylonjs/Materials/effect";
  54876. import { Mesh } from "babylonjs/Meshes/mesh";
  54877. /**
  54878. * Block used to add image processing support to fragment shader
  54879. */
  54880. export class ImageProcessingBlock extends NodeMaterialBlock {
  54881. /**
  54882. * Create a new ImageProcessingBlock
  54883. * @param name defines the block name
  54884. */
  54885. constructor(name: string);
  54886. /**
  54887. * Gets the current class name
  54888. * @returns the class name
  54889. */
  54890. getClassName(): string;
  54891. /**
  54892. * Gets the color input component
  54893. */
  54894. readonly color: NodeMaterialConnectionPoint;
  54895. /**
  54896. * Gets the output component
  54897. */
  54898. readonly output: NodeMaterialConnectionPoint;
  54899. /**
  54900. * Initialize the block and prepare the context for build
  54901. * @param state defines the state that will be used for the build
  54902. */
  54903. initialize(state: NodeMaterialBuildState): void;
  54904. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  54905. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54906. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54907. protected _buildBlock(state: NodeMaterialBuildState): this;
  54908. }
  54909. }
  54910. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  54911. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  54912. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  54913. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock";
  54914. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock";
  54915. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock";
  54916. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock";
  54917. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  54918. }
  54919. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  54920. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54921. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54922. import { Mesh } from "babylonjs/Meshes/mesh";
  54923. import { Effect } from "babylonjs/Materials/effect";
  54924. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54925. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54926. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54927. /**
  54928. * Block used to add support for scene fog
  54929. */
  54930. export class FogBlock extends NodeMaterialBlock {
  54931. private _fogDistanceName;
  54932. private _fogParameters;
  54933. /**
  54934. * Create a new FogBlock
  54935. * @param name defines the block name
  54936. */
  54937. constructor(name: string);
  54938. /**
  54939. * Gets the current class name
  54940. * @returns the class name
  54941. */
  54942. getClassName(): string;
  54943. /**
  54944. * Gets the world position input component
  54945. */
  54946. readonly worldPosition: NodeMaterialConnectionPoint;
  54947. /**
  54948. * Gets the view input component
  54949. */
  54950. readonly view: NodeMaterialConnectionPoint;
  54951. /**
  54952. * Gets the color input component
  54953. */
  54954. readonly color: NodeMaterialConnectionPoint;
  54955. /**
  54956. * Gets the fog color input component
  54957. */
  54958. readonly fogColor: NodeMaterialConnectionPoint;
  54959. /**
  54960. * Gets the output component
  54961. */
  54962. readonly output: NodeMaterialConnectionPoint;
  54963. autoConfigure(): void;
  54964. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54965. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54966. protected _buildBlock(state: NodeMaterialBuildState): this;
  54967. }
  54968. }
  54969. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  54970. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54971. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54972. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54973. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54974. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54975. import { Effect } from "babylonjs/Materials/effect";
  54976. import { Mesh } from "babylonjs/Meshes/mesh";
  54977. import { Light } from "babylonjs/Lights/light";
  54978. import { Nullable } from "babylonjs/types";
  54979. /**
  54980. * Block used to add light in the fragment shader
  54981. */
  54982. export class LightBlock extends NodeMaterialBlock {
  54983. private _lightId;
  54984. /**
  54985. * Gets or sets the light associated with this block
  54986. */
  54987. light: Nullable<Light>;
  54988. /**
  54989. * Create a new LightBlock
  54990. * @param name defines the block name
  54991. */
  54992. constructor(name: string);
  54993. /**
  54994. * Gets the current class name
  54995. * @returns the class name
  54996. */
  54997. getClassName(): string;
  54998. /**
  54999. * Gets the world position input component
  55000. */
  55001. readonly worldPosition: NodeMaterialConnectionPoint;
  55002. /**
  55003. * Gets the world normal input component
  55004. */
  55005. readonly worldNormal: NodeMaterialConnectionPoint;
  55006. /**
  55007. * Gets the camera (or eye) position component
  55008. */
  55009. readonly cameraPosition: NodeMaterialConnectionPoint;
  55010. /**
  55011. * Gets the diffuse output component
  55012. */
  55013. readonly diffuseOutput: NodeMaterialConnectionPoint;
  55014. /**
  55015. * Gets the specular output component
  55016. */
  55017. readonly specularOutput: NodeMaterialConnectionPoint;
  55018. autoConfigure(): void;
  55019. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55020. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55021. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55022. private _injectVertexCode;
  55023. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55024. }
  55025. }
  55026. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  55027. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  55028. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  55029. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55030. }
  55031. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  55032. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55033. }
  55034. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  55035. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55036. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55037. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55038. /**
  55039. * Block used to multiply 2 values
  55040. */
  55041. export class MultiplyBlock extends NodeMaterialBlock {
  55042. /**
  55043. * Creates a new MultiplyBlock
  55044. * @param name defines the block name
  55045. */
  55046. constructor(name: string);
  55047. /**
  55048. * Gets the current class name
  55049. * @returns the class name
  55050. */
  55051. getClassName(): string;
  55052. /**
  55053. * Gets the left operand input component
  55054. */
  55055. readonly left: NodeMaterialConnectionPoint;
  55056. /**
  55057. * Gets the right operand input component
  55058. */
  55059. readonly right: NodeMaterialConnectionPoint;
  55060. /**
  55061. * Gets the output component
  55062. */
  55063. readonly output: NodeMaterialConnectionPoint;
  55064. protected _buildBlock(state: NodeMaterialBuildState): this;
  55065. }
  55066. }
  55067. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  55068. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55069. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55070. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55071. /**
  55072. * Block used to add 2 vector4
  55073. */
  55074. export class AddBlock extends NodeMaterialBlock {
  55075. /**
  55076. * Creates a new AddBlock
  55077. * @param name defines the block name
  55078. */
  55079. constructor(name: string);
  55080. /**
  55081. * Gets the current class name
  55082. * @returns the class name
  55083. */
  55084. getClassName(): string;
  55085. /**
  55086. * Gets the left operand input component
  55087. */
  55088. readonly left: NodeMaterialConnectionPoint;
  55089. /**
  55090. * Gets the right operand input component
  55091. */
  55092. readonly right: NodeMaterialConnectionPoint;
  55093. /**
  55094. * Gets the output component
  55095. */
  55096. readonly output: NodeMaterialConnectionPoint;
  55097. protected _buildBlock(state: NodeMaterialBuildState): this;
  55098. }
  55099. }
  55100. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  55101. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55102. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55103. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55104. /**
  55105. * Block used to clamp a float
  55106. */
  55107. export class ClampBlock extends NodeMaterialBlock {
  55108. /** Gets or sets the minimum range */
  55109. minimum: number;
  55110. /** Gets or sets the maximum range */
  55111. maximum: number;
  55112. /**
  55113. * Creates a new ClampBlock
  55114. * @param name defines the block name
  55115. */
  55116. constructor(name: string);
  55117. /**
  55118. * Gets the current class name
  55119. * @returns the class name
  55120. */
  55121. getClassName(): string;
  55122. /**
  55123. * Gets the value input component
  55124. */
  55125. readonly value: NodeMaterialConnectionPoint;
  55126. /**
  55127. * Gets the output component
  55128. */
  55129. readonly output: NodeMaterialConnectionPoint;
  55130. protected _buildBlock(state: NodeMaterialBuildState): this;
  55131. }
  55132. }
  55133. declare module "babylonjs/Materials/Node/Blocks/vector2TransformBlock" {
  55134. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55135. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55136. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55137. /**
  55138. * Block used to transform a vector2 with a matrix
  55139. */
  55140. export class Vector2TransformBlock extends NodeMaterialBlock {
  55141. /**
  55142. * Defines the value to use to complement Vector2 to transform it to a Vector4
  55143. */
  55144. complementZ: number;
  55145. /**
  55146. * Defines the value to use to complement Vector2 to transform it to a Vector4
  55147. */
  55148. complementW: number;
  55149. /**
  55150. * Creates a new Vector2TransformBlock
  55151. * @param name defines the block name
  55152. */
  55153. constructor(name: string);
  55154. /**
  55155. * Gets the vector input
  55156. */
  55157. readonly vector: NodeMaterialConnectionPoint;
  55158. /**
  55159. * Gets the matrix transform input
  55160. */
  55161. readonly transform: NodeMaterialConnectionPoint;
  55162. /**
  55163. * Gets the output component
  55164. */
  55165. readonly output: NodeMaterialConnectionPoint;
  55166. /**
  55167. * Gets the current class name
  55168. * @returns the class name
  55169. */
  55170. getClassName(): string;
  55171. protected _buildBlock(state: NodeMaterialBuildState): this;
  55172. }
  55173. }
  55174. declare module "babylonjs/Materials/Node/Blocks/vector3TransformBlock" {
  55175. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55176. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55177. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55178. /**
  55179. * Block used to transform a vector3 with a matrix
  55180. */
  55181. export class Vector3TransformBlock extends NodeMaterialBlock {
  55182. /**
  55183. * Defines the value to use to complement Vector3 to transform it to a Vector4
  55184. */
  55185. complement: number;
  55186. /**
  55187. * Creates a new Vector3TransformBlock
  55188. * @param name defines the block name
  55189. */
  55190. constructor(name: string);
  55191. /**
  55192. * Gets the vector input
  55193. */
  55194. readonly vector: NodeMaterialConnectionPoint;
  55195. /**
  55196. * Gets the matrix transform input
  55197. */
  55198. readonly transform: NodeMaterialConnectionPoint;
  55199. /**
  55200. * Gets the output component
  55201. */
  55202. readonly output: NodeMaterialConnectionPoint;
  55203. /**
  55204. * Gets the current class name
  55205. * @returns the class name
  55206. */
  55207. getClassName(): string;
  55208. protected _buildBlock(state: NodeMaterialBuildState): this;
  55209. }
  55210. }
  55211. declare module "babylonjs/Materials/Node/Blocks/index" {
  55212. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  55213. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  55214. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  55215. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  55216. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  55217. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  55218. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  55219. export * from "babylonjs/Materials/Node/Blocks/vector2TransformBlock";
  55220. export * from "babylonjs/Materials/Node/Blocks/vector3TransformBlock";
  55221. export * from "babylonjs/Materials/Node/Blocks/vector4TransformBlock";
  55222. }
  55223. declare module "babylonjs/Materials/Node/Optimizers/index" {
  55224. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  55225. }
  55226. declare module "babylonjs/Materials/Node/index" {
  55227. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55228. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55229. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55230. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  55231. export * from "babylonjs/Materials/Node/nodeMaterial";
  55232. export * from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  55233. export * from "babylonjs/Materials/Node/Blocks/index";
  55234. export * from "babylonjs/Materials/Node/Optimizers/index";
  55235. }
  55236. declare module "babylonjs/Materials/effectRenderer" {
  55237. import { Nullable } from "babylonjs/types";
  55238. import { Texture } from "babylonjs/Materials/Textures/texture";
  55239. import { Engine } from "babylonjs/Engines/engine";
  55240. import { Observable } from "babylonjs/Misc/observable";
  55241. import { Effect } from "babylonjs/Materials/effect";
  55242. /**
  55243. * Helper class to render one or more effects
  55244. */
  55245. export class EffectRenderer {
  55246. private engine;
  55247. private static _Vertices;
  55248. private static _Indices;
  55249. private _vertexBuffers;
  55250. private _indexBuffer;
  55251. private _ringBufferIndex;
  55252. private _ringScreenBuffer;
  55253. private _getNextFrameBuffer;
  55254. /**
  55255. * Creates an effect renderer
  55256. * @param engine the engine to use for rendering
  55257. */
  55258. constructor(engine: Engine);
  55259. /**
  55260. * renders one or more effects to a specified texture
  55261. * @param effectWrappers list of effects to renderer
  55262. * @param outputTexture texture to draw to, if null it will render to the screen
  55263. */
  55264. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  55265. /**
  55266. * Disposes of the effect renderer
  55267. */
  55268. dispose(): void;
  55269. }
  55270. /**
  55271. * Options to create an EffectWrapper
  55272. */
  55273. interface EffectWrapperCreationOptions {
  55274. /**
  55275. * Engine to use to create the effect
  55276. */
  55277. engine: Engine;
  55278. /**
  55279. * Fragment shader for the effect
  55280. */
  55281. fragmentShader: string;
  55282. /**
  55283. * Attributes to use in the shader
  55284. */
  55285. attributeNames: Array<string>;
  55286. /**
  55287. * Uniforms to use in the shader
  55288. */
  55289. uniformNames: Array<string>;
  55290. /**
  55291. * Texture sampler names to use in the shader
  55292. */
  55293. samplerNames: Array<string>;
  55294. }
  55295. /**
  55296. * Wraps an effect to be used for rendering
  55297. */
  55298. export class EffectWrapper {
  55299. /**
  55300. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  55301. */
  55302. onApplyObservable: Observable<{}>;
  55303. /**
  55304. * The underlying effect
  55305. */
  55306. effect: Effect;
  55307. /**
  55308. * Creates an effect to be renderer
  55309. * @param creationOptions options to create the effect
  55310. */
  55311. constructor(creationOptions: EffectWrapperCreationOptions);
  55312. /**
  55313. * Disposes of the effect wrapper
  55314. */
  55315. dispose(): void;
  55316. }
  55317. }
  55318. declare module "babylonjs/Materials/index" {
  55319. export * from "babylonjs/Materials/Background/index";
  55320. export * from "babylonjs/Materials/colorCurves";
  55321. export * from "babylonjs/Materials/effect";
  55322. export * from "babylonjs/Materials/fresnelParameters";
  55323. export * from "babylonjs/Materials/imageProcessingConfiguration";
  55324. export * from "babylonjs/Materials/material";
  55325. export * from "babylonjs/Materials/materialDefines";
  55326. export * from "babylonjs/Materials/materialHelper";
  55327. export * from "babylonjs/Materials/multiMaterial";
  55328. export * from "babylonjs/Materials/PBR/index";
  55329. export * from "babylonjs/Materials/pushMaterial";
  55330. export * from "babylonjs/Materials/shaderMaterial";
  55331. export * from "babylonjs/Materials/standardMaterial";
  55332. export * from "babylonjs/Materials/Textures/index";
  55333. export * from "babylonjs/Materials/uniformBuffer";
  55334. export * from "babylonjs/Materials/materialFlags";
  55335. export * from "babylonjs/Materials/Node/index";
  55336. export * from "babylonjs/Materials/effectRenderer";
  55337. }
  55338. declare module "babylonjs/Maths/math.vertexFormat" {
  55339. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  55340. /**
  55341. * Contains position and normal vectors for a vertex
  55342. */
  55343. export class PositionNormalVertex {
  55344. /** the position of the vertex (defaut: 0,0,0) */
  55345. position: Vector3;
  55346. /** the normal of the vertex (defaut: 0,1,0) */
  55347. normal: Vector3;
  55348. /**
  55349. * Creates a PositionNormalVertex
  55350. * @param position the position of the vertex (defaut: 0,0,0)
  55351. * @param normal the normal of the vertex (defaut: 0,1,0)
  55352. */
  55353. constructor(
  55354. /** the position of the vertex (defaut: 0,0,0) */
  55355. position?: Vector3,
  55356. /** the normal of the vertex (defaut: 0,1,0) */
  55357. normal?: Vector3);
  55358. /**
  55359. * Clones the PositionNormalVertex
  55360. * @returns the cloned PositionNormalVertex
  55361. */
  55362. clone(): PositionNormalVertex;
  55363. }
  55364. /**
  55365. * Contains position, normal and uv vectors for a vertex
  55366. */
  55367. export class PositionNormalTextureVertex {
  55368. /** the position of the vertex (defaut: 0,0,0) */
  55369. position: Vector3;
  55370. /** the normal of the vertex (defaut: 0,1,0) */
  55371. normal: Vector3;
  55372. /** the uv of the vertex (default: 0,0) */
  55373. uv: Vector2;
  55374. /**
  55375. * Creates a PositionNormalTextureVertex
  55376. * @param position the position of the vertex (defaut: 0,0,0)
  55377. * @param normal the normal of the vertex (defaut: 0,1,0)
  55378. * @param uv the uv of the vertex (default: 0,0)
  55379. */
  55380. constructor(
  55381. /** the position of the vertex (defaut: 0,0,0) */
  55382. position?: Vector3,
  55383. /** the normal of the vertex (defaut: 0,1,0) */
  55384. normal?: Vector3,
  55385. /** the uv of the vertex (default: 0,0) */
  55386. uv?: Vector2);
  55387. /**
  55388. * Clones the PositionNormalTextureVertex
  55389. * @returns the cloned PositionNormalTextureVertex
  55390. */
  55391. clone(): PositionNormalTextureVertex;
  55392. }
  55393. }
  55394. declare module "babylonjs/Maths/math" {
  55395. export * from "babylonjs/Maths/math.axis";
  55396. export * from "babylonjs/Maths/math.color";
  55397. export * from "babylonjs/Maths/math.constants";
  55398. export * from "babylonjs/Maths/math.frustum";
  55399. export * from "babylonjs/Maths/math.path";
  55400. export * from "babylonjs/Maths/math.plane";
  55401. export * from "babylonjs/Maths/math.size";
  55402. export * from "babylonjs/Maths/math.vector";
  55403. export * from "babylonjs/Maths/math.vertexFormat";
  55404. export * from "babylonjs/Maths/math.viewport";
  55405. }
  55406. declare module "babylonjs/Maths/index" {
  55407. export * from "babylonjs/Maths/math.scalar";
  55408. export * from "babylonjs/Maths/math";
  55409. export * from "babylonjs/Maths/sphericalPolynomial";
  55410. }
  55411. declare module "babylonjs/Misc/workerPool" {
  55412. import { IDisposable } from "babylonjs/scene";
  55413. /**
  55414. * Helper class to push actions to a pool of workers.
  55415. */
  55416. export class WorkerPool implements IDisposable {
  55417. private _workerInfos;
  55418. private _pendingActions;
  55419. /**
  55420. * Constructor
  55421. * @param workers Array of workers to use for actions
  55422. */
  55423. constructor(workers: Array<Worker>);
  55424. /**
  55425. * Terminates all workers and clears any pending actions.
  55426. */
  55427. dispose(): void;
  55428. /**
  55429. * Pushes an action to the worker pool. If all the workers are active, the action will be
  55430. * pended until a worker has completed its action.
  55431. * @param action The action to perform. Call onComplete when the action is complete.
  55432. */
  55433. push(action: (worker: Worker, onComplete: () => void) => void): void;
  55434. private _execute;
  55435. }
  55436. }
  55437. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  55438. import { IDisposable } from "babylonjs/scene";
  55439. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  55440. /**
  55441. * Configuration for Draco compression
  55442. */
  55443. export interface IDracoCompressionConfiguration {
  55444. /**
  55445. * Configuration for the decoder.
  55446. */
  55447. decoder: {
  55448. /**
  55449. * The url to the WebAssembly module.
  55450. */
  55451. wasmUrl?: string;
  55452. /**
  55453. * The url to the WebAssembly binary.
  55454. */
  55455. wasmBinaryUrl?: string;
  55456. /**
  55457. * The url to the fallback JavaScript module.
  55458. */
  55459. fallbackUrl?: string;
  55460. };
  55461. }
  55462. /**
  55463. * Draco compression (https://google.github.io/draco/)
  55464. *
  55465. * This class wraps the Draco module.
  55466. *
  55467. * **Encoder**
  55468. *
  55469. * The encoder is not currently implemented.
  55470. *
  55471. * **Decoder**
  55472. *
  55473. * 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.
  55474. *
  55475. * To update the configuration, use the following code:
  55476. * ```javascript
  55477. * DracoCompression.Configuration = {
  55478. * decoder: {
  55479. * wasmUrl: "<url to the WebAssembly library>",
  55480. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  55481. * fallbackUrl: "<url to the fallback JavaScript library>",
  55482. * }
  55483. * };
  55484. * ```
  55485. *
  55486. * 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.
  55487. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  55488. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  55489. *
  55490. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  55491. * ```javascript
  55492. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  55493. * ```
  55494. *
  55495. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  55496. */
  55497. export class DracoCompression implements IDisposable {
  55498. private _workerPoolPromise?;
  55499. private _decoderModulePromise?;
  55500. /**
  55501. * The configuration. Defaults to the following urls:
  55502. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  55503. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  55504. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  55505. */
  55506. static Configuration: IDracoCompressionConfiguration;
  55507. /**
  55508. * Returns true if the decoder configuration is available.
  55509. */
  55510. static readonly DecoderAvailable: boolean;
  55511. /**
  55512. * Default number of workers to create when creating the draco compression object.
  55513. */
  55514. static DefaultNumWorkers: number;
  55515. private static GetDefaultNumWorkers;
  55516. private static _Default;
  55517. /**
  55518. * Default instance for the draco compression object.
  55519. */
  55520. static readonly Default: DracoCompression;
  55521. /**
  55522. * Constructor
  55523. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  55524. */
  55525. constructor(numWorkers?: number);
  55526. /**
  55527. * Stop all async operations and release resources.
  55528. */
  55529. dispose(): void;
  55530. /**
  55531. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  55532. * @returns a promise that resolves when ready
  55533. */
  55534. whenReadyAsync(): Promise<void>;
  55535. /**
  55536. * Decode Draco compressed mesh data to vertex data.
  55537. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  55538. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  55539. * @returns A promise that resolves with the decoded vertex data
  55540. */
  55541. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  55542. [kind: string]: number;
  55543. }): Promise<VertexData>;
  55544. }
  55545. }
  55546. declare module "babylonjs/Meshes/Compression/index" {
  55547. export * from "babylonjs/Meshes/Compression/dracoCompression";
  55548. }
  55549. declare module "babylonjs/Meshes/csg" {
  55550. import { Nullable } from "babylonjs/types";
  55551. import { Scene } from "babylonjs/scene";
  55552. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55553. import { Mesh } from "babylonjs/Meshes/mesh";
  55554. import { Material } from "babylonjs/Materials/material";
  55555. /**
  55556. * Class for building Constructive Solid Geometry
  55557. */
  55558. export class CSG {
  55559. private polygons;
  55560. /**
  55561. * The world matrix
  55562. */
  55563. matrix: Matrix;
  55564. /**
  55565. * Stores the position
  55566. */
  55567. position: Vector3;
  55568. /**
  55569. * Stores the rotation
  55570. */
  55571. rotation: Vector3;
  55572. /**
  55573. * Stores the rotation quaternion
  55574. */
  55575. rotationQuaternion: Nullable<Quaternion>;
  55576. /**
  55577. * Stores the scaling vector
  55578. */
  55579. scaling: Vector3;
  55580. /**
  55581. * Convert the Mesh to CSG
  55582. * @param mesh The Mesh to convert to CSG
  55583. * @returns A new CSG from the Mesh
  55584. */
  55585. static FromMesh(mesh: Mesh): CSG;
  55586. /**
  55587. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  55588. * @param polygons Polygons used to construct a CSG solid
  55589. */
  55590. private static FromPolygons;
  55591. /**
  55592. * Clones, or makes a deep copy, of the CSG
  55593. * @returns A new CSG
  55594. */
  55595. clone(): CSG;
  55596. /**
  55597. * Unions this CSG with another CSG
  55598. * @param csg The CSG to union against this CSG
  55599. * @returns The unioned CSG
  55600. */
  55601. union(csg: CSG): CSG;
  55602. /**
  55603. * Unions this CSG with another CSG in place
  55604. * @param csg The CSG to union against this CSG
  55605. */
  55606. unionInPlace(csg: CSG): void;
  55607. /**
  55608. * Subtracts this CSG with another CSG
  55609. * @param csg The CSG to subtract against this CSG
  55610. * @returns A new CSG
  55611. */
  55612. subtract(csg: CSG): CSG;
  55613. /**
  55614. * Subtracts this CSG with another CSG in place
  55615. * @param csg The CSG to subtact against this CSG
  55616. */
  55617. subtractInPlace(csg: CSG): void;
  55618. /**
  55619. * Intersect this CSG with another CSG
  55620. * @param csg The CSG to intersect against this CSG
  55621. * @returns A new CSG
  55622. */
  55623. intersect(csg: CSG): CSG;
  55624. /**
  55625. * Intersects this CSG with another CSG in place
  55626. * @param csg The CSG to intersect against this CSG
  55627. */
  55628. intersectInPlace(csg: CSG): void;
  55629. /**
  55630. * Return a new CSG solid with solid and empty space switched. This solid is
  55631. * not modified.
  55632. * @returns A new CSG solid with solid and empty space switched
  55633. */
  55634. inverse(): CSG;
  55635. /**
  55636. * Inverses the CSG in place
  55637. */
  55638. inverseInPlace(): void;
  55639. /**
  55640. * This is used to keep meshes transformations so they can be restored
  55641. * when we build back a Babylon Mesh
  55642. * NB : All CSG operations are performed in world coordinates
  55643. * @param csg The CSG to copy the transform attributes from
  55644. * @returns This CSG
  55645. */
  55646. copyTransformAttributes(csg: CSG): CSG;
  55647. /**
  55648. * Build Raw mesh from CSG
  55649. * Coordinates here are in world space
  55650. * @param name The name of the mesh geometry
  55651. * @param scene The Scene
  55652. * @param keepSubMeshes Specifies if the submeshes should be kept
  55653. * @returns A new Mesh
  55654. */
  55655. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  55656. /**
  55657. * Build Mesh from CSG taking material and transforms into account
  55658. * @param name The name of the Mesh
  55659. * @param material The material of the Mesh
  55660. * @param scene The Scene
  55661. * @param keepSubMeshes Specifies if submeshes should be kept
  55662. * @returns The new Mesh
  55663. */
  55664. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  55665. }
  55666. }
  55667. declare module "babylonjs/Meshes/trailMesh" {
  55668. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55669. import { Mesh } from "babylonjs/Meshes/mesh";
  55670. import { Scene } from "babylonjs/scene";
  55671. /**
  55672. * Class used to create a trail following a mesh
  55673. */
  55674. export class TrailMesh extends Mesh {
  55675. private _generator;
  55676. private _autoStart;
  55677. private _running;
  55678. private _diameter;
  55679. private _length;
  55680. private _sectionPolygonPointsCount;
  55681. private _sectionVectors;
  55682. private _sectionNormalVectors;
  55683. private _beforeRenderObserver;
  55684. /**
  55685. * @constructor
  55686. * @param name The value used by scene.getMeshByName() to do a lookup.
  55687. * @param generator The mesh to generate a trail.
  55688. * @param scene The scene to add this mesh to.
  55689. * @param diameter Diameter of trailing mesh. Default is 1.
  55690. * @param length Length of trailing mesh. Default is 60.
  55691. * @param autoStart Automatically start trailing mesh. Default true.
  55692. */
  55693. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  55694. /**
  55695. * "TrailMesh"
  55696. * @returns "TrailMesh"
  55697. */
  55698. getClassName(): string;
  55699. private _createMesh;
  55700. /**
  55701. * Start trailing mesh.
  55702. */
  55703. start(): void;
  55704. /**
  55705. * Stop trailing mesh.
  55706. */
  55707. stop(): void;
  55708. /**
  55709. * Update trailing mesh geometry.
  55710. */
  55711. update(): void;
  55712. /**
  55713. * Returns a new TrailMesh object.
  55714. * @param name is a string, the name given to the new mesh
  55715. * @param newGenerator use new generator object for cloned trail mesh
  55716. * @returns a new mesh
  55717. */
  55718. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  55719. /**
  55720. * Serializes this trail mesh
  55721. * @param serializationObject object to write serialization to
  55722. */
  55723. serialize(serializationObject: any): void;
  55724. /**
  55725. * Parses a serialized trail mesh
  55726. * @param parsedMesh the serialized mesh
  55727. * @param scene the scene to create the trail mesh in
  55728. * @returns the created trail mesh
  55729. */
  55730. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  55731. }
  55732. }
  55733. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  55734. import { Nullable } from "babylonjs/types";
  55735. import { Scene } from "babylonjs/scene";
  55736. import { Vector4 } from "babylonjs/Maths/math.vector";
  55737. import { Color4 } from "babylonjs/Maths/math.color";
  55738. import { Mesh } from "babylonjs/Meshes/mesh";
  55739. /**
  55740. * Class containing static functions to help procedurally build meshes
  55741. */
  55742. export class TiledBoxBuilder {
  55743. /**
  55744. * Creates a box mesh
  55745. * 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)
  55746. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55747. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55748. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55749. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55750. * @param name defines the name of the mesh
  55751. * @param options defines the options used to create the mesh
  55752. * @param scene defines the hosting scene
  55753. * @returns the box mesh
  55754. */
  55755. static CreateTiledBox(name: string, options: {
  55756. pattern?: number;
  55757. width?: number;
  55758. height?: number;
  55759. depth?: number;
  55760. tileSize?: number;
  55761. tileWidth?: number;
  55762. tileHeight?: number;
  55763. alignHorizontal?: number;
  55764. alignVertical?: number;
  55765. faceUV?: Vector4[];
  55766. faceColors?: Color4[];
  55767. sideOrientation?: number;
  55768. updatable?: boolean;
  55769. }, scene?: Nullable<Scene>): Mesh;
  55770. }
  55771. }
  55772. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  55773. import { Vector4 } from "babylonjs/Maths/math.vector";
  55774. import { Mesh } from "babylonjs/Meshes/mesh";
  55775. /**
  55776. * Class containing static functions to help procedurally build meshes
  55777. */
  55778. export class TorusKnotBuilder {
  55779. /**
  55780. * Creates a torus knot mesh
  55781. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55782. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55783. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55784. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55785. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55786. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55788. * @param name defines the name of the mesh
  55789. * @param options defines the options used to create the mesh
  55790. * @param scene defines the hosting scene
  55791. * @returns the torus knot mesh
  55792. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55793. */
  55794. static CreateTorusKnot(name: string, options: {
  55795. radius?: number;
  55796. tube?: number;
  55797. radialSegments?: number;
  55798. tubularSegments?: number;
  55799. p?: number;
  55800. q?: number;
  55801. updatable?: boolean;
  55802. sideOrientation?: number;
  55803. frontUVs?: Vector4;
  55804. backUVs?: Vector4;
  55805. }, scene: any): Mesh;
  55806. }
  55807. }
  55808. declare module "babylonjs/Meshes/polygonMesh" {
  55809. import { Scene } from "babylonjs/scene";
  55810. import { Vector2 } from "babylonjs/Maths/math.vector";
  55811. import { Mesh } from "babylonjs/Meshes/mesh";
  55812. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  55813. import { Path2 } from "babylonjs/Maths/math.path";
  55814. /**
  55815. * Polygon
  55816. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  55817. */
  55818. export class Polygon {
  55819. /**
  55820. * Creates a rectangle
  55821. * @param xmin bottom X coord
  55822. * @param ymin bottom Y coord
  55823. * @param xmax top X coord
  55824. * @param ymax top Y coord
  55825. * @returns points that make the resulting rectation
  55826. */
  55827. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  55828. /**
  55829. * Creates a circle
  55830. * @param radius radius of circle
  55831. * @param cx scale in x
  55832. * @param cy scale in y
  55833. * @param numberOfSides number of sides that make up the circle
  55834. * @returns points that make the resulting circle
  55835. */
  55836. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  55837. /**
  55838. * Creates a polygon from input string
  55839. * @param input Input polygon data
  55840. * @returns the parsed points
  55841. */
  55842. static Parse(input: string): Vector2[];
  55843. /**
  55844. * Starts building a polygon from x and y coordinates
  55845. * @param x x coordinate
  55846. * @param y y coordinate
  55847. * @returns the started path2
  55848. */
  55849. static StartingAt(x: number, y: number): Path2;
  55850. }
  55851. /**
  55852. * Builds a polygon
  55853. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  55854. */
  55855. export class PolygonMeshBuilder {
  55856. private _points;
  55857. private _outlinepoints;
  55858. private _holes;
  55859. private _name;
  55860. private _scene;
  55861. private _epoints;
  55862. private _eholes;
  55863. private _addToepoint;
  55864. /**
  55865. * Babylon reference to the earcut plugin.
  55866. */
  55867. bjsEarcut: any;
  55868. /**
  55869. * Creates a PolygonMeshBuilder
  55870. * @param name name of the builder
  55871. * @param contours Path of the polygon
  55872. * @param scene scene to add to when creating the mesh
  55873. * @param earcutInjection can be used to inject your own earcut reference
  55874. */
  55875. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  55876. /**
  55877. * Adds a whole within the polygon
  55878. * @param hole Array of points defining the hole
  55879. * @returns this
  55880. */
  55881. addHole(hole: Vector2[]): PolygonMeshBuilder;
  55882. /**
  55883. * Creates the polygon
  55884. * @param updatable If the mesh should be updatable
  55885. * @param depth The depth of the mesh created
  55886. * @returns the created mesh
  55887. */
  55888. build(updatable?: boolean, depth?: number): Mesh;
  55889. /**
  55890. * Creates the polygon
  55891. * @param depth The depth of the mesh created
  55892. * @returns the created VertexData
  55893. */
  55894. buildVertexData(depth?: number): VertexData;
  55895. /**
  55896. * Adds a side to the polygon
  55897. * @param positions points that make the polygon
  55898. * @param normals normals of the polygon
  55899. * @param uvs uvs of the polygon
  55900. * @param indices indices of the polygon
  55901. * @param bounds bounds of the polygon
  55902. * @param points points of the polygon
  55903. * @param depth depth of the polygon
  55904. * @param flip flip of the polygon
  55905. */
  55906. private addSide;
  55907. }
  55908. }
  55909. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  55910. import { Scene } from "babylonjs/scene";
  55911. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  55912. import { Color4 } from "babylonjs/Maths/math.color";
  55913. import { Mesh } from "babylonjs/Meshes/mesh";
  55914. import { Nullable } from "babylonjs/types";
  55915. /**
  55916. * Class containing static functions to help procedurally build meshes
  55917. */
  55918. export class PolygonBuilder {
  55919. /**
  55920. * Creates a polygon mesh
  55921. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55922. * * 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
  55923. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55924. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55925. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  55926. * * Remember you can only change the shape positions, not their number when updating a polygon
  55927. * @param name defines the name of the mesh
  55928. * @param options defines the options used to create the mesh
  55929. * @param scene defines the hosting scene
  55930. * @param earcutInjection can be used to inject your own earcut reference
  55931. * @returns the polygon mesh
  55932. */
  55933. static CreatePolygon(name: string, options: {
  55934. shape: Vector3[];
  55935. holes?: Vector3[][];
  55936. depth?: number;
  55937. faceUV?: Vector4[];
  55938. faceColors?: Color4[];
  55939. updatable?: boolean;
  55940. sideOrientation?: number;
  55941. frontUVs?: Vector4;
  55942. backUVs?: Vector4;
  55943. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55944. /**
  55945. * Creates an extruded polygon mesh, with depth in the Y direction.
  55946. * * 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)
  55947. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55948. * @param name defines the name of the mesh
  55949. * @param options defines the options used to create the mesh
  55950. * @param scene defines the hosting scene
  55951. * @param earcutInjection can be used to inject your own earcut reference
  55952. * @returns the polygon mesh
  55953. */
  55954. static ExtrudePolygon(name: string, options: {
  55955. shape: Vector3[];
  55956. holes?: Vector3[][];
  55957. depth?: number;
  55958. faceUV?: Vector4[];
  55959. faceColors?: Color4[];
  55960. updatable?: boolean;
  55961. sideOrientation?: number;
  55962. frontUVs?: Vector4;
  55963. backUVs?: Vector4;
  55964. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55965. }
  55966. }
  55967. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  55968. import { Scene } from "babylonjs/scene";
  55969. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  55970. import { Mesh } from "babylonjs/Meshes/mesh";
  55971. import { Nullable } from "babylonjs/types";
  55972. /**
  55973. * Class containing static functions to help procedurally build meshes
  55974. */
  55975. export class LatheBuilder {
  55976. /**
  55977. * Creates lathe mesh.
  55978. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55979. * * 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
  55980. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55981. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55982. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55983. * * 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
  55984. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55985. * * 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
  55986. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55987. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55988. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55990. * @param name defines the name of the mesh
  55991. * @param options defines the options used to create the mesh
  55992. * @param scene defines the hosting scene
  55993. * @returns the lathe mesh
  55994. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55995. */
  55996. static CreateLathe(name: string, options: {
  55997. shape: Vector3[];
  55998. radius?: number;
  55999. tessellation?: number;
  56000. clip?: number;
  56001. arc?: number;
  56002. closed?: boolean;
  56003. updatable?: boolean;
  56004. sideOrientation?: number;
  56005. frontUVs?: Vector4;
  56006. backUVs?: Vector4;
  56007. cap?: number;
  56008. invertUV?: boolean;
  56009. }, scene?: Nullable<Scene>): Mesh;
  56010. }
  56011. }
  56012. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  56013. import { Nullable } from "babylonjs/types";
  56014. import { Scene } from "babylonjs/scene";
  56015. import { Vector4 } from "babylonjs/Maths/math.vector";
  56016. import { Mesh } from "babylonjs/Meshes/mesh";
  56017. /**
  56018. * Class containing static functions to help procedurally build meshes
  56019. */
  56020. export class TiledPlaneBuilder {
  56021. /**
  56022. * Creates a tiled plane mesh
  56023. * * The parameter `pattern` will, depending on value, do nothing or
  56024. * * * flip (reflect about central vertical) alternate tiles across and up
  56025. * * * flip every tile on alternate rows
  56026. * * * rotate (180 degs) alternate tiles across and up
  56027. * * * rotate every tile on alternate rows
  56028. * * * flip and rotate alternate tiles across and up
  56029. * * * flip and rotate every tile on alternate rows
  56030. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  56031. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  56032. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56033. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56034. * * 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)
  56035. * * 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)
  56036. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56037. * @param name defines the name of the mesh
  56038. * @param options defines the options used to create the mesh
  56039. * @param scene defines the hosting scene
  56040. * @returns the box mesh
  56041. */
  56042. static CreateTiledPlane(name: string, options: {
  56043. pattern?: number;
  56044. tileSize?: number;
  56045. tileWidth?: number;
  56046. tileHeight?: number;
  56047. size?: number;
  56048. width?: number;
  56049. height?: number;
  56050. alignHorizontal?: number;
  56051. alignVertical?: number;
  56052. sideOrientation?: number;
  56053. frontUVs?: Vector4;
  56054. backUVs?: Vector4;
  56055. updatable?: boolean;
  56056. }, scene?: Nullable<Scene>): Mesh;
  56057. }
  56058. }
  56059. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  56060. import { Nullable } from "babylonjs/types";
  56061. import { Scene } from "babylonjs/scene";
  56062. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56063. import { Mesh } from "babylonjs/Meshes/mesh";
  56064. /**
  56065. * Class containing static functions to help procedurally build meshes
  56066. */
  56067. export class TubeBuilder {
  56068. /**
  56069. * Creates a tube mesh.
  56070. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56071. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56072. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56073. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56074. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56075. * * 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)
  56076. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56077. * * 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
  56078. * * 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
  56079. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56080. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56081. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56082. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56083. * @param name defines the name of the mesh
  56084. * @param options defines the options used to create the mesh
  56085. * @param scene defines the hosting scene
  56086. * @returns the tube mesh
  56087. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56088. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56089. */
  56090. static CreateTube(name: string, options: {
  56091. path: Vector3[];
  56092. radius?: number;
  56093. tessellation?: number;
  56094. radiusFunction?: {
  56095. (i: number, distance: number): number;
  56096. };
  56097. cap?: number;
  56098. arc?: number;
  56099. updatable?: boolean;
  56100. sideOrientation?: number;
  56101. frontUVs?: Vector4;
  56102. backUVs?: Vector4;
  56103. instance?: Mesh;
  56104. invertUV?: boolean;
  56105. }, scene?: Nullable<Scene>): Mesh;
  56106. }
  56107. }
  56108. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  56109. import { Scene } from "babylonjs/scene";
  56110. import { Vector4 } from "babylonjs/Maths/math.vector";
  56111. import { Mesh } from "babylonjs/Meshes/mesh";
  56112. import { Nullable } from "babylonjs/types";
  56113. /**
  56114. * Class containing static functions to help procedurally build meshes
  56115. */
  56116. export class IcoSphereBuilder {
  56117. /**
  56118. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56119. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56120. * * 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`)
  56121. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56122. * * 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
  56123. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56124. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56126. * @param name defines the name of the mesh
  56127. * @param options defines the options used to create the mesh
  56128. * @param scene defines the hosting scene
  56129. * @returns the icosahedron mesh
  56130. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56131. */
  56132. static CreateIcoSphere(name: string, options: {
  56133. radius?: number;
  56134. radiusX?: number;
  56135. radiusY?: number;
  56136. radiusZ?: number;
  56137. flat?: boolean;
  56138. subdivisions?: number;
  56139. sideOrientation?: number;
  56140. frontUVs?: Vector4;
  56141. backUVs?: Vector4;
  56142. updatable?: boolean;
  56143. }, scene?: Nullable<Scene>): Mesh;
  56144. }
  56145. }
  56146. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  56147. import { Vector3 } from "babylonjs/Maths/math.vector";
  56148. import { Mesh } from "babylonjs/Meshes/mesh";
  56149. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56150. /**
  56151. * Class containing static functions to help procedurally build meshes
  56152. */
  56153. export class DecalBuilder {
  56154. /**
  56155. * Creates a decal mesh.
  56156. * 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
  56157. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56158. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56159. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56160. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56161. * @param name defines the name of the mesh
  56162. * @param sourceMesh defines the mesh where the decal must be applied
  56163. * @param options defines the options used to create the mesh
  56164. * @param scene defines the hosting scene
  56165. * @returns the decal mesh
  56166. * @see https://doc.babylonjs.com/how_to/decals
  56167. */
  56168. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56169. position?: Vector3;
  56170. normal?: Vector3;
  56171. size?: Vector3;
  56172. angle?: number;
  56173. }): Mesh;
  56174. }
  56175. }
  56176. declare module "babylonjs/Meshes/meshBuilder" {
  56177. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  56178. import { Nullable } from "babylonjs/types";
  56179. import { Scene } from "babylonjs/scene";
  56180. import { Mesh } from "babylonjs/Meshes/mesh";
  56181. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  56182. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  56183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56184. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  56185. import { Plane } from "babylonjs/Maths/math.plane";
  56186. /**
  56187. * Class containing static functions to help procedurally build meshes
  56188. */
  56189. export class MeshBuilder {
  56190. /**
  56191. * Creates a box mesh
  56192. * * The parameter `size` sets the size (float) of each box side (default 1)
  56193. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56194. * * 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)
  56195. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56196. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56197. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56199. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56200. * @param name defines the name of the mesh
  56201. * @param options defines the options used to create the mesh
  56202. * @param scene defines the hosting scene
  56203. * @returns the box mesh
  56204. */
  56205. static CreateBox(name: string, options: {
  56206. size?: number;
  56207. width?: number;
  56208. height?: number;
  56209. depth?: number;
  56210. faceUV?: Vector4[];
  56211. faceColors?: Color4[];
  56212. sideOrientation?: number;
  56213. frontUVs?: Vector4;
  56214. backUVs?: Vector4;
  56215. updatable?: boolean;
  56216. }, scene?: Nullable<Scene>): Mesh;
  56217. /**
  56218. * Creates a tiled box mesh
  56219. * * faceTiles sets the pattern, tile size and number of tiles for a face
  56220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56221. * @param name defines the name of the mesh
  56222. * @param options defines the options used to create the mesh
  56223. * @param scene defines the hosting scene
  56224. * @returns the tiled box mesh
  56225. */
  56226. static CreateTiledBox(name: string, options: {
  56227. pattern?: number;
  56228. size?: number;
  56229. width?: number;
  56230. height?: number;
  56231. depth: number;
  56232. tileSize?: number;
  56233. tileWidth?: number;
  56234. tileHeight?: number;
  56235. faceUV?: Vector4[];
  56236. faceColors?: Color4[];
  56237. alignHorizontal?: number;
  56238. alignVertical?: number;
  56239. sideOrientation?: number;
  56240. updatable?: boolean;
  56241. }, scene?: Nullable<Scene>): Mesh;
  56242. /**
  56243. * Creates a sphere mesh
  56244. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  56245. * * 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`)
  56246. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  56247. * * 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
  56248. * * 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)
  56249. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56250. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56252. * @param name defines the name of the mesh
  56253. * @param options defines the options used to create the mesh
  56254. * @param scene defines the hosting scene
  56255. * @returns the sphere mesh
  56256. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  56257. */
  56258. static CreateSphere(name: string, options: {
  56259. segments?: number;
  56260. diameter?: number;
  56261. diameterX?: number;
  56262. diameterY?: number;
  56263. diameterZ?: number;
  56264. arc?: number;
  56265. slice?: number;
  56266. sideOrientation?: number;
  56267. frontUVs?: Vector4;
  56268. backUVs?: Vector4;
  56269. updatable?: boolean;
  56270. }, scene?: Nullable<Scene>): Mesh;
  56271. /**
  56272. * Creates a plane polygonal mesh. By default, this is a disc
  56273. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  56274. * * 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
  56275. * * 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
  56276. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56277. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56279. * @param name defines the name of the mesh
  56280. * @param options defines the options used to create the mesh
  56281. * @param scene defines the hosting scene
  56282. * @returns the plane polygonal mesh
  56283. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  56284. */
  56285. static CreateDisc(name: string, options: {
  56286. radius?: number;
  56287. tessellation?: number;
  56288. arc?: number;
  56289. updatable?: boolean;
  56290. sideOrientation?: number;
  56291. frontUVs?: Vector4;
  56292. backUVs?: Vector4;
  56293. }, scene?: Nullable<Scene>): Mesh;
  56294. /**
  56295. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56296. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56297. * * 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`)
  56298. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56299. * * 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
  56300. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56301. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56303. * @param name defines the name of the mesh
  56304. * @param options defines the options used to create the mesh
  56305. * @param scene defines the hosting scene
  56306. * @returns the icosahedron mesh
  56307. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56308. */
  56309. static CreateIcoSphere(name: string, options: {
  56310. radius?: number;
  56311. radiusX?: number;
  56312. radiusY?: number;
  56313. radiusZ?: number;
  56314. flat?: boolean;
  56315. subdivisions?: number;
  56316. sideOrientation?: number;
  56317. frontUVs?: Vector4;
  56318. backUVs?: Vector4;
  56319. updatable?: boolean;
  56320. }, scene?: Nullable<Scene>): Mesh;
  56321. /**
  56322. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56323. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  56324. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  56325. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  56326. * * 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
  56327. * * 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
  56328. * * 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
  56329. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56330. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56331. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56332. * * 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
  56333. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  56334. * * 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
  56335. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  56336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56337. * @param name defines the name of the mesh
  56338. * @param options defines the options used to create the mesh
  56339. * @param scene defines the hosting scene
  56340. * @returns the ribbon mesh
  56341. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  56342. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56343. */
  56344. static CreateRibbon(name: string, options: {
  56345. pathArray: Vector3[][];
  56346. closeArray?: boolean;
  56347. closePath?: boolean;
  56348. offset?: number;
  56349. updatable?: boolean;
  56350. sideOrientation?: number;
  56351. frontUVs?: Vector4;
  56352. backUVs?: Vector4;
  56353. instance?: Mesh;
  56354. invertUV?: boolean;
  56355. uvs?: Vector2[];
  56356. colors?: Color4[];
  56357. }, scene?: Nullable<Scene>): Mesh;
  56358. /**
  56359. * Creates a cylinder or a cone mesh
  56360. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  56361. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  56362. * * 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.
  56363. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  56364. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  56365. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  56366. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  56367. * * 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).
  56368. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  56369. * * 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).
  56370. * * 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
  56371. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  56372. * * 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
  56373. * * 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.
  56374. * * If `enclose` is false, a ring surface is one element.
  56375. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  56376. * * 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
  56377. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56378. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56380. * @param name defines the name of the mesh
  56381. * @param options defines the options used to create the mesh
  56382. * @param scene defines the hosting scene
  56383. * @returns the cylinder mesh
  56384. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  56385. */
  56386. static CreateCylinder(name: string, options: {
  56387. height?: number;
  56388. diameterTop?: number;
  56389. diameterBottom?: number;
  56390. diameter?: number;
  56391. tessellation?: number;
  56392. subdivisions?: number;
  56393. arc?: number;
  56394. faceColors?: Color4[];
  56395. faceUV?: Vector4[];
  56396. updatable?: boolean;
  56397. hasRings?: boolean;
  56398. enclose?: boolean;
  56399. cap?: number;
  56400. sideOrientation?: number;
  56401. frontUVs?: Vector4;
  56402. backUVs?: Vector4;
  56403. }, scene?: Nullable<Scene>): Mesh;
  56404. /**
  56405. * Creates a torus mesh
  56406. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  56407. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  56408. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  56409. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56410. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56412. * @param name defines the name of the mesh
  56413. * @param options defines the options used to create the mesh
  56414. * @param scene defines the hosting scene
  56415. * @returns the torus mesh
  56416. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  56417. */
  56418. static CreateTorus(name: string, options: {
  56419. diameter?: number;
  56420. thickness?: number;
  56421. tessellation?: number;
  56422. updatable?: boolean;
  56423. sideOrientation?: number;
  56424. frontUVs?: Vector4;
  56425. backUVs?: Vector4;
  56426. }, scene?: Nullable<Scene>): Mesh;
  56427. /**
  56428. * Creates a torus knot mesh
  56429. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56430. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56431. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56432. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56433. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56434. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56436. * @param name defines the name of the mesh
  56437. * @param options defines the options used to create the mesh
  56438. * @param scene defines the hosting scene
  56439. * @returns the torus knot mesh
  56440. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56441. */
  56442. static CreateTorusKnot(name: string, options: {
  56443. radius?: number;
  56444. tube?: number;
  56445. radialSegments?: number;
  56446. tubularSegments?: number;
  56447. p?: number;
  56448. q?: number;
  56449. updatable?: boolean;
  56450. sideOrientation?: number;
  56451. frontUVs?: Vector4;
  56452. backUVs?: Vector4;
  56453. }, scene?: Nullable<Scene>): Mesh;
  56454. /**
  56455. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  56456. * * 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
  56457. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  56458. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  56459. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  56460. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  56461. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56462. * * 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
  56463. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  56464. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56465. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  56466. * @param name defines the name of the new line system
  56467. * @param options defines the options used to create the line system
  56468. * @param scene defines the hosting scene
  56469. * @returns a new line system mesh
  56470. */
  56471. static CreateLineSystem(name: string, options: {
  56472. lines: Vector3[][];
  56473. updatable?: boolean;
  56474. instance?: Nullable<LinesMesh>;
  56475. colors?: Nullable<Color4[][]>;
  56476. useVertexAlpha?: boolean;
  56477. }, scene: Nullable<Scene>): LinesMesh;
  56478. /**
  56479. * Creates a line mesh
  56480. * 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
  56481. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56482. * * The parameter `points` is an array successive Vector3
  56483. * * 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
  56484. * * The optional parameter `colors` is an array of successive Color4, one per line point
  56485. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  56486. * * When updating an instance, remember that only point positions can change, not the number of points
  56487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56488. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  56489. * @param name defines the name of the new line system
  56490. * @param options defines the options used to create the line system
  56491. * @param scene defines the hosting scene
  56492. * @returns a new line mesh
  56493. */
  56494. static CreateLines(name: string, options: {
  56495. points: Vector3[];
  56496. updatable?: boolean;
  56497. instance?: Nullable<LinesMesh>;
  56498. colors?: Color4[];
  56499. useVertexAlpha?: boolean;
  56500. }, scene?: Nullable<Scene>): LinesMesh;
  56501. /**
  56502. * Creates a dashed line mesh
  56503. * * 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
  56504. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56505. * * The parameter `points` is an array successive Vector3
  56506. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  56507. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  56508. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  56509. * * 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
  56510. * * When updating an instance, remember that only point positions can change, not the number of points
  56511. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56512. * @param name defines the name of the mesh
  56513. * @param options defines the options used to create the mesh
  56514. * @param scene defines the hosting scene
  56515. * @returns the dashed line mesh
  56516. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  56517. */
  56518. static CreateDashedLines(name: string, options: {
  56519. points: Vector3[];
  56520. dashSize?: number;
  56521. gapSize?: number;
  56522. dashNb?: number;
  56523. updatable?: boolean;
  56524. instance?: LinesMesh;
  56525. }, scene?: Nullable<Scene>): LinesMesh;
  56526. /**
  56527. * 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.
  56528. * * 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.
  56529. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56530. * * 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.
  56531. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56532. * * 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
  56533. * * 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
  56534. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56535. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56536. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56537. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56539. * @param name defines the name of the mesh
  56540. * @param options defines the options used to create the mesh
  56541. * @param scene defines the hosting scene
  56542. * @returns the extruded shape mesh
  56543. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56544. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56545. */
  56546. static ExtrudeShape(name: string, options: {
  56547. shape: Vector3[];
  56548. path: Vector3[];
  56549. scale?: number;
  56550. rotation?: number;
  56551. cap?: number;
  56552. updatable?: boolean;
  56553. sideOrientation?: number;
  56554. frontUVs?: Vector4;
  56555. backUVs?: Vector4;
  56556. instance?: Mesh;
  56557. invertUV?: boolean;
  56558. }, scene?: Nullable<Scene>): Mesh;
  56559. /**
  56560. * Creates an custom extruded shape mesh.
  56561. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56562. * * 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.
  56563. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56564. * * 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
  56565. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56566. * * 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
  56567. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56568. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56569. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56570. * * 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
  56571. * * 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
  56572. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56573. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56574. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56575. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56577. * @param name defines the name of the mesh
  56578. * @param options defines the options used to create the mesh
  56579. * @param scene defines the hosting scene
  56580. * @returns the custom extruded shape mesh
  56581. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56582. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56583. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56584. */
  56585. static ExtrudeShapeCustom(name: string, options: {
  56586. shape: Vector3[];
  56587. path: Vector3[];
  56588. scaleFunction?: any;
  56589. rotationFunction?: any;
  56590. ribbonCloseArray?: boolean;
  56591. ribbonClosePath?: boolean;
  56592. cap?: number;
  56593. updatable?: boolean;
  56594. sideOrientation?: number;
  56595. frontUVs?: Vector4;
  56596. backUVs?: Vector4;
  56597. instance?: Mesh;
  56598. invertUV?: boolean;
  56599. }, scene?: Nullable<Scene>): Mesh;
  56600. /**
  56601. * Creates lathe mesh.
  56602. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56603. * * 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
  56604. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56605. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56606. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56607. * * 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
  56608. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56609. * * 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
  56610. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56611. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56612. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56613. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56614. * @param name defines the name of the mesh
  56615. * @param options defines the options used to create the mesh
  56616. * @param scene defines the hosting scene
  56617. * @returns the lathe mesh
  56618. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56619. */
  56620. static CreateLathe(name: string, options: {
  56621. shape: Vector3[];
  56622. radius?: number;
  56623. tessellation?: number;
  56624. clip?: number;
  56625. arc?: number;
  56626. closed?: boolean;
  56627. updatable?: boolean;
  56628. sideOrientation?: number;
  56629. frontUVs?: Vector4;
  56630. backUVs?: Vector4;
  56631. cap?: number;
  56632. invertUV?: boolean;
  56633. }, scene?: Nullable<Scene>): Mesh;
  56634. /**
  56635. * Creates a tiled plane mesh
  56636. * * You can set a limited pattern arrangement with the tiles
  56637. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56638. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56640. * @param name defines the name of the mesh
  56641. * @param options defines the options used to create the mesh
  56642. * @param scene defines the hosting scene
  56643. * @returns the plane mesh
  56644. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56645. */
  56646. static CreateTiledPlane(name: string, options: {
  56647. pattern?: number;
  56648. tileSize?: number;
  56649. tileWidth?: number;
  56650. tileHeight?: number;
  56651. size?: number;
  56652. width?: number;
  56653. height?: number;
  56654. alignHorizontal?: number;
  56655. alignVertical?: number;
  56656. sideOrientation?: number;
  56657. frontUVs?: Vector4;
  56658. backUVs?: Vector4;
  56659. updatable?: boolean;
  56660. }, scene?: Nullable<Scene>): Mesh;
  56661. /**
  56662. * Creates a plane mesh
  56663. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  56664. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  56665. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  56666. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56667. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56669. * @param name defines the name of the mesh
  56670. * @param options defines the options used to create the mesh
  56671. * @param scene defines the hosting scene
  56672. * @returns the plane mesh
  56673. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56674. */
  56675. static CreatePlane(name: string, options: {
  56676. size?: number;
  56677. width?: number;
  56678. height?: number;
  56679. sideOrientation?: number;
  56680. frontUVs?: Vector4;
  56681. backUVs?: Vector4;
  56682. updatable?: boolean;
  56683. sourcePlane?: Plane;
  56684. }, scene?: Nullable<Scene>): Mesh;
  56685. /**
  56686. * Creates a ground mesh
  56687. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  56688. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  56689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56690. * @param name defines the name of the mesh
  56691. * @param options defines the options used to create the mesh
  56692. * @param scene defines the hosting scene
  56693. * @returns the ground mesh
  56694. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  56695. */
  56696. static CreateGround(name: string, options: {
  56697. width?: number;
  56698. height?: number;
  56699. subdivisions?: number;
  56700. subdivisionsX?: number;
  56701. subdivisionsY?: number;
  56702. updatable?: boolean;
  56703. }, scene?: Nullable<Scene>): Mesh;
  56704. /**
  56705. * Creates a tiled ground mesh
  56706. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  56707. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  56708. * * 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
  56709. * * 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
  56710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56711. * @param name defines the name of the mesh
  56712. * @param options defines the options used to create the mesh
  56713. * @param scene defines the hosting scene
  56714. * @returns the tiled ground mesh
  56715. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  56716. */
  56717. static CreateTiledGround(name: string, options: {
  56718. xmin: number;
  56719. zmin: number;
  56720. xmax: number;
  56721. zmax: number;
  56722. subdivisions?: {
  56723. w: number;
  56724. h: number;
  56725. };
  56726. precision?: {
  56727. w: number;
  56728. h: number;
  56729. };
  56730. updatable?: boolean;
  56731. }, scene?: Nullable<Scene>): Mesh;
  56732. /**
  56733. * Creates a ground mesh from a height map
  56734. * * The parameter `url` sets the URL of the height map image resource.
  56735. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  56736. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  56737. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  56738. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  56739. * * 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.
  56740. * * 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).
  56741. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  56742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56743. * @param name defines the name of the mesh
  56744. * @param url defines the url to the height map
  56745. * @param options defines the options used to create the mesh
  56746. * @param scene defines the hosting scene
  56747. * @returns the ground mesh
  56748. * @see https://doc.babylonjs.com/babylon101/height_map
  56749. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  56750. */
  56751. static CreateGroundFromHeightMap(name: string, url: string, options: {
  56752. width?: number;
  56753. height?: number;
  56754. subdivisions?: number;
  56755. minHeight?: number;
  56756. maxHeight?: number;
  56757. colorFilter?: Color3;
  56758. alphaFilter?: number;
  56759. updatable?: boolean;
  56760. onReady?: (mesh: GroundMesh) => void;
  56761. }, scene?: Nullable<Scene>): GroundMesh;
  56762. /**
  56763. * Creates a polygon mesh
  56764. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56765. * * 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
  56766. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56768. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  56769. * * Remember you can only change the shape positions, not their number when updating a polygon
  56770. * @param name defines the name of the mesh
  56771. * @param options defines the options used to create the mesh
  56772. * @param scene defines the hosting scene
  56773. * @param earcutInjection can be used to inject your own earcut reference
  56774. * @returns the polygon mesh
  56775. */
  56776. static CreatePolygon(name: string, options: {
  56777. shape: Vector3[];
  56778. holes?: Vector3[][];
  56779. depth?: number;
  56780. faceUV?: Vector4[];
  56781. faceColors?: Color4[];
  56782. updatable?: boolean;
  56783. sideOrientation?: number;
  56784. frontUVs?: Vector4;
  56785. backUVs?: Vector4;
  56786. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56787. /**
  56788. * Creates an extruded polygon mesh, with depth in the Y direction.
  56789. * * 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)
  56790. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56791. * @param name defines the name of the mesh
  56792. * @param options defines the options used to create the mesh
  56793. * @param scene defines the hosting scene
  56794. * @param earcutInjection can be used to inject your own earcut reference
  56795. * @returns the polygon mesh
  56796. */
  56797. static ExtrudePolygon(name: string, options: {
  56798. shape: Vector3[];
  56799. holes?: Vector3[][];
  56800. depth?: number;
  56801. faceUV?: Vector4[];
  56802. faceColors?: Color4[];
  56803. updatable?: boolean;
  56804. sideOrientation?: number;
  56805. frontUVs?: Vector4;
  56806. backUVs?: Vector4;
  56807. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56808. /**
  56809. * Creates a tube mesh.
  56810. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56811. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56812. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56813. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56814. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56815. * * 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)
  56816. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56817. * * 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
  56818. * * 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
  56819. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56820. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56821. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56822. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56823. * @param name defines the name of the mesh
  56824. * @param options defines the options used to create the mesh
  56825. * @param scene defines the hosting scene
  56826. * @returns the tube mesh
  56827. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56828. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56829. */
  56830. static CreateTube(name: string, options: {
  56831. path: Vector3[];
  56832. radius?: number;
  56833. tessellation?: number;
  56834. radiusFunction?: {
  56835. (i: number, distance: number): number;
  56836. };
  56837. cap?: number;
  56838. arc?: number;
  56839. updatable?: boolean;
  56840. sideOrientation?: number;
  56841. frontUVs?: Vector4;
  56842. backUVs?: Vector4;
  56843. instance?: Mesh;
  56844. invertUV?: boolean;
  56845. }, scene?: Nullable<Scene>): Mesh;
  56846. /**
  56847. * Creates a polyhedron mesh
  56848. * * 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
  56849. * * The parameter `size` (positive float, default 1) sets the polygon size
  56850. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56851. * * 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`
  56852. * * 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
  56853. * * 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)`)
  56854. * * 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
  56855. * * 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
  56856. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56857. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56859. * @param name defines the name of the mesh
  56860. * @param options defines the options used to create the mesh
  56861. * @param scene defines the hosting scene
  56862. * @returns the polyhedron mesh
  56863. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56864. */
  56865. static CreatePolyhedron(name: string, options: {
  56866. type?: number;
  56867. size?: number;
  56868. sizeX?: number;
  56869. sizeY?: number;
  56870. sizeZ?: number;
  56871. custom?: any;
  56872. faceUV?: Vector4[];
  56873. faceColors?: Color4[];
  56874. flat?: boolean;
  56875. updatable?: boolean;
  56876. sideOrientation?: number;
  56877. frontUVs?: Vector4;
  56878. backUVs?: Vector4;
  56879. }, scene?: Nullable<Scene>): Mesh;
  56880. /**
  56881. * Creates a decal mesh.
  56882. * 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
  56883. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56884. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56885. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56886. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56887. * @param name defines the name of the mesh
  56888. * @param sourceMesh defines the mesh where the decal must be applied
  56889. * @param options defines the options used to create the mesh
  56890. * @param scene defines the hosting scene
  56891. * @returns the decal mesh
  56892. * @see https://doc.babylonjs.com/how_to/decals
  56893. */
  56894. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56895. position?: Vector3;
  56896. normal?: Vector3;
  56897. size?: Vector3;
  56898. angle?: number;
  56899. }): Mesh;
  56900. }
  56901. }
  56902. declare module "babylonjs/Meshes/meshSimplification" {
  56903. import { Mesh } from "babylonjs/Meshes/mesh";
  56904. /**
  56905. * A simplifier interface for future simplification implementations
  56906. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56907. */
  56908. export interface ISimplifier {
  56909. /**
  56910. * Simplification of a given mesh according to the given settings.
  56911. * Since this requires computation, it is assumed that the function runs async.
  56912. * @param settings The settings of the simplification, including quality and distance
  56913. * @param successCallback A callback that will be called after the mesh was simplified.
  56914. * @param errorCallback in case of an error, this callback will be called. optional.
  56915. */
  56916. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  56917. }
  56918. /**
  56919. * Expected simplification settings.
  56920. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  56921. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56922. */
  56923. export interface ISimplificationSettings {
  56924. /**
  56925. * Gets or sets the expected quality
  56926. */
  56927. quality: number;
  56928. /**
  56929. * Gets or sets the distance when this optimized version should be used
  56930. */
  56931. distance: number;
  56932. /**
  56933. * Gets an already optimized mesh
  56934. */
  56935. optimizeMesh?: boolean;
  56936. }
  56937. /**
  56938. * Class used to specify simplification options
  56939. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56940. */
  56941. export class SimplificationSettings implements ISimplificationSettings {
  56942. /** expected quality */
  56943. quality: number;
  56944. /** distance when this optimized version should be used */
  56945. distance: number;
  56946. /** already optimized mesh */
  56947. optimizeMesh?: boolean | undefined;
  56948. /**
  56949. * Creates a SimplificationSettings
  56950. * @param quality expected quality
  56951. * @param distance distance when this optimized version should be used
  56952. * @param optimizeMesh already optimized mesh
  56953. */
  56954. constructor(
  56955. /** expected quality */
  56956. quality: number,
  56957. /** distance when this optimized version should be used */
  56958. distance: number,
  56959. /** already optimized mesh */
  56960. optimizeMesh?: boolean | undefined);
  56961. }
  56962. /**
  56963. * Interface used to define a simplification task
  56964. */
  56965. export interface ISimplificationTask {
  56966. /**
  56967. * Array of settings
  56968. */
  56969. settings: Array<ISimplificationSettings>;
  56970. /**
  56971. * Simplification type
  56972. */
  56973. simplificationType: SimplificationType;
  56974. /**
  56975. * Mesh to simplify
  56976. */
  56977. mesh: Mesh;
  56978. /**
  56979. * Callback called on success
  56980. */
  56981. successCallback?: () => void;
  56982. /**
  56983. * Defines if parallel processing can be used
  56984. */
  56985. parallelProcessing: boolean;
  56986. }
  56987. /**
  56988. * Queue used to order the simplification tasks
  56989. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56990. */
  56991. export class SimplificationQueue {
  56992. private _simplificationArray;
  56993. /**
  56994. * Gets a boolean indicating that the process is still running
  56995. */
  56996. running: boolean;
  56997. /**
  56998. * Creates a new queue
  56999. */
  57000. constructor();
  57001. /**
  57002. * Adds a new simplification task
  57003. * @param task defines a task to add
  57004. */
  57005. addTask(task: ISimplificationTask): void;
  57006. /**
  57007. * Execute next task
  57008. */
  57009. executeNext(): void;
  57010. /**
  57011. * Execute a simplification task
  57012. * @param task defines the task to run
  57013. */
  57014. runSimplification(task: ISimplificationTask): void;
  57015. private getSimplifier;
  57016. }
  57017. /**
  57018. * The implemented types of simplification
  57019. * At the moment only Quadratic Error Decimation is implemented
  57020. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57021. */
  57022. export enum SimplificationType {
  57023. /** Quadratic error decimation */
  57024. QUADRATIC = 0
  57025. }
  57026. }
  57027. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  57028. import { Scene } from "babylonjs/scene";
  57029. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  57030. import { ISceneComponent } from "babylonjs/sceneComponent";
  57031. module "babylonjs/scene" {
  57032. interface Scene {
  57033. /** @hidden (Backing field) */
  57034. _simplificationQueue: SimplificationQueue;
  57035. /**
  57036. * Gets or sets the simplification queue attached to the scene
  57037. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57038. */
  57039. simplificationQueue: SimplificationQueue;
  57040. }
  57041. }
  57042. module "babylonjs/Meshes/mesh" {
  57043. interface Mesh {
  57044. /**
  57045. * Simplify the mesh according to the given array of settings.
  57046. * Function will return immediately and will simplify async
  57047. * @param settings a collection of simplification settings
  57048. * @param parallelProcessing should all levels calculate parallel or one after the other
  57049. * @param simplificationType the type of simplification to run
  57050. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  57051. * @returns the current mesh
  57052. */
  57053. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  57054. }
  57055. }
  57056. /**
  57057. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  57058. * created in a scene
  57059. */
  57060. export class SimplicationQueueSceneComponent implements ISceneComponent {
  57061. /**
  57062. * The component name helpfull to identify the component in the list of scene components.
  57063. */
  57064. readonly name: string;
  57065. /**
  57066. * The scene the component belongs to.
  57067. */
  57068. scene: Scene;
  57069. /**
  57070. * Creates a new instance of the component for the given scene
  57071. * @param scene Defines the scene to register the component in
  57072. */
  57073. constructor(scene: Scene);
  57074. /**
  57075. * Registers the component in a given scene
  57076. */
  57077. register(): void;
  57078. /**
  57079. * Rebuilds the elements related to this component in case of
  57080. * context lost for instance.
  57081. */
  57082. rebuild(): void;
  57083. /**
  57084. * Disposes the component and the associated ressources
  57085. */
  57086. dispose(): void;
  57087. private _beforeCameraUpdate;
  57088. }
  57089. }
  57090. declare module "babylonjs/Meshes/Builders/index" {
  57091. export * from "babylonjs/Meshes/Builders/boxBuilder";
  57092. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  57093. export * from "babylonjs/Meshes/Builders/discBuilder";
  57094. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  57095. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  57096. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  57097. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  57098. export * from "babylonjs/Meshes/Builders/torusBuilder";
  57099. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  57100. export * from "babylonjs/Meshes/Builders/linesBuilder";
  57101. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  57102. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  57103. export * from "babylonjs/Meshes/Builders/latheBuilder";
  57104. export * from "babylonjs/Meshes/Builders/planeBuilder";
  57105. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  57106. export * from "babylonjs/Meshes/Builders/groundBuilder";
  57107. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  57108. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  57109. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  57110. export * from "babylonjs/Meshes/Builders/decalBuilder";
  57111. }
  57112. declare module "babylonjs/Meshes/index" {
  57113. export * from "babylonjs/Meshes/abstractMesh";
  57114. export * from "babylonjs/Meshes/buffer";
  57115. export * from "babylonjs/Meshes/Compression/index";
  57116. export * from "babylonjs/Meshes/csg";
  57117. export * from "babylonjs/Meshes/geometry";
  57118. export * from "babylonjs/Meshes/groundMesh";
  57119. export * from "babylonjs/Meshes/trailMesh";
  57120. export * from "babylonjs/Meshes/instancedMesh";
  57121. export * from "babylonjs/Meshes/linesMesh";
  57122. export * from "babylonjs/Meshes/mesh";
  57123. export * from "babylonjs/Meshes/mesh.vertexData";
  57124. export * from "babylonjs/Meshes/meshBuilder";
  57125. export * from "babylonjs/Meshes/meshSimplification";
  57126. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  57127. export * from "babylonjs/Meshes/polygonMesh";
  57128. export * from "babylonjs/Meshes/subMesh";
  57129. export * from "babylonjs/Meshes/meshLODLevel";
  57130. export * from "babylonjs/Meshes/transformNode";
  57131. export * from "babylonjs/Meshes/Builders/index";
  57132. export * from "babylonjs/Meshes/dataBuffer";
  57133. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  57134. }
  57135. declare module "babylonjs/Morph/index" {
  57136. export * from "babylonjs/Morph/morphTarget";
  57137. export * from "babylonjs/Morph/morphTargetManager";
  57138. }
  57139. declare module "babylonjs/Offline/database" {
  57140. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  57141. /**
  57142. * Class used to enable access to IndexedDB
  57143. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  57144. */
  57145. export class Database implements IOfflineProvider {
  57146. private _callbackManifestChecked;
  57147. private _currentSceneUrl;
  57148. private _db;
  57149. private _enableSceneOffline;
  57150. private _enableTexturesOffline;
  57151. private _manifestVersionFound;
  57152. private _mustUpdateRessources;
  57153. private _hasReachedQuota;
  57154. private _isSupported;
  57155. private _idbFactory;
  57156. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  57157. private static IsUASupportingBlobStorage;
  57158. /**
  57159. * Gets a boolean indicating if Database storate is enabled (off by default)
  57160. */
  57161. static IDBStorageEnabled: boolean;
  57162. /**
  57163. * Gets a boolean indicating if scene must be saved in the database
  57164. */
  57165. readonly enableSceneOffline: boolean;
  57166. /**
  57167. * Gets a boolean indicating if textures must be saved in the database
  57168. */
  57169. readonly enableTexturesOffline: boolean;
  57170. /**
  57171. * Creates a new Database
  57172. * @param urlToScene defines the url to load the scene
  57173. * @param callbackManifestChecked defines the callback to use when manifest is checked
  57174. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  57175. */
  57176. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  57177. private static _ParseURL;
  57178. private static _ReturnFullUrlLocation;
  57179. private _checkManifestFile;
  57180. /**
  57181. * Open the database and make it available
  57182. * @param successCallback defines the callback to call on success
  57183. * @param errorCallback defines the callback to call on error
  57184. */
  57185. open(successCallback: () => void, errorCallback: () => void): void;
  57186. /**
  57187. * Loads an image from the database
  57188. * @param url defines the url to load from
  57189. * @param image defines the target DOM image
  57190. */
  57191. loadImage(url: string, image: HTMLImageElement): void;
  57192. private _loadImageFromDBAsync;
  57193. private _saveImageIntoDBAsync;
  57194. private _checkVersionFromDB;
  57195. private _loadVersionFromDBAsync;
  57196. private _saveVersionIntoDBAsync;
  57197. /**
  57198. * Loads a file from database
  57199. * @param url defines the URL to load from
  57200. * @param sceneLoaded defines a callback to call on success
  57201. * @param progressCallBack defines a callback to call when progress changed
  57202. * @param errorCallback defines a callback to call on error
  57203. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  57204. */
  57205. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  57206. private _loadFileAsync;
  57207. private _saveFileAsync;
  57208. /**
  57209. * Validates if xhr data is correct
  57210. * @param xhr defines the request to validate
  57211. * @param dataType defines the expected data type
  57212. * @returns true if data is correct
  57213. */
  57214. private static _ValidateXHRData;
  57215. }
  57216. }
  57217. declare module "babylonjs/Offline/index" {
  57218. export * from "babylonjs/Offline/database";
  57219. export * from "babylonjs/Offline/IOfflineProvider";
  57220. }
  57221. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  57222. /** @hidden */
  57223. export var gpuUpdateParticlesPixelShader: {
  57224. name: string;
  57225. shader: string;
  57226. };
  57227. }
  57228. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  57229. /** @hidden */
  57230. export var gpuUpdateParticlesVertexShader: {
  57231. name: string;
  57232. shader: string;
  57233. };
  57234. }
  57235. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  57236. /** @hidden */
  57237. export var clipPlaneFragmentDeclaration2: {
  57238. name: string;
  57239. shader: string;
  57240. };
  57241. }
  57242. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  57243. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  57244. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57245. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57246. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57247. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  57248. /** @hidden */
  57249. export var gpuRenderParticlesPixelShader: {
  57250. name: string;
  57251. shader: string;
  57252. };
  57253. }
  57254. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  57255. /** @hidden */
  57256. export var clipPlaneVertexDeclaration2: {
  57257. name: string;
  57258. shader: string;
  57259. };
  57260. }
  57261. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  57262. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  57263. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  57264. /** @hidden */
  57265. export var gpuRenderParticlesVertexShader: {
  57266. name: string;
  57267. shader: string;
  57268. };
  57269. }
  57270. declare module "babylonjs/Particles/gpuParticleSystem" {
  57271. import { Nullable } from "babylonjs/types";
  57272. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  57273. import { Observable } from "babylonjs/Misc/observable";
  57274. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  57275. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57276. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  57277. import { Scene, IDisposable } from "babylonjs/scene";
  57278. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  57279. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57280. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  57281. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  57282. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  57283. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  57284. /**
  57285. * This represents a GPU particle system in Babylon
  57286. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  57287. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  57288. */
  57289. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  57290. /**
  57291. * The layer mask we are rendering the particles through.
  57292. */
  57293. layerMask: number;
  57294. private _capacity;
  57295. private _activeCount;
  57296. private _currentActiveCount;
  57297. private _accumulatedCount;
  57298. private _renderEffect;
  57299. private _updateEffect;
  57300. private _buffer0;
  57301. private _buffer1;
  57302. private _spriteBuffer;
  57303. private _updateVAO;
  57304. private _renderVAO;
  57305. private _targetIndex;
  57306. private _sourceBuffer;
  57307. private _targetBuffer;
  57308. private _engine;
  57309. private _currentRenderId;
  57310. private _started;
  57311. private _stopped;
  57312. private _timeDelta;
  57313. private _randomTexture;
  57314. private _randomTexture2;
  57315. private _attributesStrideSize;
  57316. private _updateEffectOptions;
  57317. private _randomTextureSize;
  57318. private _actualFrame;
  57319. private readonly _rawTextureWidth;
  57320. /**
  57321. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  57322. */
  57323. static readonly IsSupported: boolean;
  57324. /**
  57325. * An event triggered when the system is disposed.
  57326. */
  57327. onDisposeObservable: Observable<GPUParticleSystem>;
  57328. /**
  57329. * Gets the maximum number of particles active at the same time.
  57330. * @returns The max number of active particles.
  57331. */
  57332. getCapacity(): number;
  57333. /**
  57334. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  57335. * to override the particles.
  57336. */
  57337. forceDepthWrite: boolean;
  57338. /**
  57339. * Gets or set the number of active particles
  57340. */
  57341. activeParticleCount: number;
  57342. private _preWarmDone;
  57343. /**
  57344. * Is this system ready to be used/rendered
  57345. * @return true if the system is ready
  57346. */
  57347. isReady(): boolean;
  57348. /**
  57349. * Gets if the system has been started. (Note: this will still be true after stop is called)
  57350. * @returns True if it has been started, otherwise false.
  57351. */
  57352. isStarted(): boolean;
  57353. /**
  57354. * Starts the particle system and begins to emit
  57355. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  57356. */
  57357. start(delay?: number): void;
  57358. /**
  57359. * Stops the particle system.
  57360. */
  57361. stop(): void;
  57362. /**
  57363. * Remove all active particles
  57364. */
  57365. reset(): void;
  57366. /**
  57367. * Returns the string "GPUParticleSystem"
  57368. * @returns a string containing the class name
  57369. */
  57370. getClassName(): string;
  57371. private _colorGradientsTexture;
  57372. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  57373. /**
  57374. * Adds a new color gradient
  57375. * @param gradient defines the gradient to use (between 0 and 1)
  57376. * @param color1 defines the color to affect to the specified gradient
  57377. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  57378. * @returns the current particle system
  57379. */
  57380. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  57381. /**
  57382. * Remove a specific color gradient
  57383. * @param gradient defines the gradient to remove
  57384. * @returns the current particle system
  57385. */
  57386. removeColorGradient(gradient: number): GPUParticleSystem;
  57387. private _angularSpeedGradientsTexture;
  57388. private _sizeGradientsTexture;
  57389. private _velocityGradientsTexture;
  57390. private _limitVelocityGradientsTexture;
  57391. private _dragGradientsTexture;
  57392. private _addFactorGradient;
  57393. /**
  57394. * Adds a new size gradient
  57395. * @param gradient defines the gradient to use (between 0 and 1)
  57396. * @param factor defines the size factor to affect to the specified gradient
  57397. * @returns the current particle system
  57398. */
  57399. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  57400. /**
  57401. * Remove a specific size gradient
  57402. * @param gradient defines the gradient to remove
  57403. * @returns the current particle system
  57404. */
  57405. removeSizeGradient(gradient: number): GPUParticleSystem;
  57406. /**
  57407. * Adds a new angular speed gradient
  57408. * @param gradient defines the gradient to use (between 0 and 1)
  57409. * @param factor defines the angular speed to affect to the specified gradient
  57410. * @returns the current particle system
  57411. */
  57412. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  57413. /**
  57414. * Remove a specific angular speed gradient
  57415. * @param gradient defines the gradient to remove
  57416. * @returns the current particle system
  57417. */
  57418. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  57419. /**
  57420. * Adds a new velocity gradient
  57421. * @param gradient defines the gradient to use (between 0 and 1)
  57422. * @param factor defines the velocity to affect to the specified gradient
  57423. * @returns the current particle system
  57424. */
  57425. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57426. /**
  57427. * Remove a specific velocity gradient
  57428. * @param gradient defines the gradient to remove
  57429. * @returns the current particle system
  57430. */
  57431. removeVelocityGradient(gradient: number): GPUParticleSystem;
  57432. /**
  57433. * Adds a new limit velocity gradient
  57434. * @param gradient defines the gradient to use (between 0 and 1)
  57435. * @param factor defines the limit velocity value to affect to the specified gradient
  57436. * @returns the current particle system
  57437. */
  57438. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57439. /**
  57440. * Remove a specific limit velocity gradient
  57441. * @param gradient defines the gradient to remove
  57442. * @returns the current particle system
  57443. */
  57444. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  57445. /**
  57446. * Adds a new drag gradient
  57447. * @param gradient defines the gradient to use (between 0 and 1)
  57448. * @param factor defines the drag value to affect to the specified gradient
  57449. * @returns the current particle system
  57450. */
  57451. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  57452. /**
  57453. * Remove a specific drag gradient
  57454. * @param gradient defines the gradient to remove
  57455. * @returns the current particle system
  57456. */
  57457. removeDragGradient(gradient: number): GPUParticleSystem;
  57458. /**
  57459. * Not supported by GPUParticleSystem
  57460. * @param gradient defines the gradient to use (between 0 and 1)
  57461. * @param factor defines the emit rate value to affect to the specified gradient
  57462. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57463. * @returns the current particle system
  57464. */
  57465. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57466. /**
  57467. * Not supported by GPUParticleSystem
  57468. * @param gradient defines the gradient to remove
  57469. * @returns the current particle system
  57470. */
  57471. removeEmitRateGradient(gradient: number): IParticleSystem;
  57472. /**
  57473. * Not supported by GPUParticleSystem
  57474. * @param gradient defines the gradient to use (between 0 and 1)
  57475. * @param factor defines the start size value to affect to the specified gradient
  57476. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57477. * @returns the current particle system
  57478. */
  57479. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57480. /**
  57481. * Not supported by GPUParticleSystem
  57482. * @param gradient defines the gradient to remove
  57483. * @returns the current particle system
  57484. */
  57485. removeStartSizeGradient(gradient: number): IParticleSystem;
  57486. /**
  57487. * Not supported by GPUParticleSystem
  57488. * @param gradient defines the gradient to use (between 0 and 1)
  57489. * @param min defines the color remap minimal range
  57490. * @param max defines the color remap maximal range
  57491. * @returns the current particle system
  57492. */
  57493. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57494. /**
  57495. * Not supported by GPUParticleSystem
  57496. * @param gradient defines the gradient to remove
  57497. * @returns the current particle system
  57498. */
  57499. removeColorRemapGradient(): IParticleSystem;
  57500. /**
  57501. * Not supported by GPUParticleSystem
  57502. * @param gradient defines the gradient to use (between 0 and 1)
  57503. * @param min defines the alpha remap minimal range
  57504. * @param max defines the alpha remap maximal range
  57505. * @returns the current particle system
  57506. */
  57507. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57508. /**
  57509. * Not supported by GPUParticleSystem
  57510. * @param gradient defines the gradient to remove
  57511. * @returns the current particle system
  57512. */
  57513. removeAlphaRemapGradient(): IParticleSystem;
  57514. /**
  57515. * Not supported by GPUParticleSystem
  57516. * @param gradient defines the gradient to use (between 0 and 1)
  57517. * @param color defines the color to affect to the specified gradient
  57518. * @returns the current particle system
  57519. */
  57520. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  57521. /**
  57522. * Not supported by GPUParticleSystem
  57523. * @param gradient defines the gradient to remove
  57524. * @returns the current particle system
  57525. */
  57526. removeRampGradient(): IParticleSystem;
  57527. /**
  57528. * Not supported by GPUParticleSystem
  57529. * @returns the list of ramp gradients
  57530. */
  57531. getRampGradients(): Nullable<Array<Color3Gradient>>;
  57532. /**
  57533. * Not supported by GPUParticleSystem
  57534. * Gets or sets a boolean indicating that ramp gradients must be used
  57535. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  57536. */
  57537. useRampGradients: boolean;
  57538. /**
  57539. * Not supported by GPUParticleSystem
  57540. * @param gradient defines the gradient to use (between 0 and 1)
  57541. * @param factor defines the life time factor to affect to the specified gradient
  57542. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57543. * @returns the current particle system
  57544. */
  57545. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57546. /**
  57547. * Not supported by GPUParticleSystem
  57548. * @param gradient defines the gradient to remove
  57549. * @returns the current particle system
  57550. */
  57551. removeLifeTimeGradient(gradient: number): IParticleSystem;
  57552. /**
  57553. * Instantiates a GPU particle system.
  57554. * 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.
  57555. * @param name The name of the particle system
  57556. * @param options The options used to create the system
  57557. * @param scene The scene the particle system belongs to
  57558. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  57559. */
  57560. constructor(name: string, options: Partial<{
  57561. capacity: number;
  57562. randomTextureSize: number;
  57563. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  57564. protected _reset(): void;
  57565. private _createUpdateVAO;
  57566. private _createRenderVAO;
  57567. private _initialize;
  57568. /** @hidden */
  57569. _recreateUpdateEffect(): void;
  57570. /** @hidden */
  57571. _recreateRenderEffect(): void;
  57572. /**
  57573. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  57574. * @param preWarm defines if we are in the pre-warmimg phase
  57575. */
  57576. animate(preWarm?: boolean): void;
  57577. private _createFactorGradientTexture;
  57578. private _createSizeGradientTexture;
  57579. private _createAngularSpeedGradientTexture;
  57580. private _createVelocityGradientTexture;
  57581. private _createLimitVelocityGradientTexture;
  57582. private _createDragGradientTexture;
  57583. private _createColorGradientTexture;
  57584. /**
  57585. * Renders the particle system in its current state
  57586. * @param preWarm defines if the system should only update the particles but not render them
  57587. * @returns the current number of particles
  57588. */
  57589. render(preWarm?: boolean): number;
  57590. /**
  57591. * Rebuilds the particle system
  57592. */
  57593. rebuild(): void;
  57594. private _releaseBuffers;
  57595. private _releaseVAOs;
  57596. /**
  57597. * Disposes the particle system and free the associated resources
  57598. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  57599. */
  57600. dispose(disposeTexture?: boolean): void;
  57601. /**
  57602. * Clones the particle system.
  57603. * @param name The name of the cloned object
  57604. * @param newEmitter The new emitter to use
  57605. * @returns the cloned particle system
  57606. */
  57607. clone(name: string, newEmitter: any): GPUParticleSystem;
  57608. /**
  57609. * Serializes the particle system to a JSON object.
  57610. * @returns the JSON object
  57611. */
  57612. serialize(): any;
  57613. /**
  57614. * Parses a JSON object to create a GPU particle system.
  57615. * @param parsedParticleSystem The JSON object to parse
  57616. * @param scene The scene to create the particle system in
  57617. * @param rootUrl The root url to use to load external dependencies like texture
  57618. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  57619. * @returns the parsed GPU particle system
  57620. */
  57621. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  57622. }
  57623. }
  57624. declare module "babylonjs/Particles/particleSystemSet" {
  57625. import { Nullable } from "babylonjs/types";
  57626. import { Color3 } from "babylonjs/Maths/math.color";
  57627. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57629. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57630. import { Scene, IDisposable } from "babylonjs/scene";
  57631. /**
  57632. * Represents a set of particle systems working together to create a specific effect
  57633. */
  57634. export class ParticleSystemSet implements IDisposable {
  57635. private _emitterCreationOptions;
  57636. private _emitterNode;
  57637. /**
  57638. * Gets the particle system list
  57639. */
  57640. systems: IParticleSystem[];
  57641. /**
  57642. * Gets the emitter node used with this set
  57643. */
  57644. readonly emitterNode: Nullable<TransformNode>;
  57645. /**
  57646. * Creates a new emitter mesh as a sphere
  57647. * @param options defines the options used to create the sphere
  57648. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  57649. * @param scene defines the hosting scene
  57650. */
  57651. setEmitterAsSphere(options: {
  57652. diameter: number;
  57653. segments: number;
  57654. color: Color3;
  57655. }, renderingGroupId: number, scene: Scene): void;
  57656. /**
  57657. * Starts all particle systems of the set
  57658. * @param emitter defines an optional mesh to use as emitter for the particle systems
  57659. */
  57660. start(emitter?: AbstractMesh): void;
  57661. /**
  57662. * Release all associated resources
  57663. */
  57664. dispose(): void;
  57665. /**
  57666. * Serialize the set into a JSON compatible object
  57667. * @returns a JSON compatible representation of the set
  57668. */
  57669. serialize(): any;
  57670. /**
  57671. * Parse a new ParticleSystemSet from a serialized source
  57672. * @param data defines a JSON compatible representation of the set
  57673. * @param scene defines the hosting scene
  57674. * @param gpu defines if we want GPU particles or CPU particles
  57675. * @returns a new ParticleSystemSet
  57676. */
  57677. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  57678. }
  57679. }
  57680. declare module "babylonjs/Particles/particleHelper" {
  57681. import { Nullable } from "babylonjs/types";
  57682. import { Scene } from "babylonjs/scene";
  57683. import { Vector3 } from "babylonjs/Maths/math.vector";
  57684. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57685. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57686. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  57687. /**
  57688. * This class is made for on one-liner static method to help creating particle system set.
  57689. */
  57690. export class ParticleHelper {
  57691. /**
  57692. * Gets or sets base Assets URL
  57693. */
  57694. static BaseAssetsUrl: string;
  57695. /**
  57696. * Create a default particle system that you can tweak
  57697. * @param emitter defines the emitter to use
  57698. * @param capacity defines the system capacity (default is 500 particles)
  57699. * @param scene defines the hosting scene
  57700. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  57701. * @returns the new Particle system
  57702. */
  57703. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  57704. /**
  57705. * This is the main static method (one-liner) of this helper to create different particle systems
  57706. * @param type This string represents the type to the particle system to create
  57707. * @param scene The scene where the particle system should live
  57708. * @param gpu If the system will use gpu
  57709. * @returns the ParticleSystemSet created
  57710. */
  57711. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  57712. /**
  57713. * Static function used to export a particle system to a ParticleSystemSet variable.
  57714. * Please note that the emitter shape is not exported
  57715. * @param systems defines the particle systems to export
  57716. * @returns the created particle system set
  57717. */
  57718. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  57719. }
  57720. }
  57721. declare module "babylonjs/Particles/particleSystemComponent" {
  57722. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57723. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  57724. import "babylonjs/Shaders/particles.vertex";
  57725. module "babylonjs/Engines/engine" {
  57726. interface Engine {
  57727. /**
  57728. * Create an effect to use with particle systems.
  57729. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  57730. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  57731. * @param uniformsNames defines a list of attribute names
  57732. * @param samplers defines an array of string used to represent textures
  57733. * @param defines defines the string containing the defines to use to compile the shaders
  57734. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  57735. * @param onCompiled defines a function to call when the effect creation is successful
  57736. * @param onError defines a function to call when the effect creation has failed
  57737. * @returns the new Effect
  57738. */
  57739. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  57740. }
  57741. }
  57742. module "babylonjs/Meshes/mesh" {
  57743. interface Mesh {
  57744. /**
  57745. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  57746. * @returns an array of IParticleSystem
  57747. */
  57748. getEmittedParticleSystems(): IParticleSystem[];
  57749. /**
  57750. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  57751. * @returns an array of IParticleSystem
  57752. */
  57753. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  57754. }
  57755. }
  57756. /**
  57757. * @hidden
  57758. */
  57759. export var _IDoNeedToBeInTheBuild: number;
  57760. }
  57761. declare module "babylonjs/Particles/index" {
  57762. export * from "babylonjs/Particles/baseParticleSystem";
  57763. export * from "babylonjs/Particles/EmitterTypes/index";
  57764. export * from "babylonjs/Particles/gpuParticleSystem";
  57765. export * from "babylonjs/Particles/IParticleSystem";
  57766. export * from "babylonjs/Particles/particle";
  57767. export * from "babylonjs/Particles/particleHelper";
  57768. export * from "babylonjs/Particles/particleSystem";
  57769. export * from "babylonjs/Particles/particleSystemComponent";
  57770. export * from "babylonjs/Particles/particleSystemSet";
  57771. export * from "babylonjs/Particles/solidParticle";
  57772. export * from "babylonjs/Particles/solidParticleSystem";
  57773. export * from "babylonjs/Particles/subEmitter";
  57774. }
  57775. declare module "babylonjs/Physics/physicsEngineComponent" {
  57776. import { Nullable } from "babylonjs/types";
  57777. import { Observable, Observer } from "babylonjs/Misc/observable";
  57778. import { Vector3 } from "babylonjs/Maths/math.vector";
  57779. import { Mesh } from "babylonjs/Meshes/mesh";
  57780. import { ISceneComponent } from "babylonjs/sceneComponent";
  57781. import { Scene } from "babylonjs/scene";
  57782. import { Node } from "babylonjs/node";
  57783. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57784. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57785. module "babylonjs/scene" {
  57786. interface Scene {
  57787. /** @hidden (Backing field) */
  57788. _physicsEngine: Nullable<IPhysicsEngine>;
  57789. /**
  57790. * Gets the current physics engine
  57791. * @returns a IPhysicsEngine or null if none attached
  57792. */
  57793. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  57794. /**
  57795. * Enables physics to the current scene
  57796. * @param gravity defines the scene's gravity for the physics engine
  57797. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  57798. * @return a boolean indicating if the physics engine was initialized
  57799. */
  57800. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  57801. /**
  57802. * Disables and disposes the physics engine associated with the scene
  57803. */
  57804. disablePhysicsEngine(): void;
  57805. /**
  57806. * Gets a boolean indicating if there is an active physics engine
  57807. * @returns a boolean indicating if there is an active physics engine
  57808. */
  57809. isPhysicsEnabled(): boolean;
  57810. /**
  57811. * Deletes a physics compound impostor
  57812. * @param compound defines the compound to delete
  57813. */
  57814. deleteCompoundImpostor(compound: any): void;
  57815. /**
  57816. * An event triggered when physic simulation is about to be run
  57817. */
  57818. onBeforePhysicsObservable: Observable<Scene>;
  57819. /**
  57820. * An event triggered when physic simulation has been done
  57821. */
  57822. onAfterPhysicsObservable: Observable<Scene>;
  57823. }
  57824. }
  57825. module "babylonjs/Meshes/abstractMesh" {
  57826. interface AbstractMesh {
  57827. /** @hidden */
  57828. _physicsImpostor: Nullable<PhysicsImpostor>;
  57829. /**
  57830. * Gets or sets impostor used for physic simulation
  57831. * @see http://doc.babylonjs.com/features/physics_engine
  57832. */
  57833. physicsImpostor: Nullable<PhysicsImpostor>;
  57834. /**
  57835. * Gets the current physics impostor
  57836. * @see http://doc.babylonjs.com/features/physics_engine
  57837. * @returns a physics impostor or null
  57838. */
  57839. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  57840. /** Apply a physic impulse to the mesh
  57841. * @param force defines the force to apply
  57842. * @param contactPoint defines where to apply the force
  57843. * @returns the current mesh
  57844. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57845. */
  57846. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  57847. /**
  57848. * Creates a physic joint between two meshes
  57849. * @param otherMesh defines the other mesh to use
  57850. * @param pivot1 defines the pivot to use on this mesh
  57851. * @param pivot2 defines the pivot to use on the other mesh
  57852. * @param options defines additional options (can be plugin dependent)
  57853. * @returns the current mesh
  57854. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  57855. */
  57856. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  57857. /** @hidden */
  57858. _disposePhysicsObserver: Nullable<Observer<Node>>;
  57859. }
  57860. }
  57861. /**
  57862. * Defines the physics engine scene component responsible to manage a physics engine
  57863. */
  57864. export class PhysicsEngineSceneComponent implements ISceneComponent {
  57865. /**
  57866. * The component name helpful to identify the component in the list of scene components.
  57867. */
  57868. readonly name: string;
  57869. /**
  57870. * The scene the component belongs to.
  57871. */
  57872. scene: Scene;
  57873. /**
  57874. * Creates a new instance of the component for the given scene
  57875. * @param scene Defines the scene to register the component in
  57876. */
  57877. constructor(scene: Scene);
  57878. /**
  57879. * Registers the component in a given scene
  57880. */
  57881. register(): void;
  57882. /**
  57883. * Rebuilds the elements related to this component in case of
  57884. * context lost for instance.
  57885. */
  57886. rebuild(): void;
  57887. /**
  57888. * Disposes the component and the associated ressources
  57889. */
  57890. dispose(): void;
  57891. }
  57892. }
  57893. declare module "babylonjs/Physics/physicsHelper" {
  57894. import { Nullable } from "babylonjs/types";
  57895. import { Vector3 } from "babylonjs/Maths/math.vector";
  57896. import { Mesh } from "babylonjs/Meshes/mesh";
  57897. import { Scene } from "babylonjs/scene";
  57898. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57899. /**
  57900. * A helper for physics simulations
  57901. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57902. */
  57903. export class PhysicsHelper {
  57904. private _scene;
  57905. private _physicsEngine;
  57906. /**
  57907. * Initializes the Physics helper
  57908. * @param scene Babylon.js scene
  57909. */
  57910. constructor(scene: Scene);
  57911. /**
  57912. * Applies a radial explosion impulse
  57913. * @param origin the origin of the explosion
  57914. * @param radiusOrEventOptions the radius or the options of radial explosion
  57915. * @param strength the explosion strength
  57916. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57917. * @returns A physics radial explosion event, or null
  57918. */
  57919. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57920. /**
  57921. * Applies a radial explosion force
  57922. * @param origin the origin of the explosion
  57923. * @param radiusOrEventOptions the radius or the options of radial explosion
  57924. * @param strength the explosion strength
  57925. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57926. * @returns A physics radial explosion event, or null
  57927. */
  57928. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57929. /**
  57930. * Creates a gravitational field
  57931. * @param origin the origin of the explosion
  57932. * @param radiusOrEventOptions the radius or the options of radial explosion
  57933. * @param strength the explosion strength
  57934. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57935. * @returns A physics gravitational field event, or null
  57936. */
  57937. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  57938. /**
  57939. * Creates a physics updraft event
  57940. * @param origin the origin of the updraft
  57941. * @param radiusOrEventOptions the radius or the options of the updraft
  57942. * @param strength the strength of the updraft
  57943. * @param height the height of the updraft
  57944. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  57945. * @returns A physics updraft event, or null
  57946. */
  57947. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  57948. /**
  57949. * Creates a physics vortex event
  57950. * @param origin the of the vortex
  57951. * @param radiusOrEventOptions the radius or the options of the vortex
  57952. * @param strength the strength of the vortex
  57953. * @param height the height of the vortex
  57954. * @returns a Physics vortex event, or null
  57955. * A physics vortex event or null
  57956. */
  57957. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  57958. }
  57959. /**
  57960. * Represents a physics radial explosion event
  57961. */
  57962. class PhysicsRadialExplosionEvent {
  57963. private _scene;
  57964. private _options;
  57965. private _sphere;
  57966. private _dataFetched;
  57967. /**
  57968. * Initializes a radial explosioin event
  57969. * @param _scene BabylonJS scene
  57970. * @param _options The options for the vortex event
  57971. */
  57972. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  57973. /**
  57974. * Returns the data related to the radial explosion event (sphere).
  57975. * @returns The radial explosion event data
  57976. */
  57977. getData(): PhysicsRadialExplosionEventData;
  57978. /**
  57979. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  57980. * @param impostor A physics imposter
  57981. * @param origin the origin of the explosion
  57982. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  57983. */
  57984. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  57985. /**
  57986. * Triggers affecterd impostors callbacks
  57987. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  57988. */
  57989. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  57990. /**
  57991. * Disposes the sphere.
  57992. * @param force Specifies if the sphere should be disposed by force
  57993. */
  57994. dispose(force?: boolean): void;
  57995. /*** Helpers ***/
  57996. private _prepareSphere;
  57997. private _intersectsWithSphere;
  57998. }
  57999. /**
  58000. * Represents a gravitational field event
  58001. */
  58002. class PhysicsGravitationalFieldEvent {
  58003. private _physicsHelper;
  58004. private _scene;
  58005. private _origin;
  58006. private _options;
  58007. private _tickCallback;
  58008. private _sphere;
  58009. private _dataFetched;
  58010. /**
  58011. * Initializes the physics gravitational field event
  58012. * @param _physicsHelper A physics helper
  58013. * @param _scene BabylonJS scene
  58014. * @param _origin The origin position of the gravitational field event
  58015. * @param _options The options for the vortex event
  58016. */
  58017. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  58018. /**
  58019. * Returns the data related to the gravitational field event (sphere).
  58020. * @returns A gravitational field event
  58021. */
  58022. getData(): PhysicsGravitationalFieldEventData;
  58023. /**
  58024. * Enables the gravitational field.
  58025. */
  58026. enable(): void;
  58027. /**
  58028. * Disables the gravitational field.
  58029. */
  58030. disable(): void;
  58031. /**
  58032. * Disposes the sphere.
  58033. * @param force The force to dispose from the gravitational field event
  58034. */
  58035. dispose(force?: boolean): void;
  58036. private _tick;
  58037. }
  58038. /**
  58039. * Represents a physics updraft event
  58040. */
  58041. class PhysicsUpdraftEvent {
  58042. private _scene;
  58043. private _origin;
  58044. private _options;
  58045. private _physicsEngine;
  58046. private _originTop;
  58047. private _originDirection;
  58048. private _tickCallback;
  58049. private _cylinder;
  58050. private _cylinderPosition;
  58051. private _dataFetched;
  58052. /**
  58053. * Initializes the physics updraft event
  58054. * @param _scene BabylonJS scene
  58055. * @param _origin The origin position of the updraft
  58056. * @param _options The options for the updraft event
  58057. */
  58058. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  58059. /**
  58060. * Returns the data related to the updraft event (cylinder).
  58061. * @returns A physics updraft event
  58062. */
  58063. getData(): PhysicsUpdraftEventData;
  58064. /**
  58065. * Enables the updraft.
  58066. */
  58067. enable(): void;
  58068. /**
  58069. * Disables the updraft.
  58070. */
  58071. disable(): void;
  58072. /**
  58073. * Disposes the cylinder.
  58074. * @param force Specifies if the updraft should be disposed by force
  58075. */
  58076. dispose(force?: boolean): void;
  58077. private getImpostorHitData;
  58078. private _tick;
  58079. /*** Helpers ***/
  58080. private _prepareCylinder;
  58081. private _intersectsWithCylinder;
  58082. }
  58083. /**
  58084. * Represents a physics vortex event
  58085. */
  58086. class PhysicsVortexEvent {
  58087. private _scene;
  58088. private _origin;
  58089. private _options;
  58090. private _physicsEngine;
  58091. private _originTop;
  58092. private _tickCallback;
  58093. private _cylinder;
  58094. private _cylinderPosition;
  58095. private _dataFetched;
  58096. /**
  58097. * Initializes the physics vortex event
  58098. * @param _scene The BabylonJS scene
  58099. * @param _origin The origin position of the vortex
  58100. * @param _options The options for the vortex event
  58101. */
  58102. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  58103. /**
  58104. * Returns the data related to the vortex event (cylinder).
  58105. * @returns The physics vortex event data
  58106. */
  58107. getData(): PhysicsVortexEventData;
  58108. /**
  58109. * Enables the vortex.
  58110. */
  58111. enable(): void;
  58112. /**
  58113. * Disables the cortex.
  58114. */
  58115. disable(): void;
  58116. /**
  58117. * Disposes the sphere.
  58118. * @param force
  58119. */
  58120. dispose(force?: boolean): void;
  58121. private getImpostorHitData;
  58122. private _tick;
  58123. /*** Helpers ***/
  58124. private _prepareCylinder;
  58125. private _intersectsWithCylinder;
  58126. }
  58127. /**
  58128. * Options fot the radial explosion event
  58129. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58130. */
  58131. export class PhysicsRadialExplosionEventOptions {
  58132. /**
  58133. * The radius of the sphere for the radial explosion.
  58134. */
  58135. radius: number;
  58136. /**
  58137. * The strenth of the explosion.
  58138. */
  58139. strength: number;
  58140. /**
  58141. * The strenght of the force in correspondence to the distance of the affected object
  58142. */
  58143. falloff: PhysicsRadialImpulseFalloff;
  58144. /**
  58145. * Sphere options for the radial explosion.
  58146. */
  58147. sphere: {
  58148. segments: number;
  58149. diameter: number;
  58150. };
  58151. /**
  58152. * Sphere options for the radial explosion.
  58153. */
  58154. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  58155. }
  58156. /**
  58157. * Options fot the updraft event
  58158. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58159. */
  58160. export class PhysicsUpdraftEventOptions {
  58161. /**
  58162. * The radius of the cylinder for the vortex
  58163. */
  58164. radius: number;
  58165. /**
  58166. * The strenth of the updraft.
  58167. */
  58168. strength: number;
  58169. /**
  58170. * The height of the cylinder for the updraft.
  58171. */
  58172. height: number;
  58173. /**
  58174. * The mode for the the updraft.
  58175. */
  58176. updraftMode: PhysicsUpdraftMode;
  58177. }
  58178. /**
  58179. * Options fot the vortex event
  58180. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58181. */
  58182. export class PhysicsVortexEventOptions {
  58183. /**
  58184. * The radius of the cylinder for the vortex
  58185. */
  58186. radius: number;
  58187. /**
  58188. * The strenth of the vortex.
  58189. */
  58190. strength: number;
  58191. /**
  58192. * The height of the cylinder for the vortex.
  58193. */
  58194. height: number;
  58195. /**
  58196. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  58197. */
  58198. centripetalForceThreshold: number;
  58199. /**
  58200. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  58201. */
  58202. centripetalForceMultiplier: number;
  58203. /**
  58204. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  58205. */
  58206. centrifugalForceMultiplier: number;
  58207. /**
  58208. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  58209. */
  58210. updraftForceMultiplier: number;
  58211. }
  58212. /**
  58213. * The strenght of the force in correspondence to the distance of the affected object
  58214. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58215. */
  58216. export enum PhysicsRadialImpulseFalloff {
  58217. /** Defines that impulse is constant in strength across it's whole radius */
  58218. Constant = 0,
  58219. /** Defines that impulse gets weaker if it's further from the origin */
  58220. Linear = 1
  58221. }
  58222. /**
  58223. * The strength of the force in correspondence to the distance of the affected object
  58224. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58225. */
  58226. export enum PhysicsUpdraftMode {
  58227. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  58228. Center = 0,
  58229. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  58230. Perpendicular = 1
  58231. }
  58232. /**
  58233. * Interface for a physics hit data
  58234. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58235. */
  58236. export interface PhysicsHitData {
  58237. /**
  58238. * The force applied at the contact point
  58239. */
  58240. force: Vector3;
  58241. /**
  58242. * The contact point
  58243. */
  58244. contactPoint: Vector3;
  58245. /**
  58246. * The distance from the origin to the contact point
  58247. */
  58248. distanceFromOrigin: number;
  58249. }
  58250. /**
  58251. * Interface for radial explosion event data
  58252. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58253. */
  58254. export interface PhysicsRadialExplosionEventData {
  58255. /**
  58256. * A sphere used for the radial explosion event
  58257. */
  58258. sphere: Mesh;
  58259. }
  58260. /**
  58261. * Interface for gravitational field event data
  58262. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58263. */
  58264. export interface PhysicsGravitationalFieldEventData {
  58265. /**
  58266. * A sphere mesh used for the gravitational field event
  58267. */
  58268. sphere: Mesh;
  58269. }
  58270. /**
  58271. * Interface for updraft event data
  58272. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58273. */
  58274. export interface PhysicsUpdraftEventData {
  58275. /**
  58276. * A cylinder used for the updraft event
  58277. */
  58278. cylinder: Mesh;
  58279. }
  58280. /**
  58281. * Interface for vortex event data
  58282. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58283. */
  58284. export interface PhysicsVortexEventData {
  58285. /**
  58286. * A cylinder used for the vortex event
  58287. */
  58288. cylinder: Mesh;
  58289. }
  58290. /**
  58291. * Interface for an affected physics impostor
  58292. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58293. */
  58294. export interface PhysicsAffectedImpostorWithData {
  58295. /**
  58296. * The impostor affected by the effect
  58297. */
  58298. impostor: PhysicsImpostor;
  58299. /**
  58300. * The data about the hit/horce from the explosion
  58301. */
  58302. hitData: PhysicsHitData;
  58303. }
  58304. }
  58305. declare module "babylonjs/Physics/Plugins/index" {
  58306. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  58307. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  58308. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  58309. }
  58310. declare module "babylonjs/Physics/index" {
  58311. export * from "babylonjs/Physics/IPhysicsEngine";
  58312. export * from "babylonjs/Physics/physicsEngine";
  58313. export * from "babylonjs/Physics/physicsEngineComponent";
  58314. export * from "babylonjs/Physics/physicsHelper";
  58315. export * from "babylonjs/Physics/physicsImpostor";
  58316. export * from "babylonjs/Physics/physicsJoint";
  58317. export * from "babylonjs/Physics/Plugins/index";
  58318. }
  58319. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  58320. /** @hidden */
  58321. export var blackAndWhitePixelShader: {
  58322. name: string;
  58323. shader: string;
  58324. };
  58325. }
  58326. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  58327. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58328. import { Camera } from "babylonjs/Cameras/camera";
  58329. import { Engine } from "babylonjs/Engines/engine";
  58330. import "babylonjs/Shaders/blackAndWhite.fragment";
  58331. /**
  58332. * Post process used to render in black and white
  58333. */
  58334. export class BlackAndWhitePostProcess extends PostProcess {
  58335. /**
  58336. * Linear about to convert he result to black and white (default: 1)
  58337. */
  58338. degree: number;
  58339. /**
  58340. * Creates a black and white post process
  58341. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  58342. * @param name The name of the effect.
  58343. * @param options The required width/height ratio to downsize to before computing the render pass.
  58344. * @param camera The camera to apply the render pass to.
  58345. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58346. * @param engine The engine which the post process will be applied. (default: current engine)
  58347. * @param reusable If the post process can be reused on the same frame. (default: false)
  58348. */
  58349. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58350. }
  58351. }
  58352. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  58353. import { Nullable } from "babylonjs/types";
  58354. import { Camera } from "babylonjs/Cameras/camera";
  58355. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  58356. import { Engine } from "babylonjs/Engines/engine";
  58357. /**
  58358. * This represents a set of one or more post processes in Babylon.
  58359. * A post process can be used to apply a shader to a texture after it is rendered.
  58360. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58361. */
  58362. export class PostProcessRenderEffect {
  58363. private _postProcesses;
  58364. private _getPostProcesses;
  58365. private _singleInstance;
  58366. private _cameras;
  58367. private _indicesForCamera;
  58368. /**
  58369. * Name of the effect
  58370. * @hidden
  58371. */
  58372. _name: string;
  58373. /**
  58374. * Instantiates a post process render effect.
  58375. * A post process can be used to apply a shader to a texture after it is rendered.
  58376. * @param engine The engine the effect is tied to
  58377. * @param name The name of the effect
  58378. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  58379. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  58380. */
  58381. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  58382. /**
  58383. * Checks if all the post processes in the effect are supported.
  58384. */
  58385. readonly isSupported: boolean;
  58386. /**
  58387. * Updates the current state of the effect
  58388. * @hidden
  58389. */
  58390. _update(): void;
  58391. /**
  58392. * Attaches the effect on cameras
  58393. * @param cameras The camera to attach to.
  58394. * @hidden
  58395. */
  58396. _attachCameras(cameras: Camera): void;
  58397. /**
  58398. * Attaches the effect on cameras
  58399. * @param cameras The camera to attach to.
  58400. * @hidden
  58401. */
  58402. _attachCameras(cameras: Camera[]): void;
  58403. /**
  58404. * Detaches the effect on cameras
  58405. * @param cameras The camera to detatch from.
  58406. * @hidden
  58407. */
  58408. _detachCameras(cameras: Camera): void;
  58409. /**
  58410. * Detatches the effect on cameras
  58411. * @param cameras The camera to detatch from.
  58412. * @hidden
  58413. */
  58414. _detachCameras(cameras: Camera[]): void;
  58415. /**
  58416. * Enables the effect on given cameras
  58417. * @param cameras The camera to enable.
  58418. * @hidden
  58419. */
  58420. _enable(cameras: Camera): void;
  58421. /**
  58422. * Enables the effect on given cameras
  58423. * @param cameras The camera to enable.
  58424. * @hidden
  58425. */
  58426. _enable(cameras: Nullable<Camera[]>): void;
  58427. /**
  58428. * Disables the effect on the given cameras
  58429. * @param cameras The camera to disable.
  58430. * @hidden
  58431. */
  58432. _disable(cameras: Camera): void;
  58433. /**
  58434. * Disables the effect on the given cameras
  58435. * @param cameras The camera to disable.
  58436. * @hidden
  58437. */
  58438. _disable(cameras: Nullable<Camera[]>): void;
  58439. /**
  58440. * Gets a list of the post processes contained in the effect.
  58441. * @param camera The camera to get the post processes on.
  58442. * @returns The list of the post processes in the effect.
  58443. */
  58444. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  58445. }
  58446. }
  58447. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  58448. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58449. /** @hidden */
  58450. export var extractHighlightsPixelShader: {
  58451. name: string;
  58452. shader: string;
  58453. };
  58454. }
  58455. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  58456. import { Nullable } from "babylonjs/types";
  58457. import { Camera } from "babylonjs/Cameras/camera";
  58458. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58459. import { Engine } from "babylonjs/Engines/engine";
  58460. import "babylonjs/Shaders/extractHighlights.fragment";
  58461. /**
  58462. * 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.
  58463. */
  58464. export class ExtractHighlightsPostProcess extends PostProcess {
  58465. /**
  58466. * The luminance threshold, pixels below this value will be set to black.
  58467. */
  58468. threshold: number;
  58469. /** @hidden */
  58470. _exposure: number;
  58471. /**
  58472. * Post process which has the input texture to be used when performing highlight extraction
  58473. * @hidden
  58474. */
  58475. _inputPostProcess: Nullable<PostProcess>;
  58476. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58477. }
  58478. }
  58479. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  58480. /** @hidden */
  58481. export var bloomMergePixelShader: {
  58482. name: string;
  58483. shader: string;
  58484. };
  58485. }
  58486. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  58487. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58488. import { Nullable } from "babylonjs/types";
  58489. import { Engine } from "babylonjs/Engines/engine";
  58490. import { Camera } from "babylonjs/Cameras/camera";
  58491. import "babylonjs/Shaders/bloomMerge.fragment";
  58492. /**
  58493. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58494. */
  58495. export class BloomMergePostProcess extends PostProcess {
  58496. /** Weight of the bloom to be added to the original input. */
  58497. weight: number;
  58498. /**
  58499. * Creates a new instance of @see BloomMergePostProcess
  58500. * @param name The name of the effect.
  58501. * @param originalFromInput Post process which's input will be used for the merge.
  58502. * @param blurred Blurred highlights post process which's output will be used.
  58503. * @param weight Weight of the bloom to be added to the original input.
  58504. * @param options The required width/height ratio to downsize to before computing the render pass.
  58505. * @param camera The camera to apply the render pass to.
  58506. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58507. * @param engine The engine which the post process will be applied. (default: current engine)
  58508. * @param reusable If the post process can be reused on the same frame. (default: false)
  58509. * @param textureType Type of textures used when performing the post process. (default: 0)
  58510. * @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)
  58511. */
  58512. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  58513. /** Weight of the bloom to be added to the original input. */
  58514. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58515. }
  58516. }
  58517. declare module "babylonjs/PostProcesses/bloomEffect" {
  58518. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  58519. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  58520. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  58521. import { Camera } from "babylonjs/Cameras/camera";
  58522. import { Scene } from "babylonjs/scene";
  58523. /**
  58524. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  58525. */
  58526. export class BloomEffect extends PostProcessRenderEffect {
  58527. private bloomScale;
  58528. /**
  58529. * @hidden Internal
  58530. */
  58531. _effects: Array<PostProcess>;
  58532. /**
  58533. * @hidden Internal
  58534. */
  58535. _downscale: ExtractHighlightsPostProcess;
  58536. private _blurX;
  58537. private _blurY;
  58538. private _merge;
  58539. /**
  58540. * The luminance threshold to find bright areas of the image to bloom.
  58541. */
  58542. threshold: number;
  58543. /**
  58544. * The strength of the bloom.
  58545. */
  58546. weight: number;
  58547. /**
  58548. * Specifies the size of the bloom blur kernel, relative to the final output size
  58549. */
  58550. kernel: number;
  58551. /**
  58552. * Creates a new instance of @see BloomEffect
  58553. * @param scene The scene the effect belongs to.
  58554. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  58555. * @param bloomKernel The size of the kernel to be used when applying the blur.
  58556. * @param bloomWeight The the strength of bloom.
  58557. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58558. * @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)
  58559. */
  58560. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  58561. /**
  58562. * Disposes each of the internal effects for a given camera.
  58563. * @param camera The camera to dispose the effect on.
  58564. */
  58565. disposeEffects(camera: Camera): void;
  58566. /**
  58567. * @hidden Internal
  58568. */
  58569. _updateEffects(): void;
  58570. /**
  58571. * Internal
  58572. * @returns if all the contained post processes are ready.
  58573. * @hidden
  58574. */
  58575. _isReady(): boolean;
  58576. }
  58577. }
  58578. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  58579. /** @hidden */
  58580. export var chromaticAberrationPixelShader: {
  58581. name: string;
  58582. shader: string;
  58583. };
  58584. }
  58585. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  58586. import { Vector2 } from "babylonjs/Maths/math.vector";
  58587. import { Nullable } from "babylonjs/types";
  58588. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58589. import { Camera } from "babylonjs/Cameras/camera";
  58590. import { Engine } from "babylonjs/Engines/engine";
  58591. import "babylonjs/Shaders/chromaticAberration.fragment";
  58592. /**
  58593. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  58594. */
  58595. export class ChromaticAberrationPostProcess extends PostProcess {
  58596. /**
  58597. * The amount of seperation of rgb channels (default: 30)
  58598. */
  58599. aberrationAmount: number;
  58600. /**
  58601. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  58602. */
  58603. radialIntensity: number;
  58604. /**
  58605. * 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))
  58606. */
  58607. direction: Vector2;
  58608. /**
  58609. * 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))
  58610. */
  58611. centerPosition: Vector2;
  58612. /**
  58613. * Creates a new instance ChromaticAberrationPostProcess
  58614. * @param name The name of the effect.
  58615. * @param screenWidth The width of the screen to apply the effect on.
  58616. * @param screenHeight The height of the screen to apply the effect on.
  58617. * @param options The required width/height ratio to downsize to before computing the render pass.
  58618. * @param camera The camera to apply the render pass to.
  58619. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58620. * @param engine The engine which the post process will be applied. (default: current engine)
  58621. * @param reusable If the post process can be reused on the same frame. (default: false)
  58622. * @param textureType Type of textures used when performing the post process. (default: 0)
  58623. * @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)
  58624. */
  58625. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58626. }
  58627. }
  58628. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  58629. /** @hidden */
  58630. export var circleOfConfusionPixelShader: {
  58631. name: string;
  58632. shader: string;
  58633. };
  58634. }
  58635. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  58636. import { Nullable } from "babylonjs/types";
  58637. import { Engine } from "babylonjs/Engines/engine";
  58638. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58639. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58640. import { Camera } from "babylonjs/Cameras/camera";
  58641. import "babylonjs/Shaders/circleOfConfusion.fragment";
  58642. /**
  58643. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  58644. */
  58645. export class CircleOfConfusionPostProcess extends PostProcess {
  58646. /**
  58647. * 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.
  58648. */
  58649. lensSize: number;
  58650. /**
  58651. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58652. */
  58653. fStop: number;
  58654. /**
  58655. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58656. */
  58657. focusDistance: number;
  58658. /**
  58659. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  58660. */
  58661. focalLength: number;
  58662. private _depthTexture;
  58663. /**
  58664. * Creates a new instance CircleOfConfusionPostProcess
  58665. * @param name The name of the effect.
  58666. * @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.
  58667. * @param options The required width/height ratio to downsize to before computing the render pass.
  58668. * @param camera The camera to apply the render pass to.
  58669. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58670. * @param engine The engine which the post process will be applied. (default: current engine)
  58671. * @param reusable If the post process can be reused on the same frame. (default: false)
  58672. * @param textureType Type of textures used when performing the post process. (default: 0)
  58673. * @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)
  58674. */
  58675. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58676. /**
  58677. * 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.
  58678. */
  58679. depthTexture: RenderTargetTexture;
  58680. }
  58681. }
  58682. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  58683. /** @hidden */
  58684. export var colorCorrectionPixelShader: {
  58685. name: string;
  58686. shader: string;
  58687. };
  58688. }
  58689. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  58690. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58691. import { Engine } from "babylonjs/Engines/engine";
  58692. import { Camera } from "babylonjs/Cameras/camera";
  58693. import "babylonjs/Shaders/colorCorrection.fragment";
  58694. /**
  58695. *
  58696. * This post-process allows the modification of rendered colors by using
  58697. * a 'look-up table' (LUT). This effect is also called Color Grading.
  58698. *
  58699. * The object needs to be provided an url to a texture containing the color
  58700. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  58701. * Use an image editing software to tweak the LUT to match your needs.
  58702. *
  58703. * For an example of a color LUT, see here:
  58704. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  58705. * For explanations on color grading, see here:
  58706. * @see http://udn.epicgames.com/Three/ColorGrading.html
  58707. *
  58708. */
  58709. export class ColorCorrectionPostProcess extends PostProcess {
  58710. private _colorTableTexture;
  58711. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58712. }
  58713. }
  58714. declare module "babylonjs/Shaders/convolution.fragment" {
  58715. /** @hidden */
  58716. export var convolutionPixelShader: {
  58717. name: string;
  58718. shader: string;
  58719. };
  58720. }
  58721. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  58722. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58723. import { Nullable } from "babylonjs/types";
  58724. import { Camera } from "babylonjs/Cameras/camera";
  58725. import { Engine } from "babylonjs/Engines/engine";
  58726. import "babylonjs/Shaders/convolution.fragment";
  58727. /**
  58728. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  58729. * input texture to perform effects such as edge detection or sharpening
  58730. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58731. */
  58732. export class ConvolutionPostProcess extends PostProcess {
  58733. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58734. kernel: number[];
  58735. /**
  58736. * Creates a new instance ConvolutionPostProcess
  58737. * @param name The name of the effect.
  58738. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  58739. * @param options The required width/height ratio to downsize to before computing the render pass.
  58740. * @param camera The camera to apply the render pass to.
  58741. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58742. * @param engine The engine which the post process will be applied. (default: current engine)
  58743. * @param reusable If the post process can be reused on the same frame. (default: false)
  58744. * @param textureType Type of textures used when performing the post process. (default: 0)
  58745. */
  58746. constructor(name: string,
  58747. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58748. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58749. /**
  58750. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58751. */
  58752. static EdgeDetect0Kernel: number[];
  58753. /**
  58754. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58755. */
  58756. static EdgeDetect1Kernel: number[];
  58757. /**
  58758. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58759. */
  58760. static EdgeDetect2Kernel: number[];
  58761. /**
  58762. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58763. */
  58764. static SharpenKernel: number[];
  58765. /**
  58766. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58767. */
  58768. static EmbossKernel: number[];
  58769. /**
  58770. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58771. */
  58772. static GaussianKernel: number[];
  58773. }
  58774. }
  58775. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  58776. import { Nullable } from "babylonjs/types";
  58777. import { Vector2 } from "babylonjs/Maths/math.vector";
  58778. import { Camera } from "babylonjs/Cameras/camera";
  58779. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58780. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  58781. import { Engine } from "babylonjs/Engines/engine";
  58782. import { Scene } from "babylonjs/scene";
  58783. /**
  58784. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  58785. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  58786. * based on samples that have a large difference in distance than the center pixel.
  58787. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  58788. */
  58789. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  58790. direction: Vector2;
  58791. /**
  58792. * Creates a new instance CircleOfConfusionPostProcess
  58793. * @param name The name of the effect.
  58794. * @param scene The scene the effect belongs to.
  58795. * @param direction The direction the blur should be applied.
  58796. * @param kernel The size of the kernel used to blur.
  58797. * @param options The required width/height ratio to downsize to before computing the render pass.
  58798. * @param camera The camera to apply the render pass to.
  58799. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  58800. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  58801. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58802. * @param engine The engine which the post process will be applied. (default: current engine)
  58803. * @param reusable If the post process can be reused on the same frame. (default: false)
  58804. * @param textureType Type of textures used when performing the post process. (default: 0)
  58805. * @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)
  58806. */
  58807. 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);
  58808. }
  58809. }
  58810. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  58811. /** @hidden */
  58812. export var depthOfFieldMergePixelShader: {
  58813. name: string;
  58814. shader: string;
  58815. };
  58816. }
  58817. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  58818. import { Nullable } from "babylonjs/types";
  58819. import { Camera } from "babylonjs/Cameras/camera";
  58820. import { Effect } from "babylonjs/Materials/effect";
  58821. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58822. import { Engine } from "babylonjs/Engines/engine";
  58823. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  58824. /**
  58825. * Options to be set when merging outputs from the default pipeline.
  58826. */
  58827. export class DepthOfFieldMergePostProcessOptions {
  58828. /**
  58829. * The original image to merge on top of
  58830. */
  58831. originalFromInput: PostProcess;
  58832. /**
  58833. * Parameters to perform the merge of the depth of field effect
  58834. */
  58835. depthOfField?: {
  58836. circleOfConfusion: PostProcess;
  58837. blurSteps: Array<PostProcess>;
  58838. };
  58839. /**
  58840. * Parameters to perform the merge of bloom effect
  58841. */
  58842. bloom?: {
  58843. blurred: PostProcess;
  58844. weight: number;
  58845. };
  58846. }
  58847. /**
  58848. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58849. */
  58850. export class DepthOfFieldMergePostProcess extends PostProcess {
  58851. private blurSteps;
  58852. /**
  58853. * Creates a new instance of DepthOfFieldMergePostProcess
  58854. * @param name The name of the effect.
  58855. * @param originalFromInput Post process which's input will be used for the merge.
  58856. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  58857. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  58858. * @param options The required width/height ratio to downsize to before computing the render pass.
  58859. * @param camera The camera to apply the render pass to.
  58860. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58861. * @param engine The engine which the post process will be applied. (default: current engine)
  58862. * @param reusable If the post process can be reused on the same frame. (default: false)
  58863. * @param textureType Type of textures used when performing the post process. (default: 0)
  58864. * @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)
  58865. */
  58866. 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);
  58867. /**
  58868. * Updates the effect with the current post process compile time values and recompiles the shader.
  58869. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  58870. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  58871. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  58872. * @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
  58873. * @param onCompiled Called when the shader has been compiled.
  58874. * @param onError Called if there is an error when compiling a shader.
  58875. */
  58876. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  58877. }
  58878. }
  58879. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  58880. import { Nullable } from "babylonjs/types";
  58881. import { Camera } from "babylonjs/Cameras/camera";
  58882. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58883. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  58884. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  58885. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  58886. import { Scene } from "babylonjs/scene";
  58887. /**
  58888. * Specifies the level of max blur that should be applied when using the depth of field effect
  58889. */
  58890. export enum DepthOfFieldEffectBlurLevel {
  58891. /**
  58892. * Subtle blur
  58893. */
  58894. Low = 0,
  58895. /**
  58896. * Medium blur
  58897. */
  58898. Medium = 1,
  58899. /**
  58900. * Large blur
  58901. */
  58902. High = 2
  58903. }
  58904. /**
  58905. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  58906. */
  58907. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  58908. private _circleOfConfusion;
  58909. /**
  58910. * @hidden Internal, blurs from high to low
  58911. */
  58912. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  58913. private _depthOfFieldBlurY;
  58914. private _dofMerge;
  58915. /**
  58916. * @hidden Internal post processes in depth of field effect
  58917. */
  58918. _effects: Array<PostProcess>;
  58919. /**
  58920. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  58921. */
  58922. focalLength: number;
  58923. /**
  58924. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58925. */
  58926. fStop: number;
  58927. /**
  58928. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58929. */
  58930. focusDistance: number;
  58931. /**
  58932. * 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.
  58933. */
  58934. lensSize: number;
  58935. /**
  58936. * Creates a new instance DepthOfFieldEffect
  58937. * @param scene The scene the effect belongs to.
  58938. * @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.
  58939. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58940. * @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)
  58941. */
  58942. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  58943. /**
  58944. * Get the current class name of the current effet
  58945. * @returns "DepthOfFieldEffect"
  58946. */
  58947. getClassName(): string;
  58948. /**
  58949. * 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.
  58950. */
  58951. depthTexture: RenderTargetTexture;
  58952. /**
  58953. * Disposes each of the internal effects for a given camera.
  58954. * @param camera The camera to dispose the effect on.
  58955. */
  58956. disposeEffects(camera: Camera): void;
  58957. /**
  58958. * @hidden Internal
  58959. */
  58960. _updateEffects(): void;
  58961. /**
  58962. * Internal
  58963. * @returns if all the contained post processes are ready.
  58964. * @hidden
  58965. */
  58966. _isReady(): boolean;
  58967. }
  58968. }
  58969. declare module "babylonjs/Shaders/displayPass.fragment" {
  58970. /** @hidden */
  58971. export var displayPassPixelShader: {
  58972. name: string;
  58973. shader: string;
  58974. };
  58975. }
  58976. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  58977. import { Nullable } from "babylonjs/types";
  58978. import { Camera } from "babylonjs/Cameras/camera";
  58979. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58980. import { Engine } from "babylonjs/Engines/engine";
  58981. import "babylonjs/Shaders/displayPass.fragment";
  58982. /**
  58983. * DisplayPassPostProcess which produces an output the same as it's input
  58984. */
  58985. export class DisplayPassPostProcess extends PostProcess {
  58986. /**
  58987. * Creates the DisplayPassPostProcess
  58988. * @param name The name of the effect.
  58989. * @param options The required width/height ratio to downsize to before computing the render pass.
  58990. * @param camera The camera to apply the render pass to.
  58991. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58992. * @param engine The engine which the post process will be applied. (default: current engine)
  58993. * @param reusable If the post process can be reused on the same frame. (default: false)
  58994. */
  58995. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58996. }
  58997. }
  58998. declare module "babylonjs/Shaders/filter.fragment" {
  58999. /** @hidden */
  59000. export var filterPixelShader: {
  59001. name: string;
  59002. shader: string;
  59003. };
  59004. }
  59005. declare module "babylonjs/PostProcesses/filterPostProcess" {
  59006. import { Nullable } from "babylonjs/types";
  59007. import { Matrix } from "babylonjs/Maths/math.vector";
  59008. import { Camera } from "babylonjs/Cameras/camera";
  59009. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59010. import { Engine } from "babylonjs/Engines/engine";
  59011. import "babylonjs/Shaders/filter.fragment";
  59012. /**
  59013. * Applies a kernel filter to the image
  59014. */
  59015. export class FilterPostProcess extends PostProcess {
  59016. /** The matrix to be applied to the image */
  59017. kernelMatrix: Matrix;
  59018. /**
  59019. *
  59020. * @param name The name of the effect.
  59021. * @param kernelMatrix The matrix to be applied to the image
  59022. * @param options The required width/height ratio to downsize to before computing the render pass.
  59023. * @param camera The camera to apply the render pass to.
  59024. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59025. * @param engine The engine which the post process will be applied. (default: current engine)
  59026. * @param reusable If the post process can be reused on the same frame. (default: false)
  59027. */
  59028. constructor(name: string,
  59029. /** The matrix to be applied to the image */
  59030. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59031. }
  59032. }
  59033. declare module "babylonjs/Shaders/fxaa.fragment" {
  59034. /** @hidden */
  59035. export var fxaaPixelShader: {
  59036. name: string;
  59037. shader: string;
  59038. };
  59039. }
  59040. declare module "babylonjs/Shaders/fxaa.vertex" {
  59041. /** @hidden */
  59042. export var fxaaVertexShader: {
  59043. name: string;
  59044. shader: string;
  59045. };
  59046. }
  59047. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  59048. import { Nullable } from "babylonjs/types";
  59049. import { Camera } from "babylonjs/Cameras/camera";
  59050. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59051. import { Engine } from "babylonjs/Engines/engine";
  59052. import "babylonjs/Shaders/fxaa.fragment";
  59053. import "babylonjs/Shaders/fxaa.vertex";
  59054. /**
  59055. * Fxaa post process
  59056. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  59057. */
  59058. export class FxaaPostProcess extends PostProcess {
  59059. /** @hidden */
  59060. texelWidth: number;
  59061. /** @hidden */
  59062. texelHeight: number;
  59063. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59064. private _getDefines;
  59065. }
  59066. }
  59067. declare module "babylonjs/Shaders/grain.fragment" {
  59068. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59069. /** @hidden */
  59070. export var grainPixelShader: {
  59071. name: string;
  59072. shader: string;
  59073. };
  59074. }
  59075. declare module "babylonjs/PostProcesses/grainPostProcess" {
  59076. import { Nullable } from "babylonjs/types";
  59077. import { Camera } from "babylonjs/Cameras/camera";
  59078. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59079. import { Engine } from "babylonjs/Engines/engine";
  59080. import "babylonjs/Shaders/grain.fragment";
  59081. /**
  59082. * The GrainPostProcess adds noise to the image at mid luminance levels
  59083. */
  59084. export class GrainPostProcess extends PostProcess {
  59085. /**
  59086. * The intensity of the grain added (default: 30)
  59087. */
  59088. intensity: number;
  59089. /**
  59090. * If the grain should be randomized on every frame
  59091. */
  59092. animated: boolean;
  59093. /**
  59094. * Creates a new instance of @see GrainPostProcess
  59095. * @param name The name of the effect.
  59096. * @param options The required width/height ratio to downsize to before computing the render pass.
  59097. * @param camera The camera to apply the render pass to.
  59098. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59099. * @param engine The engine which the post process will be applied. (default: current engine)
  59100. * @param reusable If the post process can be reused on the same frame. (default: false)
  59101. * @param textureType Type of textures used when performing the post process. (default: 0)
  59102. * @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)
  59103. */
  59104. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59105. }
  59106. }
  59107. declare module "babylonjs/Shaders/highlights.fragment" {
  59108. /** @hidden */
  59109. export var highlightsPixelShader: {
  59110. name: string;
  59111. shader: string;
  59112. };
  59113. }
  59114. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  59115. import { Nullable } from "babylonjs/types";
  59116. import { Camera } from "babylonjs/Cameras/camera";
  59117. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59118. import { Engine } from "babylonjs/Engines/engine";
  59119. import "babylonjs/Shaders/highlights.fragment";
  59120. /**
  59121. * Extracts highlights from the image
  59122. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  59123. */
  59124. export class HighlightsPostProcess extends PostProcess {
  59125. /**
  59126. * Extracts highlights from the image
  59127. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  59128. * @param name The name of the effect.
  59129. * @param options The required width/height ratio to downsize to before computing the render pass.
  59130. * @param camera The camera to apply the render pass to.
  59131. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59132. * @param engine The engine which the post process will be applied. (default: current engine)
  59133. * @param reusable If the post process can be reused on the same frame. (default: false)
  59134. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  59135. */
  59136. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59137. }
  59138. }
  59139. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  59140. /** @hidden */
  59141. export var mrtFragmentDeclaration: {
  59142. name: string;
  59143. shader: string;
  59144. };
  59145. }
  59146. declare module "babylonjs/Shaders/geometry.fragment" {
  59147. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  59148. /** @hidden */
  59149. export var geometryPixelShader: {
  59150. name: string;
  59151. shader: string;
  59152. };
  59153. }
  59154. declare module "babylonjs/Shaders/geometry.vertex" {
  59155. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59156. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59157. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59158. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59159. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  59160. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59161. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59162. /** @hidden */
  59163. export var geometryVertexShader: {
  59164. name: string;
  59165. shader: string;
  59166. };
  59167. }
  59168. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  59169. import { Matrix } from "babylonjs/Maths/math.vector";
  59170. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59171. import { Mesh } from "babylonjs/Meshes/mesh";
  59172. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  59173. import { Effect } from "babylonjs/Materials/effect";
  59174. import { Scene } from "babylonjs/scene";
  59175. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59176. import "babylonjs/Shaders/geometry.fragment";
  59177. import "babylonjs/Shaders/geometry.vertex";
  59178. /** @hidden */
  59179. interface ISavedTransformationMatrix {
  59180. world: Matrix;
  59181. viewProjection: Matrix;
  59182. }
  59183. /**
  59184. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  59185. */
  59186. export class GeometryBufferRenderer {
  59187. /**
  59188. * Constant used to retrieve the position texture index in the G-Buffer textures array
  59189. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  59190. */
  59191. static readonly POSITION_TEXTURE_TYPE: number;
  59192. /**
  59193. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  59194. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  59195. */
  59196. static readonly VELOCITY_TEXTURE_TYPE: number;
  59197. /**
  59198. * Dictionary used to store the previous transformation matrices of each rendered mesh
  59199. * in order to compute objects velocities when enableVelocity is set to "true"
  59200. * @hidden
  59201. */
  59202. _previousTransformationMatrices: {
  59203. [index: number]: ISavedTransformationMatrix;
  59204. };
  59205. /**
  59206. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  59207. * in order to compute objects velocities when enableVelocity is set to "true"
  59208. * @hidden
  59209. */
  59210. _previousBonesTransformationMatrices: {
  59211. [index: number]: Float32Array;
  59212. };
  59213. /**
  59214. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  59215. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  59216. */
  59217. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  59218. private _scene;
  59219. private _multiRenderTarget;
  59220. private _ratio;
  59221. private _enablePosition;
  59222. private _enableVelocity;
  59223. private _positionIndex;
  59224. private _velocityIndex;
  59225. protected _effect: Effect;
  59226. protected _cachedDefines: string;
  59227. /**
  59228. * Set the render list (meshes to be rendered) used in the G buffer.
  59229. */
  59230. renderList: Mesh[];
  59231. /**
  59232. * Gets wether or not G buffer are supported by the running hardware.
  59233. * This requires draw buffer supports
  59234. */
  59235. readonly isSupported: boolean;
  59236. /**
  59237. * Returns the index of the given texture type in the G-Buffer textures array
  59238. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  59239. * @returns the index of the given texture type in the G-Buffer textures array
  59240. */
  59241. getTextureIndex(textureType: number): number;
  59242. /**
  59243. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  59244. */
  59245. /**
  59246. * Sets whether or not objects positions are enabled for the G buffer.
  59247. */
  59248. enablePosition: boolean;
  59249. /**
  59250. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  59251. */
  59252. /**
  59253. * Sets wether or not objects velocities are enabled for the G buffer.
  59254. */
  59255. enableVelocity: boolean;
  59256. /**
  59257. * Gets the scene associated with the buffer.
  59258. */
  59259. readonly scene: Scene;
  59260. /**
  59261. * Gets the ratio used by the buffer during its creation.
  59262. * How big is the buffer related to the main canvas.
  59263. */
  59264. readonly ratio: number;
  59265. /** @hidden */
  59266. static _SceneComponentInitialization: (scene: Scene) => void;
  59267. /**
  59268. * Creates a new G Buffer for the scene
  59269. * @param scene The scene the buffer belongs to
  59270. * @param ratio How big is the buffer related to the main canvas.
  59271. */
  59272. constructor(scene: Scene, ratio?: number);
  59273. /**
  59274. * Checks wether everything is ready to render a submesh to the G buffer.
  59275. * @param subMesh the submesh to check readiness for
  59276. * @param useInstances is the mesh drawn using instance or not
  59277. * @returns true if ready otherwise false
  59278. */
  59279. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59280. /**
  59281. * Gets the current underlying G Buffer.
  59282. * @returns the buffer
  59283. */
  59284. getGBuffer(): MultiRenderTarget;
  59285. /**
  59286. * Gets the number of samples used to render the buffer (anti aliasing).
  59287. */
  59288. /**
  59289. * Sets the number of samples used to render the buffer (anti aliasing).
  59290. */
  59291. samples: number;
  59292. /**
  59293. * Disposes the renderer and frees up associated resources.
  59294. */
  59295. dispose(): void;
  59296. protected _createRenderTargets(): void;
  59297. private _copyBonesTransformationMatrices;
  59298. }
  59299. }
  59300. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  59301. import { Nullable } from "babylonjs/types";
  59302. import { Scene } from "babylonjs/scene";
  59303. import { ISceneComponent } from "babylonjs/sceneComponent";
  59304. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  59305. module "babylonjs/scene" {
  59306. interface Scene {
  59307. /** @hidden (Backing field) */
  59308. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  59309. /**
  59310. * Gets or Sets the current geometry buffer associated to the scene.
  59311. */
  59312. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  59313. /**
  59314. * Enables a GeometryBufferRender and associates it with the scene
  59315. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  59316. * @returns the GeometryBufferRenderer
  59317. */
  59318. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  59319. /**
  59320. * Disables the GeometryBufferRender associated with the scene
  59321. */
  59322. disableGeometryBufferRenderer(): void;
  59323. }
  59324. }
  59325. /**
  59326. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  59327. * in several rendering techniques.
  59328. */
  59329. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  59330. /**
  59331. * The component name helpful to identify the component in the list of scene components.
  59332. */
  59333. readonly name: string;
  59334. /**
  59335. * The scene the component belongs to.
  59336. */
  59337. scene: Scene;
  59338. /**
  59339. * Creates a new instance of the component for the given scene
  59340. * @param scene Defines the scene to register the component in
  59341. */
  59342. constructor(scene: Scene);
  59343. /**
  59344. * Registers the component in a given scene
  59345. */
  59346. register(): void;
  59347. /**
  59348. * Rebuilds the elements related to this component in case of
  59349. * context lost for instance.
  59350. */
  59351. rebuild(): void;
  59352. /**
  59353. * Disposes the component and the associated ressources
  59354. */
  59355. dispose(): void;
  59356. private _gatherRenderTargets;
  59357. }
  59358. }
  59359. declare module "babylonjs/Shaders/motionBlur.fragment" {
  59360. /** @hidden */
  59361. export var motionBlurPixelShader: {
  59362. name: string;
  59363. shader: string;
  59364. };
  59365. }
  59366. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  59367. import { Nullable } from "babylonjs/types";
  59368. import { Camera } from "babylonjs/Cameras/camera";
  59369. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59370. import { Scene } from "babylonjs/scene";
  59371. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59372. import "babylonjs/Animations/animatable";
  59373. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  59374. import "babylonjs/Shaders/motionBlur.fragment";
  59375. import { Engine } from "babylonjs/Engines/engine";
  59376. /**
  59377. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  59378. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  59379. * As an example, all you have to do is to create the post-process:
  59380. * var mb = new BABYLON.MotionBlurPostProcess(
  59381. * 'mb', // The name of the effect.
  59382. * scene, // The scene containing the objects to blur according to their velocity.
  59383. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  59384. * camera // The camera to apply the render pass to.
  59385. * );
  59386. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  59387. */
  59388. export class MotionBlurPostProcess extends PostProcess {
  59389. /**
  59390. * Defines how much the image is blurred by the movement. Default value is equal to 1
  59391. */
  59392. motionStrength: number;
  59393. /**
  59394. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  59395. */
  59396. /**
  59397. * Sets the number of iterations to be used for motion blur quality
  59398. */
  59399. motionBlurSamples: number;
  59400. private _motionBlurSamples;
  59401. private _geometryBufferRenderer;
  59402. /**
  59403. * Creates a new instance MotionBlurPostProcess
  59404. * @param name The name of the effect.
  59405. * @param scene The scene containing the objects to blur according to their velocity.
  59406. * @param options The required width/height ratio to downsize to before computing the render pass.
  59407. * @param camera The camera to apply the render pass to.
  59408. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59409. * @param engine The engine which the post process will be applied. (default: current engine)
  59410. * @param reusable If the post process can be reused on the same frame. (default: false)
  59411. * @param textureType Type of textures used when performing the post process. (default: 0)
  59412. * @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)
  59413. */
  59414. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59415. /**
  59416. * Excludes the given skinned mesh from computing bones velocities.
  59417. * 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.
  59418. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  59419. */
  59420. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  59421. /**
  59422. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  59423. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  59424. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  59425. */
  59426. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  59427. /**
  59428. * Disposes the post process.
  59429. * @param camera The camera to dispose the post process on.
  59430. */
  59431. dispose(camera?: Camera): void;
  59432. }
  59433. }
  59434. declare module "babylonjs/Shaders/refraction.fragment" {
  59435. /** @hidden */
  59436. export var refractionPixelShader: {
  59437. name: string;
  59438. shader: string;
  59439. };
  59440. }
  59441. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  59442. import { Color3 } from "babylonjs/Maths/math.color";
  59443. import { Camera } from "babylonjs/Cameras/camera";
  59444. import { Texture } from "babylonjs/Materials/Textures/texture";
  59445. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59446. import { Engine } from "babylonjs/Engines/engine";
  59447. import "babylonjs/Shaders/refraction.fragment";
  59448. /**
  59449. * Post process which applies a refractin texture
  59450. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  59451. */
  59452. export class RefractionPostProcess extends PostProcess {
  59453. /** the base color of the refraction (used to taint the rendering) */
  59454. color: Color3;
  59455. /** simulated refraction depth */
  59456. depth: number;
  59457. /** the coefficient of the base color (0 to remove base color tainting) */
  59458. colorLevel: number;
  59459. private _refTexture;
  59460. private _ownRefractionTexture;
  59461. /**
  59462. * Gets or sets the refraction texture
  59463. * Please note that you are responsible for disposing the texture if you set it manually
  59464. */
  59465. refractionTexture: Texture;
  59466. /**
  59467. * Initializes the RefractionPostProcess
  59468. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  59469. * @param name The name of the effect.
  59470. * @param refractionTextureUrl Url of the refraction texture to use
  59471. * @param color the base color of the refraction (used to taint the rendering)
  59472. * @param depth simulated refraction depth
  59473. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  59474. * @param camera The camera to apply the render pass to.
  59475. * @param options The required width/height ratio to downsize to before computing the render pass.
  59476. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59477. * @param engine The engine which the post process will be applied. (default: current engine)
  59478. * @param reusable If the post process can be reused on the same frame. (default: false)
  59479. */
  59480. constructor(name: string, refractionTextureUrl: string,
  59481. /** the base color of the refraction (used to taint the rendering) */
  59482. color: Color3,
  59483. /** simulated refraction depth */
  59484. depth: number,
  59485. /** the coefficient of the base color (0 to remove base color tainting) */
  59486. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59487. /**
  59488. * Disposes of the post process
  59489. * @param camera Camera to dispose post process on
  59490. */
  59491. dispose(camera: Camera): void;
  59492. }
  59493. }
  59494. declare module "babylonjs/Shaders/sharpen.fragment" {
  59495. /** @hidden */
  59496. export var sharpenPixelShader: {
  59497. name: string;
  59498. shader: string;
  59499. };
  59500. }
  59501. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  59502. import { Nullable } from "babylonjs/types";
  59503. import { Camera } from "babylonjs/Cameras/camera";
  59504. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59505. import "babylonjs/Shaders/sharpen.fragment";
  59506. import { Engine } from "babylonjs/Engines/engine";
  59507. /**
  59508. * The SharpenPostProcess applies a sharpen kernel to every pixel
  59509. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  59510. */
  59511. export class SharpenPostProcess extends PostProcess {
  59512. /**
  59513. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  59514. */
  59515. colorAmount: number;
  59516. /**
  59517. * How much sharpness should be applied (default: 0.3)
  59518. */
  59519. edgeAmount: number;
  59520. /**
  59521. * Creates a new instance ConvolutionPostProcess
  59522. * @param name The name of the effect.
  59523. * @param options The required width/height ratio to downsize to before computing the render pass.
  59524. * @param camera The camera to apply the render pass to.
  59525. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59526. * @param engine The engine which the post process will be applied. (default: current engine)
  59527. * @param reusable If the post process can be reused on the same frame. (default: false)
  59528. * @param textureType Type of textures used when performing the post process. (default: 0)
  59529. * @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)
  59530. */
  59531. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59532. }
  59533. }
  59534. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  59535. import { Nullable } from "babylonjs/types";
  59536. import { Camera } from "babylonjs/Cameras/camera";
  59537. import { Engine } from "babylonjs/Engines/engine";
  59538. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  59539. import { IInspectable } from "babylonjs/Misc/iInspectable";
  59540. /**
  59541. * PostProcessRenderPipeline
  59542. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59543. */
  59544. export class PostProcessRenderPipeline {
  59545. private engine;
  59546. private _renderEffects;
  59547. private _renderEffectsForIsolatedPass;
  59548. /**
  59549. * List of inspectable custom properties (used by the Inspector)
  59550. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  59551. */
  59552. inspectableCustomProperties: IInspectable[];
  59553. /**
  59554. * @hidden
  59555. */
  59556. protected _cameras: Camera[];
  59557. /** @hidden */
  59558. _name: string;
  59559. /**
  59560. * Gets pipeline name
  59561. */
  59562. readonly name: string;
  59563. /**
  59564. * Initializes a PostProcessRenderPipeline
  59565. * @param engine engine to add the pipeline to
  59566. * @param name name of the pipeline
  59567. */
  59568. constructor(engine: Engine, name: string);
  59569. /**
  59570. * Gets the class name
  59571. * @returns "PostProcessRenderPipeline"
  59572. */
  59573. getClassName(): string;
  59574. /**
  59575. * If all the render effects in the pipeline are supported
  59576. */
  59577. readonly isSupported: boolean;
  59578. /**
  59579. * Adds an effect to the pipeline
  59580. * @param renderEffect the effect to add
  59581. */
  59582. addEffect(renderEffect: PostProcessRenderEffect): void;
  59583. /** @hidden */
  59584. _rebuild(): void;
  59585. /** @hidden */
  59586. _enableEffect(renderEffectName: string, cameras: Camera): void;
  59587. /** @hidden */
  59588. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  59589. /** @hidden */
  59590. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  59591. /** @hidden */
  59592. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  59593. /** @hidden */
  59594. _attachCameras(cameras: Camera, unique: boolean): void;
  59595. /** @hidden */
  59596. _attachCameras(cameras: Camera[], unique: boolean): void;
  59597. /** @hidden */
  59598. _detachCameras(cameras: Camera): void;
  59599. /** @hidden */
  59600. _detachCameras(cameras: Nullable<Camera[]>): void;
  59601. /** @hidden */
  59602. _update(): void;
  59603. /** @hidden */
  59604. _reset(): void;
  59605. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  59606. /**
  59607. * Disposes of the pipeline
  59608. */
  59609. dispose(): void;
  59610. }
  59611. }
  59612. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  59613. import { Camera } from "babylonjs/Cameras/camera";
  59614. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59615. /**
  59616. * PostProcessRenderPipelineManager class
  59617. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59618. */
  59619. export class PostProcessRenderPipelineManager {
  59620. private _renderPipelines;
  59621. /**
  59622. * Initializes a PostProcessRenderPipelineManager
  59623. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59624. */
  59625. constructor();
  59626. /**
  59627. * Gets the list of supported render pipelines
  59628. */
  59629. readonly supportedPipelines: PostProcessRenderPipeline[];
  59630. /**
  59631. * Adds a pipeline to the manager
  59632. * @param renderPipeline The pipeline to add
  59633. */
  59634. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  59635. /**
  59636. * Attaches a camera to the pipeline
  59637. * @param renderPipelineName The name of the pipeline to attach to
  59638. * @param cameras the camera to attach
  59639. * @param unique if the camera can be attached multiple times to the pipeline
  59640. */
  59641. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  59642. /**
  59643. * Detaches a camera from the pipeline
  59644. * @param renderPipelineName The name of the pipeline to detach from
  59645. * @param cameras the camera to detach
  59646. */
  59647. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  59648. /**
  59649. * Enables an effect by name on a pipeline
  59650. * @param renderPipelineName the name of the pipeline to enable the effect in
  59651. * @param renderEffectName the name of the effect to enable
  59652. * @param cameras the cameras that the effect should be enabled on
  59653. */
  59654. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59655. /**
  59656. * Disables an effect by name on a pipeline
  59657. * @param renderPipelineName the name of the pipeline to disable the effect in
  59658. * @param renderEffectName the name of the effect to disable
  59659. * @param cameras the cameras that the effect should be disabled on
  59660. */
  59661. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59662. /**
  59663. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  59664. */
  59665. update(): void;
  59666. /** @hidden */
  59667. _rebuild(): void;
  59668. /**
  59669. * Disposes of the manager and pipelines
  59670. */
  59671. dispose(): void;
  59672. }
  59673. }
  59674. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  59675. import { ISceneComponent } from "babylonjs/sceneComponent";
  59676. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  59677. import { Scene } from "babylonjs/scene";
  59678. module "babylonjs/scene" {
  59679. interface Scene {
  59680. /** @hidden (Backing field) */
  59681. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59682. /**
  59683. * Gets the postprocess render pipeline manager
  59684. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59685. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59686. */
  59687. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59688. }
  59689. }
  59690. /**
  59691. * Defines the Render Pipeline scene component responsible to rendering pipelines
  59692. */
  59693. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  59694. /**
  59695. * The component name helpfull to identify the component in the list of scene components.
  59696. */
  59697. readonly name: string;
  59698. /**
  59699. * The scene the component belongs to.
  59700. */
  59701. scene: Scene;
  59702. /**
  59703. * Creates a new instance of the component for the given scene
  59704. * @param scene Defines the scene to register the component in
  59705. */
  59706. constructor(scene: Scene);
  59707. /**
  59708. * Registers the component in a given scene
  59709. */
  59710. register(): void;
  59711. /**
  59712. * Rebuilds the elements related to this component in case of
  59713. * context lost for instance.
  59714. */
  59715. rebuild(): void;
  59716. /**
  59717. * Disposes the component and the associated ressources
  59718. */
  59719. dispose(): void;
  59720. private _gatherRenderTargets;
  59721. }
  59722. }
  59723. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  59724. import { Nullable } from "babylonjs/types";
  59725. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  59726. import { Camera } from "babylonjs/Cameras/camera";
  59727. import { IDisposable } from "babylonjs/scene";
  59728. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  59729. import { Scene } from "babylonjs/scene";
  59730. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  59731. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  59732. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  59733. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  59734. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  59735. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59736. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  59737. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  59738. import { Animation } from "babylonjs/Animations/animation";
  59739. /**
  59740. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  59741. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59742. */
  59743. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59744. private _scene;
  59745. private _camerasToBeAttached;
  59746. /**
  59747. * ID of the sharpen post process,
  59748. */
  59749. private readonly SharpenPostProcessId;
  59750. /**
  59751. * @ignore
  59752. * ID of the image processing post process;
  59753. */
  59754. readonly ImageProcessingPostProcessId: string;
  59755. /**
  59756. * @ignore
  59757. * ID of the Fast Approximate Anti-Aliasing post process;
  59758. */
  59759. readonly FxaaPostProcessId: string;
  59760. /**
  59761. * ID of the chromatic aberration post process,
  59762. */
  59763. private readonly ChromaticAberrationPostProcessId;
  59764. /**
  59765. * ID of the grain post process
  59766. */
  59767. private readonly GrainPostProcessId;
  59768. /**
  59769. * Sharpen post process which will apply a sharpen convolution to enhance edges
  59770. */
  59771. sharpen: SharpenPostProcess;
  59772. private _sharpenEffect;
  59773. private bloom;
  59774. /**
  59775. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  59776. */
  59777. depthOfField: DepthOfFieldEffect;
  59778. /**
  59779. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59780. */
  59781. fxaa: FxaaPostProcess;
  59782. /**
  59783. * Image post processing pass used to perform operations such as tone mapping or color grading.
  59784. */
  59785. imageProcessing: ImageProcessingPostProcess;
  59786. /**
  59787. * Chromatic aberration post process which will shift rgb colors in the image
  59788. */
  59789. chromaticAberration: ChromaticAberrationPostProcess;
  59790. private _chromaticAberrationEffect;
  59791. /**
  59792. * Grain post process which add noise to the image
  59793. */
  59794. grain: GrainPostProcess;
  59795. private _grainEffect;
  59796. /**
  59797. * Glow post process which adds a glow to emissive areas of the image
  59798. */
  59799. private _glowLayer;
  59800. /**
  59801. * Animations which can be used to tweak settings over a period of time
  59802. */
  59803. animations: Animation[];
  59804. private _imageProcessingConfigurationObserver;
  59805. private _sharpenEnabled;
  59806. private _bloomEnabled;
  59807. private _depthOfFieldEnabled;
  59808. private _depthOfFieldBlurLevel;
  59809. private _fxaaEnabled;
  59810. private _imageProcessingEnabled;
  59811. private _defaultPipelineTextureType;
  59812. private _bloomScale;
  59813. private _chromaticAberrationEnabled;
  59814. private _grainEnabled;
  59815. private _buildAllowed;
  59816. /**
  59817. * Gets active scene
  59818. */
  59819. readonly scene: Scene;
  59820. /**
  59821. * Enable or disable the sharpen process from the pipeline
  59822. */
  59823. sharpenEnabled: boolean;
  59824. private _resizeObserver;
  59825. private _hardwareScaleLevel;
  59826. private _bloomKernel;
  59827. /**
  59828. * Specifies the size of the bloom blur kernel, relative to the final output size
  59829. */
  59830. bloomKernel: number;
  59831. /**
  59832. * Specifies the weight of the bloom in the final rendering
  59833. */
  59834. private _bloomWeight;
  59835. /**
  59836. * Specifies the luma threshold for the area that will be blurred by the bloom
  59837. */
  59838. private _bloomThreshold;
  59839. private _hdr;
  59840. /**
  59841. * The strength of the bloom.
  59842. */
  59843. bloomWeight: number;
  59844. /**
  59845. * The strength of the bloom.
  59846. */
  59847. bloomThreshold: number;
  59848. /**
  59849. * The scale of the bloom, lower value will provide better performance.
  59850. */
  59851. bloomScale: number;
  59852. /**
  59853. * Enable or disable the bloom from the pipeline
  59854. */
  59855. bloomEnabled: boolean;
  59856. private _rebuildBloom;
  59857. /**
  59858. * If the depth of field is enabled.
  59859. */
  59860. depthOfFieldEnabled: boolean;
  59861. /**
  59862. * Blur level of the depth of field effect. (Higher blur will effect performance)
  59863. */
  59864. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  59865. /**
  59866. * If the anti aliasing is enabled.
  59867. */
  59868. fxaaEnabled: boolean;
  59869. private _samples;
  59870. /**
  59871. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59872. */
  59873. samples: number;
  59874. /**
  59875. * If image processing is enabled.
  59876. */
  59877. imageProcessingEnabled: boolean;
  59878. /**
  59879. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  59880. */
  59881. glowLayerEnabled: boolean;
  59882. /**
  59883. * Gets the glow layer (or null if not defined)
  59884. */
  59885. readonly glowLayer: Nullable<GlowLayer>;
  59886. /**
  59887. * Enable or disable the chromaticAberration process from the pipeline
  59888. */
  59889. chromaticAberrationEnabled: boolean;
  59890. /**
  59891. * Enable or disable the grain process from the pipeline
  59892. */
  59893. grainEnabled: boolean;
  59894. /**
  59895. * @constructor
  59896. * @param name - The rendering pipeline name (default: "")
  59897. * @param hdr - If high dynamic range textures should be used (default: true)
  59898. * @param scene - The scene linked to this pipeline (default: the last created scene)
  59899. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  59900. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  59901. */
  59902. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  59903. /**
  59904. * Get the class name
  59905. * @returns "DefaultRenderingPipeline"
  59906. */
  59907. getClassName(): string;
  59908. /**
  59909. * Force the compilation of the entire pipeline.
  59910. */
  59911. prepare(): void;
  59912. private _hasCleared;
  59913. private _prevPostProcess;
  59914. private _prevPrevPostProcess;
  59915. private _setAutoClearAndTextureSharing;
  59916. private _depthOfFieldSceneObserver;
  59917. private _buildPipeline;
  59918. private _disposePostProcesses;
  59919. /**
  59920. * Adds a camera to the pipeline
  59921. * @param camera the camera to be added
  59922. */
  59923. addCamera(camera: Camera): void;
  59924. /**
  59925. * Removes a camera from the pipeline
  59926. * @param camera the camera to remove
  59927. */
  59928. removeCamera(camera: Camera): void;
  59929. /**
  59930. * Dispose of the pipeline and stop all post processes
  59931. */
  59932. dispose(): void;
  59933. /**
  59934. * Serialize the rendering pipeline (Used when exporting)
  59935. * @returns the serialized object
  59936. */
  59937. serialize(): any;
  59938. /**
  59939. * Parse the serialized pipeline
  59940. * @param source Source pipeline.
  59941. * @param scene The scene to load the pipeline to.
  59942. * @param rootUrl The URL of the serialized pipeline.
  59943. * @returns An instantiated pipeline from the serialized object.
  59944. */
  59945. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  59946. }
  59947. }
  59948. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  59949. /** @hidden */
  59950. export var lensHighlightsPixelShader: {
  59951. name: string;
  59952. shader: string;
  59953. };
  59954. }
  59955. declare module "babylonjs/Shaders/depthOfField.fragment" {
  59956. /** @hidden */
  59957. export var depthOfFieldPixelShader: {
  59958. name: string;
  59959. shader: string;
  59960. };
  59961. }
  59962. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  59963. import { Camera } from "babylonjs/Cameras/camera";
  59964. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59965. import { Scene } from "babylonjs/scene";
  59966. import "babylonjs/Shaders/chromaticAberration.fragment";
  59967. import "babylonjs/Shaders/lensHighlights.fragment";
  59968. import "babylonjs/Shaders/depthOfField.fragment";
  59969. /**
  59970. * BABYLON.JS Chromatic Aberration GLSL Shader
  59971. * Author: Olivier Guyot
  59972. * Separates very slightly R, G and B colors on the edges of the screen
  59973. * Inspired by Francois Tarlier & Martins Upitis
  59974. */
  59975. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  59976. /**
  59977. * @ignore
  59978. * The chromatic aberration PostProcess id in the pipeline
  59979. */
  59980. LensChromaticAberrationEffect: string;
  59981. /**
  59982. * @ignore
  59983. * The highlights enhancing PostProcess id in the pipeline
  59984. */
  59985. HighlightsEnhancingEffect: string;
  59986. /**
  59987. * @ignore
  59988. * The depth-of-field PostProcess id in the pipeline
  59989. */
  59990. LensDepthOfFieldEffect: string;
  59991. private _scene;
  59992. private _depthTexture;
  59993. private _grainTexture;
  59994. private _chromaticAberrationPostProcess;
  59995. private _highlightsPostProcess;
  59996. private _depthOfFieldPostProcess;
  59997. private _edgeBlur;
  59998. private _grainAmount;
  59999. private _chromaticAberration;
  60000. private _distortion;
  60001. private _highlightsGain;
  60002. private _highlightsThreshold;
  60003. private _dofDistance;
  60004. private _dofAperture;
  60005. private _dofDarken;
  60006. private _dofPentagon;
  60007. private _blurNoise;
  60008. /**
  60009. * @constructor
  60010. *
  60011. * Effect parameters are as follow:
  60012. * {
  60013. * chromatic_aberration: number; // from 0 to x (1 for realism)
  60014. * edge_blur: number; // from 0 to x (1 for realism)
  60015. * distortion: number; // from 0 to x (1 for realism)
  60016. * grain_amount: number; // from 0 to 1
  60017. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  60018. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  60019. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  60020. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  60021. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  60022. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  60023. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  60024. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  60025. * }
  60026. * Note: if an effect parameter is unset, effect is disabled
  60027. *
  60028. * @param name The rendering pipeline name
  60029. * @param parameters - An object containing all parameters (see above)
  60030. * @param scene The scene linked to this pipeline
  60031. * @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)
  60032. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60033. */
  60034. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  60035. /**
  60036. * Get the class name
  60037. * @returns "LensRenderingPipeline"
  60038. */
  60039. getClassName(): string;
  60040. /**
  60041. * Gets associated scene
  60042. */
  60043. readonly scene: Scene;
  60044. /**
  60045. * Gets or sets the edge blur
  60046. */
  60047. edgeBlur: number;
  60048. /**
  60049. * Gets or sets the grain amount
  60050. */
  60051. grainAmount: number;
  60052. /**
  60053. * Gets or sets the chromatic aberration amount
  60054. */
  60055. chromaticAberration: number;
  60056. /**
  60057. * Gets or sets the depth of field aperture
  60058. */
  60059. dofAperture: number;
  60060. /**
  60061. * Gets or sets the edge distortion
  60062. */
  60063. edgeDistortion: number;
  60064. /**
  60065. * Gets or sets the depth of field distortion
  60066. */
  60067. dofDistortion: number;
  60068. /**
  60069. * Gets or sets the darken out of focus amount
  60070. */
  60071. darkenOutOfFocus: number;
  60072. /**
  60073. * Gets or sets a boolean indicating if blur noise is enabled
  60074. */
  60075. blurNoise: boolean;
  60076. /**
  60077. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  60078. */
  60079. pentagonBokeh: boolean;
  60080. /**
  60081. * Gets or sets the highlight grain amount
  60082. */
  60083. highlightsGain: number;
  60084. /**
  60085. * Gets or sets the highlight threshold
  60086. */
  60087. highlightsThreshold: number;
  60088. /**
  60089. * Sets the amount of blur at the edges
  60090. * @param amount blur amount
  60091. */
  60092. setEdgeBlur(amount: number): void;
  60093. /**
  60094. * Sets edge blur to 0
  60095. */
  60096. disableEdgeBlur(): void;
  60097. /**
  60098. * Sets the amout of grain
  60099. * @param amount Amount of grain
  60100. */
  60101. setGrainAmount(amount: number): void;
  60102. /**
  60103. * Set grain amount to 0
  60104. */
  60105. disableGrain(): void;
  60106. /**
  60107. * Sets the chromatic aberration amount
  60108. * @param amount amount of chromatic aberration
  60109. */
  60110. setChromaticAberration(amount: number): void;
  60111. /**
  60112. * Sets chromatic aberration amount to 0
  60113. */
  60114. disableChromaticAberration(): void;
  60115. /**
  60116. * Sets the EdgeDistortion amount
  60117. * @param amount amount of EdgeDistortion
  60118. */
  60119. setEdgeDistortion(amount: number): void;
  60120. /**
  60121. * Sets edge distortion to 0
  60122. */
  60123. disableEdgeDistortion(): void;
  60124. /**
  60125. * Sets the FocusDistance amount
  60126. * @param amount amount of FocusDistance
  60127. */
  60128. setFocusDistance(amount: number): void;
  60129. /**
  60130. * Disables depth of field
  60131. */
  60132. disableDepthOfField(): void;
  60133. /**
  60134. * Sets the Aperture amount
  60135. * @param amount amount of Aperture
  60136. */
  60137. setAperture(amount: number): void;
  60138. /**
  60139. * Sets the DarkenOutOfFocus amount
  60140. * @param amount amount of DarkenOutOfFocus
  60141. */
  60142. setDarkenOutOfFocus(amount: number): void;
  60143. private _pentagonBokehIsEnabled;
  60144. /**
  60145. * Creates a pentagon bokeh effect
  60146. */
  60147. enablePentagonBokeh(): void;
  60148. /**
  60149. * Disables the pentagon bokeh effect
  60150. */
  60151. disablePentagonBokeh(): void;
  60152. /**
  60153. * Enables noise blur
  60154. */
  60155. enableNoiseBlur(): void;
  60156. /**
  60157. * Disables noise blur
  60158. */
  60159. disableNoiseBlur(): void;
  60160. /**
  60161. * Sets the HighlightsGain amount
  60162. * @param amount amount of HighlightsGain
  60163. */
  60164. setHighlightsGain(amount: number): void;
  60165. /**
  60166. * Sets the HighlightsThreshold amount
  60167. * @param amount amount of HighlightsThreshold
  60168. */
  60169. setHighlightsThreshold(amount: number): void;
  60170. /**
  60171. * Disables highlights
  60172. */
  60173. disableHighlights(): void;
  60174. /**
  60175. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  60176. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  60177. */
  60178. dispose(disableDepthRender?: boolean): void;
  60179. private _createChromaticAberrationPostProcess;
  60180. private _createHighlightsPostProcess;
  60181. private _createDepthOfFieldPostProcess;
  60182. private _createGrainTexture;
  60183. }
  60184. }
  60185. declare module "babylonjs/Shaders/ssao2.fragment" {
  60186. /** @hidden */
  60187. export var ssao2PixelShader: {
  60188. name: string;
  60189. shader: string;
  60190. };
  60191. }
  60192. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  60193. /** @hidden */
  60194. export var ssaoCombinePixelShader: {
  60195. name: string;
  60196. shader: string;
  60197. };
  60198. }
  60199. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  60200. import { Camera } from "babylonjs/Cameras/camera";
  60201. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60202. import { Scene } from "babylonjs/scene";
  60203. import "babylonjs/Shaders/ssao2.fragment";
  60204. import "babylonjs/Shaders/ssaoCombine.fragment";
  60205. /**
  60206. * Render pipeline to produce ssao effect
  60207. */
  60208. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  60209. /**
  60210. * @ignore
  60211. * The PassPostProcess id in the pipeline that contains the original scene color
  60212. */
  60213. SSAOOriginalSceneColorEffect: string;
  60214. /**
  60215. * @ignore
  60216. * The SSAO PostProcess id in the pipeline
  60217. */
  60218. SSAORenderEffect: string;
  60219. /**
  60220. * @ignore
  60221. * The horizontal blur PostProcess id in the pipeline
  60222. */
  60223. SSAOBlurHRenderEffect: string;
  60224. /**
  60225. * @ignore
  60226. * The vertical blur PostProcess id in the pipeline
  60227. */
  60228. SSAOBlurVRenderEffect: string;
  60229. /**
  60230. * @ignore
  60231. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  60232. */
  60233. SSAOCombineRenderEffect: string;
  60234. /**
  60235. * The output strength of the SSAO post-process. Default value is 1.0.
  60236. */
  60237. totalStrength: number;
  60238. /**
  60239. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  60240. */
  60241. maxZ: number;
  60242. /**
  60243. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  60244. */
  60245. minZAspect: number;
  60246. private _samples;
  60247. /**
  60248. * Number of samples used for the SSAO calculations. Default value is 8
  60249. */
  60250. samples: number;
  60251. private _textureSamples;
  60252. /**
  60253. * Number of samples to use for antialiasing
  60254. */
  60255. textureSamples: number;
  60256. /**
  60257. * Ratio object used for SSAO ratio and blur ratio
  60258. */
  60259. private _ratio;
  60260. /**
  60261. * Dynamically generated sphere sampler.
  60262. */
  60263. private _sampleSphere;
  60264. /**
  60265. * Blur filter offsets
  60266. */
  60267. private _samplerOffsets;
  60268. private _expensiveBlur;
  60269. /**
  60270. * If bilateral blur should be used
  60271. */
  60272. expensiveBlur: boolean;
  60273. /**
  60274. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  60275. */
  60276. radius: number;
  60277. /**
  60278. * The base color of the SSAO post-process
  60279. * The final result is "base + ssao" between [0, 1]
  60280. */
  60281. base: number;
  60282. /**
  60283. * Support test.
  60284. */
  60285. static readonly IsSupported: boolean;
  60286. private _scene;
  60287. private _depthTexture;
  60288. private _normalTexture;
  60289. private _randomTexture;
  60290. private _originalColorPostProcess;
  60291. private _ssaoPostProcess;
  60292. private _blurHPostProcess;
  60293. private _blurVPostProcess;
  60294. private _ssaoCombinePostProcess;
  60295. private _firstUpdate;
  60296. /**
  60297. * Gets active scene
  60298. */
  60299. readonly scene: Scene;
  60300. /**
  60301. * @constructor
  60302. * @param name The rendering pipeline name
  60303. * @param scene The scene linked to this pipeline
  60304. * @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 }
  60305. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60306. */
  60307. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  60308. /**
  60309. * Get the class name
  60310. * @returns "SSAO2RenderingPipeline"
  60311. */
  60312. getClassName(): string;
  60313. /**
  60314. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  60315. */
  60316. dispose(disableGeometryBufferRenderer?: boolean): void;
  60317. private _createBlurPostProcess;
  60318. /** @hidden */
  60319. _rebuild(): void;
  60320. private _bits;
  60321. private _radicalInverse_VdC;
  60322. private _hammersley;
  60323. private _hemisphereSample_uniform;
  60324. private _generateHemisphere;
  60325. private _createSSAOPostProcess;
  60326. private _createSSAOCombinePostProcess;
  60327. private _createRandomTexture;
  60328. /**
  60329. * Serialize the rendering pipeline (Used when exporting)
  60330. * @returns the serialized object
  60331. */
  60332. serialize(): any;
  60333. /**
  60334. * Parse the serialized pipeline
  60335. * @param source Source pipeline.
  60336. * @param scene The scene to load the pipeline to.
  60337. * @param rootUrl The URL of the serialized pipeline.
  60338. * @returns An instantiated pipeline from the serialized object.
  60339. */
  60340. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  60341. }
  60342. }
  60343. declare module "babylonjs/Shaders/ssao.fragment" {
  60344. /** @hidden */
  60345. export var ssaoPixelShader: {
  60346. name: string;
  60347. shader: string;
  60348. };
  60349. }
  60350. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  60351. import { Camera } from "babylonjs/Cameras/camera";
  60352. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60353. import { Scene } from "babylonjs/scene";
  60354. import "babylonjs/Shaders/ssao.fragment";
  60355. import "babylonjs/Shaders/ssaoCombine.fragment";
  60356. /**
  60357. * Render pipeline to produce ssao effect
  60358. */
  60359. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  60360. /**
  60361. * @ignore
  60362. * The PassPostProcess id in the pipeline that contains the original scene color
  60363. */
  60364. SSAOOriginalSceneColorEffect: string;
  60365. /**
  60366. * @ignore
  60367. * The SSAO PostProcess id in the pipeline
  60368. */
  60369. SSAORenderEffect: string;
  60370. /**
  60371. * @ignore
  60372. * The horizontal blur PostProcess id in the pipeline
  60373. */
  60374. SSAOBlurHRenderEffect: string;
  60375. /**
  60376. * @ignore
  60377. * The vertical blur PostProcess id in the pipeline
  60378. */
  60379. SSAOBlurVRenderEffect: string;
  60380. /**
  60381. * @ignore
  60382. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  60383. */
  60384. SSAOCombineRenderEffect: string;
  60385. /**
  60386. * The output strength of the SSAO post-process. Default value is 1.0.
  60387. */
  60388. totalStrength: number;
  60389. /**
  60390. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  60391. */
  60392. radius: number;
  60393. /**
  60394. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  60395. * Must not be equal to fallOff and superior to fallOff.
  60396. * Default value is 0.0075
  60397. */
  60398. area: number;
  60399. /**
  60400. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  60401. * Must not be equal to area and inferior to area.
  60402. * Default value is 0.000001
  60403. */
  60404. fallOff: number;
  60405. /**
  60406. * The base color of the SSAO post-process
  60407. * The final result is "base + ssao" between [0, 1]
  60408. */
  60409. base: number;
  60410. private _scene;
  60411. private _depthTexture;
  60412. private _randomTexture;
  60413. private _originalColorPostProcess;
  60414. private _ssaoPostProcess;
  60415. private _blurHPostProcess;
  60416. private _blurVPostProcess;
  60417. private _ssaoCombinePostProcess;
  60418. private _firstUpdate;
  60419. /**
  60420. * Gets active scene
  60421. */
  60422. readonly scene: Scene;
  60423. /**
  60424. * @constructor
  60425. * @param name - The rendering pipeline name
  60426. * @param scene - The scene linked to this pipeline
  60427. * @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 }
  60428. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  60429. */
  60430. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  60431. /**
  60432. * Get the class name
  60433. * @returns "SSAORenderingPipeline"
  60434. */
  60435. getClassName(): string;
  60436. /**
  60437. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  60438. */
  60439. dispose(disableDepthRender?: boolean): void;
  60440. private _createBlurPostProcess;
  60441. /** @hidden */
  60442. _rebuild(): void;
  60443. private _createSSAOPostProcess;
  60444. private _createSSAOCombinePostProcess;
  60445. private _createRandomTexture;
  60446. }
  60447. }
  60448. declare module "babylonjs/Shaders/standard.fragment" {
  60449. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  60450. /** @hidden */
  60451. export var standardPixelShader: {
  60452. name: string;
  60453. shader: string;
  60454. };
  60455. }
  60456. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  60457. import { Nullable } from "babylonjs/types";
  60458. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  60459. import { Camera } from "babylonjs/Cameras/camera";
  60460. import { Texture } from "babylonjs/Materials/Textures/texture";
  60461. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60462. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60463. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  60464. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  60465. import { IDisposable } from "babylonjs/scene";
  60466. import { SpotLight } from "babylonjs/Lights/spotLight";
  60467. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  60468. import { Scene } from "babylonjs/scene";
  60469. import { Animation } from "babylonjs/Animations/animation";
  60470. import "babylonjs/Shaders/standard.fragment";
  60471. /**
  60472. * Standard rendering pipeline
  60473. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60474. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  60475. */
  60476. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  60477. /**
  60478. * Public members
  60479. */
  60480. /**
  60481. * Post-process which contains the original scene color before the pipeline applies all the effects
  60482. */
  60483. originalPostProcess: Nullable<PostProcess>;
  60484. /**
  60485. * Post-process used to down scale an image x4
  60486. */
  60487. downSampleX4PostProcess: Nullable<PostProcess>;
  60488. /**
  60489. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  60490. */
  60491. brightPassPostProcess: Nullable<PostProcess>;
  60492. /**
  60493. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  60494. */
  60495. blurHPostProcesses: PostProcess[];
  60496. /**
  60497. * Post-process array storing all the vertical blur post-processes used by the pipeline
  60498. */
  60499. blurVPostProcesses: PostProcess[];
  60500. /**
  60501. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  60502. */
  60503. textureAdderPostProcess: Nullable<PostProcess>;
  60504. /**
  60505. * Post-process used to create volumetric lighting effect
  60506. */
  60507. volumetricLightPostProcess: Nullable<PostProcess>;
  60508. /**
  60509. * Post-process used to smooth the previous volumetric light post-process on the X axis
  60510. */
  60511. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  60512. /**
  60513. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  60514. */
  60515. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  60516. /**
  60517. * Post-process used to merge the volumetric light effect and the real scene color
  60518. */
  60519. volumetricLightMergePostProces: Nullable<PostProcess>;
  60520. /**
  60521. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  60522. */
  60523. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  60524. /**
  60525. * Base post-process used to calculate the average luminance of the final image for HDR
  60526. */
  60527. luminancePostProcess: Nullable<PostProcess>;
  60528. /**
  60529. * Post-processes used to create down sample post-processes in order to get
  60530. * the average luminance of the final image for HDR
  60531. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  60532. */
  60533. luminanceDownSamplePostProcesses: PostProcess[];
  60534. /**
  60535. * Post-process used to create a HDR effect (light adaptation)
  60536. */
  60537. hdrPostProcess: Nullable<PostProcess>;
  60538. /**
  60539. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  60540. */
  60541. textureAdderFinalPostProcess: Nullable<PostProcess>;
  60542. /**
  60543. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  60544. */
  60545. lensFlareFinalPostProcess: Nullable<PostProcess>;
  60546. /**
  60547. * Post-process used to merge the final HDR post-process and the real scene color
  60548. */
  60549. hdrFinalPostProcess: Nullable<PostProcess>;
  60550. /**
  60551. * Post-process used to create a lens flare effect
  60552. */
  60553. lensFlarePostProcess: Nullable<PostProcess>;
  60554. /**
  60555. * Post-process that merges the result of the lens flare post-process and the real scene color
  60556. */
  60557. lensFlareComposePostProcess: Nullable<PostProcess>;
  60558. /**
  60559. * Post-process used to create a motion blur effect
  60560. */
  60561. motionBlurPostProcess: Nullable<PostProcess>;
  60562. /**
  60563. * Post-process used to create a depth of field effect
  60564. */
  60565. depthOfFieldPostProcess: Nullable<PostProcess>;
  60566. /**
  60567. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  60568. */
  60569. fxaaPostProcess: Nullable<FxaaPostProcess>;
  60570. /**
  60571. * Represents the brightness threshold in order to configure the illuminated surfaces
  60572. */
  60573. brightThreshold: number;
  60574. /**
  60575. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  60576. */
  60577. blurWidth: number;
  60578. /**
  60579. * Sets if the blur for highlighted surfaces must be only horizontal
  60580. */
  60581. horizontalBlur: boolean;
  60582. /**
  60583. * Gets the overall exposure used by the pipeline
  60584. */
  60585. /**
  60586. * Sets the overall exposure used by the pipeline
  60587. */
  60588. exposure: number;
  60589. /**
  60590. * Texture used typically to simulate "dirty" on camera lens
  60591. */
  60592. lensTexture: Nullable<Texture>;
  60593. /**
  60594. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  60595. */
  60596. volumetricLightCoefficient: number;
  60597. /**
  60598. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  60599. */
  60600. volumetricLightPower: number;
  60601. /**
  60602. * Used the set the blur intensity to smooth the volumetric lights
  60603. */
  60604. volumetricLightBlurScale: number;
  60605. /**
  60606. * Light (spot or directional) used to generate the volumetric lights rays
  60607. * The source light must have a shadow generate so the pipeline can get its
  60608. * depth map
  60609. */
  60610. sourceLight: Nullable<SpotLight | DirectionalLight>;
  60611. /**
  60612. * For eye adaptation, represents the minimum luminance the eye can see
  60613. */
  60614. hdrMinimumLuminance: number;
  60615. /**
  60616. * For eye adaptation, represents the decrease luminance speed
  60617. */
  60618. hdrDecreaseRate: number;
  60619. /**
  60620. * For eye adaptation, represents the increase luminance speed
  60621. */
  60622. hdrIncreaseRate: number;
  60623. /**
  60624. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  60625. */
  60626. /**
  60627. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  60628. */
  60629. hdrAutoExposure: boolean;
  60630. /**
  60631. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  60632. */
  60633. lensColorTexture: Nullable<Texture>;
  60634. /**
  60635. * The overall strengh for the lens flare effect
  60636. */
  60637. lensFlareStrength: number;
  60638. /**
  60639. * Dispersion coefficient for lens flare ghosts
  60640. */
  60641. lensFlareGhostDispersal: number;
  60642. /**
  60643. * Main lens flare halo width
  60644. */
  60645. lensFlareHaloWidth: number;
  60646. /**
  60647. * Based on the lens distortion effect, defines how much the lens flare result
  60648. * is distorted
  60649. */
  60650. lensFlareDistortionStrength: number;
  60651. /**
  60652. * Lens star texture must be used to simulate rays on the flares and is available
  60653. * in the documentation
  60654. */
  60655. lensStarTexture: Nullable<Texture>;
  60656. /**
  60657. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  60658. * flare effect by taking account of the dirt texture
  60659. */
  60660. lensFlareDirtTexture: Nullable<Texture>;
  60661. /**
  60662. * Represents the focal length for the depth of field effect
  60663. */
  60664. depthOfFieldDistance: number;
  60665. /**
  60666. * Represents the blur intensity for the blurred part of the depth of field effect
  60667. */
  60668. depthOfFieldBlurWidth: number;
  60669. /**
  60670. * Gets how much the image is blurred by the movement while using the motion blur post-process
  60671. */
  60672. /**
  60673. * Sets how much the image is blurred by the movement while using the motion blur post-process
  60674. */
  60675. motionStrength: number;
  60676. /**
  60677. * Gets wether or not the motion blur post-process is object based or screen based.
  60678. */
  60679. /**
  60680. * Sets wether or not the motion blur post-process should be object based or screen based
  60681. */
  60682. objectBasedMotionBlur: boolean;
  60683. /**
  60684. * List of animations for the pipeline (IAnimatable implementation)
  60685. */
  60686. animations: Animation[];
  60687. /**
  60688. * Private members
  60689. */
  60690. private _scene;
  60691. private _currentDepthOfFieldSource;
  60692. private _basePostProcess;
  60693. private _fixedExposure;
  60694. private _currentExposure;
  60695. private _hdrAutoExposure;
  60696. private _hdrCurrentLuminance;
  60697. private _motionStrength;
  60698. private _isObjectBasedMotionBlur;
  60699. private _floatTextureType;
  60700. private _ratio;
  60701. private _bloomEnabled;
  60702. private _depthOfFieldEnabled;
  60703. private _vlsEnabled;
  60704. private _lensFlareEnabled;
  60705. private _hdrEnabled;
  60706. private _motionBlurEnabled;
  60707. private _fxaaEnabled;
  60708. private _motionBlurSamples;
  60709. private _volumetricLightStepsCount;
  60710. private _samples;
  60711. /**
  60712. * @ignore
  60713. * Specifies if the bloom pipeline is enabled
  60714. */
  60715. BloomEnabled: boolean;
  60716. /**
  60717. * @ignore
  60718. * Specifies if the depth of field pipeline is enabed
  60719. */
  60720. DepthOfFieldEnabled: boolean;
  60721. /**
  60722. * @ignore
  60723. * Specifies if the lens flare pipeline is enabed
  60724. */
  60725. LensFlareEnabled: boolean;
  60726. /**
  60727. * @ignore
  60728. * Specifies if the HDR pipeline is enabled
  60729. */
  60730. HDREnabled: boolean;
  60731. /**
  60732. * @ignore
  60733. * Specifies if the volumetric lights scattering effect is enabled
  60734. */
  60735. VLSEnabled: boolean;
  60736. /**
  60737. * @ignore
  60738. * Specifies if the motion blur effect is enabled
  60739. */
  60740. MotionBlurEnabled: boolean;
  60741. /**
  60742. * Specifies if anti-aliasing is enabled
  60743. */
  60744. fxaaEnabled: boolean;
  60745. /**
  60746. * Specifies the number of steps used to calculate the volumetric lights
  60747. * Typically in interval [50, 200]
  60748. */
  60749. volumetricLightStepsCount: number;
  60750. /**
  60751. * Specifies the number of samples used for the motion blur effect
  60752. * Typically in interval [16, 64]
  60753. */
  60754. motionBlurSamples: number;
  60755. /**
  60756. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60757. */
  60758. samples: number;
  60759. /**
  60760. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60761. * @constructor
  60762. * @param name The rendering pipeline name
  60763. * @param scene The scene linked to this pipeline
  60764. * @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)
  60765. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  60766. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60767. */
  60768. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  60769. private _buildPipeline;
  60770. private _createDownSampleX4PostProcess;
  60771. private _createBrightPassPostProcess;
  60772. private _createBlurPostProcesses;
  60773. private _createTextureAdderPostProcess;
  60774. private _createVolumetricLightPostProcess;
  60775. private _createLuminancePostProcesses;
  60776. private _createHdrPostProcess;
  60777. private _createLensFlarePostProcess;
  60778. private _createDepthOfFieldPostProcess;
  60779. private _createMotionBlurPostProcess;
  60780. private _getDepthTexture;
  60781. private _disposePostProcesses;
  60782. /**
  60783. * Dispose of the pipeline and stop all post processes
  60784. */
  60785. dispose(): void;
  60786. /**
  60787. * Serialize the rendering pipeline (Used when exporting)
  60788. * @returns the serialized object
  60789. */
  60790. serialize(): any;
  60791. /**
  60792. * Parse the serialized pipeline
  60793. * @param source Source pipeline.
  60794. * @param scene The scene to load the pipeline to.
  60795. * @param rootUrl The URL of the serialized pipeline.
  60796. * @returns An instantiated pipeline from the serialized object.
  60797. */
  60798. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  60799. /**
  60800. * Luminance steps
  60801. */
  60802. static LuminanceSteps: number;
  60803. }
  60804. }
  60805. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  60806. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  60807. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  60808. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  60809. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  60810. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  60811. }
  60812. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  60813. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  60814. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  60815. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60816. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  60817. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  60818. }
  60819. declare module "babylonjs/Shaders/tonemap.fragment" {
  60820. /** @hidden */
  60821. export var tonemapPixelShader: {
  60822. name: string;
  60823. shader: string;
  60824. };
  60825. }
  60826. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  60827. import { Camera } from "babylonjs/Cameras/camera";
  60828. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60829. import "babylonjs/Shaders/tonemap.fragment";
  60830. import { Engine } from "babylonjs/Engines/engine";
  60831. /** Defines operator used for tonemapping */
  60832. export enum TonemappingOperator {
  60833. /** Hable */
  60834. Hable = 0,
  60835. /** Reinhard */
  60836. Reinhard = 1,
  60837. /** HejiDawson */
  60838. HejiDawson = 2,
  60839. /** Photographic */
  60840. Photographic = 3
  60841. }
  60842. /**
  60843. * Defines a post process to apply tone mapping
  60844. */
  60845. export class TonemapPostProcess extends PostProcess {
  60846. private _operator;
  60847. /** Defines the required exposure adjustement */
  60848. exposureAdjustment: number;
  60849. /**
  60850. * Creates a new TonemapPostProcess
  60851. * @param name defines the name of the postprocess
  60852. * @param _operator defines the operator to use
  60853. * @param exposureAdjustment defines the required exposure adjustement
  60854. * @param camera defines the camera to use (can be null)
  60855. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  60856. * @param engine defines the hosting engine (can be ignore if camera is set)
  60857. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60858. */
  60859. constructor(name: string, _operator: TonemappingOperator,
  60860. /** Defines the required exposure adjustement */
  60861. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  60862. }
  60863. }
  60864. declare module "babylonjs/Shaders/depth.vertex" {
  60865. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60866. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60867. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60868. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60869. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60870. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60871. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60872. /** @hidden */
  60873. export var depthVertexShader: {
  60874. name: string;
  60875. shader: string;
  60876. };
  60877. }
  60878. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  60879. /** @hidden */
  60880. export var volumetricLightScatteringPixelShader: {
  60881. name: string;
  60882. shader: string;
  60883. };
  60884. }
  60885. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  60886. /** @hidden */
  60887. export var volumetricLightScatteringPassPixelShader: {
  60888. name: string;
  60889. shader: string;
  60890. };
  60891. }
  60892. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  60893. import { Vector3 } from "babylonjs/Maths/math.vector";
  60894. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60895. import { Mesh } from "babylonjs/Meshes/mesh";
  60896. import { Camera } from "babylonjs/Cameras/camera";
  60897. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60898. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60899. import { Scene } from "babylonjs/scene";
  60900. import "babylonjs/Meshes/Builders/planeBuilder";
  60901. import "babylonjs/Shaders/depth.vertex";
  60902. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  60903. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  60904. import { Engine } from "babylonjs/Engines/engine";
  60905. /**
  60906. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  60907. */
  60908. export class VolumetricLightScatteringPostProcess extends PostProcess {
  60909. private _volumetricLightScatteringPass;
  60910. private _volumetricLightScatteringRTT;
  60911. private _viewPort;
  60912. private _screenCoordinates;
  60913. private _cachedDefines;
  60914. /**
  60915. * If not undefined, the mesh position is computed from the attached node position
  60916. */
  60917. attachedNode: {
  60918. position: Vector3;
  60919. };
  60920. /**
  60921. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  60922. */
  60923. customMeshPosition: Vector3;
  60924. /**
  60925. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  60926. */
  60927. useCustomMeshPosition: boolean;
  60928. /**
  60929. * If the post-process should inverse the light scattering direction
  60930. */
  60931. invert: boolean;
  60932. /**
  60933. * The internal mesh used by the post-process
  60934. */
  60935. mesh: Mesh;
  60936. /**
  60937. * @hidden
  60938. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  60939. */
  60940. useDiffuseColor: boolean;
  60941. /**
  60942. * Array containing the excluded meshes not rendered in the internal pass
  60943. */
  60944. excludedMeshes: AbstractMesh[];
  60945. /**
  60946. * Controls the overall intensity of the post-process
  60947. */
  60948. exposure: number;
  60949. /**
  60950. * Dissipates each sample's contribution in range [0, 1]
  60951. */
  60952. decay: number;
  60953. /**
  60954. * Controls the overall intensity of each sample
  60955. */
  60956. weight: number;
  60957. /**
  60958. * Controls the density of each sample
  60959. */
  60960. density: number;
  60961. /**
  60962. * @constructor
  60963. * @param name The post-process name
  60964. * @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)
  60965. * @param camera The camera that the post-process will be attached to
  60966. * @param mesh The mesh used to create the light scattering
  60967. * @param samples The post-process quality, default 100
  60968. * @param samplingModeThe post-process filtering mode
  60969. * @param engine The babylon engine
  60970. * @param reusable If the post-process is reusable
  60971. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  60972. */
  60973. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  60974. /**
  60975. * Returns the string "VolumetricLightScatteringPostProcess"
  60976. * @returns "VolumetricLightScatteringPostProcess"
  60977. */
  60978. getClassName(): string;
  60979. private _isReady;
  60980. /**
  60981. * Sets the new light position for light scattering effect
  60982. * @param position The new custom light position
  60983. */
  60984. setCustomMeshPosition(position: Vector3): void;
  60985. /**
  60986. * Returns the light position for light scattering effect
  60987. * @return Vector3 The custom light position
  60988. */
  60989. getCustomMeshPosition(): Vector3;
  60990. /**
  60991. * Disposes the internal assets and detaches the post-process from the camera
  60992. */
  60993. dispose(camera: Camera): void;
  60994. /**
  60995. * Returns the render target texture used by the post-process
  60996. * @return the render target texture used by the post-process
  60997. */
  60998. getPass(): RenderTargetTexture;
  60999. private _meshExcluded;
  61000. private _createPass;
  61001. private _updateMeshScreenCoordinates;
  61002. /**
  61003. * Creates a default mesh for the Volumeric Light Scattering post-process
  61004. * @param name The mesh name
  61005. * @param scene The scene where to create the mesh
  61006. * @return the default mesh
  61007. */
  61008. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  61009. }
  61010. }
  61011. declare module "babylonjs/PostProcesses/index" {
  61012. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  61013. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  61014. export * from "babylonjs/PostProcesses/bloomEffect";
  61015. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  61016. export * from "babylonjs/PostProcesses/blurPostProcess";
  61017. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  61018. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  61019. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  61020. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  61021. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  61022. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  61023. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  61024. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  61025. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  61026. export * from "babylonjs/PostProcesses/filterPostProcess";
  61027. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  61028. export * from "babylonjs/PostProcesses/grainPostProcess";
  61029. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  61030. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  61031. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  61032. export * from "babylonjs/PostProcesses/passPostProcess";
  61033. export * from "babylonjs/PostProcesses/postProcess";
  61034. export * from "babylonjs/PostProcesses/postProcessManager";
  61035. export * from "babylonjs/PostProcesses/refractionPostProcess";
  61036. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  61037. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  61038. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  61039. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  61040. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  61041. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  61042. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  61043. }
  61044. declare module "babylonjs/Probes/index" {
  61045. export * from "babylonjs/Probes/reflectionProbe";
  61046. }
  61047. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  61048. import { Scene } from "babylonjs/scene";
  61049. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61050. import { SmartArray } from "babylonjs/Misc/smartArray";
  61051. import { ISceneComponent } from "babylonjs/sceneComponent";
  61052. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  61053. import "babylonjs/Meshes/Builders/boxBuilder";
  61054. import "babylonjs/Shaders/color.fragment";
  61055. import "babylonjs/Shaders/color.vertex";
  61056. import { Color3 } from "babylonjs/Maths/math.color";
  61057. module "babylonjs/scene" {
  61058. interface Scene {
  61059. /** @hidden (Backing field) */
  61060. _boundingBoxRenderer: BoundingBoxRenderer;
  61061. /** @hidden (Backing field) */
  61062. _forceShowBoundingBoxes: boolean;
  61063. /**
  61064. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  61065. */
  61066. forceShowBoundingBoxes: boolean;
  61067. /**
  61068. * Gets the bounding box renderer associated with the scene
  61069. * @returns a BoundingBoxRenderer
  61070. */
  61071. getBoundingBoxRenderer(): BoundingBoxRenderer;
  61072. }
  61073. }
  61074. module "babylonjs/Meshes/abstractMesh" {
  61075. interface AbstractMesh {
  61076. /** @hidden (Backing field) */
  61077. _showBoundingBox: boolean;
  61078. /**
  61079. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  61080. */
  61081. showBoundingBox: boolean;
  61082. }
  61083. }
  61084. /**
  61085. * Component responsible of rendering the bounding box of the meshes in a scene.
  61086. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  61087. */
  61088. export class BoundingBoxRenderer implements ISceneComponent {
  61089. /**
  61090. * The component name helpfull to identify the component in the list of scene components.
  61091. */
  61092. readonly name: string;
  61093. /**
  61094. * The scene the component belongs to.
  61095. */
  61096. scene: Scene;
  61097. /**
  61098. * Color of the bounding box lines placed in front of an object
  61099. */
  61100. frontColor: Color3;
  61101. /**
  61102. * Color of the bounding box lines placed behind an object
  61103. */
  61104. backColor: Color3;
  61105. /**
  61106. * Defines if the renderer should show the back lines or not
  61107. */
  61108. showBackLines: boolean;
  61109. /**
  61110. * @hidden
  61111. */
  61112. renderList: SmartArray<BoundingBox>;
  61113. private _colorShader;
  61114. private _vertexBuffers;
  61115. private _indexBuffer;
  61116. private _fillIndexBuffer;
  61117. private _fillIndexData;
  61118. /**
  61119. * Instantiates a new bounding box renderer in a scene.
  61120. * @param scene the scene the renderer renders in
  61121. */
  61122. constructor(scene: Scene);
  61123. /**
  61124. * Registers the component in a given scene
  61125. */
  61126. register(): void;
  61127. private _evaluateSubMesh;
  61128. private _activeMesh;
  61129. private _prepareRessources;
  61130. private _createIndexBuffer;
  61131. /**
  61132. * Rebuilds the elements related to this component in case of
  61133. * context lost for instance.
  61134. */
  61135. rebuild(): void;
  61136. /**
  61137. * @hidden
  61138. */
  61139. reset(): void;
  61140. /**
  61141. * Render the bounding boxes of a specific rendering group
  61142. * @param renderingGroupId defines the rendering group to render
  61143. */
  61144. render(renderingGroupId: number): void;
  61145. /**
  61146. * In case of occlusion queries, we can render the occlusion bounding box through this method
  61147. * @param mesh Define the mesh to render the occlusion bounding box for
  61148. */
  61149. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  61150. /**
  61151. * Dispose and release the resources attached to this renderer.
  61152. */
  61153. dispose(): void;
  61154. }
  61155. }
  61156. declare module "babylonjs/Shaders/depth.fragment" {
  61157. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  61158. /** @hidden */
  61159. export var depthPixelShader: {
  61160. name: string;
  61161. shader: string;
  61162. };
  61163. }
  61164. declare module "babylonjs/Rendering/depthRenderer" {
  61165. import { Nullable } from "babylonjs/types";
  61166. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61167. import { Scene } from "babylonjs/scene";
  61168. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61169. import { Camera } from "babylonjs/Cameras/camera";
  61170. import "babylonjs/Shaders/depth.fragment";
  61171. import "babylonjs/Shaders/depth.vertex";
  61172. /**
  61173. * This represents a depth renderer in Babylon.
  61174. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61175. */
  61176. export class DepthRenderer {
  61177. private _scene;
  61178. private _depthMap;
  61179. private _effect;
  61180. private readonly _storeNonLinearDepth;
  61181. private readonly _clearColor;
  61182. /** Get if the depth renderer is using packed depth or not */
  61183. readonly isPacked: boolean;
  61184. private _cachedDefines;
  61185. private _camera;
  61186. /**
  61187. * Specifiess that the depth renderer will only be used within
  61188. * the camera it is created for.
  61189. * This can help forcing its rendering during the camera processing.
  61190. */
  61191. useOnlyInActiveCamera: boolean;
  61192. /** @hidden */
  61193. static _SceneComponentInitialization: (scene: Scene) => void;
  61194. /**
  61195. * Instantiates a depth renderer
  61196. * @param scene The scene the renderer belongs to
  61197. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61198. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61199. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61200. */
  61201. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61202. /**
  61203. * Creates the depth rendering effect and checks if the effect is ready.
  61204. * @param subMesh The submesh to be used to render the depth map of
  61205. * @param useInstances If multiple world instances should be used
  61206. * @returns if the depth renderer is ready to render the depth map
  61207. */
  61208. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61209. /**
  61210. * Gets the texture which the depth map will be written to.
  61211. * @returns The depth map texture
  61212. */
  61213. getDepthMap(): RenderTargetTexture;
  61214. /**
  61215. * Disposes of the depth renderer.
  61216. */
  61217. dispose(): void;
  61218. }
  61219. }
  61220. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  61221. import { Nullable } from "babylonjs/types";
  61222. import { Scene } from "babylonjs/scene";
  61223. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  61224. import { Camera } from "babylonjs/Cameras/camera";
  61225. import { ISceneComponent } from "babylonjs/sceneComponent";
  61226. module "babylonjs/scene" {
  61227. interface Scene {
  61228. /** @hidden (Backing field) */
  61229. _depthRenderer: {
  61230. [id: string]: DepthRenderer;
  61231. };
  61232. /**
  61233. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  61234. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  61235. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61236. * @returns the created depth renderer
  61237. */
  61238. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  61239. /**
  61240. * Disables a depth renderer for a given camera
  61241. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  61242. */
  61243. disableDepthRenderer(camera?: Nullable<Camera>): void;
  61244. }
  61245. }
  61246. /**
  61247. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  61248. * in several rendering techniques.
  61249. */
  61250. export class DepthRendererSceneComponent implements ISceneComponent {
  61251. /**
  61252. * The component name helpfull to identify the component in the list of scene components.
  61253. */
  61254. readonly name: string;
  61255. /**
  61256. * The scene the component belongs to.
  61257. */
  61258. scene: Scene;
  61259. /**
  61260. * Creates a new instance of the component for the given scene
  61261. * @param scene Defines the scene to register the component in
  61262. */
  61263. constructor(scene: Scene);
  61264. /**
  61265. * Registers the component in a given scene
  61266. */
  61267. register(): void;
  61268. /**
  61269. * Rebuilds the elements related to this component in case of
  61270. * context lost for instance.
  61271. */
  61272. rebuild(): void;
  61273. /**
  61274. * Disposes the component and the associated ressources
  61275. */
  61276. dispose(): void;
  61277. private _gatherRenderTargets;
  61278. private _gatherActiveCameraRenderTargets;
  61279. }
  61280. }
  61281. declare module "babylonjs/Shaders/outline.fragment" {
  61282. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  61283. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  61284. /** @hidden */
  61285. export var outlinePixelShader: {
  61286. name: string;
  61287. shader: string;
  61288. };
  61289. }
  61290. declare module "babylonjs/Shaders/outline.vertex" {
  61291. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61292. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61293. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61294. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61295. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  61296. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61297. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61298. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61299. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  61300. /** @hidden */
  61301. export var outlineVertexShader: {
  61302. name: string;
  61303. shader: string;
  61304. };
  61305. }
  61306. declare module "babylonjs/Rendering/outlineRenderer" {
  61307. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61308. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  61309. import { Scene } from "babylonjs/scene";
  61310. import { ISceneComponent } from "babylonjs/sceneComponent";
  61311. import "babylonjs/Shaders/outline.fragment";
  61312. import "babylonjs/Shaders/outline.vertex";
  61313. module "babylonjs/scene" {
  61314. interface Scene {
  61315. /** @hidden */
  61316. _outlineRenderer: OutlineRenderer;
  61317. /**
  61318. * Gets the outline renderer associated with the scene
  61319. * @returns a OutlineRenderer
  61320. */
  61321. getOutlineRenderer(): OutlineRenderer;
  61322. }
  61323. }
  61324. module "babylonjs/Meshes/abstractMesh" {
  61325. interface AbstractMesh {
  61326. /** @hidden (Backing field) */
  61327. _renderOutline: boolean;
  61328. /**
  61329. * Gets or sets a boolean indicating if the outline must be rendered as well
  61330. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  61331. */
  61332. renderOutline: boolean;
  61333. /** @hidden (Backing field) */
  61334. _renderOverlay: boolean;
  61335. /**
  61336. * Gets or sets a boolean indicating if the overlay must be rendered as well
  61337. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  61338. */
  61339. renderOverlay: boolean;
  61340. }
  61341. }
  61342. /**
  61343. * This class is responsible to draw bothe outline/overlay of meshes.
  61344. * It should not be used directly but through the available method on mesh.
  61345. */
  61346. export class OutlineRenderer implements ISceneComponent {
  61347. /**
  61348. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  61349. */
  61350. private static _StencilReference;
  61351. /**
  61352. * The name of the component. Each component must have a unique name.
  61353. */
  61354. name: string;
  61355. /**
  61356. * The scene the component belongs to.
  61357. */
  61358. scene: Scene;
  61359. /**
  61360. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  61361. */
  61362. zOffset: number;
  61363. private _engine;
  61364. private _effect;
  61365. private _cachedDefines;
  61366. private _savedDepthWrite;
  61367. /**
  61368. * Instantiates a new outline renderer. (There could be only one per scene).
  61369. * @param scene Defines the scene it belongs to
  61370. */
  61371. constructor(scene: Scene);
  61372. /**
  61373. * Register the component to one instance of a scene.
  61374. */
  61375. register(): void;
  61376. /**
  61377. * Rebuilds the elements related to this component in case of
  61378. * context lost for instance.
  61379. */
  61380. rebuild(): void;
  61381. /**
  61382. * Disposes the component and the associated ressources.
  61383. */
  61384. dispose(): void;
  61385. /**
  61386. * Renders the outline in the canvas.
  61387. * @param subMesh Defines the sumesh to render
  61388. * @param batch Defines the batch of meshes in case of instances
  61389. * @param useOverlay Defines if the rendering is for the overlay or the outline
  61390. */
  61391. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  61392. /**
  61393. * Returns whether or not the outline renderer is ready for a given submesh.
  61394. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  61395. * @param subMesh Defines the submesh to check readyness for
  61396. * @param useInstances Defines wheter wee are trying to render instances or not
  61397. * @returns true if ready otherwise false
  61398. */
  61399. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61400. private _beforeRenderingMesh;
  61401. private _afterRenderingMesh;
  61402. }
  61403. }
  61404. declare module "babylonjs/Rendering/index" {
  61405. export * from "babylonjs/Rendering/boundingBoxRenderer";
  61406. export * from "babylonjs/Rendering/depthRenderer";
  61407. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  61408. export * from "babylonjs/Rendering/edgesRenderer";
  61409. export * from "babylonjs/Rendering/geometryBufferRenderer";
  61410. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  61411. export * from "babylonjs/Rendering/outlineRenderer";
  61412. export * from "babylonjs/Rendering/renderingGroup";
  61413. export * from "babylonjs/Rendering/renderingManager";
  61414. export * from "babylonjs/Rendering/utilityLayerRenderer";
  61415. }
  61416. declare module "babylonjs/Sprites/index" {
  61417. export * from "babylonjs/Sprites/sprite";
  61418. export * from "babylonjs/Sprites/spriteManager";
  61419. export * from "babylonjs/Sprites/spriteSceneComponent";
  61420. }
  61421. declare module "babylonjs/Misc/assetsManager" {
  61422. import { Scene } from "babylonjs/scene";
  61423. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61424. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61425. import { Skeleton } from "babylonjs/Bones/skeleton";
  61426. import { Observable } from "babylonjs/Misc/observable";
  61427. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61428. import { Texture } from "babylonjs/Materials/Textures/texture";
  61429. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  61430. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  61431. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  61432. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  61433. /**
  61434. * Defines the list of states available for a task inside a AssetsManager
  61435. */
  61436. export enum AssetTaskState {
  61437. /**
  61438. * Initialization
  61439. */
  61440. INIT = 0,
  61441. /**
  61442. * Running
  61443. */
  61444. RUNNING = 1,
  61445. /**
  61446. * Done
  61447. */
  61448. DONE = 2,
  61449. /**
  61450. * Error
  61451. */
  61452. ERROR = 3
  61453. }
  61454. /**
  61455. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  61456. */
  61457. export abstract class AbstractAssetTask {
  61458. /**
  61459. * Task name
  61460. */ name: string;
  61461. /**
  61462. * Callback called when the task is successful
  61463. */
  61464. onSuccess: (task: any) => void;
  61465. /**
  61466. * Callback called when the task is not successful
  61467. */
  61468. onError: (task: any, message?: string, exception?: any) => void;
  61469. /**
  61470. * Creates a new AssetsManager
  61471. * @param name defines the name of the task
  61472. */
  61473. constructor(
  61474. /**
  61475. * Task name
  61476. */ name: string);
  61477. private _isCompleted;
  61478. private _taskState;
  61479. private _errorObject;
  61480. /**
  61481. * Get if the task is completed
  61482. */
  61483. readonly isCompleted: boolean;
  61484. /**
  61485. * Gets the current state of the task
  61486. */
  61487. readonly taskState: AssetTaskState;
  61488. /**
  61489. * Gets the current error object (if task is in error)
  61490. */
  61491. readonly errorObject: {
  61492. message?: string;
  61493. exception?: any;
  61494. };
  61495. /**
  61496. * Internal only
  61497. * @hidden
  61498. */
  61499. _setErrorObject(message?: string, exception?: any): void;
  61500. /**
  61501. * Execute the current task
  61502. * @param scene defines the scene where you want your assets to be loaded
  61503. * @param onSuccess is a callback called when the task is successfully executed
  61504. * @param onError is a callback called if an error occurs
  61505. */
  61506. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61507. /**
  61508. * Execute the current task
  61509. * @param scene defines the scene where you want your assets to be loaded
  61510. * @param onSuccess is a callback called when the task is successfully executed
  61511. * @param onError is a callback called if an error occurs
  61512. */
  61513. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61514. /**
  61515. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  61516. * This can be used with failed tasks that have the reason for failure fixed.
  61517. */
  61518. reset(): void;
  61519. private onErrorCallback;
  61520. private onDoneCallback;
  61521. }
  61522. /**
  61523. * Define the interface used by progress events raised during assets loading
  61524. */
  61525. export interface IAssetsProgressEvent {
  61526. /**
  61527. * Defines the number of remaining tasks to process
  61528. */
  61529. remainingCount: number;
  61530. /**
  61531. * Defines the total number of tasks
  61532. */
  61533. totalCount: number;
  61534. /**
  61535. * Defines the task that was just processed
  61536. */
  61537. task: AbstractAssetTask;
  61538. }
  61539. /**
  61540. * Class used to share progress information about assets loading
  61541. */
  61542. export class AssetsProgressEvent implements IAssetsProgressEvent {
  61543. /**
  61544. * Defines the number of remaining tasks to process
  61545. */
  61546. remainingCount: number;
  61547. /**
  61548. * Defines the total number of tasks
  61549. */
  61550. totalCount: number;
  61551. /**
  61552. * Defines the task that was just processed
  61553. */
  61554. task: AbstractAssetTask;
  61555. /**
  61556. * Creates a AssetsProgressEvent
  61557. * @param remainingCount defines the number of remaining tasks to process
  61558. * @param totalCount defines the total number of tasks
  61559. * @param task defines the task that was just processed
  61560. */
  61561. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  61562. }
  61563. /**
  61564. * Define a task used by AssetsManager to load meshes
  61565. */
  61566. export class MeshAssetTask extends AbstractAssetTask {
  61567. /**
  61568. * Defines the name of the task
  61569. */
  61570. name: string;
  61571. /**
  61572. * Defines the list of mesh's names you want to load
  61573. */
  61574. meshesNames: any;
  61575. /**
  61576. * Defines the root url to use as a base to load your meshes and associated resources
  61577. */
  61578. rootUrl: string;
  61579. /**
  61580. * Defines the filename of the scene to load from
  61581. */
  61582. sceneFilename: string;
  61583. /**
  61584. * Gets the list of loaded meshes
  61585. */
  61586. loadedMeshes: Array<AbstractMesh>;
  61587. /**
  61588. * Gets the list of loaded particle systems
  61589. */
  61590. loadedParticleSystems: Array<IParticleSystem>;
  61591. /**
  61592. * Gets the list of loaded skeletons
  61593. */
  61594. loadedSkeletons: Array<Skeleton>;
  61595. /**
  61596. * Gets the list of loaded animation groups
  61597. */
  61598. loadedAnimationGroups: Array<AnimationGroup>;
  61599. /**
  61600. * Callback called when the task is successful
  61601. */
  61602. onSuccess: (task: MeshAssetTask) => void;
  61603. /**
  61604. * Callback called when the task is successful
  61605. */
  61606. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  61607. /**
  61608. * Creates a new MeshAssetTask
  61609. * @param name defines the name of the task
  61610. * @param meshesNames defines the list of mesh's names you want to load
  61611. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  61612. * @param sceneFilename defines the filename of the scene to load from
  61613. */
  61614. constructor(
  61615. /**
  61616. * Defines the name of the task
  61617. */
  61618. name: string,
  61619. /**
  61620. * Defines the list of mesh's names you want to load
  61621. */
  61622. meshesNames: any,
  61623. /**
  61624. * Defines the root url to use as a base to load your meshes and associated resources
  61625. */
  61626. rootUrl: string,
  61627. /**
  61628. * Defines the filename of the scene to load from
  61629. */
  61630. sceneFilename: string);
  61631. /**
  61632. * Execute the current task
  61633. * @param scene defines the scene where you want your assets to be loaded
  61634. * @param onSuccess is a callback called when the task is successfully executed
  61635. * @param onError is a callback called if an error occurs
  61636. */
  61637. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61638. }
  61639. /**
  61640. * Define a task used by AssetsManager to load text content
  61641. */
  61642. export class TextFileAssetTask extends AbstractAssetTask {
  61643. /**
  61644. * Defines the name of the task
  61645. */
  61646. name: string;
  61647. /**
  61648. * Defines the location of the file to load
  61649. */
  61650. url: string;
  61651. /**
  61652. * Gets the loaded text string
  61653. */
  61654. text: string;
  61655. /**
  61656. * Callback called when the task is successful
  61657. */
  61658. onSuccess: (task: TextFileAssetTask) => void;
  61659. /**
  61660. * Callback called when the task is successful
  61661. */
  61662. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  61663. /**
  61664. * Creates a new TextFileAssetTask object
  61665. * @param name defines the name of the task
  61666. * @param url defines the location of the file to load
  61667. */
  61668. constructor(
  61669. /**
  61670. * Defines the name of the task
  61671. */
  61672. name: string,
  61673. /**
  61674. * Defines the location of the file to load
  61675. */
  61676. url: string);
  61677. /**
  61678. * Execute the current task
  61679. * @param scene defines the scene where you want your assets to be loaded
  61680. * @param onSuccess is a callback called when the task is successfully executed
  61681. * @param onError is a callback called if an error occurs
  61682. */
  61683. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61684. }
  61685. /**
  61686. * Define a task used by AssetsManager to load binary data
  61687. */
  61688. export class BinaryFileAssetTask extends AbstractAssetTask {
  61689. /**
  61690. * Defines the name of the task
  61691. */
  61692. name: string;
  61693. /**
  61694. * Defines the location of the file to load
  61695. */
  61696. url: string;
  61697. /**
  61698. * Gets the lodaded data (as an array buffer)
  61699. */
  61700. data: ArrayBuffer;
  61701. /**
  61702. * Callback called when the task is successful
  61703. */
  61704. onSuccess: (task: BinaryFileAssetTask) => void;
  61705. /**
  61706. * Callback called when the task is successful
  61707. */
  61708. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  61709. /**
  61710. * Creates a new BinaryFileAssetTask object
  61711. * @param name defines the name of the new task
  61712. * @param url defines the location of the file to load
  61713. */
  61714. constructor(
  61715. /**
  61716. * Defines the name of the task
  61717. */
  61718. name: string,
  61719. /**
  61720. * Defines the location of the file to load
  61721. */
  61722. url: string);
  61723. /**
  61724. * Execute the current task
  61725. * @param scene defines the scene where you want your assets to be loaded
  61726. * @param onSuccess is a callback called when the task is successfully executed
  61727. * @param onError is a callback called if an error occurs
  61728. */
  61729. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61730. }
  61731. /**
  61732. * Define a task used by AssetsManager to load images
  61733. */
  61734. export class ImageAssetTask extends AbstractAssetTask {
  61735. /**
  61736. * Defines the name of the task
  61737. */
  61738. name: string;
  61739. /**
  61740. * Defines the location of the image to load
  61741. */
  61742. url: string;
  61743. /**
  61744. * Gets the loaded images
  61745. */
  61746. image: HTMLImageElement;
  61747. /**
  61748. * Callback called when the task is successful
  61749. */
  61750. onSuccess: (task: ImageAssetTask) => void;
  61751. /**
  61752. * Callback called when the task is successful
  61753. */
  61754. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  61755. /**
  61756. * Creates a new ImageAssetTask
  61757. * @param name defines the name of the task
  61758. * @param url defines the location of the image to load
  61759. */
  61760. constructor(
  61761. /**
  61762. * Defines the name of the task
  61763. */
  61764. name: string,
  61765. /**
  61766. * Defines the location of the image to load
  61767. */
  61768. url: string);
  61769. /**
  61770. * Execute the current task
  61771. * @param scene defines the scene where you want your assets to be loaded
  61772. * @param onSuccess is a callback called when the task is successfully executed
  61773. * @param onError is a callback called if an error occurs
  61774. */
  61775. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61776. }
  61777. /**
  61778. * Defines the interface used by texture loading tasks
  61779. */
  61780. export interface ITextureAssetTask<TEX extends BaseTexture> {
  61781. /**
  61782. * Gets the loaded texture
  61783. */
  61784. texture: TEX;
  61785. }
  61786. /**
  61787. * Define a task used by AssetsManager to load 2D textures
  61788. */
  61789. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  61790. /**
  61791. * Defines the name of the task
  61792. */
  61793. name: string;
  61794. /**
  61795. * Defines the location of the file to load
  61796. */
  61797. url: string;
  61798. /**
  61799. * Defines if mipmap should not be generated (default is false)
  61800. */
  61801. noMipmap?: boolean | undefined;
  61802. /**
  61803. * Defines if texture must be inverted on Y axis (default is false)
  61804. */
  61805. invertY?: boolean | undefined;
  61806. /**
  61807. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61808. */
  61809. samplingMode: number;
  61810. /**
  61811. * Gets the loaded texture
  61812. */
  61813. texture: Texture;
  61814. /**
  61815. * Callback called when the task is successful
  61816. */
  61817. onSuccess: (task: TextureAssetTask) => void;
  61818. /**
  61819. * Callback called when the task is successful
  61820. */
  61821. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  61822. /**
  61823. * Creates a new TextureAssetTask object
  61824. * @param name defines the name of the task
  61825. * @param url defines the location of the file to load
  61826. * @param noMipmap defines if mipmap should not be generated (default is false)
  61827. * @param invertY defines if texture must be inverted on Y axis (default is false)
  61828. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61829. */
  61830. constructor(
  61831. /**
  61832. * Defines the name of the task
  61833. */
  61834. name: string,
  61835. /**
  61836. * Defines the location of the file to load
  61837. */
  61838. url: string,
  61839. /**
  61840. * Defines if mipmap should not be generated (default is false)
  61841. */
  61842. noMipmap?: boolean | undefined,
  61843. /**
  61844. * Defines if texture must be inverted on Y axis (default is false)
  61845. */
  61846. invertY?: boolean | undefined,
  61847. /**
  61848. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61849. */
  61850. samplingMode?: number);
  61851. /**
  61852. * Execute the current task
  61853. * @param scene defines the scene where you want your assets to be loaded
  61854. * @param onSuccess is a callback called when the task is successfully executed
  61855. * @param onError is a callback called if an error occurs
  61856. */
  61857. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61858. }
  61859. /**
  61860. * Define a task used by AssetsManager to load cube textures
  61861. */
  61862. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  61863. /**
  61864. * Defines the name of the task
  61865. */
  61866. name: string;
  61867. /**
  61868. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61869. */
  61870. url: string;
  61871. /**
  61872. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61873. */
  61874. extensions?: string[] | undefined;
  61875. /**
  61876. * Defines if mipmaps should not be generated (default is false)
  61877. */
  61878. noMipmap?: boolean | undefined;
  61879. /**
  61880. * Defines the explicit list of files (undefined by default)
  61881. */
  61882. files?: string[] | undefined;
  61883. /**
  61884. * Gets the loaded texture
  61885. */
  61886. texture: CubeTexture;
  61887. /**
  61888. * Callback called when the task is successful
  61889. */
  61890. onSuccess: (task: CubeTextureAssetTask) => void;
  61891. /**
  61892. * Callback called when the task is successful
  61893. */
  61894. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  61895. /**
  61896. * Creates a new CubeTextureAssetTask
  61897. * @param name defines the name of the task
  61898. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61899. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61900. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61901. * @param files defines the explicit list of files (undefined by default)
  61902. */
  61903. constructor(
  61904. /**
  61905. * Defines the name of the task
  61906. */
  61907. name: string,
  61908. /**
  61909. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61910. */
  61911. url: string,
  61912. /**
  61913. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61914. */
  61915. extensions?: string[] | undefined,
  61916. /**
  61917. * Defines if mipmaps should not be generated (default is false)
  61918. */
  61919. noMipmap?: boolean | undefined,
  61920. /**
  61921. * Defines the explicit list of files (undefined by default)
  61922. */
  61923. files?: string[] | undefined);
  61924. /**
  61925. * Execute the current task
  61926. * @param scene defines the scene where you want your assets to be loaded
  61927. * @param onSuccess is a callback called when the task is successfully executed
  61928. * @param onError is a callback called if an error occurs
  61929. */
  61930. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61931. }
  61932. /**
  61933. * Define a task used by AssetsManager to load HDR cube textures
  61934. */
  61935. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  61936. /**
  61937. * Defines the name of the task
  61938. */
  61939. name: string;
  61940. /**
  61941. * Defines the location of the file to load
  61942. */
  61943. url: string;
  61944. /**
  61945. * Defines the desired size (the more it increases the longer the generation will be)
  61946. */
  61947. size: number;
  61948. /**
  61949. * Defines if mipmaps should not be generated (default is false)
  61950. */
  61951. noMipmap: boolean;
  61952. /**
  61953. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61954. */
  61955. generateHarmonics: boolean;
  61956. /**
  61957. * 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)
  61958. */
  61959. gammaSpace: boolean;
  61960. /**
  61961. * Internal Use Only
  61962. */
  61963. reserved: boolean;
  61964. /**
  61965. * Gets the loaded texture
  61966. */
  61967. texture: HDRCubeTexture;
  61968. /**
  61969. * Callback called when the task is successful
  61970. */
  61971. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  61972. /**
  61973. * Callback called when the task is successful
  61974. */
  61975. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  61976. /**
  61977. * Creates a new HDRCubeTextureAssetTask object
  61978. * @param name defines the name of the task
  61979. * @param url defines the location of the file to load
  61980. * @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.
  61981. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61982. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61983. * @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)
  61984. * @param reserved Internal use only
  61985. */
  61986. constructor(
  61987. /**
  61988. * Defines the name of the task
  61989. */
  61990. name: string,
  61991. /**
  61992. * Defines the location of the file to load
  61993. */
  61994. url: string,
  61995. /**
  61996. * Defines the desired size (the more it increases the longer the generation will be)
  61997. */
  61998. size: number,
  61999. /**
  62000. * Defines if mipmaps should not be generated (default is false)
  62001. */
  62002. noMipmap?: boolean,
  62003. /**
  62004. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62005. */
  62006. generateHarmonics?: boolean,
  62007. /**
  62008. * 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)
  62009. */
  62010. gammaSpace?: boolean,
  62011. /**
  62012. * Internal Use Only
  62013. */
  62014. reserved?: boolean);
  62015. /**
  62016. * Execute the current task
  62017. * @param scene defines the scene where you want your assets to be loaded
  62018. * @param onSuccess is a callback called when the task is successfully executed
  62019. * @param onError is a callback called if an error occurs
  62020. */
  62021. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62022. }
  62023. /**
  62024. * Define a task used by AssetsManager to load Equirectangular cube textures
  62025. */
  62026. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  62027. /**
  62028. * Defines the name of the task
  62029. */
  62030. name: string;
  62031. /**
  62032. * Defines the location of the file to load
  62033. */
  62034. url: string;
  62035. /**
  62036. * Defines the desired size (the more it increases the longer the generation will be)
  62037. */
  62038. size: number;
  62039. /**
  62040. * Defines if mipmaps should not be generated (default is false)
  62041. */
  62042. noMipmap: boolean;
  62043. /**
  62044. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  62045. * but the standard material would require them in Gamma space) (default is true)
  62046. */
  62047. gammaSpace: boolean;
  62048. /**
  62049. * Gets the loaded texture
  62050. */
  62051. texture: EquiRectangularCubeTexture;
  62052. /**
  62053. * Callback called when the task is successful
  62054. */
  62055. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  62056. /**
  62057. * Callback called when the task is successful
  62058. */
  62059. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  62060. /**
  62061. * Creates a new EquiRectangularCubeTextureAssetTask object
  62062. * @param name defines the name of the task
  62063. * @param url defines the location of the file to load
  62064. * @param size defines the desired size (the more it increases the longer the generation will be)
  62065. * If the size is omitted this implies you are using a preprocessed cubemap.
  62066. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62067. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  62068. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  62069. * (default is true)
  62070. */
  62071. constructor(
  62072. /**
  62073. * Defines the name of the task
  62074. */
  62075. name: string,
  62076. /**
  62077. * Defines the location of the file to load
  62078. */
  62079. url: string,
  62080. /**
  62081. * Defines the desired size (the more it increases the longer the generation will be)
  62082. */
  62083. size: number,
  62084. /**
  62085. * Defines if mipmaps should not be generated (default is false)
  62086. */
  62087. noMipmap?: boolean,
  62088. /**
  62089. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  62090. * but the standard material would require them in Gamma space) (default is true)
  62091. */
  62092. gammaSpace?: boolean);
  62093. /**
  62094. * Execute the current task
  62095. * @param scene defines the scene where you want your assets to be loaded
  62096. * @param onSuccess is a callback called when the task is successfully executed
  62097. * @param onError is a callback called if an error occurs
  62098. */
  62099. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62100. }
  62101. /**
  62102. * This class can be used to easily import assets into a scene
  62103. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  62104. */
  62105. export class AssetsManager {
  62106. private _scene;
  62107. private _isLoading;
  62108. protected _tasks: AbstractAssetTask[];
  62109. protected _waitingTasksCount: number;
  62110. protected _totalTasksCount: number;
  62111. /**
  62112. * Callback called when all tasks are processed
  62113. */
  62114. onFinish: (tasks: AbstractAssetTask[]) => void;
  62115. /**
  62116. * Callback called when a task is successful
  62117. */
  62118. onTaskSuccess: (task: AbstractAssetTask) => void;
  62119. /**
  62120. * Callback called when a task had an error
  62121. */
  62122. onTaskError: (task: AbstractAssetTask) => void;
  62123. /**
  62124. * Callback called when a task is done (whatever the result is)
  62125. */
  62126. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  62127. /**
  62128. * Observable called when all tasks are processed
  62129. */
  62130. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  62131. /**
  62132. * Observable called when a task had an error
  62133. */
  62134. onTaskErrorObservable: Observable<AbstractAssetTask>;
  62135. /**
  62136. * Observable called when all tasks were executed
  62137. */
  62138. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  62139. /**
  62140. * Observable called when a task is done (whatever the result is)
  62141. */
  62142. onProgressObservable: Observable<IAssetsProgressEvent>;
  62143. /**
  62144. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  62145. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  62146. */
  62147. useDefaultLoadingScreen: boolean;
  62148. /**
  62149. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  62150. * when all assets have been downloaded.
  62151. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  62152. */
  62153. autoHideLoadingUI: boolean;
  62154. /**
  62155. * Creates a new AssetsManager
  62156. * @param scene defines the scene to work on
  62157. */
  62158. constructor(scene: Scene);
  62159. /**
  62160. * Add a MeshAssetTask to the list of active tasks
  62161. * @param taskName defines the name of the new task
  62162. * @param meshesNames defines the name of meshes to load
  62163. * @param rootUrl defines the root url to use to locate files
  62164. * @param sceneFilename defines the filename of the scene file
  62165. * @returns a new MeshAssetTask object
  62166. */
  62167. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  62168. /**
  62169. * Add a TextFileAssetTask to the list of active tasks
  62170. * @param taskName defines the name of the new task
  62171. * @param url defines the url of the file to load
  62172. * @returns a new TextFileAssetTask object
  62173. */
  62174. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  62175. /**
  62176. * Add a BinaryFileAssetTask to the list of active tasks
  62177. * @param taskName defines the name of the new task
  62178. * @param url defines the url of the file to load
  62179. * @returns a new BinaryFileAssetTask object
  62180. */
  62181. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  62182. /**
  62183. * Add a ImageAssetTask to the list of active tasks
  62184. * @param taskName defines the name of the new task
  62185. * @param url defines the url of the file to load
  62186. * @returns a new ImageAssetTask object
  62187. */
  62188. addImageTask(taskName: string, url: string): ImageAssetTask;
  62189. /**
  62190. * Add a TextureAssetTask to the list of active tasks
  62191. * @param taskName defines the name of the new task
  62192. * @param url defines the url of the file to load
  62193. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62194. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  62195. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62196. * @returns a new TextureAssetTask object
  62197. */
  62198. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  62199. /**
  62200. * Add a CubeTextureAssetTask to the list of active tasks
  62201. * @param taskName defines the name of the new task
  62202. * @param url defines the url of the file to load
  62203. * @param extensions defines the extension to use to load the cube map (can be null)
  62204. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62205. * @param files defines the list of files to load (can be null)
  62206. * @returns a new CubeTextureAssetTask object
  62207. */
  62208. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  62209. /**
  62210. *
  62211. * Add a HDRCubeTextureAssetTask to the list of active tasks
  62212. * @param taskName defines the name of the new task
  62213. * @param url defines the url of the file to load
  62214. * @param size defines the size you want for the cubemap (can be null)
  62215. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62216. * @param generateHarmonics defines if you want to automatically generate (true by default)
  62217. * @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)
  62218. * @param reserved Internal use only
  62219. * @returns a new HDRCubeTextureAssetTask object
  62220. */
  62221. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  62222. /**
  62223. *
  62224. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  62225. * @param taskName defines the name of the new task
  62226. * @param url defines the url of the file to load
  62227. * @param size defines the size you want for the cubemap (can be null)
  62228. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62229. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62230. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62231. * @returns a new EquiRectangularCubeTextureAssetTask object
  62232. */
  62233. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  62234. /**
  62235. * Remove a task from the assets manager.
  62236. * @param task the task to remove
  62237. */
  62238. removeTask(task: AbstractAssetTask): void;
  62239. private _decreaseWaitingTasksCount;
  62240. private _runTask;
  62241. /**
  62242. * Reset the AssetsManager and remove all tasks
  62243. * @return the current instance of the AssetsManager
  62244. */
  62245. reset(): AssetsManager;
  62246. /**
  62247. * Start the loading process
  62248. * @return the current instance of the AssetsManager
  62249. */
  62250. load(): AssetsManager;
  62251. /**
  62252. * Start the loading process as an async operation
  62253. * @return a promise returning the list of failed tasks
  62254. */
  62255. loadAsync(): Promise<void>;
  62256. }
  62257. }
  62258. declare module "babylonjs/Misc/deferred" {
  62259. /**
  62260. * Wrapper class for promise with external resolve and reject.
  62261. */
  62262. export class Deferred<T> {
  62263. /**
  62264. * The promise associated with this deferred object.
  62265. */
  62266. readonly promise: Promise<T>;
  62267. private _resolve;
  62268. private _reject;
  62269. /**
  62270. * The resolve method of the promise associated with this deferred object.
  62271. */
  62272. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  62273. /**
  62274. * The reject method of the promise associated with this deferred object.
  62275. */
  62276. readonly reject: (reason?: any) => void;
  62277. /**
  62278. * Constructor for this deferred object.
  62279. */
  62280. constructor();
  62281. }
  62282. }
  62283. declare module "babylonjs/Misc/meshExploder" {
  62284. import { Mesh } from "babylonjs/Meshes/mesh";
  62285. /**
  62286. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  62287. */
  62288. export class MeshExploder {
  62289. private _centerMesh;
  62290. private _meshes;
  62291. private _meshesOrigins;
  62292. private _toCenterVectors;
  62293. private _scaledDirection;
  62294. private _newPosition;
  62295. private _centerPosition;
  62296. /**
  62297. * Explodes meshes from a center mesh.
  62298. * @param meshes The meshes to explode.
  62299. * @param centerMesh The mesh to be center of explosion.
  62300. */
  62301. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  62302. private _setCenterMesh;
  62303. /**
  62304. * Get class name
  62305. * @returns "MeshExploder"
  62306. */
  62307. getClassName(): string;
  62308. /**
  62309. * "Exploded meshes"
  62310. * @returns Array of meshes with the centerMesh at index 0.
  62311. */
  62312. getMeshes(): Array<Mesh>;
  62313. /**
  62314. * Explodes meshes giving a specific direction
  62315. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  62316. */
  62317. explode(direction?: number): void;
  62318. }
  62319. }
  62320. declare module "babylonjs/Misc/filesInput" {
  62321. import { Engine } from "babylonjs/Engines/engine";
  62322. import { Scene } from "babylonjs/scene";
  62323. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  62324. /**
  62325. * Class used to help managing file picking and drag'n'drop
  62326. */
  62327. export class FilesInput {
  62328. /**
  62329. * List of files ready to be loaded
  62330. */
  62331. static readonly FilesToLoad: {
  62332. [key: string]: File;
  62333. };
  62334. /**
  62335. * Callback called when a file is processed
  62336. */
  62337. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  62338. private _engine;
  62339. private _currentScene;
  62340. private _sceneLoadedCallback;
  62341. private _progressCallback;
  62342. private _additionalRenderLoopLogicCallback;
  62343. private _textureLoadingCallback;
  62344. private _startingProcessingFilesCallback;
  62345. private _onReloadCallback;
  62346. private _errorCallback;
  62347. private _elementToMonitor;
  62348. private _sceneFileToLoad;
  62349. private _filesToLoad;
  62350. /**
  62351. * Creates a new FilesInput
  62352. * @param engine defines the rendering engine
  62353. * @param scene defines the hosting scene
  62354. * @param sceneLoadedCallback callback called when scene is loaded
  62355. * @param progressCallback callback called to track progress
  62356. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  62357. * @param textureLoadingCallback callback called when a texture is loading
  62358. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  62359. * @param onReloadCallback callback called when a reload is requested
  62360. * @param errorCallback callback call if an error occurs
  62361. */
  62362. 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);
  62363. private _dragEnterHandler;
  62364. private _dragOverHandler;
  62365. private _dropHandler;
  62366. /**
  62367. * Calls this function to listen to drag'n'drop events on a specific DOM element
  62368. * @param elementToMonitor defines the DOM element to track
  62369. */
  62370. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  62371. /**
  62372. * Release all associated resources
  62373. */
  62374. dispose(): void;
  62375. private renderFunction;
  62376. private drag;
  62377. private drop;
  62378. private _traverseFolder;
  62379. private _processFiles;
  62380. /**
  62381. * Load files from a drop event
  62382. * @param event defines the drop event to use as source
  62383. */
  62384. loadFiles(event: any): void;
  62385. private _processReload;
  62386. /**
  62387. * Reload the current scene from the loaded files
  62388. */
  62389. reload(): void;
  62390. }
  62391. }
  62392. declare module "babylonjs/Misc/HighDynamicRange/index" {
  62393. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  62394. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  62395. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  62396. }
  62397. declare module "babylonjs/Misc/sceneOptimizer" {
  62398. import { Scene, IDisposable } from "babylonjs/scene";
  62399. import { Observable } from "babylonjs/Misc/observable";
  62400. /**
  62401. * Defines the root class used to create scene optimization to use with SceneOptimizer
  62402. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62403. */
  62404. export class SceneOptimization {
  62405. /**
  62406. * Defines the priority of this optimization (0 by default which means first in the list)
  62407. */
  62408. priority: number;
  62409. /**
  62410. * Gets a string describing the action executed by the current optimization
  62411. * @returns description string
  62412. */
  62413. getDescription(): string;
  62414. /**
  62415. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62416. * @param scene defines the current scene where to apply this optimization
  62417. * @param optimizer defines the current optimizer
  62418. * @returns true if everything that can be done was applied
  62419. */
  62420. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62421. /**
  62422. * Creates the SceneOptimization object
  62423. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62424. * @param desc defines the description associated with the optimization
  62425. */
  62426. constructor(
  62427. /**
  62428. * Defines the priority of this optimization (0 by default which means first in the list)
  62429. */
  62430. priority?: number);
  62431. }
  62432. /**
  62433. * Defines an optimization used to reduce the size of render target textures
  62434. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62435. */
  62436. export class TextureOptimization extends SceneOptimization {
  62437. /**
  62438. * Defines the priority of this optimization (0 by default which means first in the list)
  62439. */
  62440. priority: number;
  62441. /**
  62442. * 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
  62443. */
  62444. maximumSize: number;
  62445. /**
  62446. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62447. */
  62448. step: number;
  62449. /**
  62450. * Gets a string describing the action executed by the current optimization
  62451. * @returns description string
  62452. */
  62453. getDescription(): string;
  62454. /**
  62455. * Creates the TextureOptimization object
  62456. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62457. * @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
  62458. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62459. */
  62460. constructor(
  62461. /**
  62462. * Defines the priority of this optimization (0 by default which means first in the list)
  62463. */
  62464. priority?: number,
  62465. /**
  62466. * 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
  62467. */
  62468. maximumSize?: number,
  62469. /**
  62470. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62471. */
  62472. step?: number);
  62473. /**
  62474. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62475. * @param scene defines the current scene where to apply this optimization
  62476. * @param optimizer defines the current optimizer
  62477. * @returns true if everything that can be done was applied
  62478. */
  62479. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62480. }
  62481. /**
  62482. * Defines an optimization used to increase or decrease the rendering resolution
  62483. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62484. */
  62485. export class HardwareScalingOptimization extends SceneOptimization {
  62486. /**
  62487. * Defines the priority of this optimization (0 by default which means first in the list)
  62488. */
  62489. priority: number;
  62490. /**
  62491. * Defines the maximum scale to use (2 by default)
  62492. */
  62493. maximumScale: number;
  62494. /**
  62495. * Defines the step to use between two passes (0.5 by default)
  62496. */
  62497. step: number;
  62498. private _currentScale;
  62499. private _directionOffset;
  62500. /**
  62501. * Gets a string describing the action executed by the current optimization
  62502. * @return description string
  62503. */
  62504. getDescription(): string;
  62505. /**
  62506. * Creates the HardwareScalingOptimization object
  62507. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62508. * @param maximumScale defines the maximum scale to use (2 by default)
  62509. * @param step defines the step to use between two passes (0.5 by default)
  62510. */
  62511. constructor(
  62512. /**
  62513. * Defines the priority of this optimization (0 by default which means first in the list)
  62514. */
  62515. priority?: number,
  62516. /**
  62517. * Defines the maximum scale to use (2 by default)
  62518. */
  62519. maximumScale?: number,
  62520. /**
  62521. * Defines the step to use between two passes (0.5 by default)
  62522. */
  62523. step?: number);
  62524. /**
  62525. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62526. * @param scene defines the current scene where to apply this optimization
  62527. * @param optimizer defines the current optimizer
  62528. * @returns true if everything that can be done was applied
  62529. */
  62530. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62531. }
  62532. /**
  62533. * Defines an optimization used to remove shadows
  62534. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62535. */
  62536. export class ShadowsOptimization extends SceneOptimization {
  62537. /**
  62538. * Gets a string describing the action executed by the current optimization
  62539. * @return description string
  62540. */
  62541. getDescription(): string;
  62542. /**
  62543. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62544. * @param scene defines the current scene where to apply this optimization
  62545. * @param optimizer defines the current optimizer
  62546. * @returns true if everything that can be done was applied
  62547. */
  62548. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62549. }
  62550. /**
  62551. * Defines an optimization used to turn post-processes off
  62552. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62553. */
  62554. export class PostProcessesOptimization extends SceneOptimization {
  62555. /**
  62556. * Gets a string describing the action executed by the current optimization
  62557. * @return description string
  62558. */
  62559. getDescription(): string;
  62560. /**
  62561. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62562. * @param scene defines the current scene where to apply this optimization
  62563. * @param optimizer defines the current optimizer
  62564. * @returns true if everything that can be done was applied
  62565. */
  62566. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62567. }
  62568. /**
  62569. * Defines an optimization used to turn lens flares off
  62570. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62571. */
  62572. export class LensFlaresOptimization extends SceneOptimization {
  62573. /**
  62574. * Gets a string describing the action executed by the current optimization
  62575. * @return description string
  62576. */
  62577. getDescription(): string;
  62578. /**
  62579. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62580. * @param scene defines the current scene where to apply this optimization
  62581. * @param optimizer defines the current optimizer
  62582. * @returns true if everything that can be done was applied
  62583. */
  62584. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62585. }
  62586. /**
  62587. * Defines an optimization based on user defined callback.
  62588. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62589. */
  62590. export class CustomOptimization extends SceneOptimization {
  62591. /**
  62592. * Callback called to apply the custom optimization.
  62593. */
  62594. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  62595. /**
  62596. * Callback called to get custom description
  62597. */
  62598. onGetDescription: () => string;
  62599. /**
  62600. * Gets a string describing the action executed by the current optimization
  62601. * @returns description string
  62602. */
  62603. getDescription(): string;
  62604. /**
  62605. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62606. * @param scene defines the current scene where to apply this optimization
  62607. * @param optimizer defines the current optimizer
  62608. * @returns true if everything that can be done was applied
  62609. */
  62610. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62611. }
  62612. /**
  62613. * Defines an optimization used to turn particles off
  62614. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62615. */
  62616. export class ParticlesOptimization extends SceneOptimization {
  62617. /**
  62618. * Gets a string describing the action executed by the current optimization
  62619. * @return description string
  62620. */
  62621. getDescription(): string;
  62622. /**
  62623. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62624. * @param scene defines the current scene where to apply this optimization
  62625. * @param optimizer defines the current optimizer
  62626. * @returns true if everything that can be done was applied
  62627. */
  62628. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62629. }
  62630. /**
  62631. * Defines an optimization used to turn render targets off
  62632. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62633. */
  62634. export class RenderTargetsOptimization extends SceneOptimization {
  62635. /**
  62636. * Gets a string describing the action executed by the current optimization
  62637. * @return description string
  62638. */
  62639. getDescription(): string;
  62640. /**
  62641. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62642. * @param scene defines the current scene where to apply this optimization
  62643. * @param optimizer defines the current optimizer
  62644. * @returns true if everything that can be done was applied
  62645. */
  62646. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62647. }
  62648. /**
  62649. * Defines an optimization used to merge meshes with compatible materials
  62650. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62651. */
  62652. export class MergeMeshesOptimization extends SceneOptimization {
  62653. private static _UpdateSelectionTree;
  62654. /**
  62655. * Gets or sets a boolean which defines if optimization octree has to be updated
  62656. */
  62657. /**
  62658. * Gets or sets a boolean which defines if optimization octree has to be updated
  62659. */
  62660. static UpdateSelectionTree: boolean;
  62661. /**
  62662. * Gets a string describing the action executed by the current optimization
  62663. * @return description string
  62664. */
  62665. getDescription(): string;
  62666. private _canBeMerged;
  62667. /**
  62668. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62669. * @param scene defines the current scene where to apply this optimization
  62670. * @param optimizer defines the current optimizer
  62671. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  62672. * @returns true if everything that can be done was applied
  62673. */
  62674. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  62675. }
  62676. /**
  62677. * Defines a list of options used by SceneOptimizer
  62678. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62679. */
  62680. export class SceneOptimizerOptions {
  62681. /**
  62682. * Defines the target frame rate to reach (60 by default)
  62683. */
  62684. targetFrameRate: number;
  62685. /**
  62686. * Defines the interval between two checkes (2000ms by default)
  62687. */
  62688. trackerDuration: number;
  62689. /**
  62690. * Gets the list of optimizations to apply
  62691. */
  62692. optimizations: SceneOptimization[];
  62693. /**
  62694. * Creates a new list of options used by SceneOptimizer
  62695. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  62696. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  62697. */
  62698. constructor(
  62699. /**
  62700. * Defines the target frame rate to reach (60 by default)
  62701. */
  62702. targetFrameRate?: number,
  62703. /**
  62704. * Defines the interval between two checkes (2000ms by default)
  62705. */
  62706. trackerDuration?: number);
  62707. /**
  62708. * Add a new optimization
  62709. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  62710. * @returns the current SceneOptimizerOptions
  62711. */
  62712. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  62713. /**
  62714. * Add a new custom optimization
  62715. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  62716. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  62717. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62718. * @returns the current SceneOptimizerOptions
  62719. */
  62720. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  62721. /**
  62722. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  62723. * @param targetFrameRate defines the target frame rate (60 by default)
  62724. * @returns a SceneOptimizerOptions object
  62725. */
  62726. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62727. /**
  62728. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  62729. * @param targetFrameRate defines the target frame rate (60 by default)
  62730. * @returns a SceneOptimizerOptions object
  62731. */
  62732. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62733. /**
  62734. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  62735. * @param targetFrameRate defines the target frame rate (60 by default)
  62736. * @returns a SceneOptimizerOptions object
  62737. */
  62738. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62739. }
  62740. /**
  62741. * Class used to run optimizations in order to reach a target frame rate
  62742. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62743. */
  62744. export class SceneOptimizer implements IDisposable {
  62745. private _isRunning;
  62746. private _options;
  62747. private _scene;
  62748. private _currentPriorityLevel;
  62749. private _targetFrameRate;
  62750. private _trackerDuration;
  62751. private _currentFrameRate;
  62752. private _sceneDisposeObserver;
  62753. private _improvementMode;
  62754. /**
  62755. * Defines an observable called when the optimizer reaches the target frame rate
  62756. */
  62757. onSuccessObservable: Observable<SceneOptimizer>;
  62758. /**
  62759. * Defines an observable called when the optimizer enables an optimization
  62760. */
  62761. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  62762. /**
  62763. * Defines an observable called when the optimizer is not able to reach the target frame rate
  62764. */
  62765. onFailureObservable: Observable<SceneOptimizer>;
  62766. /**
  62767. * Gets a boolean indicating if the optimizer is in improvement mode
  62768. */
  62769. readonly isInImprovementMode: boolean;
  62770. /**
  62771. * Gets the current priority level (0 at start)
  62772. */
  62773. readonly currentPriorityLevel: number;
  62774. /**
  62775. * Gets the current frame rate checked by the SceneOptimizer
  62776. */
  62777. readonly currentFrameRate: number;
  62778. /**
  62779. * Gets or sets the current target frame rate (60 by default)
  62780. */
  62781. /**
  62782. * Gets or sets the current target frame rate (60 by default)
  62783. */
  62784. targetFrameRate: number;
  62785. /**
  62786. * Gets or sets the current interval between two checks (every 2000ms by default)
  62787. */
  62788. /**
  62789. * Gets or sets the current interval between two checks (every 2000ms by default)
  62790. */
  62791. trackerDuration: number;
  62792. /**
  62793. * Gets the list of active optimizations
  62794. */
  62795. readonly optimizations: SceneOptimization[];
  62796. /**
  62797. * Creates a new SceneOptimizer
  62798. * @param scene defines the scene to work on
  62799. * @param options defines the options to use with the SceneOptimizer
  62800. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  62801. * @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)
  62802. */
  62803. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  62804. /**
  62805. * Stops the current optimizer
  62806. */
  62807. stop(): void;
  62808. /**
  62809. * Reset the optimizer to initial step (current priority level = 0)
  62810. */
  62811. reset(): void;
  62812. /**
  62813. * Start the optimizer. By default it will try to reach a specific framerate
  62814. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  62815. */
  62816. start(): void;
  62817. private _checkCurrentState;
  62818. /**
  62819. * Release all resources
  62820. */
  62821. dispose(): void;
  62822. /**
  62823. * Helper function to create a SceneOptimizer with one single line of code
  62824. * @param scene defines the scene to work on
  62825. * @param options defines the options to use with the SceneOptimizer
  62826. * @param onSuccess defines a callback to call on success
  62827. * @param onFailure defines a callback to call on failure
  62828. * @returns the new SceneOptimizer object
  62829. */
  62830. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  62831. }
  62832. }
  62833. declare module "babylonjs/Misc/sceneSerializer" {
  62834. import { Scene } from "babylonjs/scene";
  62835. /**
  62836. * Class used to serialize a scene into a string
  62837. */
  62838. export class SceneSerializer {
  62839. /**
  62840. * Clear cache used by a previous serialization
  62841. */
  62842. static ClearCache(): void;
  62843. /**
  62844. * Serialize a scene into a JSON compatible object
  62845. * @param scene defines the scene to serialize
  62846. * @returns a JSON compatible object
  62847. */
  62848. static Serialize(scene: Scene): any;
  62849. /**
  62850. * Serialize a mesh into a JSON compatible object
  62851. * @param toSerialize defines the mesh to serialize
  62852. * @param withParents defines if parents must be serialized as well
  62853. * @param withChildren defines if children must be serialized as well
  62854. * @returns a JSON compatible object
  62855. */
  62856. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  62857. }
  62858. }
  62859. declare module "babylonjs/Misc/textureTools" {
  62860. import { Texture } from "babylonjs/Materials/Textures/texture";
  62861. /**
  62862. * Class used to host texture specific utilities
  62863. */
  62864. export class TextureTools {
  62865. /**
  62866. * Uses the GPU to create a copy texture rescaled at a given size
  62867. * @param texture Texture to copy from
  62868. * @param width defines the desired width
  62869. * @param height defines the desired height
  62870. * @param useBilinearMode defines if bilinear mode has to be used
  62871. * @return the generated texture
  62872. */
  62873. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  62874. }
  62875. }
  62876. declare module "babylonjs/Misc/videoRecorder" {
  62877. import { Nullable } from "babylonjs/types";
  62878. import { Engine } from "babylonjs/Engines/engine";
  62879. /**
  62880. * This represents the different options available for the video capture.
  62881. */
  62882. export interface VideoRecorderOptions {
  62883. /** Defines the mime type of the video. */
  62884. mimeType: string;
  62885. /** Defines the FPS the video should be recorded at. */
  62886. fps: number;
  62887. /** Defines the chunk size for the recording data. */
  62888. recordChunckSize: number;
  62889. /** The audio tracks to attach to the recording. */
  62890. audioTracks?: MediaStreamTrack[];
  62891. }
  62892. /**
  62893. * This can help with recording videos from BabylonJS.
  62894. * This is based on the available WebRTC functionalities of the browser.
  62895. *
  62896. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  62897. */
  62898. export class VideoRecorder {
  62899. private static readonly _defaultOptions;
  62900. /**
  62901. * Returns whether or not the VideoRecorder is available in your browser.
  62902. * @param engine Defines the Babylon Engine.
  62903. * @returns true if supported otherwise false.
  62904. */
  62905. static IsSupported(engine: Engine): boolean;
  62906. private readonly _options;
  62907. private _canvas;
  62908. private _mediaRecorder;
  62909. private _recordedChunks;
  62910. private _fileName;
  62911. private _resolve;
  62912. private _reject;
  62913. /**
  62914. * True when a recording is already in progress.
  62915. */
  62916. readonly isRecording: boolean;
  62917. /**
  62918. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  62919. * @param engine Defines the BabylonJS Engine you wish to record.
  62920. * @param options Defines options that can be used to customize the capture.
  62921. */
  62922. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  62923. /**
  62924. * Stops the current recording before the default capture timeout passed in the startRecording function.
  62925. */
  62926. stopRecording(): void;
  62927. /**
  62928. * Starts recording the canvas for a max duration specified in parameters.
  62929. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  62930. * If null no automatic download will start and you can rely on the promise to get the data back.
  62931. * @param maxDuration Defines the maximum recording time in seconds.
  62932. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  62933. * @return A promise callback at the end of the recording with the video data in Blob.
  62934. */
  62935. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  62936. /**
  62937. * Releases internal resources used during the recording.
  62938. */
  62939. dispose(): void;
  62940. private _handleDataAvailable;
  62941. private _handleError;
  62942. private _handleStop;
  62943. }
  62944. }
  62945. declare module "babylonjs/Misc/screenshotTools" {
  62946. import { Camera } from "babylonjs/Cameras/camera";
  62947. import { Engine } from "babylonjs/Engines/engine";
  62948. /**
  62949. * Class containing a set of static utilities functions for screenshots
  62950. */
  62951. export class ScreenshotTools {
  62952. /**
  62953. * Captures a screenshot of the current rendering
  62954. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62955. * @param engine defines the rendering engine
  62956. * @param camera defines the source camera
  62957. * @param size This parameter can be set to a single number or to an object with the
  62958. * following (optional) properties: precision, width, height. If a single number is passed,
  62959. * it will be used for both width and height. If an object is passed, the screenshot size
  62960. * will be derived from the parameters. The precision property is a multiplier allowing
  62961. * rendering at a higher or lower resolution
  62962. * @param successCallback defines the callback receives a single parameter which contains the
  62963. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62964. * src parameter of an <img> to display it
  62965. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  62966. * Check your browser for supported MIME types
  62967. */
  62968. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  62969. /**
  62970. * Generates an image screenshot from the specified camera.
  62971. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62972. * @param engine The engine to use for rendering
  62973. * @param camera The camera to use for rendering
  62974. * @param size This parameter can be set to a single number or to an object with the
  62975. * following (optional) properties: precision, width, height. If a single number is passed,
  62976. * it will be used for both width and height. If an object is passed, the screenshot size
  62977. * will be derived from the parameters. The precision property is a multiplier allowing
  62978. * rendering at a higher or lower resolution
  62979. * @param successCallback The callback receives a single parameter which contains the
  62980. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62981. * src parameter of an <img> to display it
  62982. * @param mimeType The MIME type of the screenshot image (default: image/png).
  62983. * Check your browser for supported MIME types
  62984. * @param samples Texture samples (default: 1)
  62985. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  62986. * @param fileName A name for for the downloaded file.
  62987. */
  62988. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  62989. }
  62990. }
  62991. declare module "babylonjs/Misc/index" {
  62992. export * from "babylonjs/Misc/andOrNotEvaluator";
  62993. export * from "babylonjs/Misc/assetsManager";
  62994. export * from "babylonjs/Misc/dds";
  62995. export * from "babylonjs/Misc/decorators";
  62996. export * from "babylonjs/Misc/deferred";
  62997. export * from "babylonjs/Misc/environmentTextureTools";
  62998. export * from "babylonjs/Misc/meshExploder";
  62999. export * from "babylonjs/Misc/filesInput";
  63000. export * from "babylonjs/Misc/HighDynamicRange/index";
  63001. export * from "babylonjs/Misc/khronosTextureContainer";
  63002. export * from "babylonjs/Misc/observable";
  63003. export * from "babylonjs/Misc/performanceMonitor";
  63004. export * from "babylonjs/Misc/promise";
  63005. export * from "babylonjs/Misc/sceneOptimizer";
  63006. export * from "babylonjs/Misc/sceneSerializer";
  63007. export * from "babylonjs/Misc/smartArray";
  63008. export * from "babylonjs/Misc/stringDictionary";
  63009. export * from "babylonjs/Misc/tags";
  63010. export * from "babylonjs/Misc/textureTools";
  63011. export * from "babylonjs/Misc/tga";
  63012. export * from "babylonjs/Misc/tools";
  63013. export * from "babylonjs/Misc/videoRecorder";
  63014. export * from "babylonjs/Misc/virtualJoystick";
  63015. export * from "babylonjs/Misc/workerPool";
  63016. export * from "babylonjs/Misc/logger";
  63017. export * from "babylonjs/Misc/typeStore";
  63018. export * from "babylonjs/Misc/filesInputStore";
  63019. export * from "babylonjs/Misc/deepCopier";
  63020. export * from "babylonjs/Misc/pivotTools";
  63021. export * from "babylonjs/Misc/precisionDate";
  63022. export * from "babylonjs/Misc/screenshotTools";
  63023. export * from "babylonjs/Misc/typeStore";
  63024. export * from "babylonjs/Misc/webRequest";
  63025. export * from "babylonjs/Misc/iInspectable";
  63026. export * from "babylonjs/Misc/brdfTextureTools";
  63027. export * from "babylonjs/Misc/gradients";
  63028. export * from "babylonjs/Misc/perfCounter";
  63029. export * from "babylonjs/Misc/fileRequest";
  63030. export * from "babylonjs/Misc/customAnimationFrameRequester";
  63031. export * from "babylonjs/Misc/retryStrategy";
  63032. export * from "babylonjs/Misc/loadFileError";
  63033. }
  63034. declare module "babylonjs/index" {
  63035. export * from "babylonjs/abstractScene";
  63036. export * from "babylonjs/Actions/index";
  63037. export * from "babylonjs/Animations/index";
  63038. export * from "babylonjs/assetContainer";
  63039. export * from "babylonjs/Audio/index";
  63040. export * from "babylonjs/Behaviors/index";
  63041. export * from "babylonjs/Bones/index";
  63042. export * from "babylonjs/Cameras/index";
  63043. export * from "babylonjs/Collisions/index";
  63044. export * from "babylonjs/Culling/index";
  63045. export * from "babylonjs/Debug/index";
  63046. export * from "babylonjs/Engines/index";
  63047. export * from "babylonjs/Events/index";
  63048. export * from "babylonjs/Gamepads/index";
  63049. export * from "babylonjs/Gizmos/index";
  63050. export * from "babylonjs/Helpers/index";
  63051. export * from "babylonjs/Instrumentation/index";
  63052. export * from "babylonjs/Layers/index";
  63053. export * from "babylonjs/LensFlares/index";
  63054. export * from "babylonjs/Lights/index";
  63055. export * from "babylonjs/Loading/index";
  63056. export * from "babylonjs/Materials/index";
  63057. export * from "babylonjs/Maths/index";
  63058. export * from "babylonjs/Meshes/index";
  63059. export * from "babylonjs/Morph/index";
  63060. export * from "babylonjs/node";
  63061. export * from "babylonjs/Offline/index";
  63062. export * from "babylonjs/Particles/index";
  63063. export * from "babylonjs/Physics/index";
  63064. export * from "babylonjs/PostProcesses/index";
  63065. export * from "babylonjs/Probes/index";
  63066. export * from "babylonjs/Rendering/index";
  63067. export * from "babylonjs/scene";
  63068. export * from "babylonjs/sceneComponent";
  63069. export * from "babylonjs/Sprites/index";
  63070. export * from "babylonjs/States/index";
  63071. export * from "babylonjs/Misc/index";
  63072. export * from "babylonjs/types";
  63073. }
  63074. declare module "babylonjs/Animations/pathCursor" {
  63075. import { Vector3 } from "babylonjs/Maths/math.vector";
  63076. import { Path2 } from "babylonjs/Maths/math.path";
  63077. /**
  63078. * A cursor which tracks a point on a path
  63079. */
  63080. export class PathCursor {
  63081. private path;
  63082. /**
  63083. * Stores path cursor callbacks for when an onchange event is triggered
  63084. */
  63085. private _onchange;
  63086. /**
  63087. * The value of the path cursor
  63088. */
  63089. value: number;
  63090. /**
  63091. * The animation array of the path cursor
  63092. */
  63093. animations: Animation[];
  63094. /**
  63095. * Initializes the path cursor
  63096. * @param path The path to track
  63097. */
  63098. constructor(path: Path2);
  63099. /**
  63100. * Gets the cursor point on the path
  63101. * @returns A point on the path cursor at the cursor location
  63102. */
  63103. getPoint(): Vector3;
  63104. /**
  63105. * Moves the cursor ahead by the step amount
  63106. * @param step The amount to move the cursor forward
  63107. * @returns This path cursor
  63108. */
  63109. moveAhead(step?: number): PathCursor;
  63110. /**
  63111. * Moves the cursor behind by the step amount
  63112. * @param step The amount to move the cursor back
  63113. * @returns This path cursor
  63114. */
  63115. moveBack(step?: number): PathCursor;
  63116. /**
  63117. * Moves the cursor by the step amount
  63118. * If the step amount is greater than one, an exception is thrown
  63119. * @param step The amount to move the cursor
  63120. * @returns This path cursor
  63121. */
  63122. move(step: number): PathCursor;
  63123. /**
  63124. * Ensures that the value is limited between zero and one
  63125. * @returns This path cursor
  63126. */
  63127. private ensureLimits;
  63128. /**
  63129. * Runs onchange callbacks on change (used by the animation engine)
  63130. * @returns This path cursor
  63131. */
  63132. private raiseOnChange;
  63133. /**
  63134. * Executes a function on change
  63135. * @param f A path cursor onchange callback
  63136. * @returns This path cursor
  63137. */
  63138. onchange(f: (cursor: PathCursor) => void): PathCursor;
  63139. }
  63140. }
  63141. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  63142. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  63143. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  63144. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  63145. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  63146. }
  63147. declare module "babylonjs/Engines/Processors/Expressions/index" {
  63148. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  63149. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  63150. }
  63151. declare module "babylonjs/Engines/Processors/index" {
  63152. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  63153. export * from "babylonjs/Engines/Processors/Expressions/index";
  63154. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  63155. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  63156. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  63157. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  63158. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  63159. export * from "babylonjs/Engines/Processors/shaderProcessor";
  63160. }
  63161. declare module "babylonjs/Legacy/legacy" {
  63162. import * as Babylon from "babylonjs/index";
  63163. export * from "babylonjs/index";
  63164. }
  63165. declare module "babylonjs/Shaders/blur.fragment" {
  63166. /** @hidden */
  63167. export var blurPixelShader: {
  63168. name: string;
  63169. shader: string;
  63170. };
  63171. }
  63172. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  63173. /** @hidden */
  63174. export var pointCloudVertexDeclaration: {
  63175. name: string;
  63176. shader: string;
  63177. };
  63178. }
  63179. declare module "babylonjs" {
  63180. export * from "babylonjs/Legacy/legacy";
  63181. }
  63182. declare module BABYLON {
  63183. /** Alias type for value that can be null */
  63184. export type Nullable<T> = T | null;
  63185. /**
  63186. * Alias type for number that are floats
  63187. * @ignorenaming
  63188. */
  63189. export type float = number;
  63190. /**
  63191. * Alias type for number that are doubles.
  63192. * @ignorenaming
  63193. */
  63194. export type double = number;
  63195. /**
  63196. * Alias type for number that are integer
  63197. * @ignorenaming
  63198. */
  63199. export type int = number;
  63200. /** Alias type for number array or Float32Array */
  63201. export type FloatArray = number[] | Float32Array;
  63202. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  63203. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  63204. /**
  63205. * Alias for types that can be used by a Buffer or VertexBuffer.
  63206. */
  63207. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  63208. /**
  63209. * Alias type for primitive types
  63210. * @ignorenaming
  63211. */
  63212. type Primitive = undefined | null | boolean | string | number | Function;
  63213. /**
  63214. * Type modifier to make all the properties of an object Readonly
  63215. */
  63216. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  63217. /**
  63218. * Type modifier to make all the properties of an object Readonly recursively
  63219. */
  63220. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  63221. /** @hidden */
  63222. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  63223. }
  63224. /** @hidden */
  63225. /** @hidden */
  63226. type DeepImmutableObject<T> = {
  63227. readonly [K in keyof T]: DeepImmutable<T[K]>;
  63228. };
  63229. }
  63230. declare module BABYLON {
  63231. /**
  63232. * A class serves as a medium between the observable and its observers
  63233. */
  63234. export class EventState {
  63235. /**
  63236. * Create a new EventState
  63237. * @param mask defines the mask associated with this state
  63238. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  63239. * @param target defines the original target of the state
  63240. * @param currentTarget defines the current target of the state
  63241. */
  63242. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63243. /**
  63244. * Initialize the current event state
  63245. * @param mask defines the mask associated with this state
  63246. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  63247. * @param target defines the original target of the state
  63248. * @param currentTarget defines the current target of the state
  63249. * @returns the current event state
  63250. */
  63251. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  63252. /**
  63253. * An Observer can set this property to true to prevent subsequent observers of being notified
  63254. */
  63255. skipNextObservers: boolean;
  63256. /**
  63257. * Get the mask value that were used to trigger the event corresponding to this EventState object
  63258. */
  63259. mask: number;
  63260. /**
  63261. * The object that originally notified the event
  63262. */
  63263. target?: any;
  63264. /**
  63265. * The current object in the bubbling phase
  63266. */
  63267. currentTarget?: any;
  63268. /**
  63269. * This will be populated with the return value of the last function that was executed.
  63270. * If it is the first function in the callback chain it will be the event data.
  63271. */
  63272. lastReturnValue?: any;
  63273. }
  63274. /**
  63275. * Represent an Observer registered to a given Observable object.
  63276. */
  63277. export class Observer<T> {
  63278. /**
  63279. * Defines the callback to call when the observer is notified
  63280. */
  63281. callback: (eventData: T, eventState: EventState) => void;
  63282. /**
  63283. * Defines the mask of the observer (used to filter notifications)
  63284. */
  63285. mask: number;
  63286. /**
  63287. * Defines the current scope used to restore the JS context
  63288. */
  63289. scope: any;
  63290. /** @hidden */
  63291. _willBeUnregistered: boolean;
  63292. /**
  63293. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  63294. */
  63295. unregisterOnNextCall: boolean;
  63296. /**
  63297. * Creates a new observer
  63298. * @param callback defines the callback to call when the observer is notified
  63299. * @param mask defines the mask of the observer (used to filter notifications)
  63300. * @param scope defines the current scope used to restore the JS context
  63301. */
  63302. constructor(
  63303. /**
  63304. * Defines the callback to call when the observer is notified
  63305. */
  63306. callback: (eventData: T, eventState: EventState) => void,
  63307. /**
  63308. * Defines the mask of the observer (used to filter notifications)
  63309. */
  63310. mask: number,
  63311. /**
  63312. * Defines the current scope used to restore the JS context
  63313. */
  63314. scope?: any);
  63315. }
  63316. /**
  63317. * Represent a list of observers registered to multiple Observables object.
  63318. */
  63319. export class MultiObserver<T> {
  63320. private _observers;
  63321. private _observables;
  63322. /**
  63323. * Release associated resources
  63324. */
  63325. dispose(): void;
  63326. /**
  63327. * Raise a callback when one of the observable will notify
  63328. * @param observables defines a list of observables to watch
  63329. * @param callback defines the callback to call on notification
  63330. * @param mask defines the mask used to filter notifications
  63331. * @param scope defines the current scope used to restore the JS context
  63332. * @returns the new MultiObserver
  63333. */
  63334. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  63335. }
  63336. /**
  63337. * The Observable class is a simple implementation of the Observable pattern.
  63338. *
  63339. * 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.
  63340. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  63341. * 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).
  63342. * 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.
  63343. */
  63344. export class Observable<T> {
  63345. private _observers;
  63346. private _eventState;
  63347. private _onObserverAdded;
  63348. /**
  63349. * Gets the list of observers
  63350. */
  63351. readonly observers: Array<Observer<T>>;
  63352. /**
  63353. * Creates a new observable
  63354. * @param onObserverAdded defines a callback to call when a new observer is added
  63355. */
  63356. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  63357. /**
  63358. * Create a new Observer with the specified callback
  63359. * @param callback the callback that will be executed for that Observer
  63360. * @param mask the mask used to filter observers
  63361. * @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.
  63362. * @param scope optional scope for the callback to be called from
  63363. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  63364. * @returns the new observer created for the callback
  63365. */
  63366. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  63367. /**
  63368. * Create a new Observer with the specified callback and unregisters after the next notification
  63369. * @param callback the callback that will be executed for that Observer
  63370. * @returns the new observer created for the callback
  63371. */
  63372. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  63373. /**
  63374. * Remove an Observer from the Observable object
  63375. * @param observer the instance of the Observer to remove
  63376. * @returns false if it doesn't belong to this Observable
  63377. */
  63378. remove(observer: Nullable<Observer<T>>): boolean;
  63379. /**
  63380. * Remove a callback from the Observable object
  63381. * @param callback the callback to remove
  63382. * @param scope optional scope. If used only the callbacks with this scope will be removed
  63383. * @returns false if it doesn't belong to this Observable
  63384. */
  63385. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  63386. private _deferUnregister;
  63387. private _remove;
  63388. /**
  63389. * Moves the observable to the top of the observer list making it get called first when notified
  63390. * @param observer the observer to move
  63391. */
  63392. makeObserverTopPriority(observer: Observer<T>): void;
  63393. /**
  63394. * Moves the observable to the bottom of the observer list making it get called last when notified
  63395. * @param observer the observer to move
  63396. */
  63397. makeObserverBottomPriority(observer: Observer<T>): void;
  63398. /**
  63399. * Notify all Observers by calling their respective callback with the given data
  63400. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  63401. * @param eventData defines the data to send to all observers
  63402. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  63403. * @param target defines the original target of the state
  63404. * @param currentTarget defines the current target of the state
  63405. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  63406. */
  63407. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  63408. /**
  63409. * Calling this will execute each callback, expecting it to be a promise or return a value.
  63410. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  63411. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  63412. * and it is crucial that all callbacks will be executed.
  63413. * The order of the callbacks is kept, callbacks are not executed parallel.
  63414. *
  63415. * @param eventData The data to be sent to each callback
  63416. * @param mask is used to filter observers defaults to -1
  63417. * @param target defines the callback target (see EventState)
  63418. * @param currentTarget defines he current object in the bubbling phase
  63419. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  63420. */
  63421. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  63422. /**
  63423. * Notify a specific observer
  63424. * @param observer defines the observer to notify
  63425. * @param eventData defines the data to be sent to each callback
  63426. * @param mask is used to filter observers defaults to -1
  63427. */
  63428. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  63429. /**
  63430. * Gets a boolean indicating if the observable has at least one observer
  63431. * @returns true is the Observable has at least one Observer registered
  63432. */
  63433. hasObservers(): boolean;
  63434. /**
  63435. * Clear the list of observers
  63436. */
  63437. clear(): void;
  63438. /**
  63439. * Clone the current observable
  63440. * @returns a new observable
  63441. */
  63442. clone(): Observable<T>;
  63443. /**
  63444. * Does this observable handles observer registered with a given mask
  63445. * @param mask defines the mask to be tested
  63446. * @return whether or not one observer registered with the given mask is handeled
  63447. **/
  63448. hasSpecificMask(mask?: number): boolean;
  63449. }
  63450. }
  63451. declare module BABYLON {
  63452. /**
  63453. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  63454. * Babylon.js
  63455. */
  63456. export class DomManagement {
  63457. /**
  63458. * Checks if the window object exists
  63459. * @returns true if the window object exists
  63460. */
  63461. static IsWindowObjectExist(): boolean;
  63462. /**
  63463. * Extracts text content from a DOM element hierarchy
  63464. * @param element defines the root element
  63465. * @returns a string
  63466. */
  63467. static GetDOMTextContent(element: HTMLElement): string;
  63468. }
  63469. }
  63470. declare module BABYLON {
  63471. /**
  63472. * Logger used througouht the application to allow configuration of
  63473. * the log level required for the messages.
  63474. */
  63475. export class Logger {
  63476. /**
  63477. * No log
  63478. */
  63479. static readonly NoneLogLevel: number;
  63480. /**
  63481. * Only message logs
  63482. */
  63483. static readonly MessageLogLevel: number;
  63484. /**
  63485. * Only warning logs
  63486. */
  63487. static readonly WarningLogLevel: number;
  63488. /**
  63489. * Only error logs
  63490. */
  63491. static readonly ErrorLogLevel: number;
  63492. /**
  63493. * All logs
  63494. */
  63495. static readonly AllLogLevel: number;
  63496. private static _LogCache;
  63497. /**
  63498. * Gets a value indicating the number of loading errors
  63499. * @ignorenaming
  63500. */
  63501. static errorsCount: number;
  63502. /**
  63503. * Callback called when a new log is added
  63504. */
  63505. static OnNewCacheEntry: (entry: string) => void;
  63506. private static _AddLogEntry;
  63507. private static _FormatMessage;
  63508. private static _LogDisabled;
  63509. private static _LogEnabled;
  63510. private static _WarnDisabled;
  63511. private static _WarnEnabled;
  63512. private static _ErrorDisabled;
  63513. private static _ErrorEnabled;
  63514. /**
  63515. * Log a message to the console
  63516. */
  63517. static Log: (message: string) => void;
  63518. /**
  63519. * Write a warning message to the console
  63520. */
  63521. static Warn: (message: string) => void;
  63522. /**
  63523. * Write an error message to the console
  63524. */
  63525. static Error: (message: string) => void;
  63526. /**
  63527. * Gets current log cache (list of logs)
  63528. */
  63529. static readonly LogCache: string;
  63530. /**
  63531. * Clears the log cache
  63532. */
  63533. static ClearLogCache(): void;
  63534. /**
  63535. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  63536. */
  63537. static LogLevels: number;
  63538. }
  63539. }
  63540. declare module BABYLON {
  63541. /** @hidden */
  63542. export class _TypeStore {
  63543. /** @hidden */
  63544. static RegisteredTypes: {
  63545. [key: string]: Object;
  63546. };
  63547. /** @hidden */
  63548. static GetClass(fqdn: string): any;
  63549. }
  63550. }
  63551. declare module BABYLON {
  63552. /**
  63553. * Class containing a set of static utilities functions for deep copy.
  63554. */
  63555. export class DeepCopier {
  63556. /**
  63557. * Tries to copy an object by duplicating every property
  63558. * @param source defines the source object
  63559. * @param destination defines the target object
  63560. * @param doNotCopyList defines a list of properties to avoid
  63561. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  63562. */
  63563. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  63564. }
  63565. }
  63566. declare module BABYLON {
  63567. /**
  63568. * Class containing a set of static utilities functions for precision date
  63569. */
  63570. export class PrecisionDate {
  63571. /**
  63572. * Gets either window.performance.now() if supported or Date.now() else
  63573. */
  63574. static readonly Now: number;
  63575. }
  63576. }
  63577. declare module BABYLON {
  63578. /** @hidden */
  63579. export class _DevTools {
  63580. static WarnImport(name: string): string;
  63581. }
  63582. }
  63583. declare module BABYLON {
  63584. /**
  63585. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  63586. */
  63587. export class WebRequest {
  63588. private _xhr;
  63589. /**
  63590. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  63591. * i.e. when loading files, where the server/service expects an Authorization header
  63592. */
  63593. static CustomRequestHeaders: {
  63594. [key: string]: string;
  63595. };
  63596. /**
  63597. * Add callback functions in this array to update all the requests before they get sent to the network
  63598. */
  63599. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  63600. private _injectCustomRequestHeaders;
  63601. /**
  63602. * Gets or sets a function to be called when loading progress changes
  63603. */
  63604. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  63605. /**
  63606. * Returns client's state
  63607. */
  63608. readonly readyState: number;
  63609. /**
  63610. * Returns client's status
  63611. */
  63612. readonly status: number;
  63613. /**
  63614. * Returns client's status as a text
  63615. */
  63616. readonly statusText: string;
  63617. /**
  63618. * Returns client's response
  63619. */
  63620. readonly response: any;
  63621. /**
  63622. * Returns client's response url
  63623. */
  63624. readonly responseURL: string;
  63625. /**
  63626. * Returns client's response as text
  63627. */
  63628. readonly responseText: string;
  63629. /**
  63630. * Gets or sets the expected response type
  63631. */
  63632. responseType: XMLHttpRequestResponseType;
  63633. /** @hidden */
  63634. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  63635. /** @hidden */
  63636. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  63637. /**
  63638. * Cancels any network activity
  63639. */
  63640. abort(): void;
  63641. /**
  63642. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  63643. * @param body defines an optional request body
  63644. */
  63645. send(body?: Document | BodyInit | null): void;
  63646. /**
  63647. * Sets the request method, request URL
  63648. * @param method defines the method to use (GET, POST, etc..)
  63649. * @param url defines the url to connect with
  63650. */
  63651. open(method: string, url: string): void;
  63652. }
  63653. }
  63654. declare module BABYLON {
  63655. /**
  63656. * File request interface
  63657. */
  63658. export interface IFileRequest {
  63659. /**
  63660. * Raised when the request is complete (success or error).
  63661. */
  63662. onCompleteObservable: Observable<IFileRequest>;
  63663. /**
  63664. * Aborts the request for a file.
  63665. */
  63666. abort: () => void;
  63667. }
  63668. }
  63669. declare module BABYLON {
  63670. /**
  63671. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  63672. */
  63673. export class PerformanceMonitor {
  63674. private _enabled;
  63675. private _rollingFrameTime;
  63676. private _lastFrameTimeMs;
  63677. /**
  63678. * constructor
  63679. * @param frameSampleSize The number of samples required to saturate the sliding window
  63680. */
  63681. constructor(frameSampleSize?: number);
  63682. /**
  63683. * Samples current frame
  63684. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  63685. */
  63686. sampleFrame(timeMs?: number): void;
  63687. /**
  63688. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  63689. */
  63690. readonly averageFrameTime: number;
  63691. /**
  63692. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  63693. */
  63694. readonly averageFrameTimeVariance: number;
  63695. /**
  63696. * Returns the frame time of the most recent frame
  63697. */
  63698. readonly instantaneousFrameTime: number;
  63699. /**
  63700. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  63701. */
  63702. readonly averageFPS: number;
  63703. /**
  63704. * Returns the average framerate in frames per second using the most recent frame time
  63705. */
  63706. readonly instantaneousFPS: number;
  63707. /**
  63708. * Returns true if enough samples have been taken to completely fill the sliding window
  63709. */
  63710. readonly isSaturated: boolean;
  63711. /**
  63712. * Enables contributions to the sliding window sample set
  63713. */
  63714. enable(): void;
  63715. /**
  63716. * Disables contributions to the sliding window sample set
  63717. * Samples will not be interpolated over the disabled period
  63718. */
  63719. disable(): void;
  63720. /**
  63721. * Returns true if sampling is enabled
  63722. */
  63723. readonly isEnabled: boolean;
  63724. /**
  63725. * Resets performance monitor
  63726. */
  63727. reset(): void;
  63728. }
  63729. /**
  63730. * RollingAverage
  63731. *
  63732. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  63733. */
  63734. export class RollingAverage {
  63735. /**
  63736. * Current average
  63737. */
  63738. average: number;
  63739. /**
  63740. * Current variance
  63741. */
  63742. variance: number;
  63743. protected _samples: Array<number>;
  63744. protected _sampleCount: number;
  63745. protected _pos: number;
  63746. protected _m2: number;
  63747. /**
  63748. * constructor
  63749. * @param length The number of samples required to saturate the sliding window
  63750. */
  63751. constructor(length: number);
  63752. /**
  63753. * Adds a sample to the sample set
  63754. * @param v The sample value
  63755. */
  63756. add(v: number): void;
  63757. /**
  63758. * Returns previously added values or null if outside of history or outside the sliding window domain
  63759. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  63760. * @return Value previously recorded with add() or null if outside of range
  63761. */
  63762. history(i: number): number;
  63763. /**
  63764. * Returns true if enough samples have been taken to completely fill the sliding window
  63765. * @return true if sample-set saturated
  63766. */
  63767. isSaturated(): boolean;
  63768. /**
  63769. * Resets the rolling average (equivalent to 0 samples taken so far)
  63770. */
  63771. reset(): void;
  63772. /**
  63773. * Wraps a value around the sample range boundaries
  63774. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  63775. * @return Wrapped position in sample range
  63776. */
  63777. protected _wrapPosition(i: number): number;
  63778. }
  63779. }
  63780. declare module BABYLON {
  63781. /**
  63782. * This class implement a typical dictionary using a string as key and the generic type T as value.
  63783. * The underlying implementation relies on an associative array to ensure the best performances.
  63784. * The value can be anything including 'null' but except 'undefined'
  63785. */
  63786. export class StringDictionary<T> {
  63787. /**
  63788. * This will clear this dictionary and copy the content from the 'source' one.
  63789. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  63790. * @param source the dictionary to take the content from and copy to this dictionary
  63791. */
  63792. copyFrom(source: StringDictionary<T>): void;
  63793. /**
  63794. * Get a value based from its key
  63795. * @param key the given key to get the matching value from
  63796. * @return the value if found, otherwise undefined is returned
  63797. */
  63798. get(key: string): T | undefined;
  63799. /**
  63800. * Get a value from its key or add it if it doesn't exist.
  63801. * This method will ensure you that a given key/data will be present in the dictionary.
  63802. * @param key the given key to get the matching value from
  63803. * @param factory the factory that will create the value if the key is not present in the dictionary.
  63804. * The factory will only be invoked if there's no data for the given key.
  63805. * @return the value corresponding to the key.
  63806. */
  63807. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  63808. /**
  63809. * Get a value from its key if present in the dictionary otherwise add it
  63810. * @param key the key to get the value from
  63811. * @param val if there's no such key/value pair in the dictionary add it with this value
  63812. * @return the value corresponding to the key
  63813. */
  63814. getOrAdd(key: string, val: T): T;
  63815. /**
  63816. * Check if there's a given key in the dictionary
  63817. * @param key the key to check for
  63818. * @return true if the key is present, false otherwise
  63819. */
  63820. contains(key: string): boolean;
  63821. /**
  63822. * Add a new key and its corresponding value
  63823. * @param key the key to add
  63824. * @param value the value corresponding to the key
  63825. * @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
  63826. */
  63827. add(key: string, value: T): boolean;
  63828. /**
  63829. * Update a specific value associated to a key
  63830. * @param key defines the key to use
  63831. * @param value defines the value to store
  63832. * @returns true if the value was updated (or false if the key was not found)
  63833. */
  63834. set(key: string, value: T): boolean;
  63835. /**
  63836. * Get the element of the given key and remove it from the dictionary
  63837. * @param key defines the key to search
  63838. * @returns the value associated with the key or null if not found
  63839. */
  63840. getAndRemove(key: string): Nullable<T>;
  63841. /**
  63842. * Remove a key/value from the dictionary.
  63843. * @param key the key to remove
  63844. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  63845. */
  63846. remove(key: string): boolean;
  63847. /**
  63848. * Clear the whole content of the dictionary
  63849. */
  63850. clear(): void;
  63851. /**
  63852. * Gets the current count
  63853. */
  63854. readonly count: number;
  63855. /**
  63856. * Execute a callback on each key/val of the dictionary.
  63857. * Note that you can remove any element in this dictionary in the callback implementation
  63858. * @param callback the callback to execute on a given key/value pair
  63859. */
  63860. forEach(callback: (key: string, val: T) => void): void;
  63861. /**
  63862. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  63863. * If the callback returns null or undefined the method will iterate to the next key/value pair
  63864. * Note that you can remove any element in this dictionary in the callback implementation
  63865. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  63866. * @returns the first item
  63867. */
  63868. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  63869. private _count;
  63870. private _data;
  63871. }
  63872. }
  63873. declare module BABYLON {
  63874. /**
  63875. * Class used to store gfx data (like WebGLBuffer)
  63876. */
  63877. export class DataBuffer {
  63878. /**
  63879. * Gets or sets the number of objects referencing this buffer
  63880. */
  63881. references: number;
  63882. /** Gets or sets the size of the underlying buffer */
  63883. capacity: number;
  63884. /**
  63885. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  63886. */
  63887. is32Bits: boolean;
  63888. /**
  63889. * Gets the underlying buffer
  63890. */
  63891. readonly underlyingResource: any;
  63892. }
  63893. }
  63894. declare module BABYLON {
  63895. /**
  63896. * Class used to store data that will be store in GPU memory
  63897. */
  63898. export class Buffer {
  63899. private _engine;
  63900. private _buffer;
  63901. /** @hidden */
  63902. _data: Nullable<DataArray>;
  63903. private _updatable;
  63904. private _instanced;
  63905. /**
  63906. * Gets the byte stride.
  63907. */
  63908. readonly byteStride: number;
  63909. /**
  63910. * Constructor
  63911. * @param engine the engine
  63912. * @param data the data to use for this buffer
  63913. * @param updatable whether the data is updatable
  63914. * @param stride the stride (optional)
  63915. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  63916. * @param instanced whether the buffer is instanced (optional)
  63917. * @param useBytes set to true if the stride in in bytes (optional)
  63918. */
  63919. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  63920. /**
  63921. * Create a new VertexBuffer based on the current buffer
  63922. * @param kind defines the vertex buffer kind (position, normal, etc.)
  63923. * @param offset defines offset in the buffer (0 by default)
  63924. * @param size defines the size in floats of attributes (position is 3 for instance)
  63925. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  63926. * @param instanced defines if the vertex buffer contains indexed data
  63927. * @param useBytes defines if the offset and stride are in bytes
  63928. * @returns the new vertex buffer
  63929. */
  63930. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  63931. /**
  63932. * Gets a boolean indicating if the Buffer is updatable?
  63933. * @returns true if the buffer is updatable
  63934. */
  63935. isUpdatable(): boolean;
  63936. /**
  63937. * Gets current buffer's data
  63938. * @returns a DataArray or null
  63939. */
  63940. getData(): Nullable<DataArray>;
  63941. /**
  63942. * Gets underlying native buffer
  63943. * @returns underlying native buffer
  63944. */
  63945. getBuffer(): Nullable<DataBuffer>;
  63946. /**
  63947. * Gets the stride in float32 units (i.e. byte stride / 4).
  63948. * May not be an integer if the byte stride is not divisible by 4.
  63949. * DEPRECATED. Use byteStride instead.
  63950. * @returns the stride in float32 units
  63951. */
  63952. getStrideSize(): number;
  63953. /**
  63954. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  63955. * @param data defines the data to store
  63956. */
  63957. create(data?: Nullable<DataArray>): void;
  63958. /** @hidden */
  63959. _rebuild(): void;
  63960. /**
  63961. * Update current buffer data
  63962. * @param data defines the data to store
  63963. */
  63964. update(data: DataArray): void;
  63965. /**
  63966. * Updates the data directly.
  63967. * @param data the new data
  63968. * @param offset the new offset
  63969. * @param vertexCount the vertex count (optional)
  63970. * @param useBytes set to true if the offset is in bytes
  63971. */
  63972. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  63973. /**
  63974. * Release all resources
  63975. */
  63976. dispose(): void;
  63977. }
  63978. /**
  63979. * Specialized buffer used to store vertex data
  63980. */
  63981. export class VertexBuffer {
  63982. /** @hidden */
  63983. _buffer: Buffer;
  63984. private _kind;
  63985. private _size;
  63986. private _ownsBuffer;
  63987. private _instanced;
  63988. private _instanceDivisor;
  63989. /**
  63990. * The byte type.
  63991. */
  63992. static readonly BYTE: number;
  63993. /**
  63994. * The unsigned byte type.
  63995. */
  63996. static readonly UNSIGNED_BYTE: number;
  63997. /**
  63998. * The short type.
  63999. */
  64000. static readonly SHORT: number;
  64001. /**
  64002. * The unsigned short type.
  64003. */
  64004. static readonly UNSIGNED_SHORT: number;
  64005. /**
  64006. * The integer type.
  64007. */
  64008. static readonly INT: number;
  64009. /**
  64010. * The unsigned integer type.
  64011. */
  64012. static readonly UNSIGNED_INT: number;
  64013. /**
  64014. * The float type.
  64015. */
  64016. static readonly FLOAT: number;
  64017. /**
  64018. * Gets or sets the instance divisor when in instanced mode
  64019. */
  64020. instanceDivisor: number;
  64021. /**
  64022. * Gets the byte stride.
  64023. */
  64024. readonly byteStride: number;
  64025. /**
  64026. * Gets the byte offset.
  64027. */
  64028. readonly byteOffset: number;
  64029. /**
  64030. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  64031. */
  64032. readonly normalized: boolean;
  64033. /**
  64034. * Gets the data type of each component in the array.
  64035. */
  64036. readonly type: number;
  64037. /**
  64038. * Constructor
  64039. * @param engine the engine
  64040. * @param data the data to use for this vertex buffer
  64041. * @param kind the vertex buffer kind
  64042. * @param updatable whether the data is updatable
  64043. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  64044. * @param stride the stride (optional)
  64045. * @param instanced whether the buffer is instanced (optional)
  64046. * @param offset the offset of the data (optional)
  64047. * @param size the number of components (optional)
  64048. * @param type the type of the component (optional)
  64049. * @param normalized whether the data contains normalized data (optional)
  64050. * @param useBytes set to true if stride and offset are in bytes (optional)
  64051. */
  64052. 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);
  64053. /** @hidden */
  64054. _rebuild(): void;
  64055. /**
  64056. * Returns the kind of the VertexBuffer (string)
  64057. * @returns a string
  64058. */
  64059. getKind(): string;
  64060. /**
  64061. * Gets a boolean indicating if the VertexBuffer is updatable?
  64062. * @returns true if the buffer is updatable
  64063. */
  64064. isUpdatable(): boolean;
  64065. /**
  64066. * Gets current buffer's data
  64067. * @returns a DataArray or null
  64068. */
  64069. getData(): Nullable<DataArray>;
  64070. /**
  64071. * Gets underlying native buffer
  64072. * @returns underlying native buffer
  64073. */
  64074. getBuffer(): Nullable<DataBuffer>;
  64075. /**
  64076. * Gets the stride in float32 units (i.e. byte stride / 4).
  64077. * May not be an integer if the byte stride is not divisible by 4.
  64078. * DEPRECATED. Use byteStride instead.
  64079. * @returns the stride in float32 units
  64080. */
  64081. getStrideSize(): number;
  64082. /**
  64083. * Returns the offset as a multiple of the type byte length.
  64084. * DEPRECATED. Use byteOffset instead.
  64085. * @returns the offset in bytes
  64086. */
  64087. getOffset(): number;
  64088. /**
  64089. * Returns the number of components per vertex attribute (integer)
  64090. * @returns the size in float
  64091. */
  64092. getSize(): number;
  64093. /**
  64094. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  64095. * @returns true if this buffer is instanced
  64096. */
  64097. getIsInstanced(): boolean;
  64098. /**
  64099. * Returns the instancing divisor, zero for non-instanced (integer).
  64100. * @returns a number
  64101. */
  64102. getInstanceDivisor(): number;
  64103. /**
  64104. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  64105. * @param data defines the data to store
  64106. */
  64107. create(data?: DataArray): void;
  64108. /**
  64109. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  64110. * This function will create a new buffer if the current one is not updatable
  64111. * @param data defines the data to store
  64112. */
  64113. update(data: DataArray): void;
  64114. /**
  64115. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  64116. * Returns the directly updated WebGLBuffer.
  64117. * @param data the new data
  64118. * @param offset the new offset
  64119. * @param useBytes set to true if the offset is in bytes
  64120. */
  64121. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  64122. /**
  64123. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  64124. */
  64125. dispose(): void;
  64126. /**
  64127. * Enumerates each value of this vertex buffer as numbers.
  64128. * @param count the number of values to enumerate
  64129. * @param callback the callback function called for each value
  64130. */
  64131. forEach(count: number, callback: (value: number, index: number) => void): void;
  64132. /**
  64133. * Positions
  64134. */
  64135. static readonly PositionKind: string;
  64136. /**
  64137. * Normals
  64138. */
  64139. static readonly NormalKind: string;
  64140. /**
  64141. * Tangents
  64142. */
  64143. static readonly TangentKind: string;
  64144. /**
  64145. * Texture coordinates
  64146. */
  64147. static readonly UVKind: string;
  64148. /**
  64149. * Texture coordinates 2
  64150. */
  64151. static readonly UV2Kind: string;
  64152. /**
  64153. * Texture coordinates 3
  64154. */
  64155. static readonly UV3Kind: string;
  64156. /**
  64157. * Texture coordinates 4
  64158. */
  64159. static readonly UV4Kind: string;
  64160. /**
  64161. * Texture coordinates 5
  64162. */
  64163. static readonly UV5Kind: string;
  64164. /**
  64165. * Texture coordinates 6
  64166. */
  64167. static readonly UV6Kind: string;
  64168. /**
  64169. * Colors
  64170. */
  64171. static readonly ColorKind: string;
  64172. /**
  64173. * Matrix indices (for bones)
  64174. */
  64175. static readonly MatricesIndicesKind: string;
  64176. /**
  64177. * Matrix weights (for bones)
  64178. */
  64179. static readonly MatricesWeightsKind: string;
  64180. /**
  64181. * Additional matrix indices (for bones)
  64182. */
  64183. static readonly MatricesIndicesExtraKind: string;
  64184. /**
  64185. * Additional matrix weights (for bones)
  64186. */
  64187. static readonly MatricesWeightsExtraKind: string;
  64188. /**
  64189. * Deduces the stride given a kind.
  64190. * @param kind The kind string to deduce
  64191. * @returns The deduced stride
  64192. */
  64193. static DeduceStride(kind: string): number;
  64194. /**
  64195. * Gets the byte length of the given type.
  64196. * @param type the type
  64197. * @returns the number of bytes
  64198. */
  64199. static GetTypeByteLength(type: number): number;
  64200. /**
  64201. * Enumerates each value of the given parameters as numbers.
  64202. * @param data the data to enumerate
  64203. * @param byteOffset the byte offset of the data
  64204. * @param byteStride the byte stride of the data
  64205. * @param componentCount the number of components per element
  64206. * @param componentType the type of the component
  64207. * @param count the number of values to enumerate
  64208. * @param normalized whether the data is normalized
  64209. * @param callback the callback function called for each value
  64210. */
  64211. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  64212. private static _GetFloatValue;
  64213. }
  64214. }
  64215. declare module BABYLON {
  64216. /**
  64217. * Scalar computation library
  64218. */
  64219. export class Scalar {
  64220. /**
  64221. * Two pi constants convenient for computation.
  64222. */
  64223. static TwoPi: number;
  64224. /**
  64225. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  64226. * @param a number
  64227. * @param b number
  64228. * @param epsilon (default = 1.401298E-45)
  64229. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  64230. */
  64231. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  64232. /**
  64233. * Returns a string : the upper case translation of the number i to hexadecimal.
  64234. * @param i number
  64235. * @returns the upper case translation of the number i to hexadecimal.
  64236. */
  64237. static ToHex(i: number): string;
  64238. /**
  64239. * Returns -1 if value is negative and +1 is value is positive.
  64240. * @param value the value
  64241. * @returns the value itself if it's equal to zero.
  64242. */
  64243. static Sign(value: number): number;
  64244. /**
  64245. * Returns the value itself if it's between min and max.
  64246. * Returns min if the value is lower than min.
  64247. * Returns max if the value is greater than max.
  64248. * @param value the value to clmap
  64249. * @param min the min value to clamp to (default: 0)
  64250. * @param max the max value to clamp to (default: 1)
  64251. * @returns the clamped value
  64252. */
  64253. static Clamp(value: number, min?: number, max?: number): number;
  64254. /**
  64255. * the log2 of value.
  64256. * @param value the value to compute log2 of
  64257. * @returns the log2 of value.
  64258. */
  64259. static Log2(value: number): number;
  64260. /**
  64261. * Loops the value, so that it is never larger than length and never smaller than 0.
  64262. *
  64263. * This is similar to the modulo operator but it works with floating point numbers.
  64264. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  64265. * With t = 5 and length = 2.5, the result would be 0.0.
  64266. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  64267. * @param value the value
  64268. * @param length the length
  64269. * @returns the looped value
  64270. */
  64271. static Repeat(value: number, length: number): number;
  64272. /**
  64273. * Normalize the value between 0.0 and 1.0 using min and max values
  64274. * @param value value to normalize
  64275. * @param min max to normalize between
  64276. * @param max min to normalize between
  64277. * @returns the normalized value
  64278. */
  64279. static Normalize(value: number, min: number, max: number): number;
  64280. /**
  64281. * Denormalize the value from 0.0 and 1.0 using min and max values
  64282. * @param normalized value to denormalize
  64283. * @param min max to denormalize between
  64284. * @param max min to denormalize between
  64285. * @returns the denormalized value
  64286. */
  64287. static Denormalize(normalized: number, min: number, max: number): number;
  64288. /**
  64289. * Calculates the shortest difference between two given angles given in degrees.
  64290. * @param current current angle in degrees
  64291. * @param target target angle in degrees
  64292. * @returns the delta
  64293. */
  64294. static DeltaAngle(current: number, target: number): number;
  64295. /**
  64296. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  64297. * @param tx value
  64298. * @param length length
  64299. * @returns The returned value will move back and forth between 0 and length
  64300. */
  64301. static PingPong(tx: number, length: number): number;
  64302. /**
  64303. * Interpolates between min and max with smoothing at the limits.
  64304. *
  64305. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  64306. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  64307. * @param from from
  64308. * @param to to
  64309. * @param tx value
  64310. * @returns the smooth stepped value
  64311. */
  64312. static SmoothStep(from: number, to: number, tx: number): number;
  64313. /**
  64314. * Moves a value current towards target.
  64315. *
  64316. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  64317. * Negative values of maxDelta pushes the value away from target.
  64318. * @param current current value
  64319. * @param target target value
  64320. * @param maxDelta max distance to move
  64321. * @returns resulting value
  64322. */
  64323. static MoveTowards(current: number, target: number, maxDelta: number): number;
  64324. /**
  64325. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  64326. *
  64327. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  64328. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  64329. * @param current current value
  64330. * @param target target value
  64331. * @param maxDelta max distance to move
  64332. * @returns resulting angle
  64333. */
  64334. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  64335. /**
  64336. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  64337. * @param start start value
  64338. * @param end target value
  64339. * @param amount amount to lerp between
  64340. * @returns the lerped value
  64341. */
  64342. static Lerp(start: number, end: number, amount: number): number;
  64343. /**
  64344. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  64345. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  64346. * @param start start value
  64347. * @param end target value
  64348. * @param amount amount to lerp between
  64349. * @returns the lerped value
  64350. */
  64351. static LerpAngle(start: number, end: number, amount: number): number;
  64352. /**
  64353. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  64354. * @param a start value
  64355. * @param b target value
  64356. * @param value value between a and b
  64357. * @returns the inverseLerp value
  64358. */
  64359. static InverseLerp(a: number, b: number, value: number): number;
  64360. /**
  64361. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  64362. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  64363. * @param value1 spline value
  64364. * @param tangent1 spline value
  64365. * @param value2 spline value
  64366. * @param tangent2 spline value
  64367. * @param amount input value
  64368. * @returns hermite result
  64369. */
  64370. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  64371. /**
  64372. * Returns a random float number between and min and max values
  64373. * @param min min value of random
  64374. * @param max max value of random
  64375. * @returns random value
  64376. */
  64377. static RandomRange(min: number, max: number): number;
  64378. /**
  64379. * This function returns percentage of a number in a given range.
  64380. *
  64381. * RangeToPercent(40,20,60) will return 0.5 (50%)
  64382. * RangeToPercent(34,0,100) will return 0.34 (34%)
  64383. * @param number to convert to percentage
  64384. * @param min min range
  64385. * @param max max range
  64386. * @returns the percentage
  64387. */
  64388. static RangeToPercent(number: number, min: number, max: number): number;
  64389. /**
  64390. * This function returns number that corresponds to the percentage in a given range.
  64391. *
  64392. * PercentToRange(0.34,0,100) will return 34.
  64393. * @param percent to convert to number
  64394. * @param min min range
  64395. * @param max max range
  64396. * @returns the number
  64397. */
  64398. static PercentToRange(percent: number, min: number, max: number): number;
  64399. /**
  64400. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  64401. * @param angle The angle to normalize in radian.
  64402. * @return The converted angle.
  64403. */
  64404. static NormalizeRadians(angle: number): number;
  64405. }
  64406. }
  64407. declare module BABYLON {
  64408. /**
  64409. * Constant used to convert a value to gamma space
  64410. * @ignorenaming
  64411. */
  64412. export const ToGammaSpace: number;
  64413. /**
  64414. * Constant used to convert a value to linear space
  64415. * @ignorenaming
  64416. */
  64417. export const ToLinearSpace = 2.2;
  64418. /**
  64419. * Constant used to define the minimal number value in Babylon.js
  64420. * @ignorenaming
  64421. */
  64422. let Epsilon: number;
  64423. }
  64424. declare module BABYLON {
  64425. /**
  64426. * Class used to represent a viewport on screen
  64427. */
  64428. export class Viewport {
  64429. /** viewport left coordinate */
  64430. x: number;
  64431. /** viewport top coordinate */
  64432. y: number;
  64433. /**viewport width */
  64434. width: number;
  64435. /** viewport height */
  64436. height: number;
  64437. /**
  64438. * Creates a Viewport object located at (x, y) and sized (width, height)
  64439. * @param x defines viewport left coordinate
  64440. * @param y defines viewport top coordinate
  64441. * @param width defines the viewport width
  64442. * @param height defines the viewport height
  64443. */
  64444. constructor(
  64445. /** viewport left coordinate */
  64446. x: number,
  64447. /** viewport top coordinate */
  64448. y: number,
  64449. /**viewport width */
  64450. width: number,
  64451. /** viewport height */
  64452. height: number);
  64453. /**
  64454. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  64455. * @param renderWidth defines the rendering width
  64456. * @param renderHeight defines the rendering height
  64457. * @returns a new Viewport
  64458. */
  64459. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  64460. /**
  64461. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  64462. * @param renderWidth defines the rendering width
  64463. * @param renderHeight defines the rendering height
  64464. * @param ref defines the target viewport
  64465. * @returns the current viewport
  64466. */
  64467. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  64468. /**
  64469. * Returns a new Viewport copied from the current one
  64470. * @returns a new Viewport
  64471. */
  64472. clone(): Viewport;
  64473. }
  64474. }
  64475. declare module BABYLON {
  64476. /**
  64477. * Class containing a set of static utilities functions for arrays.
  64478. */
  64479. export class ArrayTools {
  64480. /**
  64481. * Returns an array of the given size filled with element built from the given constructor and the paramters
  64482. * @param size the number of element to construct and put in the array
  64483. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  64484. * @returns a new array filled with new objects
  64485. */
  64486. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  64487. }
  64488. }
  64489. declare module BABYLON {
  64490. /**
  64491. * @hidden
  64492. */
  64493. export interface IColor4Like {
  64494. r: float;
  64495. g: float;
  64496. b: float;
  64497. a: float;
  64498. }
  64499. /**
  64500. * @hidden
  64501. */
  64502. export interface IColor3Like {
  64503. r: float;
  64504. g: float;
  64505. b: float;
  64506. }
  64507. /**
  64508. * @hidden
  64509. */
  64510. export interface IVector4Like {
  64511. x: float;
  64512. y: float;
  64513. z: float;
  64514. w: float;
  64515. }
  64516. /**
  64517. * @hidden
  64518. */
  64519. export interface IVector3Like {
  64520. x: float;
  64521. y: float;
  64522. z: float;
  64523. }
  64524. /**
  64525. * @hidden
  64526. */
  64527. export interface IVector2Like {
  64528. x: float;
  64529. y: float;
  64530. }
  64531. /**
  64532. * @hidden
  64533. */
  64534. export interface IMatrixLike {
  64535. toArray(): DeepImmutable<Float32Array>;
  64536. updateFlag: int;
  64537. }
  64538. /**
  64539. * @hidden
  64540. */
  64541. export interface IViewportLike {
  64542. x: float;
  64543. y: float;
  64544. width: float;
  64545. height: float;
  64546. }
  64547. /**
  64548. * @hidden
  64549. */
  64550. export interface IPlaneLike {
  64551. normal: IVector3Like;
  64552. d: float;
  64553. normalize(): void;
  64554. }
  64555. }
  64556. declare module BABYLON {
  64557. /**
  64558. * Class representing a vector containing 2 coordinates
  64559. */
  64560. export class Vector2 {
  64561. /** defines the first coordinate */
  64562. x: number;
  64563. /** defines the second coordinate */
  64564. y: number;
  64565. /**
  64566. * Creates a new Vector2 from the given x and y coordinates
  64567. * @param x defines the first coordinate
  64568. * @param y defines the second coordinate
  64569. */
  64570. constructor(
  64571. /** defines the first coordinate */
  64572. x?: number,
  64573. /** defines the second coordinate */
  64574. y?: number);
  64575. /**
  64576. * Gets a string with the Vector2 coordinates
  64577. * @returns a string with the Vector2 coordinates
  64578. */
  64579. toString(): string;
  64580. /**
  64581. * Gets class name
  64582. * @returns the string "Vector2"
  64583. */
  64584. getClassName(): string;
  64585. /**
  64586. * Gets current vector hash code
  64587. * @returns the Vector2 hash code as a number
  64588. */
  64589. getHashCode(): number;
  64590. /**
  64591. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  64592. * @param array defines the source array
  64593. * @param index defines the offset in source array
  64594. * @returns the current Vector2
  64595. */
  64596. toArray(array: FloatArray, index?: number): Vector2;
  64597. /**
  64598. * Copy the current vector to an array
  64599. * @returns a new array with 2 elements: the Vector2 coordinates.
  64600. */
  64601. asArray(): number[];
  64602. /**
  64603. * Sets the Vector2 coordinates with the given Vector2 coordinates
  64604. * @param source defines the source Vector2
  64605. * @returns the current updated Vector2
  64606. */
  64607. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  64608. /**
  64609. * Sets the Vector2 coordinates with the given floats
  64610. * @param x defines the first coordinate
  64611. * @param y defines the second coordinate
  64612. * @returns the current updated Vector2
  64613. */
  64614. copyFromFloats(x: number, y: number): Vector2;
  64615. /**
  64616. * Sets the Vector2 coordinates with the given floats
  64617. * @param x defines the first coordinate
  64618. * @param y defines the second coordinate
  64619. * @returns the current updated Vector2
  64620. */
  64621. set(x: number, y: number): Vector2;
  64622. /**
  64623. * Add another vector with the current one
  64624. * @param otherVector defines the other vector
  64625. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  64626. */
  64627. add(otherVector: DeepImmutable<Vector2>): Vector2;
  64628. /**
  64629. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  64630. * @param otherVector defines the other vector
  64631. * @param result defines the target vector
  64632. * @returns the unmodified current Vector2
  64633. */
  64634. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  64635. /**
  64636. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  64637. * @param otherVector defines the other vector
  64638. * @returns the current updated Vector2
  64639. */
  64640. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  64641. /**
  64642. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  64643. * @param otherVector defines the other vector
  64644. * @returns a new Vector2
  64645. */
  64646. addVector3(otherVector: Vector3): Vector2;
  64647. /**
  64648. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  64649. * @param otherVector defines the other vector
  64650. * @returns a new Vector2
  64651. */
  64652. subtract(otherVector: Vector2): Vector2;
  64653. /**
  64654. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  64655. * @param otherVector defines the other vector
  64656. * @param result defines the target vector
  64657. * @returns the unmodified current Vector2
  64658. */
  64659. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  64660. /**
  64661. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  64662. * @param otherVector defines the other vector
  64663. * @returns the current updated Vector2
  64664. */
  64665. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  64666. /**
  64667. * Multiplies in place the current Vector2 coordinates by the given ones
  64668. * @param otherVector defines the other vector
  64669. * @returns the current updated Vector2
  64670. */
  64671. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  64672. /**
  64673. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  64674. * @param otherVector defines the other vector
  64675. * @returns a new Vector2
  64676. */
  64677. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  64678. /**
  64679. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  64680. * @param otherVector defines the other vector
  64681. * @param result defines the target vector
  64682. * @returns the unmodified current Vector2
  64683. */
  64684. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  64685. /**
  64686. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  64687. * @param x defines the first coordinate
  64688. * @param y defines the second coordinate
  64689. * @returns a new Vector2
  64690. */
  64691. multiplyByFloats(x: number, y: number): Vector2;
  64692. /**
  64693. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  64694. * @param otherVector defines the other vector
  64695. * @returns a new Vector2
  64696. */
  64697. divide(otherVector: Vector2): Vector2;
  64698. /**
  64699. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  64700. * @param otherVector defines the other vector
  64701. * @param result defines the target vector
  64702. * @returns the unmodified current Vector2
  64703. */
  64704. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  64705. /**
  64706. * Divides the current Vector2 coordinates by the given ones
  64707. * @param otherVector defines the other vector
  64708. * @returns the current updated Vector2
  64709. */
  64710. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  64711. /**
  64712. * Gets a new Vector2 with current Vector2 negated coordinates
  64713. * @returns a new Vector2
  64714. */
  64715. negate(): Vector2;
  64716. /**
  64717. * Multiply the Vector2 coordinates by scale
  64718. * @param scale defines the scaling factor
  64719. * @returns the current updated Vector2
  64720. */
  64721. scaleInPlace(scale: number): Vector2;
  64722. /**
  64723. * Returns a new Vector2 scaled by "scale" from the current Vector2
  64724. * @param scale defines the scaling factor
  64725. * @returns a new Vector2
  64726. */
  64727. scale(scale: number): Vector2;
  64728. /**
  64729. * Scale the current Vector2 values by a factor to a given Vector2
  64730. * @param scale defines the scale factor
  64731. * @param result defines the Vector2 object where to store the result
  64732. * @returns the unmodified current Vector2
  64733. */
  64734. scaleToRef(scale: number, result: Vector2): Vector2;
  64735. /**
  64736. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  64737. * @param scale defines the scale factor
  64738. * @param result defines the Vector2 object where to store the result
  64739. * @returns the unmodified current Vector2
  64740. */
  64741. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  64742. /**
  64743. * Gets a boolean if two vectors are equals
  64744. * @param otherVector defines the other vector
  64745. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  64746. */
  64747. equals(otherVector: DeepImmutable<Vector2>): boolean;
  64748. /**
  64749. * Gets a boolean if two vectors are equals (using an epsilon value)
  64750. * @param otherVector defines the other vector
  64751. * @param epsilon defines the minimal distance to consider equality
  64752. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  64753. */
  64754. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  64755. /**
  64756. * Gets a new Vector2 from current Vector2 floored values
  64757. * @returns a new Vector2
  64758. */
  64759. floor(): Vector2;
  64760. /**
  64761. * Gets a new Vector2 from current Vector2 floored values
  64762. * @returns a new Vector2
  64763. */
  64764. fract(): Vector2;
  64765. /**
  64766. * Gets the length of the vector
  64767. * @returns the vector length (float)
  64768. */
  64769. length(): number;
  64770. /**
  64771. * Gets the vector squared length
  64772. * @returns the vector squared length (float)
  64773. */
  64774. lengthSquared(): number;
  64775. /**
  64776. * Normalize the vector
  64777. * @returns the current updated Vector2
  64778. */
  64779. normalize(): Vector2;
  64780. /**
  64781. * Gets a new Vector2 copied from the Vector2
  64782. * @returns a new Vector2
  64783. */
  64784. clone(): Vector2;
  64785. /**
  64786. * Gets a new Vector2(0, 0)
  64787. * @returns a new Vector2
  64788. */
  64789. static Zero(): Vector2;
  64790. /**
  64791. * Gets a new Vector2(1, 1)
  64792. * @returns a new Vector2
  64793. */
  64794. static One(): Vector2;
  64795. /**
  64796. * Gets a new Vector2 set from the given index element of the given array
  64797. * @param array defines the data source
  64798. * @param offset defines the offset in the data source
  64799. * @returns a new Vector2
  64800. */
  64801. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  64802. /**
  64803. * Sets "result" from the given index element of the given array
  64804. * @param array defines the data source
  64805. * @param offset defines the offset in the data source
  64806. * @param result defines the target vector
  64807. */
  64808. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  64809. /**
  64810. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  64811. * @param value1 defines 1st point of control
  64812. * @param value2 defines 2nd point of control
  64813. * @param value3 defines 3rd point of control
  64814. * @param value4 defines 4th point of control
  64815. * @param amount defines the interpolation factor
  64816. * @returns a new Vector2
  64817. */
  64818. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  64819. /**
  64820. * 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".
  64821. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  64822. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  64823. * @param value defines the value to clamp
  64824. * @param min defines the lower limit
  64825. * @param max defines the upper limit
  64826. * @returns a new Vector2
  64827. */
  64828. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  64829. /**
  64830. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  64831. * @param value1 defines the 1st control point
  64832. * @param tangent1 defines the outgoing tangent
  64833. * @param value2 defines the 2nd control point
  64834. * @param tangent2 defines the incoming tangent
  64835. * @param amount defines the interpolation factor
  64836. * @returns a new Vector2
  64837. */
  64838. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  64839. /**
  64840. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  64841. * @param start defines the start vector
  64842. * @param end defines the end vector
  64843. * @param amount defines the interpolation factor
  64844. * @returns a new Vector2
  64845. */
  64846. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  64847. /**
  64848. * Gets the dot product of the vector "left" and the vector "right"
  64849. * @param left defines first vector
  64850. * @param right defines second vector
  64851. * @returns the dot product (float)
  64852. */
  64853. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  64854. /**
  64855. * Returns a new Vector2 equal to the normalized given vector
  64856. * @param vector defines the vector to normalize
  64857. * @returns a new Vector2
  64858. */
  64859. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  64860. /**
  64861. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  64862. * @param left defines 1st vector
  64863. * @param right defines 2nd vector
  64864. * @returns a new Vector2
  64865. */
  64866. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  64867. /**
  64868. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  64869. * @param left defines 1st vector
  64870. * @param right defines 2nd vector
  64871. * @returns a new Vector2
  64872. */
  64873. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  64874. /**
  64875. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  64876. * @param vector defines the vector to transform
  64877. * @param transformation defines the matrix to apply
  64878. * @returns a new Vector2
  64879. */
  64880. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  64881. /**
  64882. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  64883. * @param vector defines the vector to transform
  64884. * @param transformation defines the matrix to apply
  64885. * @param result defines the target vector
  64886. */
  64887. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  64888. /**
  64889. * Determines if a given vector is included in a triangle
  64890. * @param p defines the vector to test
  64891. * @param p0 defines 1st triangle point
  64892. * @param p1 defines 2nd triangle point
  64893. * @param p2 defines 3rd triangle point
  64894. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  64895. */
  64896. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  64897. /**
  64898. * Gets the distance between the vectors "value1" and "value2"
  64899. * @param value1 defines first vector
  64900. * @param value2 defines second vector
  64901. * @returns the distance between vectors
  64902. */
  64903. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  64904. /**
  64905. * Returns the squared distance between the vectors "value1" and "value2"
  64906. * @param value1 defines first vector
  64907. * @param value2 defines second vector
  64908. * @returns the squared distance between vectors
  64909. */
  64910. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  64911. /**
  64912. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  64913. * @param value1 defines first vector
  64914. * @param value2 defines second vector
  64915. * @returns a new Vector2
  64916. */
  64917. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  64918. /**
  64919. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  64920. * @param p defines the middle point
  64921. * @param segA defines one point of the segment
  64922. * @param segB defines the other point of the segment
  64923. * @returns the shortest distance
  64924. */
  64925. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  64926. }
  64927. /**
  64928. * Classed used to store (x,y,z) vector representation
  64929. * A Vector3 is the main object used in 3D geometry
  64930. * It can represent etiher the coordinates of a point the space, either a direction
  64931. * Reminder: js uses a left handed forward facing system
  64932. */
  64933. export class Vector3 {
  64934. /**
  64935. * Defines the first coordinates (on X axis)
  64936. */
  64937. x: number;
  64938. /**
  64939. * Defines the second coordinates (on Y axis)
  64940. */
  64941. y: number;
  64942. /**
  64943. * Defines the third coordinates (on Z axis)
  64944. */
  64945. z: number;
  64946. private static _UpReadOnly;
  64947. private static _ZeroReadOnly;
  64948. /**
  64949. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  64950. * @param x defines the first coordinates (on X axis)
  64951. * @param y defines the second coordinates (on Y axis)
  64952. * @param z defines the third coordinates (on Z axis)
  64953. */
  64954. constructor(
  64955. /**
  64956. * Defines the first coordinates (on X axis)
  64957. */
  64958. x?: number,
  64959. /**
  64960. * Defines the second coordinates (on Y axis)
  64961. */
  64962. y?: number,
  64963. /**
  64964. * Defines the third coordinates (on Z axis)
  64965. */
  64966. z?: number);
  64967. /**
  64968. * Creates a string representation of the Vector3
  64969. * @returns a string with the Vector3 coordinates.
  64970. */
  64971. toString(): string;
  64972. /**
  64973. * Gets the class name
  64974. * @returns the string "Vector3"
  64975. */
  64976. getClassName(): string;
  64977. /**
  64978. * Creates the Vector3 hash code
  64979. * @returns a number which tends to be unique between Vector3 instances
  64980. */
  64981. getHashCode(): number;
  64982. /**
  64983. * Creates an array containing three elements : the coordinates of the Vector3
  64984. * @returns a new array of numbers
  64985. */
  64986. asArray(): number[];
  64987. /**
  64988. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  64989. * @param array defines the destination array
  64990. * @param index defines the offset in the destination array
  64991. * @returns the current Vector3
  64992. */
  64993. toArray(array: FloatArray, index?: number): Vector3;
  64994. /**
  64995. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  64996. * @returns a new Quaternion object, computed from the Vector3 coordinates
  64997. */
  64998. toQuaternion(): Quaternion;
  64999. /**
  65000. * Adds the given vector to the current Vector3
  65001. * @param otherVector defines the second operand
  65002. * @returns the current updated Vector3
  65003. */
  65004. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  65005. /**
  65006. * Adds the given coordinates to the current Vector3
  65007. * @param x defines the x coordinate of the operand
  65008. * @param y defines the y coordinate of the operand
  65009. * @param z defines the z coordinate of the operand
  65010. * @returns the current updated Vector3
  65011. */
  65012. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  65013. /**
  65014. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  65015. * @param otherVector defines the second operand
  65016. * @returns the resulting Vector3
  65017. */
  65018. add(otherVector: DeepImmutable<Vector3>): Vector3;
  65019. /**
  65020. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  65021. * @param otherVector defines the second operand
  65022. * @param result defines the Vector3 object where to store the result
  65023. * @returns the current Vector3
  65024. */
  65025. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  65026. /**
  65027. * Subtract the given vector from the current Vector3
  65028. * @param otherVector defines the second operand
  65029. * @returns the current updated Vector3
  65030. */
  65031. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  65032. /**
  65033. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  65034. * @param otherVector defines the second operand
  65035. * @returns the resulting Vector3
  65036. */
  65037. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  65038. /**
  65039. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  65040. * @param otherVector defines the second operand
  65041. * @param result defines the Vector3 object where to store the result
  65042. * @returns the current Vector3
  65043. */
  65044. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  65045. /**
  65046. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  65047. * @param x defines the x coordinate of the operand
  65048. * @param y defines the y coordinate of the operand
  65049. * @param z defines the z coordinate of the operand
  65050. * @returns the resulting Vector3
  65051. */
  65052. subtractFromFloats(x: number, y: number, z: number): Vector3;
  65053. /**
  65054. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  65055. * @param x defines the x coordinate of the operand
  65056. * @param y defines the y coordinate of the operand
  65057. * @param z defines the z coordinate of the operand
  65058. * @param result defines the Vector3 object where to store the result
  65059. * @returns the current Vector3
  65060. */
  65061. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  65062. /**
  65063. * Gets a new Vector3 set with the current Vector3 negated coordinates
  65064. * @returns a new Vector3
  65065. */
  65066. negate(): Vector3;
  65067. /**
  65068. * Multiplies the Vector3 coordinates by the float "scale"
  65069. * @param scale defines the multiplier factor
  65070. * @returns the current updated Vector3
  65071. */
  65072. scaleInPlace(scale: number): Vector3;
  65073. /**
  65074. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  65075. * @param scale defines the multiplier factor
  65076. * @returns a new Vector3
  65077. */
  65078. scale(scale: number): Vector3;
  65079. /**
  65080. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  65081. * @param scale defines the multiplier factor
  65082. * @param result defines the Vector3 object where to store the result
  65083. * @returns the current Vector3
  65084. */
  65085. scaleToRef(scale: number, result: Vector3): Vector3;
  65086. /**
  65087. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  65088. * @param scale defines the scale factor
  65089. * @param result defines the Vector3 object where to store the result
  65090. * @returns the unmodified current Vector3
  65091. */
  65092. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  65093. /**
  65094. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  65095. * @param otherVector defines the second operand
  65096. * @returns true if both vectors are equals
  65097. */
  65098. equals(otherVector: DeepImmutable<Vector3>): boolean;
  65099. /**
  65100. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  65101. * @param otherVector defines the second operand
  65102. * @param epsilon defines the minimal distance to define values as equals
  65103. * @returns true if both vectors are distant less than epsilon
  65104. */
  65105. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  65106. /**
  65107. * Returns true if the current Vector3 coordinates equals the given floats
  65108. * @param x defines the x coordinate of the operand
  65109. * @param y defines the y coordinate of the operand
  65110. * @param z defines the z coordinate of the operand
  65111. * @returns true if both vectors are equals
  65112. */
  65113. equalsToFloats(x: number, y: number, z: number): boolean;
  65114. /**
  65115. * Multiplies the current Vector3 coordinates by the given ones
  65116. * @param otherVector defines the second operand
  65117. * @returns the current updated Vector3
  65118. */
  65119. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  65120. /**
  65121. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  65122. * @param otherVector defines the second operand
  65123. * @returns the new Vector3
  65124. */
  65125. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  65126. /**
  65127. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  65128. * @param otherVector defines the second operand
  65129. * @param result defines the Vector3 object where to store the result
  65130. * @returns the current Vector3
  65131. */
  65132. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  65133. /**
  65134. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  65135. * @param x defines the x coordinate of the operand
  65136. * @param y defines the y coordinate of the operand
  65137. * @param z defines the z coordinate of the operand
  65138. * @returns the new Vector3
  65139. */
  65140. multiplyByFloats(x: number, y: number, z: number): Vector3;
  65141. /**
  65142. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  65143. * @param otherVector defines the second operand
  65144. * @returns the new Vector3
  65145. */
  65146. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  65147. /**
  65148. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  65149. * @param otherVector defines the second operand
  65150. * @param result defines the Vector3 object where to store the result
  65151. * @returns the current Vector3
  65152. */
  65153. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  65154. /**
  65155. * Divides the current Vector3 coordinates by the given ones.
  65156. * @param otherVector defines the second operand
  65157. * @returns the current updated Vector3
  65158. */
  65159. divideInPlace(otherVector: Vector3): Vector3;
  65160. /**
  65161. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  65162. * @param other defines the second operand
  65163. * @returns the current updated Vector3
  65164. */
  65165. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  65166. /**
  65167. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  65168. * @param other defines the second operand
  65169. * @returns the current updated Vector3
  65170. */
  65171. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  65172. /**
  65173. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  65174. * @param x defines the x coordinate of the operand
  65175. * @param y defines the y coordinate of the operand
  65176. * @param z defines the z coordinate of the operand
  65177. * @returns the current updated Vector3
  65178. */
  65179. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  65180. /**
  65181. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  65182. * @param x defines the x coordinate of the operand
  65183. * @param y defines the y coordinate of the operand
  65184. * @param z defines the z coordinate of the operand
  65185. * @returns the current updated Vector3
  65186. */
  65187. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  65188. /**
  65189. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  65190. * Check if is non uniform within a certain amount of decimal places to account for this
  65191. * @param epsilon the amount the values can differ
  65192. * @returns if the the vector is non uniform to a certain number of decimal places
  65193. */
  65194. isNonUniformWithinEpsilon(epsilon: number): boolean;
  65195. /**
  65196. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  65197. */
  65198. readonly isNonUniform: boolean;
  65199. /**
  65200. * Gets a new Vector3 from current Vector3 floored values
  65201. * @returns a new Vector3
  65202. */
  65203. floor(): Vector3;
  65204. /**
  65205. * Gets a new Vector3 from current Vector3 floored values
  65206. * @returns a new Vector3
  65207. */
  65208. fract(): Vector3;
  65209. /**
  65210. * Gets the length of the Vector3
  65211. * @returns the length of the Vector3
  65212. */
  65213. length(): number;
  65214. /**
  65215. * Gets the squared length of the Vector3
  65216. * @returns squared length of the Vector3
  65217. */
  65218. lengthSquared(): number;
  65219. /**
  65220. * Normalize the current Vector3.
  65221. * Please note that this is an in place operation.
  65222. * @returns the current updated Vector3
  65223. */
  65224. normalize(): Vector3;
  65225. /**
  65226. * Reorders the x y z properties of the vector in place
  65227. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  65228. * @returns the current updated vector
  65229. */
  65230. reorderInPlace(order: string): this;
  65231. /**
  65232. * Rotates the vector around 0,0,0 by a quaternion
  65233. * @param quaternion the rotation quaternion
  65234. * @param result vector to store the result
  65235. * @returns the resulting vector
  65236. */
  65237. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  65238. /**
  65239. * Rotates a vector around a given point
  65240. * @param quaternion the rotation quaternion
  65241. * @param point the point to rotate around
  65242. * @param result vector to store the result
  65243. * @returns the resulting vector
  65244. */
  65245. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  65246. /**
  65247. * Normalize the current Vector3 with the given input length.
  65248. * Please note that this is an in place operation.
  65249. * @param len the length of the vector
  65250. * @returns the current updated Vector3
  65251. */
  65252. normalizeFromLength(len: number): Vector3;
  65253. /**
  65254. * Normalize the current Vector3 to a new vector
  65255. * @returns the new Vector3
  65256. */
  65257. normalizeToNew(): Vector3;
  65258. /**
  65259. * Normalize the current Vector3 to the reference
  65260. * @param reference define the Vector3 to update
  65261. * @returns the updated Vector3
  65262. */
  65263. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  65264. /**
  65265. * Creates a new Vector3 copied from the current Vector3
  65266. * @returns the new Vector3
  65267. */
  65268. clone(): Vector3;
  65269. /**
  65270. * Copies the given vector coordinates to the current Vector3 ones
  65271. * @param source defines the source Vector3
  65272. * @returns the current updated Vector3
  65273. */
  65274. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  65275. /**
  65276. * Copies the given floats to the current Vector3 coordinates
  65277. * @param x defines the x coordinate of the operand
  65278. * @param y defines the y coordinate of the operand
  65279. * @param z defines the z coordinate of the operand
  65280. * @returns the current updated Vector3
  65281. */
  65282. copyFromFloats(x: number, y: number, z: number): Vector3;
  65283. /**
  65284. * Copies the given floats to the current Vector3 coordinates
  65285. * @param x defines the x coordinate of the operand
  65286. * @param y defines the y coordinate of the operand
  65287. * @param z defines the z coordinate of the operand
  65288. * @returns the current updated Vector3
  65289. */
  65290. set(x: number, y: number, z: number): Vector3;
  65291. /**
  65292. * Copies the given float to the current Vector3 coordinates
  65293. * @param v defines the x, y and z coordinates of the operand
  65294. * @returns the current updated Vector3
  65295. */
  65296. setAll(v: number): Vector3;
  65297. /**
  65298. * Get the clip factor between two vectors
  65299. * @param vector0 defines the first operand
  65300. * @param vector1 defines the second operand
  65301. * @param axis defines the axis to use
  65302. * @param size defines the size along the axis
  65303. * @returns the clip factor
  65304. */
  65305. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  65306. /**
  65307. * Get angle between two vectors
  65308. * @param vector0 angle between vector0 and vector1
  65309. * @param vector1 angle between vector0 and vector1
  65310. * @param normal direction of the normal
  65311. * @return the angle between vector0 and vector1
  65312. */
  65313. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  65314. /**
  65315. * Returns a new Vector3 set from the index "offset" of the given array
  65316. * @param array defines the source array
  65317. * @param offset defines the offset in the source array
  65318. * @returns the new Vector3
  65319. */
  65320. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  65321. /**
  65322. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  65323. * This function is deprecated. Use FromArray instead
  65324. * @param array defines the source array
  65325. * @param offset defines the offset in the source array
  65326. * @returns the new Vector3
  65327. */
  65328. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  65329. /**
  65330. * Sets the given vector "result" with the element values from the index "offset" of the given array
  65331. * @param array defines the source array
  65332. * @param offset defines the offset in the source array
  65333. * @param result defines the Vector3 where to store the result
  65334. */
  65335. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  65336. /**
  65337. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  65338. * This function is deprecated. Use FromArrayToRef instead.
  65339. * @param array defines the source array
  65340. * @param offset defines the offset in the source array
  65341. * @param result defines the Vector3 where to store the result
  65342. */
  65343. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  65344. /**
  65345. * Sets the given vector "result" with the given floats.
  65346. * @param x defines the x coordinate of the source
  65347. * @param y defines the y coordinate of the source
  65348. * @param z defines the z coordinate of the source
  65349. * @param result defines the Vector3 where to store the result
  65350. */
  65351. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  65352. /**
  65353. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  65354. * @returns a new empty Vector3
  65355. */
  65356. static Zero(): Vector3;
  65357. /**
  65358. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  65359. * @returns a new unit Vector3
  65360. */
  65361. static One(): Vector3;
  65362. /**
  65363. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  65364. * @returns a new up Vector3
  65365. */
  65366. static Up(): Vector3;
  65367. /**
  65368. * Gets a up Vector3 that must not be updated
  65369. */
  65370. static readonly UpReadOnly: DeepImmutable<Vector3>;
  65371. /**
  65372. * Gets a zero Vector3 that must not be updated
  65373. */
  65374. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  65375. /**
  65376. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  65377. * @returns a new down Vector3
  65378. */
  65379. static Down(): Vector3;
  65380. /**
  65381. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  65382. * @returns a new forward Vector3
  65383. */
  65384. static Forward(): Vector3;
  65385. /**
  65386. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  65387. * @returns a new forward Vector3
  65388. */
  65389. static Backward(): Vector3;
  65390. /**
  65391. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  65392. * @returns a new right Vector3
  65393. */
  65394. static Right(): Vector3;
  65395. /**
  65396. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  65397. * @returns a new left Vector3
  65398. */
  65399. static Left(): Vector3;
  65400. /**
  65401. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  65402. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  65403. * @param vector defines the Vector3 to transform
  65404. * @param transformation defines the transformation matrix
  65405. * @returns the transformed Vector3
  65406. */
  65407. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  65408. /**
  65409. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  65410. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  65411. * @param vector defines the Vector3 to transform
  65412. * @param transformation defines the transformation matrix
  65413. * @param result defines the Vector3 where to store the result
  65414. */
  65415. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  65416. /**
  65417. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  65418. * This method computes tranformed coordinates only, not transformed direction vectors
  65419. * @param x define the x coordinate of the source vector
  65420. * @param y define the y coordinate of the source vector
  65421. * @param z define the z coordinate of the source vector
  65422. * @param transformation defines the transformation matrix
  65423. * @param result defines the Vector3 where to store the result
  65424. */
  65425. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  65426. /**
  65427. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  65428. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  65429. * @param vector defines the Vector3 to transform
  65430. * @param transformation defines the transformation matrix
  65431. * @returns the new Vector3
  65432. */
  65433. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  65434. /**
  65435. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  65436. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  65437. * @param vector defines the Vector3 to transform
  65438. * @param transformation defines the transformation matrix
  65439. * @param result defines the Vector3 where to store the result
  65440. */
  65441. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  65442. /**
  65443. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  65444. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  65445. * @param x define the x coordinate of the source vector
  65446. * @param y define the y coordinate of the source vector
  65447. * @param z define the z coordinate of the source vector
  65448. * @param transformation defines the transformation matrix
  65449. * @param result defines the Vector3 where to store the result
  65450. */
  65451. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  65452. /**
  65453. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  65454. * @param value1 defines the first control point
  65455. * @param value2 defines the second control point
  65456. * @param value3 defines the third control point
  65457. * @param value4 defines the fourth control point
  65458. * @param amount defines the amount on the spline to use
  65459. * @returns the new Vector3
  65460. */
  65461. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  65462. /**
  65463. * 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"
  65464. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  65465. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  65466. * @param value defines the current value
  65467. * @param min defines the lower range value
  65468. * @param max defines the upper range value
  65469. * @returns the new Vector3
  65470. */
  65471. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  65472. /**
  65473. * 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"
  65474. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  65475. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  65476. * @param value defines the current value
  65477. * @param min defines the lower range value
  65478. * @param max defines the upper range value
  65479. * @param result defines the Vector3 where to store the result
  65480. */
  65481. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  65482. /**
  65483. * Checks if a given vector is inside a specific range
  65484. * @param v defines the vector to test
  65485. * @param min defines the minimum range
  65486. * @param max defines the maximum range
  65487. */
  65488. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  65489. /**
  65490. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  65491. * @param value1 defines the first control point
  65492. * @param tangent1 defines the first tangent vector
  65493. * @param value2 defines the second control point
  65494. * @param tangent2 defines the second tangent vector
  65495. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  65496. * @returns the new Vector3
  65497. */
  65498. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  65499. /**
  65500. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  65501. * @param start defines the start value
  65502. * @param end defines the end value
  65503. * @param amount max defines amount between both (between 0 and 1)
  65504. * @returns the new Vector3
  65505. */
  65506. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  65507. /**
  65508. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  65509. * @param start defines the start value
  65510. * @param end defines the end value
  65511. * @param amount max defines amount between both (between 0 and 1)
  65512. * @param result defines the Vector3 where to store the result
  65513. */
  65514. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  65515. /**
  65516. * Returns the dot product (float) between the vectors "left" and "right"
  65517. * @param left defines the left operand
  65518. * @param right defines the right operand
  65519. * @returns the dot product
  65520. */
  65521. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  65522. /**
  65523. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  65524. * The cross product is then orthogonal to both "left" and "right"
  65525. * @param left defines the left operand
  65526. * @param right defines the right operand
  65527. * @returns the cross product
  65528. */
  65529. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  65530. /**
  65531. * Sets the given vector "result" with the cross product of "left" and "right"
  65532. * The cross product is then orthogonal to both "left" and "right"
  65533. * @param left defines the left operand
  65534. * @param right defines the right operand
  65535. * @param result defines the Vector3 where to store the result
  65536. */
  65537. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  65538. /**
  65539. * Returns a new Vector3 as the normalization of the given vector
  65540. * @param vector defines the Vector3 to normalize
  65541. * @returns the new Vector3
  65542. */
  65543. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  65544. /**
  65545. * Sets the given vector "result" with the normalization of the given first vector
  65546. * @param vector defines the Vector3 to normalize
  65547. * @param result defines the Vector3 where to store the result
  65548. */
  65549. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  65550. /**
  65551. * Project a Vector3 onto screen space
  65552. * @param vector defines the Vector3 to project
  65553. * @param world defines the world matrix to use
  65554. * @param transform defines the transform (view x projection) matrix to use
  65555. * @param viewport defines the screen viewport to use
  65556. * @returns the new Vector3
  65557. */
  65558. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  65559. /** @hidden */
  65560. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  65561. /**
  65562. * Unproject from screen space to object space
  65563. * @param source defines the screen space Vector3 to use
  65564. * @param viewportWidth defines the current width of the viewport
  65565. * @param viewportHeight defines the current height of the viewport
  65566. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  65567. * @param transform defines the transform (view x projection) matrix to use
  65568. * @returns the new Vector3
  65569. */
  65570. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  65571. /**
  65572. * Unproject from screen space to object space
  65573. * @param source defines the screen space Vector3 to use
  65574. * @param viewportWidth defines the current width of the viewport
  65575. * @param viewportHeight defines the current height of the viewport
  65576. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  65577. * @param view defines the view matrix to use
  65578. * @param projection defines the projection matrix to use
  65579. * @returns the new Vector3
  65580. */
  65581. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  65582. /**
  65583. * Unproject from screen space to object space
  65584. * @param source defines the screen space Vector3 to use
  65585. * @param viewportWidth defines the current width of the viewport
  65586. * @param viewportHeight defines the current height of the viewport
  65587. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  65588. * @param view defines the view matrix to use
  65589. * @param projection defines the projection matrix to use
  65590. * @param result defines the Vector3 where to store the result
  65591. */
  65592. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  65593. /**
  65594. * Unproject from screen space to object space
  65595. * @param sourceX defines the screen space x coordinate to use
  65596. * @param sourceY defines the screen space y coordinate to use
  65597. * @param sourceZ defines the screen space z coordinate to use
  65598. * @param viewportWidth defines the current width of the viewport
  65599. * @param viewportHeight defines the current height of the viewport
  65600. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  65601. * @param view defines the view matrix to use
  65602. * @param projection defines the projection matrix to use
  65603. * @param result defines the Vector3 where to store the result
  65604. */
  65605. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  65606. /**
  65607. * Gets the minimal coordinate values between two Vector3
  65608. * @param left defines the first operand
  65609. * @param right defines the second operand
  65610. * @returns the new Vector3
  65611. */
  65612. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  65613. /**
  65614. * Gets the maximal coordinate values between two Vector3
  65615. * @param left defines the first operand
  65616. * @param right defines the second operand
  65617. * @returns the new Vector3
  65618. */
  65619. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  65620. /**
  65621. * Returns the distance between the vectors "value1" and "value2"
  65622. * @param value1 defines the first operand
  65623. * @param value2 defines the second operand
  65624. * @returns the distance
  65625. */
  65626. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  65627. /**
  65628. * Returns the squared distance between the vectors "value1" and "value2"
  65629. * @param value1 defines the first operand
  65630. * @param value2 defines the second operand
  65631. * @returns the squared distance
  65632. */
  65633. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  65634. /**
  65635. * Returns a new Vector3 located at the center between "value1" and "value2"
  65636. * @param value1 defines the first operand
  65637. * @param value2 defines the second operand
  65638. * @returns the new Vector3
  65639. */
  65640. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  65641. /**
  65642. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  65643. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  65644. * to something in order to rotate it from its local system to the given target system
  65645. * Note: axis1, axis2 and axis3 are normalized during this operation
  65646. * @param axis1 defines the first axis
  65647. * @param axis2 defines the second axis
  65648. * @param axis3 defines the third axis
  65649. * @returns a new Vector3
  65650. */
  65651. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  65652. /**
  65653. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  65654. * @param axis1 defines the first axis
  65655. * @param axis2 defines the second axis
  65656. * @param axis3 defines the third axis
  65657. * @param ref defines the Vector3 where to store the result
  65658. */
  65659. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  65660. }
  65661. /**
  65662. * Vector4 class created for EulerAngle class conversion to Quaternion
  65663. */
  65664. export class Vector4 {
  65665. /** x value of the vector */
  65666. x: number;
  65667. /** y value of the vector */
  65668. y: number;
  65669. /** z value of the vector */
  65670. z: number;
  65671. /** w value of the vector */
  65672. w: number;
  65673. /**
  65674. * Creates a Vector4 object from the given floats.
  65675. * @param x x value of the vector
  65676. * @param y y value of the vector
  65677. * @param z z value of the vector
  65678. * @param w w value of the vector
  65679. */
  65680. constructor(
  65681. /** x value of the vector */
  65682. x: number,
  65683. /** y value of the vector */
  65684. y: number,
  65685. /** z value of the vector */
  65686. z: number,
  65687. /** w value of the vector */
  65688. w: number);
  65689. /**
  65690. * Returns the string with the Vector4 coordinates.
  65691. * @returns a string containing all the vector values
  65692. */
  65693. toString(): string;
  65694. /**
  65695. * Returns the string "Vector4".
  65696. * @returns "Vector4"
  65697. */
  65698. getClassName(): string;
  65699. /**
  65700. * Returns the Vector4 hash code.
  65701. * @returns a unique hash code
  65702. */
  65703. getHashCode(): number;
  65704. /**
  65705. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  65706. * @returns the resulting array
  65707. */
  65708. asArray(): number[];
  65709. /**
  65710. * Populates the given array from the given index with the Vector4 coordinates.
  65711. * @param array array to populate
  65712. * @param index index of the array to start at (default: 0)
  65713. * @returns the Vector4.
  65714. */
  65715. toArray(array: FloatArray, index?: number): Vector4;
  65716. /**
  65717. * Adds the given vector to the current Vector4.
  65718. * @param otherVector the vector to add
  65719. * @returns the updated Vector4.
  65720. */
  65721. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  65722. /**
  65723. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  65724. * @param otherVector the vector to add
  65725. * @returns the resulting vector
  65726. */
  65727. add(otherVector: DeepImmutable<Vector4>): Vector4;
  65728. /**
  65729. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  65730. * @param otherVector the vector to add
  65731. * @param result the vector to store the result
  65732. * @returns the current Vector4.
  65733. */
  65734. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  65735. /**
  65736. * Subtract in place the given vector from the current Vector4.
  65737. * @param otherVector the vector to subtract
  65738. * @returns the updated Vector4.
  65739. */
  65740. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  65741. /**
  65742. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  65743. * @param otherVector the vector to add
  65744. * @returns the new vector with the result
  65745. */
  65746. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  65747. /**
  65748. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  65749. * @param otherVector the vector to subtract
  65750. * @param result the vector to store the result
  65751. * @returns the current Vector4.
  65752. */
  65753. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  65754. /**
  65755. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  65756. */
  65757. /**
  65758. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  65759. * @param x value to subtract
  65760. * @param y value to subtract
  65761. * @param z value to subtract
  65762. * @param w value to subtract
  65763. * @returns new vector containing the result
  65764. */
  65765. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  65766. /**
  65767. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  65768. * @param x value to subtract
  65769. * @param y value to subtract
  65770. * @param z value to subtract
  65771. * @param w value to subtract
  65772. * @param result the vector to store the result in
  65773. * @returns the current Vector4.
  65774. */
  65775. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  65776. /**
  65777. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  65778. * @returns a new vector with the negated values
  65779. */
  65780. negate(): Vector4;
  65781. /**
  65782. * Multiplies the current Vector4 coordinates by scale (float).
  65783. * @param scale the number to scale with
  65784. * @returns the updated Vector4.
  65785. */
  65786. scaleInPlace(scale: number): Vector4;
  65787. /**
  65788. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  65789. * @param scale the number to scale with
  65790. * @returns a new vector with the result
  65791. */
  65792. scale(scale: number): Vector4;
  65793. /**
  65794. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  65795. * @param scale the number to scale with
  65796. * @param result a vector to store the result in
  65797. * @returns the current Vector4.
  65798. */
  65799. scaleToRef(scale: number, result: Vector4): Vector4;
  65800. /**
  65801. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  65802. * @param scale defines the scale factor
  65803. * @param result defines the Vector4 object where to store the result
  65804. * @returns the unmodified current Vector4
  65805. */
  65806. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  65807. /**
  65808. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  65809. * @param otherVector the vector to compare against
  65810. * @returns true if they are equal
  65811. */
  65812. equals(otherVector: DeepImmutable<Vector4>): boolean;
  65813. /**
  65814. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  65815. * @param otherVector vector to compare against
  65816. * @param epsilon (Default: very small number)
  65817. * @returns true if they are equal
  65818. */
  65819. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  65820. /**
  65821. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  65822. * @param x x value to compare against
  65823. * @param y y value to compare against
  65824. * @param z z value to compare against
  65825. * @param w w value to compare against
  65826. * @returns true if equal
  65827. */
  65828. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  65829. /**
  65830. * Multiplies in place the current Vector4 by the given one.
  65831. * @param otherVector vector to multiple with
  65832. * @returns the updated Vector4.
  65833. */
  65834. multiplyInPlace(otherVector: Vector4): Vector4;
  65835. /**
  65836. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  65837. * @param otherVector vector to multiple with
  65838. * @returns resulting new vector
  65839. */
  65840. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  65841. /**
  65842. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  65843. * @param otherVector vector to multiple with
  65844. * @param result vector to store the result
  65845. * @returns the current Vector4.
  65846. */
  65847. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  65848. /**
  65849. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  65850. * @param x x value multiply with
  65851. * @param y y value multiply with
  65852. * @param z z value multiply with
  65853. * @param w w value multiply with
  65854. * @returns resulting new vector
  65855. */
  65856. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  65857. /**
  65858. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  65859. * @param otherVector vector to devide with
  65860. * @returns resulting new vector
  65861. */
  65862. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  65863. /**
  65864. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  65865. * @param otherVector vector to devide with
  65866. * @param result vector to store the result
  65867. * @returns the current Vector4.
  65868. */
  65869. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  65870. /**
  65871. * Divides the current Vector3 coordinates by the given ones.
  65872. * @param otherVector vector to devide with
  65873. * @returns the updated Vector3.
  65874. */
  65875. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  65876. /**
  65877. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  65878. * @param other defines the second operand
  65879. * @returns the current updated Vector4
  65880. */
  65881. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  65882. /**
  65883. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  65884. * @param other defines the second operand
  65885. * @returns the current updated Vector4
  65886. */
  65887. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  65888. /**
  65889. * Gets a new Vector4 from current Vector4 floored values
  65890. * @returns a new Vector4
  65891. */
  65892. floor(): Vector4;
  65893. /**
  65894. * Gets a new Vector4 from current Vector3 floored values
  65895. * @returns a new Vector4
  65896. */
  65897. fract(): Vector4;
  65898. /**
  65899. * Returns the Vector4 length (float).
  65900. * @returns the length
  65901. */
  65902. length(): number;
  65903. /**
  65904. * Returns the Vector4 squared length (float).
  65905. * @returns the length squared
  65906. */
  65907. lengthSquared(): number;
  65908. /**
  65909. * Normalizes in place the Vector4.
  65910. * @returns the updated Vector4.
  65911. */
  65912. normalize(): Vector4;
  65913. /**
  65914. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  65915. * @returns this converted to a new vector3
  65916. */
  65917. toVector3(): Vector3;
  65918. /**
  65919. * Returns a new Vector4 copied from the current one.
  65920. * @returns the new cloned vector
  65921. */
  65922. clone(): Vector4;
  65923. /**
  65924. * Updates the current Vector4 with the given one coordinates.
  65925. * @param source the source vector to copy from
  65926. * @returns the updated Vector4.
  65927. */
  65928. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  65929. /**
  65930. * Updates the current Vector4 coordinates with the given floats.
  65931. * @param x float to copy from
  65932. * @param y float to copy from
  65933. * @param z float to copy from
  65934. * @param w float to copy from
  65935. * @returns the updated Vector4.
  65936. */
  65937. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  65938. /**
  65939. * Updates the current Vector4 coordinates with the given floats.
  65940. * @param x float to set from
  65941. * @param y float to set from
  65942. * @param z float to set from
  65943. * @param w float to set from
  65944. * @returns the updated Vector4.
  65945. */
  65946. set(x: number, y: number, z: number, w: number): Vector4;
  65947. /**
  65948. * Copies the given float to the current Vector3 coordinates
  65949. * @param v defines the x, y, z and w coordinates of the operand
  65950. * @returns the current updated Vector3
  65951. */
  65952. setAll(v: number): Vector4;
  65953. /**
  65954. * Returns a new Vector4 set from the starting index of the given array.
  65955. * @param array the array to pull values from
  65956. * @param offset the offset into the array to start at
  65957. * @returns the new vector
  65958. */
  65959. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  65960. /**
  65961. * Updates the given vector "result" from the starting index of the given array.
  65962. * @param array the array to pull values from
  65963. * @param offset the offset into the array to start at
  65964. * @param result the vector to store the result in
  65965. */
  65966. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  65967. /**
  65968. * Updates the given vector "result" from the starting index of the given Float32Array.
  65969. * @param array the array to pull values from
  65970. * @param offset the offset into the array to start at
  65971. * @param result the vector to store the result in
  65972. */
  65973. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  65974. /**
  65975. * Updates the given vector "result" coordinates from the given floats.
  65976. * @param x float to set from
  65977. * @param y float to set from
  65978. * @param z float to set from
  65979. * @param w float to set from
  65980. * @param result the vector to the floats in
  65981. */
  65982. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  65983. /**
  65984. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  65985. * @returns the new vector
  65986. */
  65987. static Zero(): Vector4;
  65988. /**
  65989. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  65990. * @returns the new vector
  65991. */
  65992. static One(): Vector4;
  65993. /**
  65994. * Returns a new normalized Vector4 from the given one.
  65995. * @param vector the vector to normalize
  65996. * @returns the vector
  65997. */
  65998. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  65999. /**
  66000. * Updates the given vector "result" from the normalization of the given one.
  66001. * @param vector the vector to normalize
  66002. * @param result the vector to store the result in
  66003. */
  66004. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  66005. /**
  66006. * Returns a vector with the minimum values from the left and right vectors
  66007. * @param left left vector to minimize
  66008. * @param right right vector to minimize
  66009. * @returns a new vector with the minimum of the left and right vector values
  66010. */
  66011. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  66012. /**
  66013. * Returns a vector with the maximum values from the left and right vectors
  66014. * @param left left vector to maximize
  66015. * @param right right vector to maximize
  66016. * @returns a new vector with the maximum of the left and right vector values
  66017. */
  66018. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  66019. /**
  66020. * Returns the distance (float) between the vectors "value1" and "value2".
  66021. * @param value1 value to calulate the distance between
  66022. * @param value2 value to calulate the distance between
  66023. * @return the distance between the two vectors
  66024. */
  66025. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  66026. /**
  66027. * Returns the squared distance (float) between the vectors "value1" and "value2".
  66028. * @param value1 value to calulate the distance between
  66029. * @param value2 value to calulate the distance between
  66030. * @return the distance between the two vectors squared
  66031. */
  66032. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  66033. /**
  66034. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  66035. * @param value1 value to calulate the center between
  66036. * @param value2 value to calulate the center between
  66037. * @return the center between the two vectors
  66038. */
  66039. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  66040. /**
  66041. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  66042. * This methods computes transformed normalized direction vectors only.
  66043. * @param vector the vector to transform
  66044. * @param transformation the transformation matrix to apply
  66045. * @returns the new vector
  66046. */
  66047. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  66048. /**
  66049. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  66050. * This methods computes transformed normalized direction vectors only.
  66051. * @param vector the vector to transform
  66052. * @param transformation the transformation matrix to apply
  66053. * @param result the vector to store the result in
  66054. */
  66055. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  66056. /**
  66057. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  66058. * This methods computes transformed normalized direction vectors only.
  66059. * @param x value to transform
  66060. * @param y value to transform
  66061. * @param z value to transform
  66062. * @param w value to transform
  66063. * @param transformation the transformation matrix to apply
  66064. * @param result the vector to store the results in
  66065. */
  66066. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  66067. /**
  66068. * Creates a new Vector4 from a Vector3
  66069. * @param source defines the source data
  66070. * @param w defines the 4th component (default is 0)
  66071. * @returns a new Vector4
  66072. */
  66073. static FromVector3(source: Vector3, w?: number): Vector4;
  66074. }
  66075. /**
  66076. * Class used to store quaternion data
  66077. * @see https://en.wikipedia.org/wiki/Quaternion
  66078. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  66079. */
  66080. export class Quaternion {
  66081. /** defines the first component (0 by default) */
  66082. x: number;
  66083. /** defines the second component (0 by default) */
  66084. y: number;
  66085. /** defines the third component (0 by default) */
  66086. z: number;
  66087. /** defines the fourth component (1.0 by default) */
  66088. w: number;
  66089. /**
  66090. * Creates a new Quaternion from the given floats
  66091. * @param x defines the first component (0 by default)
  66092. * @param y defines the second component (0 by default)
  66093. * @param z defines the third component (0 by default)
  66094. * @param w defines the fourth component (1.0 by default)
  66095. */
  66096. constructor(
  66097. /** defines the first component (0 by default) */
  66098. x?: number,
  66099. /** defines the second component (0 by default) */
  66100. y?: number,
  66101. /** defines the third component (0 by default) */
  66102. z?: number,
  66103. /** defines the fourth component (1.0 by default) */
  66104. w?: number);
  66105. /**
  66106. * Gets a string representation for the current quaternion
  66107. * @returns a string with the Quaternion coordinates
  66108. */
  66109. toString(): string;
  66110. /**
  66111. * Gets the class name of the quaternion
  66112. * @returns the string "Quaternion"
  66113. */
  66114. getClassName(): string;
  66115. /**
  66116. * Gets a hash code for this quaternion
  66117. * @returns the quaternion hash code
  66118. */
  66119. getHashCode(): number;
  66120. /**
  66121. * Copy the quaternion to an array
  66122. * @returns a new array populated with 4 elements from the quaternion coordinates
  66123. */
  66124. asArray(): number[];
  66125. /**
  66126. * Check if two quaternions are equals
  66127. * @param otherQuaternion defines the second operand
  66128. * @return true if the current quaternion and the given one coordinates are strictly equals
  66129. */
  66130. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  66131. /**
  66132. * Clone the current quaternion
  66133. * @returns a new quaternion copied from the current one
  66134. */
  66135. clone(): Quaternion;
  66136. /**
  66137. * Copy a quaternion to the current one
  66138. * @param other defines the other quaternion
  66139. * @returns the updated current quaternion
  66140. */
  66141. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  66142. /**
  66143. * Updates the current quaternion with the given float coordinates
  66144. * @param x defines the x coordinate
  66145. * @param y defines the y coordinate
  66146. * @param z defines the z coordinate
  66147. * @param w defines the w coordinate
  66148. * @returns the updated current quaternion
  66149. */
  66150. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  66151. /**
  66152. * Updates the current quaternion from the given float coordinates
  66153. * @param x defines the x coordinate
  66154. * @param y defines the y coordinate
  66155. * @param z defines the z coordinate
  66156. * @param w defines the w coordinate
  66157. * @returns the updated current quaternion
  66158. */
  66159. set(x: number, y: number, z: number, w: number): Quaternion;
  66160. /**
  66161. * Adds two quaternions
  66162. * @param other defines the second operand
  66163. * @returns a new quaternion as the addition result of the given one and the current quaternion
  66164. */
  66165. add(other: DeepImmutable<Quaternion>): Quaternion;
  66166. /**
  66167. * Add a quaternion to the current one
  66168. * @param other defines the quaternion to add
  66169. * @returns the current quaternion
  66170. */
  66171. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  66172. /**
  66173. * Subtract two quaternions
  66174. * @param other defines the second operand
  66175. * @returns a new quaternion as the subtraction result of the given one from the current one
  66176. */
  66177. subtract(other: Quaternion): Quaternion;
  66178. /**
  66179. * Multiplies the current quaternion by a scale factor
  66180. * @param value defines the scale factor
  66181. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  66182. */
  66183. scale(value: number): Quaternion;
  66184. /**
  66185. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  66186. * @param scale defines the scale factor
  66187. * @param result defines the Quaternion object where to store the result
  66188. * @returns the unmodified current quaternion
  66189. */
  66190. scaleToRef(scale: number, result: Quaternion): Quaternion;
  66191. /**
  66192. * Multiplies in place the current quaternion by a scale factor
  66193. * @param value defines the scale factor
  66194. * @returns the current modified quaternion
  66195. */
  66196. scaleInPlace(value: number): Quaternion;
  66197. /**
  66198. * Scale the current quaternion values by a factor and add the result to a given quaternion
  66199. * @param scale defines the scale factor
  66200. * @param result defines the Quaternion object where to store the result
  66201. * @returns the unmodified current quaternion
  66202. */
  66203. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  66204. /**
  66205. * Multiplies two quaternions
  66206. * @param q1 defines the second operand
  66207. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  66208. */
  66209. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  66210. /**
  66211. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  66212. * @param q1 defines the second operand
  66213. * @param result defines the target quaternion
  66214. * @returns the current quaternion
  66215. */
  66216. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  66217. /**
  66218. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  66219. * @param q1 defines the second operand
  66220. * @returns the currentupdated quaternion
  66221. */
  66222. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  66223. /**
  66224. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  66225. * @param ref defines the target quaternion
  66226. * @returns the current quaternion
  66227. */
  66228. conjugateToRef(ref: Quaternion): Quaternion;
  66229. /**
  66230. * Conjugates in place (1-q) the current quaternion
  66231. * @returns the current updated quaternion
  66232. */
  66233. conjugateInPlace(): Quaternion;
  66234. /**
  66235. * Conjugates in place (1-q) the current quaternion
  66236. * @returns a new quaternion
  66237. */
  66238. conjugate(): Quaternion;
  66239. /**
  66240. * Gets length of current quaternion
  66241. * @returns the quaternion length (float)
  66242. */
  66243. length(): number;
  66244. /**
  66245. * Normalize in place the current quaternion
  66246. * @returns the current updated quaternion
  66247. */
  66248. normalize(): Quaternion;
  66249. /**
  66250. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  66251. * @param order is a reserved parameter and is ignore for now
  66252. * @returns a new Vector3 containing the Euler angles
  66253. */
  66254. toEulerAngles(order?: string): Vector3;
  66255. /**
  66256. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  66257. * @param result defines the vector which will be filled with the Euler angles
  66258. * @param order is a reserved parameter and is ignore for now
  66259. * @returns the current unchanged quaternion
  66260. */
  66261. toEulerAnglesToRef(result: Vector3): Quaternion;
  66262. /**
  66263. * Updates the given rotation matrix with the current quaternion values
  66264. * @param result defines the target matrix
  66265. * @returns the current unchanged quaternion
  66266. */
  66267. toRotationMatrix(result: Matrix): Quaternion;
  66268. /**
  66269. * Updates the current quaternion from the given rotation matrix values
  66270. * @param matrix defines the source matrix
  66271. * @returns the current updated quaternion
  66272. */
  66273. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  66274. /**
  66275. * Creates a new quaternion from a rotation matrix
  66276. * @param matrix defines the source matrix
  66277. * @returns a new quaternion created from the given rotation matrix values
  66278. */
  66279. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  66280. /**
  66281. * Updates the given quaternion with the given rotation matrix values
  66282. * @param matrix defines the source matrix
  66283. * @param result defines the target quaternion
  66284. */
  66285. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  66286. /**
  66287. * Returns the dot product (float) between the quaternions "left" and "right"
  66288. * @param left defines the left operand
  66289. * @param right defines the right operand
  66290. * @returns the dot product
  66291. */
  66292. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  66293. /**
  66294. * Checks if the two quaternions are close to each other
  66295. * @param quat0 defines the first quaternion to check
  66296. * @param quat1 defines the second quaternion to check
  66297. * @returns true if the two quaternions are close to each other
  66298. */
  66299. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  66300. /**
  66301. * Creates an empty quaternion
  66302. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  66303. */
  66304. static Zero(): Quaternion;
  66305. /**
  66306. * Inverse a given quaternion
  66307. * @param q defines the source quaternion
  66308. * @returns a new quaternion as the inverted current quaternion
  66309. */
  66310. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  66311. /**
  66312. * Inverse a given quaternion
  66313. * @param q defines the source quaternion
  66314. * @param result the quaternion the result will be stored in
  66315. * @returns the result quaternion
  66316. */
  66317. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  66318. /**
  66319. * Creates an identity quaternion
  66320. * @returns the identity quaternion
  66321. */
  66322. static Identity(): Quaternion;
  66323. /**
  66324. * Gets a boolean indicating if the given quaternion is identity
  66325. * @param quaternion defines the quaternion to check
  66326. * @returns true if the quaternion is identity
  66327. */
  66328. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  66329. /**
  66330. * Creates a quaternion from a rotation around an axis
  66331. * @param axis defines the axis to use
  66332. * @param angle defines the angle to use
  66333. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  66334. */
  66335. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  66336. /**
  66337. * Creates a rotation around an axis and stores it into the given quaternion
  66338. * @param axis defines the axis to use
  66339. * @param angle defines the angle to use
  66340. * @param result defines the target quaternion
  66341. * @returns the target quaternion
  66342. */
  66343. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  66344. /**
  66345. * Creates a new quaternion from data stored into an array
  66346. * @param array defines the data source
  66347. * @param offset defines the offset in the source array where the data starts
  66348. * @returns a new quaternion
  66349. */
  66350. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  66351. /**
  66352. * Create a quaternion from Euler rotation angles
  66353. * @param x Pitch
  66354. * @param y Yaw
  66355. * @param z Roll
  66356. * @returns the new Quaternion
  66357. */
  66358. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  66359. /**
  66360. * Updates a quaternion from Euler rotation angles
  66361. * @param x Pitch
  66362. * @param y Yaw
  66363. * @param z Roll
  66364. * @param result the quaternion to store the result
  66365. * @returns the updated quaternion
  66366. */
  66367. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  66368. /**
  66369. * Create a quaternion from Euler rotation vector
  66370. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  66371. * @returns the new Quaternion
  66372. */
  66373. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  66374. /**
  66375. * Updates a quaternion from Euler rotation vector
  66376. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  66377. * @param result the quaternion to store the result
  66378. * @returns the updated quaternion
  66379. */
  66380. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  66381. /**
  66382. * Creates a new quaternion from the given Euler float angles (y, x, z)
  66383. * @param yaw defines the rotation around Y axis
  66384. * @param pitch defines the rotation around X axis
  66385. * @param roll defines the rotation around Z axis
  66386. * @returns the new quaternion
  66387. */
  66388. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  66389. /**
  66390. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  66391. * @param yaw defines the rotation around Y axis
  66392. * @param pitch defines the rotation around X axis
  66393. * @param roll defines the rotation around Z axis
  66394. * @param result defines the target quaternion
  66395. */
  66396. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  66397. /**
  66398. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  66399. * @param alpha defines the rotation around first axis
  66400. * @param beta defines the rotation around second axis
  66401. * @param gamma defines the rotation around third axis
  66402. * @returns the new quaternion
  66403. */
  66404. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  66405. /**
  66406. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  66407. * @param alpha defines the rotation around first axis
  66408. * @param beta defines the rotation around second axis
  66409. * @param gamma defines the rotation around third axis
  66410. * @param result defines the target quaternion
  66411. */
  66412. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  66413. /**
  66414. * 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)
  66415. * @param axis1 defines the first axis
  66416. * @param axis2 defines the second axis
  66417. * @param axis3 defines the third axis
  66418. * @returns the new quaternion
  66419. */
  66420. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  66421. /**
  66422. * 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
  66423. * @param axis1 defines the first axis
  66424. * @param axis2 defines the second axis
  66425. * @param axis3 defines the third axis
  66426. * @param ref defines the target quaternion
  66427. */
  66428. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  66429. /**
  66430. * Interpolates between two quaternions
  66431. * @param left defines first quaternion
  66432. * @param right defines second quaternion
  66433. * @param amount defines the gradient to use
  66434. * @returns the new interpolated quaternion
  66435. */
  66436. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  66437. /**
  66438. * Interpolates between two quaternions and stores it into a target quaternion
  66439. * @param left defines first quaternion
  66440. * @param right defines second quaternion
  66441. * @param amount defines the gradient to use
  66442. * @param result defines the target quaternion
  66443. */
  66444. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  66445. /**
  66446. * Interpolate between two quaternions using Hermite interpolation
  66447. * @param value1 defines first quaternion
  66448. * @param tangent1 defines the incoming tangent
  66449. * @param value2 defines second quaternion
  66450. * @param tangent2 defines the outgoing tangent
  66451. * @param amount defines the target quaternion
  66452. * @returns the new interpolated quaternion
  66453. */
  66454. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  66455. }
  66456. /**
  66457. * Class used to store matrix data (4x4)
  66458. */
  66459. export class Matrix {
  66460. private static _updateFlagSeed;
  66461. private static _identityReadOnly;
  66462. private _isIdentity;
  66463. private _isIdentityDirty;
  66464. private _isIdentity3x2;
  66465. private _isIdentity3x2Dirty;
  66466. /**
  66467. * Gets the update flag of the matrix which is an unique number for the matrix.
  66468. * It will be incremented every time the matrix data change.
  66469. * You can use it to speed the comparison between two versions of the same matrix.
  66470. */
  66471. updateFlag: number;
  66472. private readonly _m;
  66473. /**
  66474. * Gets the internal data of the matrix
  66475. */
  66476. readonly m: DeepImmutable<Float32Array>;
  66477. /** @hidden */
  66478. _markAsUpdated(): void;
  66479. /** @hidden */
  66480. private _updateIdentityStatus;
  66481. /**
  66482. * Creates an empty matrix (filled with zeros)
  66483. */
  66484. constructor();
  66485. /**
  66486. * Check if the current matrix is identity
  66487. * @returns true is the matrix is the identity matrix
  66488. */
  66489. isIdentity(): boolean;
  66490. /**
  66491. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  66492. * @returns true is the matrix is the identity matrix
  66493. */
  66494. isIdentityAs3x2(): boolean;
  66495. /**
  66496. * Gets the determinant of the matrix
  66497. * @returns the matrix determinant
  66498. */
  66499. determinant(): number;
  66500. /**
  66501. * Returns the matrix as a Float32Array
  66502. * @returns the matrix underlying array
  66503. */
  66504. toArray(): DeepImmutable<Float32Array>;
  66505. /**
  66506. * Returns the matrix as a Float32Array
  66507. * @returns the matrix underlying array.
  66508. */
  66509. asArray(): DeepImmutable<Float32Array>;
  66510. /**
  66511. * Inverts the current matrix in place
  66512. * @returns the current inverted matrix
  66513. */
  66514. invert(): Matrix;
  66515. /**
  66516. * Sets all the matrix elements to zero
  66517. * @returns the current matrix
  66518. */
  66519. reset(): Matrix;
  66520. /**
  66521. * Adds the current matrix with a second one
  66522. * @param other defines the matrix to add
  66523. * @returns a new matrix as the addition of the current matrix and the given one
  66524. */
  66525. add(other: DeepImmutable<Matrix>): Matrix;
  66526. /**
  66527. * Sets the given matrix "result" to the addition of the current matrix and the given one
  66528. * @param other defines the matrix to add
  66529. * @param result defines the target matrix
  66530. * @returns the current matrix
  66531. */
  66532. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  66533. /**
  66534. * Adds in place the given matrix to the current matrix
  66535. * @param other defines the second operand
  66536. * @returns the current updated matrix
  66537. */
  66538. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  66539. /**
  66540. * Sets the given matrix to the current inverted Matrix
  66541. * @param other defines the target matrix
  66542. * @returns the unmodified current matrix
  66543. */
  66544. invertToRef(other: Matrix): Matrix;
  66545. /**
  66546. * add a value at the specified position in the current Matrix
  66547. * @param index the index of the value within the matrix. between 0 and 15.
  66548. * @param value the value to be added
  66549. * @returns the current updated matrix
  66550. */
  66551. addAtIndex(index: number, value: number): Matrix;
  66552. /**
  66553. * mutiply the specified position in the current Matrix by a value
  66554. * @param index the index of the value within the matrix. between 0 and 15.
  66555. * @param value the value to be added
  66556. * @returns the current updated matrix
  66557. */
  66558. multiplyAtIndex(index: number, value: number): Matrix;
  66559. /**
  66560. * Inserts the translation vector (using 3 floats) in the current matrix
  66561. * @param x defines the 1st component of the translation
  66562. * @param y defines the 2nd component of the translation
  66563. * @param z defines the 3rd component of the translation
  66564. * @returns the current updated matrix
  66565. */
  66566. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  66567. /**
  66568. * Adds the translation vector (using 3 floats) in the current matrix
  66569. * @param x defines the 1st component of the translation
  66570. * @param y defines the 2nd component of the translation
  66571. * @param z defines the 3rd component of the translation
  66572. * @returns the current updated matrix
  66573. */
  66574. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  66575. /**
  66576. * Inserts the translation vector in the current matrix
  66577. * @param vector3 defines the translation to insert
  66578. * @returns the current updated matrix
  66579. */
  66580. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  66581. /**
  66582. * Gets the translation value of the current matrix
  66583. * @returns a new Vector3 as the extracted translation from the matrix
  66584. */
  66585. getTranslation(): Vector3;
  66586. /**
  66587. * Fill a Vector3 with the extracted translation from the matrix
  66588. * @param result defines the Vector3 where to store the translation
  66589. * @returns the current matrix
  66590. */
  66591. getTranslationToRef(result: Vector3): Matrix;
  66592. /**
  66593. * Remove rotation and scaling part from the matrix
  66594. * @returns the updated matrix
  66595. */
  66596. removeRotationAndScaling(): Matrix;
  66597. /**
  66598. * Multiply two matrices
  66599. * @param other defines the second operand
  66600. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  66601. */
  66602. multiply(other: DeepImmutable<Matrix>): Matrix;
  66603. /**
  66604. * Copy the current matrix from the given one
  66605. * @param other defines the source matrix
  66606. * @returns the current updated matrix
  66607. */
  66608. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  66609. /**
  66610. * Populates the given array from the starting index with the current matrix values
  66611. * @param array defines the target array
  66612. * @param offset defines the offset in the target array where to start storing values
  66613. * @returns the current matrix
  66614. */
  66615. copyToArray(array: Float32Array, offset?: number): Matrix;
  66616. /**
  66617. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  66618. * @param other defines the second operand
  66619. * @param result defines the matrix where to store the multiplication
  66620. * @returns the current matrix
  66621. */
  66622. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  66623. /**
  66624. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  66625. * @param other defines the second operand
  66626. * @param result defines the array where to store the multiplication
  66627. * @param offset defines the offset in the target array where to start storing values
  66628. * @returns the current matrix
  66629. */
  66630. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  66631. /**
  66632. * Check equality between this matrix and a second one
  66633. * @param value defines the second matrix to compare
  66634. * @returns true is the current matrix and the given one values are strictly equal
  66635. */
  66636. equals(value: DeepImmutable<Matrix>): boolean;
  66637. /**
  66638. * Clone the current matrix
  66639. * @returns a new matrix from the current matrix
  66640. */
  66641. clone(): Matrix;
  66642. /**
  66643. * Returns the name of the current matrix class
  66644. * @returns the string "Matrix"
  66645. */
  66646. getClassName(): string;
  66647. /**
  66648. * Gets the hash code of the current matrix
  66649. * @returns the hash code
  66650. */
  66651. getHashCode(): number;
  66652. /**
  66653. * Decomposes the current Matrix into a translation, rotation and scaling components
  66654. * @param scale defines the scale vector3 given as a reference to update
  66655. * @param rotation defines the rotation quaternion given as a reference to update
  66656. * @param translation defines the translation vector3 given as a reference to update
  66657. * @returns true if operation was successful
  66658. */
  66659. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  66660. /**
  66661. * Gets specific row of the matrix
  66662. * @param index defines the number of the row to get
  66663. * @returns the index-th row of the current matrix as a new Vector4
  66664. */
  66665. getRow(index: number): Nullable<Vector4>;
  66666. /**
  66667. * Sets the index-th row of the current matrix to the vector4 values
  66668. * @param index defines the number of the row to set
  66669. * @param row defines the target vector4
  66670. * @returns the updated current matrix
  66671. */
  66672. setRow(index: number, row: Vector4): Matrix;
  66673. /**
  66674. * Compute the transpose of the matrix
  66675. * @returns the new transposed matrix
  66676. */
  66677. transpose(): Matrix;
  66678. /**
  66679. * Compute the transpose of the matrix and store it in a given matrix
  66680. * @param result defines the target matrix
  66681. * @returns the current matrix
  66682. */
  66683. transposeToRef(result: Matrix): Matrix;
  66684. /**
  66685. * Sets the index-th row of the current matrix with the given 4 x float values
  66686. * @param index defines the row index
  66687. * @param x defines the x component to set
  66688. * @param y defines the y component to set
  66689. * @param z defines the z component to set
  66690. * @param w defines the w component to set
  66691. * @returns the updated current matrix
  66692. */
  66693. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  66694. /**
  66695. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  66696. * @param scale defines the scale factor
  66697. * @returns a new matrix
  66698. */
  66699. scale(scale: number): Matrix;
  66700. /**
  66701. * Scale the current matrix values by a factor to a given result matrix
  66702. * @param scale defines the scale factor
  66703. * @param result defines the matrix to store the result
  66704. * @returns the current matrix
  66705. */
  66706. scaleToRef(scale: number, result: Matrix): Matrix;
  66707. /**
  66708. * Scale the current matrix values by a factor and add the result to a given matrix
  66709. * @param scale defines the scale factor
  66710. * @param result defines the Matrix to store the result
  66711. * @returns the current matrix
  66712. */
  66713. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  66714. /**
  66715. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  66716. * @param ref matrix to store the result
  66717. */
  66718. toNormalMatrix(ref: Matrix): void;
  66719. /**
  66720. * Gets only rotation part of the current matrix
  66721. * @returns a new matrix sets to the extracted rotation matrix from the current one
  66722. */
  66723. getRotationMatrix(): Matrix;
  66724. /**
  66725. * Extracts the rotation matrix from the current one and sets it as the given "result"
  66726. * @param result defines the target matrix to store data to
  66727. * @returns the current matrix
  66728. */
  66729. getRotationMatrixToRef(result: Matrix): Matrix;
  66730. /**
  66731. * Toggles model matrix from being right handed to left handed in place and vice versa
  66732. */
  66733. toggleModelMatrixHandInPlace(): void;
  66734. /**
  66735. * Toggles projection matrix from being right handed to left handed in place and vice versa
  66736. */
  66737. toggleProjectionMatrixHandInPlace(): void;
  66738. /**
  66739. * Creates a matrix from an array
  66740. * @param array defines the source array
  66741. * @param offset defines an offset in the source array
  66742. * @returns a new Matrix set from the starting index of the given array
  66743. */
  66744. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  66745. /**
  66746. * Copy the content of an array into a given matrix
  66747. * @param array defines the source array
  66748. * @param offset defines an offset in the source array
  66749. * @param result defines the target matrix
  66750. */
  66751. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  66752. /**
  66753. * Stores an array into a matrix after having multiplied each component by a given factor
  66754. * @param array defines the source array
  66755. * @param offset defines the offset in the source array
  66756. * @param scale defines the scaling factor
  66757. * @param result defines the target matrix
  66758. */
  66759. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  66760. /**
  66761. * Gets an identity matrix that must not be updated
  66762. */
  66763. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  66764. /**
  66765. * Stores a list of values (16) inside a given matrix
  66766. * @param initialM11 defines 1st value of 1st row
  66767. * @param initialM12 defines 2nd value of 1st row
  66768. * @param initialM13 defines 3rd value of 1st row
  66769. * @param initialM14 defines 4th value of 1st row
  66770. * @param initialM21 defines 1st value of 2nd row
  66771. * @param initialM22 defines 2nd value of 2nd row
  66772. * @param initialM23 defines 3rd value of 2nd row
  66773. * @param initialM24 defines 4th value of 2nd row
  66774. * @param initialM31 defines 1st value of 3rd row
  66775. * @param initialM32 defines 2nd value of 3rd row
  66776. * @param initialM33 defines 3rd value of 3rd row
  66777. * @param initialM34 defines 4th value of 3rd row
  66778. * @param initialM41 defines 1st value of 4th row
  66779. * @param initialM42 defines 2nd value of 4th row
  66780. * @param initialM43 defines 3rd value of 4th row
  66781. * @param initialM44 defines 4th value of 4th row
  66782. * @param result defines the target matrix
  66783. */
  66784. 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;
  66785. /**
  66786. * Creates new matrix from a list of values (16)
  66787. * @param initialM11 defines 1st value of 1st row
  66788. * @param initialM12 defines 2nd value of 1st row
  66789. * @param initialM13 defines 3rd value of 1st row
  66790. * @param initialM14 defines 4th value of 1st row
  66791. * @param initialM21 defines 1st value of 2nd row
  66792. * @param initialM22 defines 2nd value of 2nd row
  66793. * @param initialM23 defines 3rd value of 2nd row
  66794. * @param initialM24 defines 4th value of 2nd row
  66795. * @param initialM31 defines 1st value of 3rd row
  66796. * @param initialM32 defines 2nd value of 3rd row
  66797. * @param initialM33 defines 3rd value of 3rd row
  66798. * @param initialM34 defines 4th value of 3rd row
  66799. * @param initialM41 defines 1st value of 4th row
  66800. * @param initialM42 defines 2nd value of 4th row
  66801. * @param initialM43 defines 3rd value of 4th row
  66802. * @param initialM44 defines 4th value of 4th row
  66803. * @returns the new matrix
  66804. */
  66805. 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;
  66806. /**
  66807. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  66808. * @param scale defines the scale vector3
  66809. * @param rotation defines the rotation quaternion
  66810. * @param translation defines the translation vector3
  66811. * @returns a new matrix
  66812. */
  66813. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  66814. /**
  66815. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  66816. * @param scale defines the scale vector3
  66817. * @param rotation defines the rotation quaternion
  66818. * @param translation defines the translation vector3
  66819. * @param result defines the target matrix
  66820. */
  66821. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  66822. /**
  66823. * Creates a new identity matrix
  66824. * @returns a new identity matrix
  66825. */
  66826. static Identity(): Matrix;
  66827. /**
  66828. * Creates a new identity matrix and stores the result in a given matrix
  66829. * @param result defines the target matrix
  66830. */
  66831. static IdentityToRef(result: Matrix): void;
  66832. /**
  66833. * Creates a new zero matrix
  66834. * @returns a new zero matrix
  66835. */
  66836. static Zero(): Matrix;
  66837. /**
  66838. * Creates a new rotation matrix for "angle" radians around the X axis
  66839. * @param angle defines the angle (in radians) to use
  66840. * @return the new matrix
  66841. */
  66842. static RotationX(angle: number): Matrix;
  66843. /**
  66844. * Creates a new matrix as the invert of a given matrix
  66845. * @param source defines the source matrix
  66846. * @returns the new matrix
  66847. */
  66848. static Invert(source: DeepImmutable<Matrix>): Matrix;
  66849. /**
  66850. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  66851. * @param angle defines the angle (in radians) to use
  66852. * @param result defines the target matrix
  66853. */
  66854. static RotationXToRef(angle: number, result: Matrix): void;
  66855. /**
  66856. * Creates a new rotation matrix for "angle" radians around the Y axis
  66857. * @param angle defines the angle (in radians) to use
  66858. * @return the new matrix
  66859. */
  66860. static RotationY(angle: number): Matrix;
  66861. /**
  66862. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  66863. * @param angle defines the angle (in radians) to use
  66864. * @param result defines the target matrix
  66865. */
  66866. static RotationYToRef(angle: number, result: Matrix): void;
  66867. /**
  66868. * Creates a new rotation matrix for "angle" radians around the Z axis
  66869. * @param angle defines the angle (in radians) to use
  66870. * @return the new matrix
  66871. */
  66872. static RotationZ(angle: number): Matrix;
  66873. /**
  66874. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  66875. * @param angle defines the angle (in radians) to use
  66876. * @param result defines the target matrix
  66877. */
  66878. static RotationZToRef(angle: number, result: Matrix): void;
  66879. /**
  66880. * Creates a new rotation matrix for "angle" radians around the given axis
  66881. * @param axis defines the axis to use
  66882. * @param angle defines the angle (in radians) to use
  66883. * @return the new matrix
  66884. */
  66885. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  66886. /**
  66887. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  66888. * @param axis defines the axis to use
  66889. * @param angle defines the angle (in radians) to use
  66890. * @param result defines the target matrix
  66891. */
  66892. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  66893. /**
  66894. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  66895. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  66896. * @param from defines the vector to align
  66897. * @param to defines the vector to align to
  66898. * @param result defines the target matrix
  66899. */
  66900. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  66901. /**
  66902. * Creates a rotation matrix
  66903. * @param yaw defines the yaw angle in radians (Y axis)
  66904. * @param pitch defines the pitch angle in radians (X axis)
  66905. * @param roll defines the roll angle in radians (X axis)
  66906. * @returns the new rotation matrix
  66907. */
  66908. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  66909. /**
  66910. * Creates a rotation matrix and stores it in a given matrix
  66911. * @param yaw defines the yaw angle in radians (Y axis)
  66912. * @param pitch defines the pitch angle in radians (X axis)
  66913. * @param roll defines the roll angle in radians (X axis)
  66914. * @param result defines the target matrix
  66915. */
  66916. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  66917. /**
  66918. * Creates a scaling matrix
  66919. * @param x defines the scale factor on X axis
  66920. * @param y defines the scale factor on Y axis
  66921. * @param z defines the scale factor on Z axis
  66922. * @returns the new matrix
  66923. */
  66924. static Scaling(x: number, y: number, z: number): Matrix;
  66925. /**
  66926. * Creates a scaling matrix and stores it in a given matrix
  66927. * @param x defines the scale factor on X axis
  66928. * @param y defines the scale factor on Y axis
  66929. * @param z defines the scale factor on Z axis
  66930. * @param result defines the target matrix
  66931. */
  66932. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  66933. /**
  66934. * Creates a translation matrix
  66935. * @param x defines the translation on X axis
  66936. * @param y defines the translation on Y axis
  66937. * @param z defines the translationon Z axis
  66938. * @returns the new matrix
  66939. */
  66940. static Translation(x: number, y: number, z: number): Matrix;
  66941. /**
  66942. * Creates a translation matrix and stores it in a given matrix
  66943. * @param x defines the translation on X axis
  66944. * @param y defines the translation on Y axis
  66945. * @param z defines the translationon Z axis
  66946. * @param result defines the target matrix
  66947. */
  66948. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  66949. /**
  66950. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  66951. * @param startValue defines the start value
  66952. * @param endValue defines the end value
  66953. * @param gradient defines the gradient factor
  66954. * @returns the new matrix
  66955. */
  66956. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  66957. /**
  66958. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  66959. * @param startValue defines the start value
  66960. * @param endValue defines the end value
  66961. * @param gradient defines the gradient factor
  66962. * @param result defines the Matrix object where to store data
  66963. */
  66964. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  66965. /**
  66966. * Builds a new matrix whose values are computed by:
  66967. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  66968. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  66969. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  66970. * @param startValue defines the first matrix
  66971. * @param endValue defines the second matrix
  66972. * @param gradient defines the gradient between the two matrices
  66973. * @returns the new matrix
  66974. */
  66975. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  66976. /**
  66977. * Update a matrix to values which are computed by:
  66978. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  66979. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  66980. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  66981. * @param startValue defines the first matrix
  66982. * @param endValue defines the second matrix
  66983. * @param gradient defines the gradient between the two matrices
  66984. * @param result defines the target matrix
  66985. */
  66986. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  66987. /**
  66988. * 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"
  66989. * This function works in left handed mode
  66990. * @param eye defines the final position of the entity
  66991. * @param target defines where the entity should look at
  66992. * @param up defines the up vector for the entity
  66993. * @returns the new matrix
  66994. */
  66995. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  66996. /**
  66997. * 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".
  66998. * This function works in left handed mode
  66999. * @param eye defines the final position of the entity
  67000. * @param target defines where the entity should look at
  67001. * @param up defines the up vector for the entity
  67002. * @param result defines the target matrix
  67003. */
  67004. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  67005. /**
  67006. * 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"
  67007. * This function works in right handed mode
  67008. * @param eye defines the final position of the entity
  67009. * @param target defines where the entity should look at
  67010. * @param up defines the up vector for the entity
  67011. * @returns the new matrix
  67012. */
  67013. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  67014. /**
  67015. * 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".
  67016. * This function works in right handed mode
  67017. * @param eye defines the final position of the entity
  67018. * @param target defines where the entity should look at
  67019. * @param up defines the up vector for the entity
  67020. * @param result defines the target matrix
  67021. */
  67022. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  67023. /**
  67024. * Create a left-handed orthographic projection matrix
  67025. * @param width defines the viewport width
  67026. * @param height defines the viewport height
  67027. * @param znear defines the near clip plane
  67028. * @param zfar defines the far clip plane
  67029. * @returns a new matrix as a left-handed orthographic projection matrix
  67030. */
  67031. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  67032. /**
  67033. * Store a left-handed orthographic projection to a given matrix
  67034. * @param width defines the viewport width
  67035. * @param height defines the viewport height
  67036. * @param znear defines the near clip plane
  67037. * @param zfar defines the far clip plane
  67038. * @param result defines the target matrix
  67039. */
  67040. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  67041. /**
  67042. * Create a left-handed orthographic projection matrix
  67043. * @param left defines the viewport left coordinate
  67044. * @param right defines the viewport right coordinate
  67045. * @param bottom defines the viewport bottom coordinate
  67046. * @param top defines the viewport top coordinate
  67047. * @param znear defines the near clip plane
  67048. * @param zfar defines the far clip plane
  67049. * @returns a new matrix as a left-handed orthographic projection matrix
  67050. */
  67051. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  67052. /**
  67053. * Stores a left-handed orthographic projection into a given matrix
  67054. * @param left defines the viewport left coordinate
  67055. * @param right defines the viewport right coordinate
  67056. * @param bottom defines the viewport bottom coordinate
  67057. * @param top defines the viewport top coordinate
  67058. * @param znear defines the near clip plane
  67059. * @param zfar defines the far clip plane
  67060. * @param result defines the target matrix
  67061. */
  67062. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  67063. /**
  67064. * Creates a right-handed orthographic projection matrix
  67065. * @param left defines the viewport left coordinate
  67066. * @param right defines the viewport right coordinate
  67067. * @param bottom defines the viewport bottom coordinate
  67068. * @param top defines the viewport top coordinate
  67069. * @param znear defines the near clip plane
  67070. * @param zfar defines the far clip plane
  67071. * @returns a new matrix as a right-handed orthographic projection matrix
  67072. */
  67073. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  67074. /**
  67075. * Stores a right-handed orthographic projection into a given matrix
  67076. * @param left defines the viewport left coordinate
  67077. * @param right defines the viewport right coordinate
  67078. * @param bottom defines the viewport bottom coordinate
  67079. * @param top defines the viewport top coordinate
  67080. * @param znear defines the near clip plane
  67081. * @param zfar defines the far clip plane
  67082. * @param result defines the target matrix
  67083. */
  67084. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  67085. /**
  67086. * Creates a left-handed perspective projection matrix
  67087. * @param width defines the viewport width
  67088. * @param height defines the viewport height
  67089. * @param znear defines the near clip plane
  67090. * @param zfar defines the far clip plane
  67091. * @returns a new matrix as a left-handed perspective projection matrix
  67092. */
  67093. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  67094. /**
  67095. * Creates a left-handed perspective projection matrix
  67096. * @param fov defines the horizontal field of view
  67097. * @param aspect defines the aspect ratio
  67098. * @param znear defines the near clip plane
  67099. * @param zfar defines the far clip plane
  67100. * @returns a new matrix as a left-handed perspective projection matrix
  67101. */
  67102. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  67103. /**
  67104. * Stores a left-handed perspective projection into a given matrix
  67105. * @param fov defines the horizontal field of view
  67106. * @param aspect defines the aspect ratio
  67107. * @param znear defines the near clip plane
  67108. * @param zfar defines the far clip plane
  67109. * @param result defines the target matrix
  67110. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  67111. */
  67112. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  67113. /**
  67114. * Creates a right-handed perspective projection matrix
  67115. * @param fov defines the horizontal field of view
  67116. * @param aspect defines the aspect ratio
  67117. * @param znear defines the near clip plane
  67118. * @param zfar defines the far clip plane
  67119. * @returns a new matrix as a right-handed perspective projection matrix
  67120. */
  67121. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  67122. /**
  67123. * Stores a right-handed perspective projection into a given matrix
  67124. * @param fov defines the horizontal field of view
  67125. * @param aspect defines the aspect ratio
  67126. * @param znear defines the near clip plane
  67127. * @param zfar defines the far clip plane
  67128. * @param result defines the target matrix
  67129. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  67130. */
  67131. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  67132. /**
  67133. * Stores a perspective projection for WebVR info a given matrix
  67134. * @param fov defines the field of view
  67135. * @param znear defines the near clip plane
  67136. * @param zfar defines the far clip plane
  67137. * @param result defines the target matrix
  67138. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  67139. */
  67140. static PerspectiveFovWebVRToRef(fov: {
  67141. upDegrees: number;
  67142. downDegrees: number;
  67143. leftDegrees: number;
  67144. rightDegrees: number;
  67145. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  67146. /**
  67147. * Computes a complete transformation matrix
  67148. * @param viewport defines the viewport to use
  67149. * @param world defines the world matrix
  67150. * @param view defines the view matrix
  67151. * @param projection defines the projection matrix
  67152. * @param zmin defines the near clip plane
  67153. * @param zmax defines the far clip plane
  67154. * @returns the transformation matrix
  67155. */
  67156. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  67157. /**
  67158. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  67159. * @param matrix defines the matrix to use
  67160. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  67161. */
  67162. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  67163. /**
  67164. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  67165. * @param matrix defines the matrix to use
  67166. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  67167. */
  67168. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  67169. /**
  67170. * Compute the transpose of a given matrix
  67171. * @param matrix defines the matrix to transpose
  67172. * @returns the new matrix
  67173. */
  67174. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  67175. /**
  67176. * Compute the transpose of a matrix and store it in a target matrix
  67177. * @param matrix defines the matrix to transpose
  67178. * @param result defines the target matrix
  67179. */
  67180. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  67181. /**
  67182. * Computes a reflection matrix from a plane
  67183. * @param plane defines the reflection plane
  67184. * @returns a new matrix
  67185. */
  67186. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  67187. /**
  67188. * Computes a reflection matrix from a plane
  67189. * @param plane defines the reflection plane
  67190. * @param result defines the target matrix
  67191. */
  67192. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  67193. /**
  67194. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  67195. * @param xaxis defines the value of the 1st axis
  67196. * @param yaxis defines the value of the 2nd axis
  67197. * @param zaxis defines the value of the 3rd axis
  67198. * @param result defines the target matrix
  67199. */
  67200. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  67201. /**
  67202. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  67203. * @param quat defines the quaternion to use
  67204. * @param result defines the target matrix
  67205. */
  67206. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  67207. }
  67208. /**
  67209. * @hidden
  67210. */
  67211. export class TmpVectors {
  67212. static Vector2: Vector2[];
  67213. static Vector3: Vector3[];
  67214. static Vector4: Vector4[];
  67215. static Quaternion: Quaternion[];
  67216. static Matrix: Matrix[];
  67217. }
  67218. }
  67219. declare module BABYLON {
  67220. /** Defines the cross module used constants to avoid circular dependncies */
  67221. export class Constants {
  67222. /** Defines that alpha blending is disabled */
  67223. static readonly ALPHA_DISABLE: number;
  67224. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  67225. static readonly ALPHA_ADD: number;
  67226. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  67227. static readonly ALPHA_COMBINE: number;
  67228. /** Defines that alpha blending to DEST - SRC * DEST */
  67229. static readonly ALPHA_SUBTRACT: number;
  67230. /** Defines that alpha blending to SRC * DEST */
  67231. static readonly ALPHA_MULTIPLY: number;
  67232. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  67233. static readonly ALPHA_MAXIMIZED: number;
  67234. /** Defines that alpha blending to SRC + DEST */
  67235. static readonly ALPHA_ONEONE: number;
  67236. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  67237. static readonly ALPHA_PREMULTIPLIED: number;
  67238. /**
  67239. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  67240. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  67241. */
  67242. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  67243. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  67244. static readonly ALPHA_INTERPOLATE: number;
  67245. /**
  67246. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  67247. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  67248. */
  67249. static readonly ALPHA_SCREENMODE: number;
  67250. /** Defines that the ressource is not delayed*/
  67251. static readonly DELAYLOADSTATE_NONE: number;
  67252. /** Defines that the ressource was successfully delay loaded */
  67253. static readonly DELAYLOADSTATE_LOADED: number;
  67254. /** Defines that the ressource is currently delay loading */
  67255. static readonly DELAYLOADSTATE_LOADING: number;
  67256. /** Defines that the ressource is delayed and has not started loading */
  67257. static readonly DELAYLOADSTATE_NOTLOADED: number;
  67258. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  67259. static readonly NEVER: number;
  67260. /** 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 */
  67261. static readonly ALWAYS: number;
  67262. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  67263. static readonly LESS: number;
  67264. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  67265. static readonly EQUAL: number;
  67266. /** 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 */
  67267. static readonly LEQUAL: number;
  67268. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  67269. static readonly GREATER: number;
  67270. /** 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 */
  67271. static readonly GEQUAL: number;
  67272. /** 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 */
  67273. static readonly NOTEQUAL: number;
  67274. /** Passed to stencilOperation to specify that stencil value must be kept */
  67275. static readonly KEEP: number;
  67276. /** Passed to stencilOperation to specify that stencil value must be replaced */
  67277. static readonly REPLACE: number;
  67278. /** Passed to stencilOperation to specify that stencil value must be incremented */
  67279. static readonly INCR: number;
  67280. /** Passed to stencilOperation to specify that stencil value must be decremented */
  67281. static readonly DECR: number;
  67282. /** Passed to stencilOperation to specify that stencil value must be inverted */
  67283. static readonly INVERT: number;
  67284. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  67285. static readonly INCR_WRAP: number;
  67286. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  67287. static readonly DECR_WRAP: number;
  67288. /** Texture is not repeating outside of 0..1 UVs */
  67289. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  67290. /** Texture is repeating outside of 0..1 UVs */
  67291. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  67292. /** Texture is repeating and mirrored */
  67293. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  67294. /** ALPHA */
  67295. static readonly TEXTUREFORMAT_ALPHA: number;
  67296. /** LUMINANCE */
  67297. static readonly TEXTUREFORMAT_LUMINANCE: number;
  67298. /** LUMINANCE_ALPHA */
  67299. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  67300. /** RGB */
  67301. static readonly TEXTUREFORMAT_RGB: number;
  67302. /** RGBA */
  67303. static readonly TEXTUREFORMAT_RGBA: number;
  67304. /** RED */
  67305. static readonly TEXTUREFORMAT_RED: number;
  67306. /** RED (2nd reference) */
  67307. static readonly TEXTUREFORMAT_R: number;
  67308. /** RG */
  67309. static readonly TEXTUREFORMAT_RG: number;
  67310. /** RED_INTEGER */
  67311. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  67312. /** RED_INTEGER (2nd reference) */
  67313. static readonly TEXTUREFORMAT_R_INTEGER: number;
  67314. /** RG_INTEGER */
  67315. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  67316. /** RGB_INTEGER */
  67317. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  67318. /** RGBA_INTEGER */
  67319. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  67320. /** UNSIGNED_BYTE */
  67321. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  67322. /** UNSIGNED_BYTE (2nd reference) */
  67323. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  67324. /** FLOAT */
  67325. static readonly TEXTURETYPE_FLOAT: number;
  67326. /** HALF_FLOAT */
  67327. static readonly TEXTURETYPE_HALF_FLOAT: number;
  67328. /** BYTE */
  67329. static readonly TEXTURETYPE_BYTE: number;
  67330. /** SHORT */
  67331. static readonly TEXTURETYPE_SHORT: number;
  67332. /** UNSIGNED_SHORT */
  67333. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  67334. /** INT */
  67335. static readonly TEXTURETYPE_INT: number;
  67336. /** UNSIGNED_INT */
  67337. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  67338. /** UNSIGNED_SHORT_4_4_4_4 */
  67339. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  67340. /** UNSIGNED_SHORT_5_5_5_1 */
  67341. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  67342. /** UNSIGNED_SHORT_5_6_5 */
  67343. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  67344. /** UNSIGNED_INT_2_10_10_10_REV */
  67345. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  67346. /** UNSIGNED_INT_24_8 */
  67347. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  67348. /** UNSIGNED_INT_10F_11F_11F_REV */
  67349. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  67350. /** UNSIGNED_INT_5_9_9_9_REV */
  67351. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  67352. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  67353. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  67354. /** nearest is mag = nearest and min = nearest and mip = linear */
  67355. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  67356. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67357. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  67358. /** Trilinear is mag = linear and min = linear and mip = linear */
  67359. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  67360. /** nearest is mag = nearest and min = nearest and mip = linear */
  67361. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  67362. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67363. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  67364. /** Trilinear is mag = linear and min = linear and mip = linear */
  67365. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  67366. /** mag = nearest and min = nearest and mip = nearest */
  67367. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  67368. /** mag = nearest and min = linear and mip = nearest */
  67369. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  67370. /** mag = nearest and min = linear and mip = linear */
  67371. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  67372. /** mag = nearest and min = linear and mip = none */
  67373. static readonly TEXTURE_NEAREST_LINEAR: number;
  67374. /** mag = nearest and min = nearest and mip = none */
  67375. static readonly TEXTURE_NEAREST_NEAREST: number;
  67376. /** mag = linear and min = nearest and mip = nearest */
  67377. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  67378. /** mag = linear and min = nearest and mip = linear */
  67379. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  67380. /** mag = linear and min = linear and mip = none */
  67381. static readonly TEXTURE_LINEAR_LINEAR: number;
  67382. /** mag = linear and min = nearest and mip = none */
  67383. static readonly TEXTURE_LINEAR_NEAREST: number;
  67384. /** Explicit coordinates mode */
  67385. static readonly TEXTURE_EXPLICIT_MODE: number;
  67386. /** Spherical coordinates mode */
  67387. static readonly TEXTURE_SPHERICAL_MODE: number;
  67388. /** Planar coordinates mode */
  67389. static readonly TEXTURE_PLANAR_MODE: number;
  67390. /** Cubic coordinates mode */
  67391. static readonly TEXTURE_CUBIC_MODE: number;
  67392. /** Projection coordinates mode */
  67393. static readonly TEXTURE_PROJECTION_MODE: number;
  67394. /** Skybox coordinates mode */
  67395. static readonly TEXTURE_SKYBOX_MODE: number;
  67396. /** Inverse Cubic coordinates mode */
  67397. static readonly TEXTURE_INVCUBIC_MODE: number;
  67398. /** Equirectangular coordinates mode */
  67399. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  67400. /** Equirectangular Fixed coordinates mode */
  67401. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  67402. /** Equirectangular Fixed Mirrored coordinates mode */
  67403. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  67404. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  67405. static readonly SCALEMODE_FLOOR: number;
  67406. /** Defines that texture rescaling will look for the nearest power of 2 size */
  67407. static readonly SCALEMODE_NEAREST: number;
  67408. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  67409. static readonly SCALEMODE_CEILING: number;
  67410. /**
  67411. * The dirty texture flag value
  67412. */
  67413. static readonly MATERIAL_TextureDirtyFlag: number;
  67414. /**
  67415. * The dirty light flag value
  67416. */
  67417. static readonly MATERIAL_LightDirtyFlag: number;
  67418. /**
  67419. * The dirty fresnel flag value
  67420. */
  67421. static readonly MATERIAL_FresnelDirtyFlag: number;
  67422. /**
  67423. * The dirty attribute flag value
  67424. */
  67425. static readonly MATERIAL_AttributesDirtyFlag: number;
  67426. /**
  67427. * The dirty misc flag value
  67428. */
  67429. static readonly MATERIAL_MiscDirtyFlag: number;
  67430. /**
  67431. * The all dirty flag value
  67432. */
  67433. static readonly MATERIAL_AllDirtyFlag: number;
  67434. /**
  67435. * Returns the triangle fill mode
  67436. */
  67437. static readonly MATERIAL_TriangleFillMode: number;
  67438. /**
  67439. * Returns the wireframe mode
  67440. */
  67441. static readonly MATERIAL_WireFrameFillMode: number;
  67442. /**
  67443. * Returns the point fill mode
  67444. */
  67445. static readonly MATERIAL_PointFillMode: number;
  67446. /**
  67447. * Returns the point list draw mode
  67448. */
  67449. static readonly MATERIAL_PointListDrawMode: number;
  67450. /**
  67451. * Returns the line list draw mode
  67452. */
  67453. static readonly MATERIAL_LineListDrawMode: number;
  67454. /**
  67455. * Returns the line loop draw mode
  67456. */
  67457. static readonly MATERIAL_LineLoopDrawMode: number;
  67458. /**
  67459. * Returns the line strip draw mode
  67460. */
  67461. static readonly MATERIAL_LineStripDrawMode: number;
  67462. /**
  67463. * Returns the triangle strip draw mode
  67464. */
  67465. static readonly MATERIAL_TriangleStripDrawMode: number;
  67466. /**
  67467. * Returns the triangle fan draw mode
  67468. */
  67469. static readonly MATERIAL_TriangleFanDrawMode: number;
  67470. /**
  67471. * Stores the clock-wise side orientation
  67472. */
  67473. static readonly MATERIAL_ClockWiseSideOrientation: number;
  67474. /**
  67475. * Stores the counter clock-wise side orientation
  67476. */
  67477. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  67478. /**
  67479. * Nothing
  67480. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67481. */
  67482. static readonly ACTION_NothingTrigger: number;
  67483. /**
  67484. * On pick
  67485. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67486. */
  67487. static readonly ACTION_OnPickTrigger: number;
  67488. /**
  67489. * On left pick
  67490. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67491. */
  67492. static readonly ACTION_OnLeftPickTrigger: number;
  67493. /**
  67494. * On right pick
  67495. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67496. */
  67497. static readonly ACTION_OnRightPickTrigger: number;
  67498. /**
  67499. * On center pick
  67500. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67501. */
  67502. static readonly ACTION_OnCenterPickTrigger: number;
  67503. /**
  67504. * On pick down
  67505. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67506. */
  67507. static readonly ACTION_OnPickDownTrigger: number;
  67508. /**
  67509. * On double pick
  67510. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67511. */
  67512. static readonly ACTION_OnDoublePickTrigger: number;
  67513. /**
  67514. * On pick up
  67515. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67516. */
  67517. static readonly ACTION_OnPickUpTrigger: number;
  67518. /**
  67519. * On pick out.
  67520. * This trigger will only be raised if you also declared a OnPickDown
  67521. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67522. */
  67523. static readonly ACTION_OnPickOutTrigger: number;
  67524. /**
  67525. * On long press
  67526. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67527. */
  67528. static readonly ACTION_OnLongPressTrigger: number;
  67529. /**
  67530. * On pointer over
  67531. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67532. */
  67533. static readonly ACTION_OnPointerOverTrigger: number;
  67534. /**
  67535. * On pointer out
  67536. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67537. */
  67538. static readonly ACTION_OnPointerOutTrigger: number;
  67539. /**
  67540. * On every frame
  67541. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67542. */
  67543. static readonly ACTION_OnEveryFrameTrigger: number;
  67544. /**
  67545. * On intersection enter
  67546. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67547. */
  67548. static readonly ACTION_OnIntersectionEnterTrigger: number;
  67549. /**
  67550. * On intersection exit
  67551. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67552. */
  67553. static readonly ACTION_OnIntersectionExitTrigger: number;
  67554. /**
  67555. * On key down
  67556. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67557. */
  67558. static readonly ACTION_OnKeyDownTrigger: number;
  67559. /**
  67560. * On key up
  67561. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67562. */
  67563. static readonly ACTION_OnKeyUpTrigger: number;
  67564. /**
  67565. * Billboard mode will only apply to Y axis
  67566. */
  67567. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  67568. /**
  67569. * Billboard mode will apply to all axes
  67570. */
  67571. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  67572. /**
  67573. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  67574. */
  67575. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  67576. /**
  67577. * Gets or sets base Assets URL
  67578. */
  67579. static PARTICLES_BaseAssetsUrl: string;
  67580. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  67581. * Test order :
  67582. * Is the bounding sphere outside the frustum ?
  67583. * If not, are the bounding box vertices outside the frustum ?
  67584. * It not, then the cullable object is in the frustum.
  67585. */
  67586. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  67587. /** Culling strategy : Bounding Sphere Only.
  67588. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  67589. * It's also less accurate than the standard because some not visible objects can still be selected.
  67590. * Test : is the bounding sphere outside the frustum ?
  67591. * If not, then the cullable object is in the frustum.
  67592. */
  67593. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  67594. /** Culling strategy : Optimistic Inclusion.
  67595. * This in an inclusion test first, then the standard exclusion test.
  67596. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  67597. * 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.
  67598. * Anyway, it's as accurate as the standard strategy.
  67599. * Test :
  67600. * Is the cullable object bounding sphere center in the frustum ?
  67601. * If not, apply the default culling strategy.
  67602. */
  67603. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  67604. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  67605. * This in an inclusion test first, then the bounding sphere only exclusion test.
  67606. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  67607. * 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.
  67608. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  67609. * Test :
  67610. * Is the cullable object bounding sphere center in the frustum ?
  67611. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  67612. */
  67613. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  67614. /**
  67615. * No logging while loading
  67616. */
  67617. static readonly SCENELOADER_NO_LOGGING: number;
  67618. /**
  67619. * Minimal logging while loading
  67620. */
  67621. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  67622. /**
  67623. * Summary logging while loading
  67624. */
  67625. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  67626. /**
  67627. * Detailled logging while loading
  67628. */
  67629. static readonly SCENELOADER_DETAILED_LOGGING: number;
  67630. }
  67631. }
  67632. declare module BABYLON {
  67633. /**
  67634. * Class used to store and describe the pipeline context associated with an effect
  67635. */
  67636. export interface IPipelineContext {
  67637. /**
  67638. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  67639. */
  67640. isAsync: boolean;
  67641. /**
  67642. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  67643. */
  67644. isReady: boolean;
  67645. /** @hidden */
  67646. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  67647. }
  67648. }
  67649. declare module BABYLON {
  67650. /** @hidden */
  67651. export interface IShaderProcessor {
  67652. attributeProcessor?: (attribute: string) => string;
  67653. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  67654. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  67655. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  67656. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  67657. lineProcessor?: (line: string, isFragment: boolean) => string;
  67658. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  67659. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  67660. }
  67661. }
  67662. declare module BABYLON {
  67663. /** @hidden */
  67664. export interface ProcessingOptions {
  67665. defines: string[];
  67666. indexParameters: any;
  67667. isFragment: boolean;
  67668. shouldUseHighPrecisionShader: boolean;
  67669. supportsUniformBuffers: boolean;
  67670. shadersRepository: string;
  67671. includesShadersStore: {
  67672. [key: string]: string;
  67673. };
  67674. processor?: IShaderProcessor;
  67675. version: string;
  67676. platformName: string;
  67677. lookForClosingBracketForUniformBuffer?: boolean;
  67678. }
  67679. }
  67680. declare module BABYLON {
  67681. /**
  67682. * Helper to manipulate strings
  67683. */
  67684. export class StringTools {
  67685. /**
  67686. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  67687. * @param str Source string
  67688. * @param suffix Suffix to search for in the source string
  67689. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  67690. */
  67691. static EndsWith(str: string, suffix: string): boolean;
  67692. /**
  67693. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  67694. * @param str Source string
  67695. * @param suffix Suffix to search for in the source string
  67696. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  67697. */
  67698. static StartsWith(str: string, suffix: string): boolean;
  67699. }
  67700. }
  67701. declare module BABYLON {
  67702. /** @hidden */
  67703. export class ShaderCodeNode {
  67704. line: string;
  67705. children: ShaderCodeNode[];
  67706. additionalDefineKey?: string;
  67707. additionalDefineValue?: string;
  67708. isValid(preprocessors: {
  67709. [key: string]: string;
  67710. }): boolean;
  67711. process(preprocessors: {
  67712. [key: string]: string;
  67713. }, options: ProcessingOptions): string;
  67714. }
  67715. }
  67716. declare module BABYLON {
  67717. /** @hidden */
  67718. export class ShaderCodeCursor {
  67719. private _lines;
  67720. lineIndex: number;
  67721. readonly currentLine: string;
  67722. readonly canRead: boolean;
  67723. lines: string[];
  67724. }
  67725. }
  67726. declare module BABYLON {
  67727. /** @hidden */
  67728. export class ShaderCodeConditionNode extends ShaderCodeNode {
  67729. process(preprocessors: {
  67730. [key: string]: string;
  67731. }, options: ProcessingOptions): string;
  67732. }
  67733. }
  67734. declare module BABYLON {
  67735. /** @hidden */
  67736. export class ShaderDefineExpression {
  67737. isTrue(preprocessors: {
  67738. [key: string]: string;
  67739. }): boolean;
  67740. }
  67741. }
  67742. declare module BABYLON {
  67743. /** @hidden */
  67744. export class ShaderCodeTestNode extends ShaderCodeNode {
  67745. testExpression: ShaderDefineExpression;
  67746. isValid(preprocessors: {
  67747. [key: string]: string;
  67748. }): boolean;
  67749. }
  67750. }
  67751. declare module BABYLON {
  67752. /** @hidden */
  67753. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  67754. define: string;
  67755. not: boolean;
  67756. constructor(define: string, not?: boolean);
  67757. isTrue(preprocessors: {
  67758. [key: string]: string;
  67759. }): boolean;
  67760. }
  67761. }
  67762. declare module BABYLON {
  67763. /** @hidden */
  67764. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  67765. leftOperand: ShaderDefineExpression;
  67766. rightOperand: ShaderDefineExpression;
  67767. isTrue(preprocessors: {
  67768. [key: string]: string;
  67769. }): boolean;
  67770. }
  67771. }
  67772. declare module BABYLON {
  67773. /** @hidden */
  67774. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  67775. leftOperand: ShaderDefineExpression;
  67776. rightOperand: ShaderDefineExpression;
  67777. isTrue(preprocessors: {
  67778. [key: string]: string;
  67779. }): boolean;
  67780. }
  67781. }
  67782. declare module BABYLON {
  67783. /** @hidden */
  67784. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  67785. define: string;
  67786. operand: string;
  67787. testValue: string;
  67788. constructor(define: string, operand: string, testValue: string);
  67789. isTrue(preprocessors: {
  67790. [key: string]: string;
  67791. }): boolean;
  67792. }
  67793. }
  67794. declare module BABYLON {
  67795. /**
  67796. * @ignore
  67797. * Application error to support additional information when loading a file
  67798. */
  67799. export class LoadFileError extends Error {
  67800. /** defines the optional web request */
  67801. request?: WebRequest | undefined;
  67802. private static _setPrototypeOf;
  67803. /**
  67804. * Creates a new LoadFileError
  67805. * @param message defines the message of the error
  67806. * @param request defines the optional web request
  67807. */
  67808. constructor(message: string,
  67809. /** defines the optional web request */
  67810. request?: WebRequest | undefined);
  67811. }
  67812. }
  67813. declare module BABYLON {
  67814. /**
  67815. * Class used to enable access to offline support
  67816. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  67817. */
  67818. export interface IOfflineProvider {
  67819. /**
  67820. * Gets a boolean indicating if scene must be saved in the database
  67821. */
  67822. enableSceneOffline: boolean;
  67823. /**
  67824. * Gets a boolean indicating if textures must be saved in the database
  67825. */
  67826. enableTexturesOffline: boolean;
  67827. /**
  67828. * Open the offline support and make it available
  67829. * @param successCallback defines the callback to call on success
  67830. * @param errorCallback defines the callback to call on error
  67831. */
  67832. open(successCallback: () => void, errorCallback: () => void): void;
  67833. /**
  67834. * Loads an image from the offline support
  67835. * @param url defines the url to load from
  67836. * @param image defines the target DOM image
  67837. */
  67838. loadImage(url: string, image: HTMLImageElement): void;
  67839. /**
  67840. * Loads a file from offline support
  67841. * @param url defines the URL to load from
  67842. * @param sceneLoaded defines a callback to call on success
  67843. * @param progressCallBack defines a callback to call when progress changed
  67844. * @param errorCallback defines a callback to call on error
  67845. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  67846. */
  67847. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  67848. }
  67849. }
  67850. declare module BABYLON {
  67851. /**
  67852. * Class used to help managing file picking and drag'n'drop
  67853. * File Storage
  67854. */
  67855. export class FilesInputStore {
  67856. /**
  67857. * List of files ready to be loaded
  67858. */
  67859. static FilesToLoad: {
  67860. [key: string]: File;
  67861. };
  67862. }
  67863. }
  67864. declare module BABYLON {
  67865. /**
  67866. * Class used to define a retry strategy when error happens while loading assets
  67867. */
  67868. export class RetryStrategy {
  67869. /**
  67870. * Function used to defines an exponential back off strategy
  67871. * @param maxRetries defines the maximum number of retries (3 by default)
  67872. * @param baseInterval defines the interval between retries
  67873. * @returns the strategy function to use
  67874. */
  67875. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  67876. }
  67877. }
  67878. declare module BABYLON {
  67879. /**
  67880. * @hidden
  67881. */
  67882. export class FileTools {
  67883. /**
  67884. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  67885. */
  67886. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  67887. /**
  67888. * Gets or sets the base URL to use to load assets
  67889. */
  67890. static BaseUrl: string;
  67891. /**
  67892. * Default behaviour for cors in the application.
  67893. * It can be a string if the expected behavior is identical in the entire app.
  67894. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  67895. */
  67896. static CorsBehavior: string | ((url: string | string[]) => string);
  67897. /**
  67898. * Gets or sets a function used to pre-process url before using them to load assets
  67899. */
  67900. static PreprocessUrl: (url: string) => string;
  67901. /**
  67902. * Removes unwanted characters from an url
  67903. * @param url defines the url to clean
  67904. * @returns the cleaned url
  67905. */
  67906. private static _CleanUrl;
  67907. /**
  67908. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  67909. * @param url define the url we are trying
  67910. * @param element define the dom element where to configure the cors policy
  67911. */
  67912. static SetCorsBehavior(url: string | string[], element: {
  67913. crossOrigin: string | null;
  67914. }): void;
  67915. /**
  67916. * Loads an image as an HTMLImageElement.
  67917. * @param input url string, ArrayBuffer, or Blob to load
  67918. * @param onLoad callback called when the image successfully loads
  67919. * @param onError callback called when the image fails to load
  67920. * @param offlineProvider offline provider for caching
  67921. * @returns the HTMLImageElement of the loaded image
  67922. */
  67923. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  67924. /**
  67925. * Loads a file
  67926. * @param fileToLoad defines the file to load
  67927. * @param callback defines the callback to call when data is loaded
  67928. * @param progressCallBack defines the callback to call during loading process
  67929. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  67930. * @returns a file request object
  67931. */
  67932. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  67933. /**
  67934. * Loads a file
  67935. * @param url url string, ArrayBuffer, or Blob to load
  67936. * @param onSuccess callback called when the file successfully loads
  67937. * @param onProgress callback called while file is loading (if the server supports this mode)
  67938. * @param offlineProvider defines the offline provider for caching
  67939. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  67940. * @param onError callback called when the file fails to load
  67941. * @returns a file request object
  67942. */
  67943. 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;
  67944. /**
  67945. * Checks if the loaded document was accessed via `file:`-Protocol.
  67946. * @returns boolean
  67947. */
  67948. static IsFileURL(): boolean;
  67949. }
  67950. }
  67951. declare module BABYLON {
  67952. /** @hidden */
  67953. export class ShaderProcessor {
  67954. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  67955. private static _ProcessPrecision;
  67956. private static _ExtractOperation;
  67957. private static _BuildSubExpression;
  67958. private static _BuildExpression;
  67959. private static _MoveCursorWithinIf;
  67960. private static _MoveCursor;
  67961. private static _EvaluatePreProcessors;
  67962. private static _PreparePreProcessors;
  67963. private static _ProcessShaderConversion;
  67964. private static _ProcessIncludes;
  67965. }
  67966. }
  67967. declare module BABYLON {
  67968. /**
  67969. * Class used to hold a RBG color
  67970. */
  67971. export class Color3 {
  67972. /**
  67973. * Defines the red component (between 0 and 1, default is 0)
  67974. */
  67975. r: number;
  67976. /**
  67977. * Defines the green component (between 0 and 1, default is 0)
  67978. */
  67979. g: number;
  67980. /**
  67981. * Defines the blue component (between 0 and 1, default is 0)
  67982. */
  67983. b: number;
  67984. /**
  67985. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  67986. * @param r defines the red component (between 0 and 1, default is 0)
  67987. * @param g defines the green component (between 0 and 1, default is 0)
  67988. * @param b defines the blue component (between 0 and 1, default is 0)
  67989. */
  67990. constructor(
  67991. /**
  67992. * Defines the red component (between 0 and 1, default is 0)
  67993. */
  67994. r?: number,
  67995. /**
  67996. * Defines the green component (between 0 and 1, default is 0)
  67997. */
  67998. g?: number,
  67999. /**
  68000. * Defines the blue component (between 0 and 1, default is 0)
  68001. */
  68002. b?: number);
  68003. /**
  68004. * Creates a string with the Color3 current values
  68005. * @returns the string representation of the Color3 object
  68006. */
  68007. toString(): string;
  68008. /**
  68009. * Returns the string "Color3"
  68010. * @returns "Color3"
  68011. */
  68012. getClassName(): string;
  68013. /**
  68014. * Compute the Color3 hash code
  68015. * @returns an unique number that can be used to hash Color3 objects
  68016. */
  68017. getHashCode(): number;
  68018. /**
  68019. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  68020. * @param array defines the array where to store the r,g,b components
  68021. * @param index defines an optional index in the target array to define where to start storing values
  68022. * @returns the current Color3 object
  68023. */
  68024. toArray(array: FloatArray, index?: number): Color3;
  68025. /**
  68026. * Returns a new Color4 object from the current Color3 and the given alpha
  68027. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  68028. * @returns a new Color4 object
  68029. */
  68030. toColor4(alpha?: number): Color4;
  68031. /**
  68032. * Returns a new array populated with 3 numeric elements : red, green and blue values
  68033. * @returns the new array
  68034. */
  68035. asArray(): number[];
  68036. /**
  68037. * Returns the luminance value
  68038. * @returns a float value
  68039. */
  68040. toLuminance(): number;
  68041. /**
  68042. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  68043. * @param otherColor defines the second operand
  68044. * @returns the new Color3 object
  68045. */
  68046. multiply(otherColor: DeepImmutable<Color3>): Color3;
  68047. /**
  68048. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  68049. * @param otherColor defines the second operand
  68050. * @param result defines the Color3 object where to store the result
  68051. * @returns the current Color3
  68052. */
  68053. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  68054. /**
  68055. * Determines equality between Color3 objects
  68056. * @param otherColor defines the second operand
  68057. * @returns true if the rgb values are equal to the given ones
  68058. */
  68059. equals(otherColor: DeepImmutable<Color3>): boolean;
  68060. /**
  68061. * Determines equality between the current Color3 object and a set of r,b,g values
  68062. * @param r defines the red component to check
  68063. * @param g defines the green component to check
  68064. * @param b defines the blue component to check
  68065. * @returns true if the rgb values are equal to the given ones
  68066. */
  68067. equalsFloats(r: number, g: number, b: number): boolean;
  68068. /**
  68069. * Multiplies in place each rgb value by scale
  68070. * @param scale defines the scaling factor
  68071. * @returns the updated Color3
  68072. */
  68073. scale(scale: number): Color3;
  68074. /**
  68075. * Multiplies the rgb values by scale and stores the result into "result"
  68076. * @param scale defines the scaling factor
  68077. * @param result defines the Color3 object where to store the result
  68078. * @returns the unmodified current Color3
  68079. */
  68080. scaleToRef(scale: number, result: Color3): Color3;
  68081. /**
  68082. * Scale the current Color3 values by a factor and add the result to a given Color3
  68083. * @param scale defines the scale factor
  68084. * @param result defines color to store the result into
  68085. * @returns the unmodified current Color3
  68086. */
  68087. scaleAndAddToRef(scale: number, result: Color3): Color3;
  68088. /**
  68089. * Clamps the rgb values by the min and max values and stores the result into "result"
  68090. * @param min defines minimum clamping value (default is 0)
  68091. * @param max defines maximum clamping value (default is 1)
  68092. * @param result defines color to store the result into
  68093. * @returns the original Color3
  68094. */
  68095. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  68096. /**
  68097. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  68098. * @param otherColor defines the second operand
  68099. * @returns the new Color3
  68100. */
  68101. add(otherColor: DeepImmutable<Color3>): Color3;
  68102. /**
  68103. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  68104. * @param otherColor defines the second operand
  68105. * @param result defines Color3 object to store the result into
  68106. * @returns the unmodified current Color3
  68107. */
  68108. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  68109. /**
  68110. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  68111. * @param otherColor defines the second operand
  68112. * @returns the new Color3
  68113. */
  68114. subtract(otherColor: DeepImmutable<Color3>): Color3;
  68115. /**
  68116. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  68117. * @param otherColor defines the second operand
  68118. * @param result defines Color3 object to store the result into
  68119. * @returns the unmodified current Color3
  68120. */
  68121. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  68122. /**
  68123. * Copy the current object
  68124. * @returns a new Color3 copied the current one
  68125. */
  68126. clone(): Color3;
  68127. /**
  68128. * Copies the rgb values from the source in the current Color3
  68129. * @param source defines the source Color3 object
  68130. * @returns the updated Color3 object
  68131. */
  68132. copyFrom(source: DeepImmutable<Color3>): Color3;
  68133. /**
  68134. * Updates the Color3 rgb values from the given floats
  68135. * @param r defines the red component to read from
  68136. * @param g defines the green component to read from
  68137. * @param b defines the blue component to read from
  68138. * @returns the current Color3 object
  68139. */
  68140. copyFromFloats(r: number, g: number, b: number): Color3;
  68141. /**
  68142. * Updates the Color3 rgb values from the given floats
  68143. * @param r defines the red component to read from
  68144. * @param g defines the green component to read from
  68145. * @param b defines the blue component to read from
  68146. * @returns the current Color3 object
  68147. */
  68148. set(r: number, g: number, b: number): Color3;
  68149. /**
  68150. * Compute the Color3 hexadecimal code as a string
  68151. * @returns a string containing the hexadecimal representation of the Color3 object
  68152. */
  68153. toHexString(): string;
  68154. /**
  68155. * Computes a new Color3 converted from the current one to linear space
  68156. * @returns a new Color3 object
  68157. */
  68158. toLinearSpace(): Color3;
  68159. /**
  68160. * Converts current color in rgb space to HSV values
  68161. * @returns a new color3 representing the HSV values
  68162. */
  68163. toHSV(): Color3;
  68164. /**
  68165. * Converts current color in rgb space to HSV values
  68166. * @param result defines the Color3 where to store the HSV values
  68167. */
  68168. toHSVToRef(result: Color3): void;
  68169. /**
  68170. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  68171. * @param convertedColor defines the Color3 object where to store the linear space version
  68172. * @returns the unmodified Color3
  68173. */
  68174. toLinearSpaceToRef(convertedColor: Color3): Color3;
  68175. /**
  68176. * Computes a new Color3 converted from the current one to gamma space
  68177. * @returns a new Color3 object
  68178. */
  68179. toGammaSpace(): Color3;
  68180. /**
  68181. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  68182. * @param convertedColor defines the Color3 object where to store the gamma space version
  68183. * @returns the unmodified Color3
  68184. */
  68185. toGammaSpaceToRef(convertedColor: Color3): Color3;
  68186. private static _BlackReadOnly;
  68187. /**
  68188. * Convert Hue, saturation and value to a Color3 (RGB)
  68189. * @param hue defines the hue
  68190. * @param saturation defines the saturation
  68191. * @param value defines the value
  68192. * @param result defines the Color3 where to store the RGB values
  68193. */
  68194. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  68195. /**
  68196. * Creates a new Color3 from the string containing valid hexadecimal values
  68197. * @param hex defines a string containing valid hexadecimal values
  68198. * @returns a new Color3 object
  68199. */
  68200. static FromHexString(hex: string): Color3;
  68201. /**
  68202. * Creates a new Color3 from the starting index of the given array
  68203. * @param array defines the source array
  68204. * @param offset defines an offset in the source array
  68205. * @returns a new Color3 object
  68206. */
  68207. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  68208. /**
  68209. * Creates a new Color3 from integer values (< 256)
  68210. * @param r defines the red component to read from (value between 0 and 255)
  68211. * @param g defines the green component to read from (value between 0 and 255)
  68212. * @param b defines the blue component to read from (value between 0 and 255)
  68213. * @returns a new Color3 object
  68214. */
  68215. static FromInts(r: number, g: number, b: number): Color3;
  68216. /**
  68217. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  68218. * @param start defines the start Color3 value
  68219. * @param end defines the end Color3 value
  68220. * @param amount defines the gradient value between start and end
  68221. * @returns a new Color3 object
  68222. */
  68223. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  68224. /**
  68225. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  68226. * @param left defines the start value
  68227. * @param right defines the end value
  68228. * @param amount defines the gradient factor
  68229. * @param result defines the Color3 object where to store the result
  68230. */
  68231. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  68232. /**
  68233. * Returns a Color3 value containing a red color
  68234. * @returns a new Color3 object
  68235. */
  68236. static Red(): Color3;
  68237. /**
  68238. * Returns a Color3 value containing a green color
  68239. * @returns a new Color3 object
  68240. */
  68241. static Green(): Color3;
  68242. /**
  68243. * Returns a Color3 value containing a blue color
  68244. * @returns a new Color3 object
  68245. */
  68246. static Blue(): Color3;
  68247. /**
  68248. * Returns a Color3 value containing a black color
  68249. * @returns a new Color3 object
  68250. */
  68251. static Black(): Color3;
  68252. /**
  68253. * Gets a Color3 value containing a black color that must not be updated
  68254. */
  68255. static readonly BlackReadOnly: DeepImmutable<Color3>;
  68256. /**
  68257. * Returns a Color3 value containing a white color
  68258. * @returns a new Color3 object
  68259. */
  68260. static White(): Color3;
  68261. /**
  68262. * Returns a Color3 value containing a purple color
  68263. * @returns a new Color3 object
  68264. */
  68265. static Purple(): Color3;
  68266. /**
  68267. * Returns a Color3 value containing a magenta color
  68268. * @returns a new Color3 object
  68269. */
  68270. static Magenta(): Color3;
  68271. /**
  68272. * Returns a Color3 value containing a yellow color
  68273. * @returns a new Color3 object
  68274. */
  68275. static Yellow(): Color3;
  68276. /**
  68277. * Returns a Color3 value containing a gray color
  68278. * @returns a new Color3 object
  68279. */
  68280. static Gray(): Color3;
  68281. /**
  68282. * Returns a Color3 value containing a teal color
  68283. * @returns a new Color3 object
  68284. */
  68285. static Teal(): Color3;
  68286. /**
  68287. * Returns a Color3 value containing a random color
  68288. * @returns a new Color3 object
  68289. */
  68290. static Random(): Color3;
  68291. }
  68292. /**
  68293. * Class used to hold a RBGA color
  68294. */
  68295. export class Color4 {
  68296. /**
  68297. * Defines the red component (between 0 and 1, default is 0)
  68298. */
  68299. r: number;
  68300. /**
  68301. * Defines the green component (between 0 and 1, default is 0)
  68302. */
  68303. g: number;
  68304. /**
  68305. * Defines the blue component (between 0 and 1, default is 0)
  68306. */
  68307. b: number;
  68308. /**
  68309. * Defines the alpha component (between 0 and 1, default is 1)
  68310. */
  68311. a: number;
  68312. /**
  68313. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  68314. * @param r defines the red component (between 0 and 1, default is 0)
  68315. * @param g defines the green component (between 0 and 1, default is 0)
  68316. * @param b defines the blue component (between 0 and 1, default is 0)
  68317. * @param a defines the alpha component (between 0 and 1, default is 1)
  68318. */
  68319. constructor(
  68320. /**
  68321. * Defines the red component (between 0 and 1, default is 0)
  68322. */
  68323. r?: number,
  68324. /**
  68325. * Defines the green component (between 0 and 1, default is 0)
  68326. */
  68327. g?: number,
  68328. /**
  68329. * Defines the blue component (between 0 and 1, default is 0)
  68330. */
  68331. b?: number,
  68332. /**
  68333. * Defines the alpha component (between 0 and 1, default is 1)
  68334. */
  68335. a?: number);
  68336. /**
  68337. * Adds in place the given Color4 values to the current Color4 object
  68338. * @param right defines the second operand
  68339. * @returns the current updated Color4 object
  68340. */
  68341. addInPlace(right: DeepImmutable<Color4>): Color4;
  68342. /**
  68343. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  68344. * @returns the new array
  68345. */
  68346. asArray(): number[];
  68347. /**
  68348. * Stores from the starting index in the given array the Color4 successive values
  68349. * @param array defines the array where to store the r,g,b components
  68350. * @param index defines an optional index in the target array to define where to start storing values
  68351. * @returns the current Color4 object
  68352. */
  68353. toArray(array: number[], index?: number): Color4;
  68354. /**
  68355. * Determines equality between Color4 objects
  68356. * @param otherColor defines the second operand
  68357. * @returns true if the rgba values are equal to the given ones
  68358. */
  68359. equals(otherColor: DeepImmutable<Color4>): boolean;
  68360. /**
  68361. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  68362. * @param right defines the second operand
  68363. * @returns a new Color4 object
  68364. */
  68365. add(right: DeepImmutable<Color4>): Color4;
  68366. /**
  68367. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  68368. * @param right defines the second operand
  68369. * @returns a new Color4 object
  68370. */
  68371. subtract(right: DeepImmutable<Color4>): Color4;
  68372. /**
  68373. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  68374. * @param right defines the second operand
  68375. * @param result defines the Color4 object where to store the result
  68376. * @returns the current Color4 object
  68377. */
  68378. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  68379. /**
  68380. * Creates a new Color4 with the current Color4 values multiplied by scale
  68381. * @param scale defines the scaling factor to apply
  68382. * @returns a new Color4 object
  68383. */
  68384. scale(scale: number): Color4;
  68385. /**
  68386. * Multiplies the current Color4 values by scale and stores the result in "result"
  68387. * @param scale defines the scaling factor to apply
  68388. * @param result defines the Color4 object where to store the result
  68389. * @returns the current unmodified Color4
  68390. */
  68391. scaleToRef(scale: number, result: Color4): Color4;
  68392. /**
  68393. * Scale the current Color4 values by a factor and add the result to a given Color4
  68394. * @param scale defines the scale factor
  68395. * @param result defines the Color4 object where to store the result
  68396. * @returns the unmodified current Color4
  68397. */
  68398. scaleAndAddToRef(scale: number, result: Color4): Color4;
  68399. /**
  68400. * Clamps the rgb values by the min and max values and stores the result into "result"
  68401. * @param min defines minimum clamping value (default is 0)
  68402. * @param max defines maximum clamping value (default is 1)
  68403. * @param result defines color to store the result into.
  68404. * @returns the cuurent Color4
  68405. */
  68406. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  68407. /**
  68408. * Multipy an Color4 value by another and return a new Color4 object
  68409. * @param color defines the Color4 value to multiply by
  68410. * @returns a new Color4 object
  68411. */
  68412. multiply(color: Color4): Color4;
  68413. /**
  68414. * Multipy a Color4 value by another and push the result in a reference value
  68415. * @param color defines the Color4 value to multiply by
  68416. * @param result defines the Color4 to fill the result in
  68417. * @returns the result Color4
  68418. */
  68419. multiplyToRef(color: Color4, result: Color4): Color4;
  68420. /**
  68421. * Creates a string with the Color4 current values
  68422. * @returns the string representation of the Color4 object
  68423. */
  68424. toString(): string;
  68425. /**
  68426. * Returns the string "Color4"
  68427. * @returns "Color4"
  68428. */
  68429. getClassName(): string;
  68430. /**
  68431. * Compute the Color4 hash code
  68432. * @returns an unique number that can be used to hash Color4 objects
  68433. */
  68434. getHashCode(): number;
  68435. /**
  68436. * Creates a new Color4 copied from the current one
  68437. * @returns a new Color4 object
  68438. */
  68439. clone(): Color4;
  68440. /**
  68441. * Copies the given Color4 values into the current one
  68442. * @param source defines the source Color4 object
  68443. * @returns the current updated Color4 object
  68444. */
  68445. copyFrom(source: Color4): Color4;
  68446. /**
  68447. * Copies the given float values into the current one
  68448. * @param r defines the red component to read from
  68449. * @param g defines the green component to read from
  68450. * @param b defines the blue component to read from
  68451. * @param a defines the alpha component to read from
  68452. * @returns the current updated Color4 object
  68453. */
  68454. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  68455. /**
  68456. * Copies the given float values into the current one
  68457. * @param r defines the red component to read from
  68458. * @param g defines the green component to read from
  68459. * @param b defines the blue component to read from
  68460. * @param a defines the alpha component to read from
  68461. * @returns the current updated Color4 object
  68462. */
  68463. set(r: number, g: number, b: number, a: number): Color4;
  68464. /**
  68465. * Compute the Color4 hexadecimal code as a string
  68466. * @returns a string containing the hexadecimal representation of the Color4 object
  68467. */
  68468. toHexString(): string;
  68469. /**
  68470. * Computes a new Color4 converted from the current one to linear space
  68471. * @returns a new Color4 object
  68472. */
  68473. toLinearSpace(): Color4;
  68474. /**
  68475. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  68476. * @param convertedColor defines the Color4 object where to store the linear space version
  68477. * @returns the unmodified Color4
  68478. */
  68479. toLinearSpaceToRef(convertedColor: Color4): Color4;
  68480. /**
  68481. * Computes a new Color4 converted from the current one to gamma space
  68482. * @returns a new Color4 object
  68483. */
  68484. toGammaSpace(): Color4;
  68485. /**
  68486. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  68487. * @param convertedColor defines the Color4 object where to store the gamma space version
  68488. * @returns the unmodified Color4
  68489. */
  68490. toGammaSpaceToRef(convertedColor: Color4): Color4;
  68491. /**
  68492. * Creates a new Color4 from the string containing valid hexadecimal values
  68493. * @param hex defines a string containing valid hexadecimal values
  68494. * @returns a new Color4 object
  68495. */
  68496. static FromHexString(hex: string): Color4;
  68497. /**
  68498. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  68499. * @param left defines the start value
  68500. * @param right defines the end value
  68501. * @param amount defines the gradient factor
  68502. * @returns a new Color4 object
  68503. */
  68504. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  68505. /**
  68506. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  68507. * @param left defines the start value
  68508. * @param right defines the end value
  68509. * @param amount defines the gradient factor
  68510. * @param result defines the Color4 object where to store data
  68511. */
  68512. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  68513. /**
  68514. * Creates a new Color4 from a Color3 and an alpha value
  68515. * @param color3 defines the source Color3 to read from
  68516. * @param alpha defines the alpha component (1.0 by default)
  68517. * @returns a new Color4 object
  68518. */
  68519. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  68520. /**
  68521. * Creates a new Color4 from the starting index element of the given array
  68522. * @param array defines the source array to read from
  68523. * @param offset defines the offset in the source array
  68524. * @returns a new Color4 object
  68525. */
  68526. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  68527. /**
  68528. * Creates a new Color3 from integer values (< 256)
  68529. * @param r defines the red component to read from (value between 0 and 255)
  68530. * @param g defines the green component to read from (value between 0 and 255)
  68531. * @param b defines the blue component to read from (value between 0 and 255)
  68532. * @param a defines the alpha component to read from (value between 0 and 255)
  68533. * @returns a new Color3 object
  68534. */
  68535. static FromInts(r: number, g: number, b: number, a: number): Color4;
  68536. /**
  68537. * Check the content of a given array and convert it to an array containing RGBA data
  68538. * If the original array was already containing count * 4 values then it is returned directly
  68539. * @param colors defines the array to check
  68540. * @param count defines the number of RGBA data to expect
  68541. * @returns an array containing count * 4 values (RGBA)
  68542. */
  68543. static CheckColors4(colors: number[], count: number): number[];
  68544. }
  68545. /**
  68546. * @hidden
  68547. */
  68548. export class TmpColors {
  68549. static Color3: Color3[];
  68550. static Color4: Color4[];
  68551. }
  68552. }
  68553. declare module BABYLON {
  68554. /**
  68555. * Class representing spherical harmonics coefficients to the 3rd degree
  68556. */
  68557. export class SphericalHarmonics {
  68558. /**
  68559. * Defines whether or not the harmonics have been prescaled for rendering.
  68560. */
  68561. preScaled: boolean;
  68562. /**
  68563. * The l0,0 coefficients of the spherical harmonics
  68564. */
  68565. l00: Vector3;
  68566. /**
  68567. * The l1,-1 coefficients of the spherical harmonics
  68568. */
  68569. l1_1: Vector3;
  68570. /**
  68571. * The l1,0 coefficients of the spherical harmonics
  68572. */
  68573. l10: Vector3;
  68574. /**
  68575. * The l1,1 coefficients of the spherical harmonics
  68576. */
  68577. l11: Vector3;
  68578. /**
  68579. * The l2,-2 coefficients of the spherical harmonics
  68580. */
  68581. l2_2: Vector3;
  68582. /**
  68583. * The l2,-1 coefficients of the spherical harmonics
  68584. */
  68585. l2_1: Vector3;
  68586. /**
  68587. * The l2,0 coefficients of the spherical harmonics
  68588. */
  68589. l20: Vector3;
  68590. /**
  68591. * The l2,1 coefficients of the spherical harmonics
  68592. */
  68593. l21: Vector3;
  68594. /**
  68595. * The l2,2 coefficients of the spherical harmonics
  68596. */
  68597. l22: Vector3;
  68598. /**
  68599. * Adds a light to the spherical harmonics
  68600. * @param direction the direction of the light
  68601. * @param color the color of the light
  68602. * @param deltaSolidAngle the delta solid angle of the light
  68603. */
  68604. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  68605. /**
  68606. * Scales the spherical harmonics by the given amount
  68607. * @param scale the amount to scale
  68608. */
  68609. scaleInPlace(scale: number): void;
  68610. /**
  68611. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  68612. *
  68613. * ```
  68614. * E_lm = A_l * L_lm
  68615. * ```
  68616. *
  68617. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  68618. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  68619. * the scaling factors are given in equation 9.
  68620. */
  68621. convertIncidentRadianceToIrradiance(): void;
  68622. /**
  68623. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  68624. *
  68625. * ```
  68626. * L = (1/pi) * E * rho
  68627. * ```
  68628. *
  68629. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  68630. */
  68631. convertIrradianceToLambertianRadiance(): void;
  68632. /**
  68633. * Integrates the reconstruction coefficients directly in to the SH preventing further
  68634. * required operations at run time.
  68635. *
  68636. * This is simply done by scaling back the SH with Ylm constants parameter.
  68637. * The trigonometric part being applied by the shader at run time.
  68638. */
  68639. preScaleForRendering(): void;
  68640. /**
  68641. * Constructs a spherical harmonics from an array.
  68642. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  68643. * @returns the spherical harmonics
  68644. */
  68645. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  68646. /**
  68647. * Gets the spherical harmonics from polynomial
  68648. * @param polynomial the spherical polynomial
  68649. * @returns the spherical harmonics
  68650. */
  68651. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  68652. }
  68653. /**
  68654. * Class representing spherical polynomial coefficients to the 3rd degree
  68655. */
  68656. export class SphericalPolynomial {
  68657. private _harmonics;
  68658. /**
  68659. * The spherical harmonics used to create the polynomials.
  68660. */
  68661. readonly preScaledHarmonics: SphericalHarmonics;
  68662. /**
  68663. * The x coefficients of the spherical polynomial
  68664. */
  68665. x: Vector3;
  68666. /**
  68667. * The y coefficients of the spherical polynomial
  68668. */
  68669. y: Vector3;
  68670. /**
  68671. * The z coefficients of the spherical polynomial
  68672. */
  68673. z: Vector3;
  68674. /**
  68675. * The xx coefficients of the spherical polynomial
  68676. */
  68677. xx: Vector3;
  68678. /**
  68679. * The yy coefficients of the spherical polynomial
  68680. */
  68681. yy: Vector3;
  68682. /**
  68683. * The zz coefficients of the spherical polynomial
  68684. */
  68685. zz: Vector3;
  68686. /**
  68687. * The xy coefficients of the spherical polynomial
  68688. */
  68689. xy: Vector3;
  68690. /**
  68691. * The yz coefficients of the spherical polynomial
  68692. */
  68693. yz: Vector3;
  68694. /**
  68695. * The zx coefficients of the spherical polynomial
  68696. */
  68697. zx: Vector3;
  68698. /**
  68699. * Adds an ambient color to the spherical polynomial
  68700. * @param color the color to add
  68701. */
  68702. addAmbient(color: Color3): void;
  68703. /**
  68704. * Scales the spherical polynomial by the given amount
  68705. * @param scale the amount to scale
  68706. */
  68707. scaleInPlace(scale: number): void;
  68708. /**
  68709. * Gets the spherical polynomial from harmonics
  68710. * @param harmonics the spherical harmonics
  68711. * @returns the spherical polynomial
  68712. */
  68713. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  68714. /**
  68715. * Constructs a spherical polynomial from an array.
  68716. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  68717. * @returns the spherical polynomial
  68718. */
  68719. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  68720. }
  68721. }
  68722. declare module BABYLON {
  68723. /**
  68724. * Define options used to create a render target texture
  68725. */
  68726. export class RenderTargetCreationOptions {
  68727. /**
  68728. * Specifies is mipmaps must be generated
  68729. */
  68730. generateMipMaps?: boolean;
  68731. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  68732. generateDepthBuffer?: boolean;
  68733. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  68734. generateStencilBuffer?: boolean;
  68735. /** Defines texture type (int by default) */
  68736. type?: number;
  68737. /** Defines sampling mode (trilinear by default) */
  68738. samplingMode?: number;
  68739. /** Defines format (RGBA by default) */
  68740. format?: number;
  68741. }
  68742. }
  68743. declare module BABYLON {
  68744. /**
  68745. * @hidden
  68746. **/
  68747. export class _AlphaState {
  68748. private _isAlphaBlendDirty;
  68749. private _isBlendFunctionParametersDirty;
  68750. private _isBlendEquationParametersDirty;
  68751. private _isBlendConstantsDirty;
  68752. private _alphaBlend;
  68753. private _blendFunctionParameters;
  68754. private _blendEquationParameters;
  68755. private _blendConstants;
  68756. /**
  68757. * Initializes the state.
  68758. */
  68759. constructor();
  68760. readonly isDirty: boolean;
  68761. alphaBlend: boolean;
  68762. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  68763. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  68764. setAlphaEquationParameters(rgb: number, alpha: number): void;
  68765. reset(): void;
  68766. apply(gl: WebGLRenderingContext): void;
  68767. }
  68768. }
  68769. declare module BABYLON {
  68770. /**
  68771. * @hidden
  68772. **/
  68773. export class _DepthCullingState {
  68774. private _isDepthTestDirty;
  68775. private _isDepthMaskDirty;
  68776. private _isDepthFuncDirty;
  68777. private _isCullFaceDirty;
  68778. private _isCullDirty;
  68779. private _isZOffsetDirty;
  68780. private _isFrontFaceDirty;
  68781. private _depthTest;
  68782. private _depthMask;
  68783. private _depthFunc;
  68784. private _cull;
  68785. private _cullFace;
  68786. private _zOffset;
  68787. private _frontFace;
  68788. /**
  68789. * Initializes the state.
  68790. */
  68791. constructor();
  68792. readonly isDirty: boolean;
  68793. zOffset: number;
  68794. cullFace: Nullable<number>;
  68795. cull: Nullable<boolean>;
  68796. depthFunc: Nullable<number>;
  68797. depthMask: boolean;
  68798. depthTest: boolean;
  68799. frontFace: Nullable<number>;
  68800. reset(): void;
  68801. apply(gl: WebGLRenderingContext): void;
  68802. }
  68803. }
  68804. declare module BABYLON {
  68805. /**
  68806. * @hidden
  68807. **/
  68808. export class _StencilState {
  68809. /** 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 */
  68810. static readonly ALWAYS: number;
  68811. /** Passed to stencilOperation to specify that stencil value must be kept */
  68812. static readonly KEEP: number;
  68813. /** Passed to stencilOperation to specify that stencil value must be replaced */
  68814. static readonly REPLACE: number;
  68815. private _isStencilTestDirty;
  68816. private _isStencilMaskDirty;
  68817. private _isStencilFuncDirty;
  68818. private _isStencilOpDirty;
  68819. private _stencilTest;
  68820. private _stencilMask;
  68821. private _stencilFunc;
  68822. private _stencilFuncRef;
  68823. private _stencilFuncMask;
  68824. private _stencilOpStencilFail;
  68825. private _stencilOpDepthFail;
  68826. private _stencilOpStencilDepthPass;
  68827. readonly isDirty: boolean;
  68828. stencilFunc: number;
  68829. stencilFuncRef: number;
  68830. stencilFuncMask: number;
  68831. stencilOpStencilFail: number;
  68832. stencilOpDepthFail: number;
  68833. stencilOpStencilDepthPass: number;
  68834. stencilMask: number;
  68835. stencilTest: boolean;
  68836. constructor();
  68837. reset(): void;
  68838. apply(gl: WebGLRenderingContext): void;
  68839. }
  68840. }
  68841. declare module BABYLON {
  68842. /**
  68843. * @hidden
  68844. **/
  68845. export class _TimeToken {
  68846. _startTimeQuery: Nullable<WebGLQuery>;
  68847. _endTimeQuery: Nullable<WebGLQuery>;
  68848. _timeElapsedQuery: Nullable<WebGLQuery>;
  68849. _timeElapsedQueryEnded: boolean;
  68850. }
  68851. }
  68852. declare module BABYLON {
  68853. /**
  68854. * Class used to evalaute queries containing `and` and `or` operators
  68855. */
  68856. export class AndOrNotEvaluator {
  68857. /**
  68858. * Evaluate a query
  68859. * @param query defines the query to evaluate
  68860. * @param evaluateCallback defines the callback used to filter result
  68861. * @returns true if the query matches
  68862. */
  68863. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  68864. private static _HandleParenthesisContent;
  68865. private static _SimplifyNegation;
  68866. }
  68867. }
  68868. declare module BABYLON {
  68869. /**
  68870. * Class used to store custom tags
  68871. */
  68872. export class Tags {
  68873. /**
  68874. * Adds support for tags on the given object
  68875. * @param obj defines the object to use
  68876. */
  68877. static EnableFor(obj: any): void;
  68878. /**
  68879. * Removes tags support
  68880. * @param obj defines the object to use
  68881. */
  68882. static DisableFor(obj: any): void;
  68883. /**
  68884. * Gets a boolean indicating if the given object has tags
  68885. * @param obj defines the object to use
  68886. * @returns a boolean
  68887. */
  68888. static HasTags(obj: any): boolean;
  68889. /**
  68890. * Gets the tags available on a given object
  68891. * @param obj defines the object to use
  68892. * @param asString defines if the tags must be returned as a string instead of an array of strings
  68893. * @returns the tags
  68894. */
  68895. static GetTags(obj: any, asString?: boolean): any;
  68896. /**
  68897. * Adds tags to an object
  68898. * @param obj defines the object to use
  68899. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  68900. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  68901. */
  68902. static AddTagsTo(obj: any, tagsString: string): void;
  68903. /**
  68904. * @hidden
  68905. */
  68906. static _AddTagTo(obj: any, tag: string): void;
  68907. /**
  68908. * Removes specific tags from a specific object
  68909. * @param obj defines the object to use
  68910. * @param tagsString defines the tags to remove
  68911. */
  68912. static RemoveTagsFrom(obj: any, tagsString: string): void;
  68913. /**
  68914. * @hidden
  68915. */
  68916. static _RemoveTagFrom(obj: any, tag: string): void;
  68917. /**
  68918. * Defines if tags hosted on an object match a given query
  68919. * @param obj defines the object to use
  68920. * @param tagsQuery defines the tag query
  68921. * @returns a boolean
  68922. */
  68923. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  68924. }
  68925. }
  68926. declare module BABYLON {
  68927. /**
  68928. * Defines potential orientation for back face culling
  68929. */
  68930. export enum Orientation {
  68931. /**
  68932. * Clockwise
  68933. */
  68934. CW = 0,
  68935. /** Counter clockwise */
  68936. CCW = 1
  68937. }
  68938. /** Class used to represent a Bezier curve */
  68939. export class BezierCurve {
  68940. /**
  68941. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  68942. * @param t defines the time
  68943. * @param x1 defines the left coordinate on X axis
  68944. * @param y1 defines the left coordinate on Y axis
  68945. * @param x2 defines the right coordinate on X axis
  68946. * @param y2 defines the right coordinate on Y axis
  68947. * @returns the interpolated value
  68948. */
  68949. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  68950. }
  68951. /**
  68952. * Defines angle representation
  68953. */
  68954. export class Angle {
  68955. private _radians;
  68956. /**
  68957. * Creates an Angle object of "radians" radians (float).
  68958. * @param radians the angle in radians
  68959. */
  68960. constructor(radians: number);
  68961. /**
  68962. * Get value in degrees
  68963. * @returns the Angle value in degrees (float)
  68964. */
  68965. degrees(): number;
  68966. /**
  68967. * Get value in radians
  68968. * @returns the Angle value in radians (float)
  68969. */
  68970. radians(): number;
  68971. /**
  68972. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  68973. * @param a defines first vector
  68974. * @param b defines second vector
  68975. * @returns a new Angle
  68976. */
  68977. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  68978. /**
  68979. * Gets a new Angle object from the given float in radians
  68980. * @param radians defines the angle value in radians
  68981. * @returns a new Angle
  68982. */
  68983. static FromRadians(radians: number): Angle;
  68984. /**
  68985. * Gets a new Angle object from the given float in degrees
  68986. * @param degrees defines the angle value in degrees
  68987. * @returns a new Angle
  68988. */
  68989. static FromDegrees(degrees: number): Angle;
  68990. }
  68991. /**
  68992. * This represents an arc in a 2d space.
  68993. */
  68994. export class Arc2 {
  68995. /** Defines the start point of the arc */
  68996. startPoint: Vector2;
  68997. /** Defines the mid point of the arc */
  68998. midPoint: Vector2;
  68999. /** Defines the end point of the arc */
  69000. endPoint: Vector2;
  69001. /**
  69002. * Defines the center point of the arc.
  69003. */
  69004. centerPoint: Vector2;
  69005. /**
  69006. * Defines the radius of the arc.
  69007. */
  69008. radius: number;
  69009. /**
  69010. * Defines the angle of the arc (from mid point to end point).
  69011. */
  69012. angle: Angle;
  69013. /**
  69014. * Defines the start angle of the arc (from start point to middle point).
  69015. */
  69016. startAngle: Angle;
  69017. /**
  69018. * Defines the orientation of the arc (clock wise/counter clock wise).
  69019. */
  69020. orientation: Orientation;
  69021. /**
  69022. * Creates an Arc object from the three given points : start, middle and end.
  69023. * @param startPoint Defines the start point of the arc
  69024. * @param midPoint Defines the midlle point of the arc
  69025. * @param endPoint Defines the end point of the arc
  69026. */
  69027. constructor(
  69028. /** Defines the start point of the arc */
  69029. startPoint: Vector2,
  69030. /** Defines the mid point of the arc */
  69031. midPoint: Vector2,
  69032. /** Defines the end point of the arc */
  69033. endPoint: Vector2);
  69034. }
  69035. /**
  69036. * Represents a 2D path made up of multiple 2D points
  69037. */
  69038. export class Path2 {
  69039. private _points;
  69040. private _length;
  69041. /**
  69042. * If the path start and end point are the same
  69043. */
  69044. closed: boolean;
  69045. /**
  69046. * Creates a Path2 object from the starting 2D coordinates x and y.
  69047. * @param x the starting points x value
  69048. * @param y the starting points y value
  69049. */
  69050. constructor(x: number, y: number);
  69051. /**
  69052. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  69053. * @param x the added points x value
  69054. * @param y the added points y value
  69055. * @returns the updated Path2.
  69056. */
  69057. addLineTo(x: number, y: number): Path2;
  69058. /**
  69059. * 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.
  69060. * @param midX middle point x value
  69061. * @param midY middle point y value
  69062. * @param endX end point x value
  69063. * @param endY end point y value
  69064. * @param numberOfSegments (default: 36)
  69065. * @returns the updated Path2.
  69066. */
  69067. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  69068. /**
  69069. * Closes the Path2.
  69070. * @returns the Path2.
  69071. */
  69072. close(): Path2;
  69073. /**
  69074. * Gets the sum of the distance between each sequential point in the path
  69075. * @returns the Path2 total length (float).
  69076. */
  69077. length(): number;
  69078. /**
  69079. * Gets the points which construct the path
  69080. * @returns the Path2 internal array of points.
  69081. */
  69082. getPoints(): Vector2[];
  69083. /**
  69084. * Retreives the point at the distance aways from the starting point
  69085. * @param normalizedLengthPosition the length along the path to retreive the point from
  69086. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  69087. */
  69088. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  69089. /**
  69090. * Creates a new path starting from an x and y position
  69091. * @param x starting x value
  69092. * @param y starting y value
  69093. * @returns a new Path2 starting at the coordinates (x, y).
  69094. */
  69095. static StartingAt(x: number, y: number): Path2;
  69096. }
  69097. /**
  69098. * Represents a 3D path made up of multiple 3D points
  69099. */
  69100. export class Path3D {
  69101. /**
  69102. * an array of Vector3, the curve axis of the Path3D
  69103. */
  69104. path: Vector3[];
  69105. private _curve;
  69106. private _distances;
  69107. private _tangents;
  69108. private _normals;
  69109. private _binormals;
  69110. private _raw;
  69111. /**
  69112. * new Path3D(path, normal, raw)
  69113. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  69114. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  69115. * @param path an array of Vector3, the curve axis of the Path3D
  69116. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  69117. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  69118. */
  69119. constructor(
  69120. /**
  69121. * an array of Vector3, the curve axis of the Path3D
  69122. */
  69123. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  69124. /**
  69125. * Returns the Path3D array of successive Vector3 designing its curve.
  69126. * @returns the Path3D array of successive Vector3 designing its curve.
  69127. */
  69128. getCurve(): Vector3[];
  69129. /**
  69130. * Returns an array populated with tangent vectors on each Path3D curve point.
  69131. * @returns an array populated with tangent vectors on each Path3D curve point.
  69132. */
  69133. getTangents(): Vector3[];
  69134. /**
  69135. * Returns an array populated with normal vectors on each Path3D curve point.
  69136. * @returns an array populated with normal vectors on each Path3D curve point.
  69137. */
  69138. getNormals(): Vector3[];
  69139. /**
  69140. * Returns an array populated with binormal vectors on each Path3D curve point.
  69141. * @returns an array populated with binormal vectors on each Path3D curve point.
  69142. */
  69143. getBinormals(): Vector3[];
  69144. /**
  69145. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  69146. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  69147. */
  69148. getDistances(): number[];
  69149. /**
  69150. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  69151. * @param path path which all values are copied into the curves points
  69152. * @param firstNormal which should be projected onto the curve
  69153. * @returns the same object updated.
  69154. */
  69155. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  69156. private _compute;
  69157. private _getFirstNonNullVector;
  69158. private _getLastNonNullVector;
  69159. private _normalVector;
  69160. }
  69161. /**
  69162. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  69163. * A Curve3 is designed from a series of successive Vector3.
  69164. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  69165. */
  69166. export class Curve3 {
  69167. private _points;
  69168. private _length;
  69169. /**
  69170. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  69171. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  69172. * @param v1 (Vector3) the control point
  69173. * @param v2 (Vector3) the end point of the Quadratic Bezier
  69174. * @param nbPoints (integer) the wanted number of points in the curve
  69175. * @returns the created Curve3
  69176. */
  69177. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  69178. /**
  69179. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  69180. * @param v0 (Vector3) the origin point of the Cubic Bezier
  69181. * @param v1 (Vector3) the first control point
  69182. * @param v2 (Vector3) the second control point
  69183. * @param v3 (Vector3) the end point of the Cubic Bezier
  69184. * @param nbPoints (integer) the wanted number of points in the curve
  69185. * @returns the created Curve3
  69186. */
  69187. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  69188. /**
  69189. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  69190. * @param p1 (Vector3) the origin point of the Hermite Spline
  69191. * @param t1 (Vector3) the tangent vector at the origin point
  69192. * @param p2 (Vector3) the end point of the Hermite Spline
  69193. * @param t2 (Vector3) the tangent vector at the end point
  69194. * @param nbPoints (integer) the wanted number of points in the curve
  69195. * @returns the created Curve3
  69196. */
  69197. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  69198. /**
  69199. * Returns a Curve3 object along a CatmullRom Spline curve :
  69200. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  69201. * @param nbPoints (integer) the wanted number of points between each curve control points
  69202. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  69203. * @returns the created Curve3
  69204. */
  69205. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  69206. /**
  69207. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  69208. * A Curve3 is designed from a series of successive Vector3.
  69209. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  69210. * @param points points which make up the curve
  69211. */
  69212. constructor(points: Vector3[]);
  69213. /**
  69214. * @returns the Curve3 stored array of successive Vector3
  69215. */
  69216. getPoints(): Vector3[];
  69217. /**
  69218. * @returns the computed length (float) of the curve.
  69219. */
  69220. length(): number;
  69221. /**
  69222. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  69223. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  69224. * curveA and curveB keep unchanged.
  69225. * @param curve the curve to continue from this curve
  69226. * @returns the newly constructed curve
  69227. */
  69228. continue(curve: DeepImmutable<Curve3>): Curve3;
  69229. private _computeLength;
  69230. }
  69231. }
  69232. declare module BABYLON {
  69233. /**
  69234. * This represents the main contract an easing function should follow.
  69235. * Easing functions are used throughout the animation system.
  69236. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69237. */
  69238. export interface IEasingFunction {
  69239. /**
  69240. * Given an input gradient between 0 and 1, this returns the corrseponding value
  69241. * of the easing function.
  69242. * The link below provides some of the most common examples of easing functions.
  69243. * @see https://easings.net/
  69244. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69245. * @returns the corresponding value on the curve defined by the easing function
  69246. */
  69247. ease(gradient: number): number;
  69248. }
  69249. /**
  69250. * Base class used for every default easing function.
  69251. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69252. */
  69253. export class EasingFunction implements IEasingFunction {
  69254. /**
  69255. * Interpolation follows the mathematical formula associated with the easing function.
  69256. */
  69257. static readonly EASINGMODE_EASEIN: number;
  69258. /**
  69259. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  69260. */
  69261. static readonly EASINGMODE_EASEOUT: number;
  69262. /**
  69263. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  69264. */
  69265. static readonly EASINGMODE_EASEINOUT: number;
  69266. private _easingMode;
  69267. /**
  69268. * Sets the easing mode of the current function.
  69269. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  69270. */
  69271. setEasingMode(easingMode: number): void;
  69272. /**
  69273. * Gets the current easing mode.
  69274. * @returns the easing mode
  69275. */
  69276. getEasingMode(): number;
  69277. /**
  69278. * @hidden
  69279. */
  69280. easeInCore(gradient: number): number;
  69281. /**
  69282. * Given an input gradient between 0 and 1, this returns the corresponding value
  69283. * of the easing function.
  69284. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69285. * @returns the corresponding value on the curve defined by the easing function
  69286. */
  69287. ease(gradient: number): number;
  69288. }
  69289. /**
  69290. * Easing function with a circle shape (see link below).
  69291. * @see https://easings.net/#easeInCirc
  69292. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69293. */
  69294. export class CircleEase extends EasingFunction implements IEasingFunction {
  69295. /** @hidden */
  69296. easeInCore(gradient: number): number;
  69297. }
  69298. /**
  69299. * Easing function with a ease back shape (see link below).
  69300. * @see https://easings.net/#easeInBack
  69301. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69302. */
  69303. export class BackEase extends EasingFunction implements IEasingFunction {
  69304. /** Defines the amplitude of the function */
  69305. amplitude: number;
  69306. /**
  69307. * Instantiates a back ease easing
  69308. * @see https://easings.net/#easeInBack
  69309. * @param amplitude Defines the amplitude of the function
  69310. */
  69311. constructor(
  69312. /** Defines the amplitude of the function */
  69313. amplitude?: number);
  69314. /** @hidden */
  69315. easeInCore(gradient: number): number;
  69316. }
  69317. /**
  69318. * Easing function with a bouncing shape (see link below).
  69319. * @see https://easings.net/#easeInBounce
  69320. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69321. */
  69322. export class BounceEase extends EasingFunction implements IEasingFunction {
  69323. /** Defines the number of bounces */
  69324. bounces: number;
  69325. /** Defines the amplitude of the bounce */
  69326. bounciness: number;
  69327. /**
  69328. * Instantiates a bounce easing
  69329. * @see https://easings.net/#easeInBounce
  69330. * @param bounces Defines the number of bounces
  69331. * @param bounciness Defines the amplitude of the bounce
  69332. */
  69333. constructor(
  69334. /** Defines the number of bounces */
  69335. bounces?: number,
  69336. /** Defines the amplitude of the bounce */
  69337. bounciness?: number);
  69338. /** @hidden */
  69339. easeInCore(gradient: number): number;
  69340. }
  69341. /**
  69342. * Easing function with a power of 3 shape (see link below).
  69343. * @see https://easings.net/#easeInCubic
  69344. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69345. */
  69346. export class CubicEase extends EasingFunction implements IEasingFunction {
  69347. /** @hidden */
  69348. easeInCore(gradient: number): number;
  69349. }
  69350. /**
  69351. * Easing function with an elastic shape (see link below).
  69352. * @see https://easings.net/#easeInElastic
  69353. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69354. */
  69355. export class ElasticEase extends EasingFunction implements IEasingFunction {
  69356. /** Defines the number of oscillations*/
  69357. oscillations: number;
  69358. /** Defines the amplitude of the oscillations*/
  69359. springiness: number;
  69360. /**
  69361. * Instantiates an elastic easing function
  69362. * @see https://easings.net/#easeInElastic
  69363. * @param oscillations Defines the number of oscillations
  69364. * @param springiness Defines the amplitude of the oscillations
  69365. */
  69366. constructor(
  69367. /** Defines the number of oscillations*/
  69368. oscillations?: number,
  69369. /** Defines the amplitude of the oscillations*/
  69370. springiness?: number);
  69371. /** @hidden */
  69372. easeInCore(gradient: number): number;
  69373. }
  69374. /**
  69375. * Easing function with an exponential shape (see link below).
  69376. * @see https://easings.net/#easeInExpo
  69377. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69378. */
  69379. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  69380. /** Defines the exponent of the function */
  69381. exponent: number;
  69382. /**
  69383. * Instantiates an exponential easing function
  69384. * @see https://easings.net/#easeInExpo
  69385. * @param exponent Defines the exponent of the function
  69386. */
  69387. constructor(
  69388. /** Defines the exponent of the function */
  69389. exponent?: number);
  69390. /** @hidden */
  69391. easeInCore(gradient: number): number;
  69392. }
  69393. /**
  69394. * Easing function with a power shape (see link below).
  69395. * @see https://easings.net/#easeInQuad
  69396. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69397. */
  69398. export class PowerEase extends EasingFunction implements IEasingFunction {
  69399. /** Defines the power of the function */
  69400. power: number;
  69401. /**
  69402. * Instantiates an power base easing function
  69403. * @see https://easings.net/#easeInQuad
  69404. * @param power Defines the power of the function
  69405. */
  69406. constructor(
  69407. /** Defines the power of the function */
  69408. power?: number);
  69409. /** @hidden */
  69410. easeInCore(gradient: number): number;
  69411. }
  69412. /**
  69413. * Easing function with a power of 2 shape (see link below).
  69414. * @see https://easings.net/#easeInQuad
  69415. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69416. */
  69417. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  69418. /** @hidden */
  69419. easeInCore(gradient: number): number;
  69420. }
  69421. /**
  69422. * Easing function with a power of 4 shape (see link below).
  69423. * @see https://easings.net/#easeInQuart
  69424. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69425. */
  69426. export class QuarticEase extends EasingFunction implements IEasingFunction {
  69427. /** @hidden */
  69428. easeInCore(gradient: number): number;
  69429. }
  69430. /**
  69431. * Easing function with a power of 5 shape (see link below).
  69432. * @see https://easings.net/#easeInQuint
  69433. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69434. */
  69435. export class QuinticEase extends EasingFunction implements IEasingFunction {
  69436. /** @hidden */
  69437. easeInCore(gradient: number): number;
  69438. }
  69439. /**
  69440. * Easing function with a sin shape (see link below).
  69441. * @see https://easings.net/#easeInSine
  69442. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69443. */
  69444. export class SineEase extends EasingFunction implements IEasingFunction {
  69445. /** @hidden */
  69446. easeInCore(gradient: number): number;
  69447. }
  69448. /**
  69449. * Easing function with a bezier shape (see link below).
  69450. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  69451. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69452. */
  69453. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  69454. /** Defines the x component of the start tangent in the bezier curve */
  69455. x1: number;
  69456. /** Defines the y component of the start tangent in the bezier curve */
  69457. y1: number;
  69458. /** Defines the x component of the end tangent in the bezier curve */
  69459. x2: number;
  69460. /** Defines the y component of the end tangent in the bezier curve */
  69461. y2: number;
  69462. /**
  69463. * Instantiates a bezier function
  69464. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  69465. * @param x1 Defines the x component of the start tangent in the bezier curve
  69466. * @param y1 Defines the y component of the start tangent in the bezier curve
  69467. * @param x2 Defines the x component of the end tangent in the bezier curve
  69468. * @param y2 Defines the y component of the end tangent in the bezier curve
  69469. */
  69470. constructor(
  69471. /** Defines the x component of the start tangent in the bezier curve */
  69472. x1?: number,
  69473. /** Defines the y component of the start tangent in the bezier curve */
  69474. y1?: number,
  69475. /** Defines the x component of the end tangent in the bezier curve */
  69476. x2?: number,
  69477. /** Defines the y component of the end tangent in the bezier curve */
  69478. y2?: number);
  69479. /** @hidden */
  69480. easeInCore(gradient: number): number;
  69481. }
  69482. }
  69483. declare module BABYLON {
  69484. /**
  69485. * Defines an interface which represents an animation key frame
  69486. */
  69487. export interface IAnimationKey {
  69488. /**
  69489. * Frame of the key frame
  69490. */
  69491. frame: number;
  69492. /**
  69493. * Value at the specifies key frame
  69494. */
  69495. value: any;
  69496. /**
  69497. * The input tangent for the cubic hermite spline
  69498. */
  69499. inTangent?: any;
  69500. /**
  69501. * The output tangent for the cubic hermite spline
  69502. */
  69503. outTangent?: any;
  69504. /**
  69505. * The animation interpolation type
  69506. */
  69507. interpolation?: AnimationKeyInterpolation;
  69508. }
  69509. /**
  69510. * Enum for the animation key frame interpolation type
  69511. */
  69512. export enum AnimationKeyInterpolation {
  69513. /**
  69514. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  69515. */
  69516. STEP = 1
  69517. }
  69518. }
  69519. declare module BABYLON {
  69520. /**
  69521. * Represents the range of an animation
  69522. */
  69523. export class AnimationRange {
  69524. /**The name of the animation range**/
  69525. name: string;
  69526. /**The starting frame of the animation */
  69527. from: number;
  69528. /**The ending frame of the animation*/
  69529. to: number;
  69530. /**
  69531. * Initializes the range of an animation
  69532. * @param name The name of the animation range
  69533. * @param from The starting frame of the animation
  69534. * @param to The ending frame of the animation
  69535. */
  69536. constructor(
  69537. /**The name of the animation range**/
  69538. name: string,
  69539. /**The starting frame of the animation */
  69540. from: number,
  69541. /**The ending frame of the animation*/
  69542. to: number);
  69543. /**
  69544. * Makes a copy of the animation range
  69545. * @returns A copy of the animation range
  69546. */
  69547. clone(): AnimationRange;
  69548. }
  69549. }
  69550. declare module BABYLON {
  69551. /**
  69552. * Composed of a frame, and an action function
  69553. */
  69554. export class AnimationEvent {
  69555. /** The frame for which the event is triggered **/
  69556. frame: number;
  69557. /** The event to perform when triggered **/
  69558. action: (currentFrame: number) => void;
  69559. /** Specifies if the event should be triggered only once**/
  69560. onlyOnce?: boolean | undefined;
  69561. /**
  69562. * Specifies if the animation event is done
  69563. */
  69564. isDone: boolean;
  69565. /**
  69566. * Initializes the animation event
  69567. * @param frame The frame for which the event is triggered
  69568. * @param action The event to perform when triggered
  69569. * @param onlyOnce Specifies if the event should be triggered only once
  69570. */
  69571. constructor(
  69572. /** The frame for which the event is triggered **/
  69573. frame: number,
  69574. /** The event to perform when triggered **/
  69575. action: (currentFrame: number) => void,
  69576. /** Specifies if the event should be triggered only once**/
  69577. onlyOnce?: boolean | undefined);
  69578. /** @hidden */
  69579. _clone(): AnimationEvent;
  69580. }
  69581. }
  69582. declare module BABYLON {
  69583. /**
  69584. * Interface used to define a behavior
  69585. */
  69586. export interface Behavior<T> {
  69587. /** gets or sets behavior's name */
  69588. name: string;
  69589. /**
  69590. * Function called when the behavior needs to be initialized (after attaching it to a target)
  69591. */
  69592. init(): void;
  69593. /**
  69594. * Called when the behavior is attached to a target
  69595. * @param target defines the target where the behavior is attached to
  69596. */
  69597. attach(target: T): void;
  69598. /**
  69599. * Called when the behavior is detached from its target
  69600. */
  69601. detach(): void;
  69602. }
  69603. /**
  69604. * Interface implemented by classes supporting behaviors
  69605. */
  69606. export interface IBehaviorAware<T> {
  69607. /**
  69608. * Attach a behavior
  69609. * @param behavior defines the behavior to attach
  69610. * @returns the current host
  69611. */
  69612. addBehavior(behavior: Behavior<T>): T;
  69613. /**
  69614. * Remove a behavior from the current object
  69615. * @param behavior defines the behavior to detach
  69616. * @returns the current host
  69617. */
  69618. removeBehavior(behavior: Behavior<T>): T;
  69619. /**
  69620. * Gets a behavior using its name to search
  69621. * @param name defines the name to search
  69622. * @returns the behavior or null if not found
  69623. */
  69624. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  69625. }
  69626. }
  69627. declare module BABYLON {
  69628. /**
  69629. * Defines an array and its length.
  69630. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  69631. */
  69632. export interface ISmartArrayLike<T> {
  69633. /**
  69634. * The data of the array.
  69635. */
  69636. data: Array<T>;
  69637. /**
  69638. * The active length of the array.
  69639. */
  69640. length: number;
  69641. }
  69642. /**
  69643. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  69644. */
  69645. export class SmartArray<T> implements ISmartArrayLike<T> {
  69646. /**
  69647. * The full set of data from the array.
  69648. */
  69649. data: Array<T>;
  69650. /**
  69651. * The active length of the array.
  69652. */
  69653. length: number;
  69654. protected _id: number;
  69655. /**
  69656. * Instantiates a Smart Array.
  69657. * @param capacity defines the default capacity of the array.
  69658. */
  69659. constructor(capacity: number);
  69660. /**
  69661. * Pushes a value at the end of the active data.
  69662. * @param value defines the object to push in the array.
  69663. */
  69664. push(value: T): void;
  69665. /**
  69666. * Iterates over the active data and apply the lambda to them.
  69667. * @param func defines the action to apply on each value.
  69668. */
  69669. forEach(func: (content: T) => void): void;
  69670. /**
  69671. * Sorts the full sets of data.
  69672. * @param compareFn defines the comparison function to apply.
  69673. */
  69674. sort(compareFn: (a: T, b: T) => number): void;
  69675. /**
  69676. * Resets the active data to an empty array.
  69677. */
  69678. reset(): void;
  69679. /**
  69680. * Releases all the data from the array as well as the array.
  69681. */
  69682. dispose(): void;
  69683. /**
  69684. * Concats the active data with a given array.
  69685. * @param array defines the data to concatenate with.
  69686. */
  69687. concat(array: any): void;
  69688. /**
  69689. * Returns the position of a value in the active data.
  69690. * @param value defines the value to find the index for
  69691. * @returns the index if found in the active data otherwise -1
  69692. */
  69693. indexOf(value: T): number;
  69694. /**
  69695. * Returns whether an element is part of the active data.
  69696. * @param value defines the value to look for
  69697. * @returns true if found in the active data otherwise false
  69698. */
  69699. contains(value: T): boolean;
  69700. private static _GlobalId;
  69701. }
  69702. /**
  69703. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  69704. * The data in this array can only be present once
  69705. */
  69706. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  69707. private _duplicateId;
  69708. /**
  69709. * Pushes a value at the end of the active data.
  69710. * THIS DOES NOT PREVENT DUPPLICATE DATA
  69711. * @param value defines the object to push in the array.
  69712. */
  69713. push(value: T): void;
  69714. /**
  69715. * Pushes a value at the end of the active data.
  69716. * If the data is already present, it won t be added again
  69717. * @param value defines the object to push in the array.
  69718. * @returns true if added false if it was already present
  69719. */
  69720. pushNoDuplicate(value: T): boolean;
  69721. /**
  69722. * Resets the active data to an empty array.
  69723. */
  69724. reset(): void;
  69725. /**
  69726. * Concats the active data with a given array.
  69727. * This ensures no dupplicate will be present in the result.
  69728. * @param array defines the data to concatenate with.
  69729. */
  69730. concatWithNoDuplicate(array: any): void;
  69731. }
  69732. }
  69733. declare module BABYLON {
  69734. /**
  69735. * @ignore
  69736. * This is a list of all the different input types that are available in the application.
  69737. * Fo instance: ArcRotateCameraGamepadInput...
  69738. */
  69739. export var CameraInputTypes: {};
  69740. /**
  69741. * This is the contract to implement in order to create a new input class.
  69742. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  69743. */
  69744. export interface ICameraInput<TCamera extends Camera> {
  69745. /**
  69746. * Defines the camera the input is attached to.
  69747. */
  69748. camera: Nullable<TCamera>;
  69749. /**
  69750. * Gets the class name of the current intput.
  69751. * @returns the class name
  69752. */
  69753. getClassName(): string;
  69754. /**
  69755. * Get the friendly name associated with the input class.
  69756. * @returns the input friendly name
  69757. */
  69758. getSimpleName(): string;
  69759. /**
  69760. * Attach the input controls to a specific dom element to get the input from.
  69761. * @param element Defines the element the controls should be listened from
  69762. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69763. */
  69764. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69765. /**
  69766. * Detach the current controls from the specified dom element.
  69767. * @param element Defines the element to stop listening the inputs from
  69768. */
  69769. detachControl(element: Nullable<HTMLElement>): void;
  69770. /**
  69771. * Update the current camera state depending on the inputs that have been used this frame.
  69772. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  69773. */
  69774. checkInputs?: () => void;
  69775. }
  69776. /**
  69777. * Represents a map of input types to input instance or input index to input instance.
  69778. */
  69779. export interface CameraInputsMap<TCamera extends Camera> {
  69780. /**
  69781. * Accessor to the input by input type.
  69782. */
  69783. [name: string]: ICameraInput<TCamera>;
  69784. /**
  69785. * Accessor to the input by input index.
  69786. */
  69787. [idx: number]: ICameraInput<TCamera>;
  69788. }
  69789. /**
  69790. * This represents the input manager used within a camera.
  69791. * It helps dealing with all the different kind of input attached to a camera.
  69792. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69793. */
  69794. export class CameraInputsManager<TCamera extends Camera> {
  69795. /**
  69796. * Defines the list of inputs attahed to the camera.
  69797. */
  69798. attached: CameraInputsMap<TCamera>;
  69799. /**
  69800. * Defines the dom element the camera is collecting inputs from.
  69801. * This is null if the controls have not been attached.
  69802. */
  69803. attachedElement: Nullable<HTMLElement>;
  69804. /**
  69805. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69806. */
  69807. noPreventDefault: boolean;
  69808. /**
  69809. * Defined the camera the input manager belongs to.
  69810. */
  69811. camera: TCamera;
  69812. /**
  69813. * Update the current camera state depending on the inputs that have been used this frame.
  69814. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  69815. */
  69816. checkInputs: () => void;
  69817. /**
  69818. * Instantiate a new Camera Input Manager.
  69819. * @param camera Defines the camera the input manager blongs to
  69820. */
  69821. constructor(camera: TCamera);
  69822. /**
  69823. * Add an input method to a camera
  69824. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69825. * @param input camera input method
  69826. */
  69827. add(input: ICameraInput<TCamera>): void;
  69828. /**
  69829. * Remove a specific input method from a camera
  69830. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  69831. * @param inputToRemove camera input method
  69832. */
  69833. remove(inputToRemove: ICameraInput<TCamera>): void;
  69834. /**
  69835. * Remove a specific input type from a camera
  69836. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  69837. * @param inputType the type of the input to remove
  69838. */
  69839. removeByType(inputType: string): void;
  69840. private _addCheckInputs;
  69841. /**
  69842. * Attach the input controls to the currently attached dom element to listen the events from.
  69843. * @param input Defines the input to attach
  69844. */
  69845. attachInput(input: ICameraInput<TCamera>): void;
  69846. /**
  69847. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  69848. * @param element Defines the dom element to collect the events from
  69849. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69850. */
  69851. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  69852. /**
  69853. * Detach the current manager inputs controls from a specific dom element.
  69854. * @param element Defines the dom element to collect the events from
  69855. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  69856. */
  69857. detachElement(element: HTMLElement, disconnect?: boolean): void;
  69858. /**
  69859. * Rebuild the dynamic inputCheck function from the current list of
  69860. * defined inputs in the manager.
  69861. */
  69862. rebuildInputCheck(): void;
  69863. /**
  69864. * Remove all attached input methods from a camera
  69865. */
  69866. clear(): void;
  69867. /**
  69868. * Serialize the current input manager attached to a camera.
  69869. * This ensures than once parsed,
  69870. * the input associated to the camera will be identical to the current ones
  69871. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  69872. */
  69873. serialize(serializedCamera: any): void;
  69874. /**
  69875. * Parses an input manager serialized JSON to restore the previous list of inputs
  69876. * and states associated to a camera.
  69877. * @param parsedCamera Defines the JSON to parse
  69878. */
  69879. parse(parsedCamera: any): void;
  69880. }
  69881. }
  69882. declare module BABYLON {
  69883. /**
  69884. * @hidden
  69885. */
  69886. export class IntersectionInfo {
  69887. bu: Nullable<number>;
  69888. bv: Nullable<number>;
  69889. distance: number;
  69890. faceId: number;
  69891. subMeshId: number;
  69892. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  69893. }
  69894. }
  69895. declare module BABYLON {
  69896. /**
  69897. * Represens a plane by the equation ax + by + cz + d = 0
  69898. */
  69899. export class Plane {
  69900. private static _TmpMatrix;
  69901. /**
  69902. * Normal of the plane (a,b,c)
  69903. */
  69904. normal: Vector3;
  69905. /**
  69906. * d component of the plane
  69907. */
  69908. d: number;
  69909. /**
  69910. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  69911. * @param a a component of the plane
  69912. * @param b b component of the plane
  69913. * @param c c component of the plane
  69914. * @param d d component of the plane
  69915. */
  69916. constructor(a: number, b: number, c: number, d: number);
  69917. /**
  69918. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  69919. */
  69920. asArray(): number[];
  69921. /**
  69922. * @returns a new plane copied from the current Plane.
  69923. */
  69924. clone(): Plane;
  69925. /**
  69926. * @returns the string "Plane".
  69927. */
  69928. getClassName(): string;
  69929. /**
  69930. * @returns the Plane hash code.
  69931. */
  69932. getHashCode(): number;
  69933. /**
  69934. * Normalize the current Plane in place.
  69935. * @returns the updated Plane.
  69936. */
  69937. normalize(): Plane;
  69938. /**
  69939. * Applies a transformation the plane and returns the result
  69940. * @param transformation the transformation matrix to be applied to the plane
  69941. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  69942. */
  69943. transform(transformation: DeepImmutable<Matrix>): Plane;
  69944. /**
  69945. * Calcualtte the dot product between the point and the plane normal
  69946. * @param point point to calculate the dot product with
  69947. * @returns the dot product (float) of the point coordinates and the plane normal.
  69948. */
  69949. dotCoordinate(point: DeepImmutable<Vector3>): number;
  69950. /**
  69951. * Updates the current Plane from the plane defined by the three given points.
  69952. * @param point1 one of the points used to contruct the plane
  69953. * @param point2 one of the points used to contruct the plane
  69954. * @param point3 one of the points used to contruct the plane
  69955. * @returns the updated Plane.
  69956. */
  69957. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  69958. /**
  69959. * Checks if the plane is facing a given direction
  69960. * @param direction the direction to check if the plane is facing
  69961. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  69962. * @returns True is the vector "direction" is the same side than the plane normal.
  69963. */
  69964. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  69965. /**
  69966. * Calculates the distance to a point
  69967. * @param point point to calculate distance to
  69968. * @returns the signed distance (float) from the given point to the Plane.
  69969. */
  69970. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  69971. /**
  69972. * Creates a plane from an array
  69973. * @param array the array to create a plane from
  69974. * @returns a new Plane from the given array.
  69975. */
  69976. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  69977. /**
  69978. * Creates a plane from three points
  69979. * @param point1 point used to create the plane
  69980. * @param point2 point used to create the plane
  69981. * @param point3 point used to create the plane
  69982. * @returns a new Plane defined by the three given points.
  69983. */
  69984. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  69985. /**
  69986. * Creates a plane from an origin point and a normal
  69987. * @param origin origin of the plane to be constructed
  69988. * @param normal normal of the plane to be constructed
  69989. * @returns a new Plane the normal vector to this plane at the given origin point.
  69990. * Note : the vector "normal" is updated because normalized.
  69991. */
  69992. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  69993. /**
  69994. * Calculates the distance from a plane and a point
  69995. * @param origin origin of the plane to be constructed
  69996. * @param normal normal of the plane to be constructed
  69997. * @param point point to calculate distance to
  69998. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  69999. */
  70000. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  70001. }
  70002. }
  70003. declare module BABYLON {
  70004. /**
  70005. * Class used to store bounding sphere information
  70006. */
  70007. export class BoundingSphere {
  70008. /**
  70009. * Gets the center of the bounding sphere in local space
  70010. */
  70011. readonly center: Vector3;
  70012. /**
  70013. * Radius of the bounding sphere in local space
  70014. */
  70015. radius: number;
  70016. /**
  70017. * Gets the center of the bounding sphere in world space
  70018. */
  70019. readonly centerWorld: Vector3;
  70020. /**
  70021. * Radius of the bounding sphere in world space
  70022. */
  70023. radiusWorld: number;
  70024. /**
  70025. * Gets the minimum vector in local space
  70026. */
  70027. readonly minimum: Vector3;
  70028. /**
  70029. * Gets the maximum vector in local space
  70030. */
  70031. readonly maximum: Vector3;
  70032. private _worldMatrix;
  70033. private static readonly TmpVector3;
  70034. /**
  70035. * Creates a new bounding sphere
  70036. * @param min defines the minimum vector (in local space)
  70037. * @param max defines the maximum vector (in local space)
  70038. * @param worldMatrix defines the new world matrix
  70039. */
  70040. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  70041. /**
  70042. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  70043. * @param min defines the new minimum vector (in local space)
  70044. * @param max defines the new maximum vector (in local space)
  70045. * @param worldMatrix defines the new world matrix
  70046. */
  70047. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  70048. /**
  70049. * Scale the current bounding sphere by applying a scale factor
  70050. * @param factor defines the scale factor to apply
  70051. * @returns the current bounding box
  70052. */
  70053. scale(factor: number): BoundingSphere;
  70054. /**
  70055. * Gets the world matrix of the bounding box
  70056. * @returns a matrix
  70057. */
  70058. getWorldMatrix(): DeepImmutable<Matrix>;
  70059. /** @hidden */
  70060. _update(worldMatrix: DeepImmutable<Matrix>): void;
  70061. /**
  70062. * Tests if the bounding sphere is intersecting the frustum planes
  70063. * @param frustumPlanes defines the frustum planes to test
  70064. * @returns true if there is an intersection
  70065. */
  70066. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70067. /**
  70068. * Tests if the bounding sphere center is in between the frustum planes.
  70069. * Used for optimistic fast inclusion.
  70070. * @param frustumPlanes defines the frustum planes to test
  70071. * @returns true if the sphere center is in between the frustum planes
  70072. */
  70073. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70074. /**
  70075. * Tests if a point is inside the bounding sphere
  70076. * @param point defines the point to test
  70077. * @returns true if the point is inside the bounding sphere
  70078. */
  70079. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70080. /**
  70081. * Checks if two sphere intersct
  70082. * @param sphere0 sphere 0
  70083. * @param sphere1 sphere 1
  70084. * @returns true if the speres intersect
  70085. */
  70086. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  70087. }
  70088. }
  70089. declare module BABYLON {
  70090. /**
  70091. * Class used to store bounding box information
  70092. */
  70093. export class BoundingBox implements ICullable {
  70094. /**
  70095. * Gets the 8 vectors representing the bounding box in local space
  70096. */
  70097. readonly vectors: Vector3[];
  70098. /**
  70099. * Gets the center of the bounding box in local space
  70100. */
  70101. readonly center: Vector3;
  70102. /**
  70103. * Gets the center of the bounding box in world space
  70104. */
  70105. readonly centerWorld: Vector3;
  70106. /**
  70107. * Gets the extend size in local space
  70108. */
  70109. readonly extendSize: Vector3;
  70110. /**
  70111. * Gets the extend size in world space
  70112. */
  70113. readonly extendSizeWorld: Vector3;
  70114. /**
  70115. * Gets the OBB (object bounding box) directions
  70116. */
  70117. readonly directions: Vector3[];
  70118. /**
  70119. * Gets the 8 vectors representing the bounding box in world space
  70120. */
  70121. readonly vectorsWorld: Vector3[];
  70122. /**
  70123. * Gets the minimum vector in world space
  70124. */
  70125. readonly minimumWorld: Vector3;
  70126. /**
  70127. * Gets the maximum vector in world space
  70128. */
  70129. readonly maximumWorld: Vector3;
  70130. /**
  70131. * Gets the minimum vector in local space
  70132. */
  70133. readonly minimum: Vector3;
  70134. /**
  70135. * Gets the maximum vector in local space
  70136. */
  70137. readonly maximum: Vector3;
  70138. private _worldMatrix;
  70139. private static readonly TmpVector3;
  70140. /**
  70141. * @hidden
  70142. */
  70143. _tag: number;
  70144. /**
  70145. * Creates a new bounding box
  70146. * @param min defines the minimum vector (in local space)
  70147. * @param max defines the maximum vector (in local space)
  70148. * @param worldMatrix defines the new world matrix
  70149. */
  70150. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  70151. /**
  70152. * Recreates the entire bounding box from scratch as if we call the constructor in place
  70153. * @param min defines the new minimum vector (in local space)
  70154. * @param max defines the new maximum vector (in local space)
  70155. * @param worldMatrix defines the new world matrix
  70156. */
  70157. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  70158. /**
  70159. * Scale the current bounding box by applying a scale factor
  70160. * @param factor defines the scale factor to apply
  70161. * @returns the current bounding box
  70162. */
  70163. scale(factor: number): BoundingBox;
  70164. /**
  70165. * Gets the world matrix of the bounding box
  70166. * @returns a matrix
  70167. */
  70168. getWorldMatrix(): DeepImmutable<Matrix>;
  70169. /** @hidden */
  70170. _update(world: DeepImmutable<Matrix>): void;
  70171. /**
  70172. * Tests if the bounding box is intersecting the frustum planes
  70173. * @param frustumPlanes defines the frustum planes to test
  70174. * @returns true if there is an intersection
  70175. */
  70176. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70177. /**
  70178. * Tests if the bounding box is entirely inside the frustum planes
  70179. * @param frustumPlanes defines the frustum planes to test
  70180. * @returns true if there is an inclusion
  70181. */
  70182. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70183. /**
  70184. * Tests if a point is inside the bounding box
  70185. * @param point defines the point to test
  70186. * @returns true if the point is inside the bounding box
  70187. */
  70188. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70189. /**
  70190. * Tests if the bounding box intersects with a bounding sphere
  70191. * @param sphere defines the sphere to test
  70192. * @returns true if there is an intersection
  70193. */
  70194. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  70195. /**
  70196. * Tests if the bounding box intersects with a box defined by a min and max vectors
  70197. * @param min defines the min vector to use
  70198. * @param max defines the max vector to use
  70199. * @returns true if there is an intersection
  70200. */
  70201. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  70202. /**
  70203. * Tests if two bounding boxes are intersections
  70204. * @param box0 defines the first box to test
  70205. * @param box1 defines the second box to test
  70206. * @returns true if there is an intersection
  70207. */
  70208. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  70209. /**
  70210. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  70211. * @param minPoint defines the minimum vector of the bounding box
  70212. * @param maxPoint defines the maximum vector of the bounding box
  70213. * @param sphereCenter defines the sphere center
  70214. * @param sphereRadius defines the sphere radius
  70215. * @returns true if there is an intersection
  70216. */
  70217. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  70218. /**
  70219. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  70220. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  70221. * @param frustumPlanes defines the frustum planes to test
  70222. * @return true if there is an inclusion
  70223. */
  70224. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70225. /**
  70226. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  70227. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  70228. * @param frustumPlanes defines the frustum planes to test
  70229. * @return true if there is an intersection
  70230. */
  70231. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70232. }
  70233. }
  70234. declare module BABYLON {
  70235. /** @hidden */
  70236. export class Collider {
  70237. /** Define if a collision was found */
  70238. collisionFound: boolean;
  70239. /**
  70240. * Define last intersection point in local space
  70241. */
  70242. intersectionPoint: Vector3;
  70243. /**
  70244. * Define last collided mesh
  70245. */
  70246. collidedMesh: Nullable<AbstractMesh>;
  70247. private _collisionPoint;
  70248. private _planeIntersectionPoint;
  70249. private _tempVector;
  70250. private _tempVector2;
  70251. private _tempVector3;
  70252. private _tempVector4;
  70253. private _edge;
  70254. private _baseToVertex;
  70255. private _destinationPoint;
  70256. private _slidePlaneNormal;
  70257. private _displacementVector;
  70258. /** @hidden */
  70259. _radius: Vector3;
  70260. /** @hidden */
  70261. _retry: number;
  70262. private _velocity;
  70263. private _basePoint;
  70264. private _epsilon;
  70265. /** @hidden */
  70266. _velocityWorldLength: number;
  70267. /** @hidden */
  70268. _basePointWorld: Vector3;
  70269. private _velocityWorld;
  70270. private _normalizedVelocity;
  70271. /** @hidden */
  70272. _initialVelocity: Vector3;
  70273. /** @hidden */
  70274. _initialPosition: Vector3;
  70275. private _nearestDistance;
  70276. private _collisionMask;
  70277. collisionMask: number;
  70278. /**
  70279. * Gets the plane normal used to compute the sliding response (in local space)
  70280. */
  70281. readonly slidePlaneNormal: Vector3;
  70282. /** @hidden */
  70283. _initialize(source: Vector3, dir: Vector3, e: number): void;
  70284. /** @hidden */
  70285. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  70286. /** @hidden */
  70287. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  70288. /** @hidden */
  70289. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  70290. /** @hidden */
  70291. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  70292. /** @hidden */
  70293. _getResponse(pos: Vector3, vel: Vector3): void;
  70294. }
  70295. }
  70296. declare module BABYLON {
  70297. /**
  70298. * Interface for cullable objects
  70299. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  70300. */
  70301. export interface ICullable {
  70302. /**
  70303. * Checks if the object or part of the object is in the frustum
  70304. * @param frustumPlanes Camera near/planes
  70305. * @returns true if the object is in frustum otherwise false
  70306. */
  70307. isInFrustum(frustumPlanes: Plane[]): boolean;
  70308. /**
  70309. * Checks if a cullable object (mesh...) is in the camera frustum
  70310. * Unlike isInFrustum this cheks the full bounding box
  70311. * @param frustumPlanes Camera near/planes
  70312. * @returns true if the object is in frustum otherwise false
  70313. */
  70314. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  70315. }
  70316. /**
  70317. * Info for a bounding data of a mesh
  70318. */
  70319. export class BoundingInfo implements ICullable {
  70320. /**
  70321. * Bounding box for the mesh
  70322. */
  70323. readonly boundingBox: BoundingBox;
  70324. /**
  70325. * Bounding sphere for the mesh
  70326. */
  70327. readonly boundingSphere: BoundingSphere;
  70328. private _isLocked;
  70329. private static readonly TmpVector3;
  70330. /**
  70331. * Constructs bounding info
  70332. * @param minimum min vector of the bounding box/sphere
  70333. * @param maximum max vector of the bounding box/sphere
  70334. * @param worldMatrix defines the new world matrix
  70335. */
  70336. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  70337. /**
  70338. * Recreates the entire bounding info from scratch as if we call the constructor in place
  70339. * @param min defines the new minimum vector (in local space)
  70340. * @param max defines the new maximum vector (in local space)
  70341. * @param worldMatrix defines the new world matrix
  70342. */
  70343. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  70344. /**
  70345. * min vector of the bounding box/sphere
  70346. */
  70347. readonly minimum: Vector3;
  70348. /**
  70349. * max vector of the bounding box/sphere
  70350. */
  70351. readonly maximum: Vector3;
  70352. /**
  70353. * If the info is locked and won't be updated to avoid perf overhead
  70354. */
  70355. isLocked: boolean;
  70356. /**
  70357. * Updates the bounding sphere and box
  70358. * @param world world matrix to be used to update
  70359. */
  70360. update(world: DeepImmutable<Matrix>): void;
  70361. /**
  70362. * Recreate the bounding info to be centered around a specific point given a specific extend.
  70363. * @param center New center of the bounding info
  70364. * @param extend New extend of the bounding info
  70365. * @returns the current bounding info
  70366. */
  70367. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  70368. /**
  70369. * Scale the current bounding info by applying a scale factor
  70370. * @param factor defines the scale factor to apply
  70371. * @returns the current bounding info
  70372. */
  70373. scale(factor: number): BoundingInfo;
  70374. /**
  70375. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  70376. * @param frustumPlanes defines the frustum to test
  70377. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  70378. * @returns true if the bounding info is in the frustum planes
  70379. */
  70380. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  70381. /**
  70382. * Gets the world distance between the min and max points of the bounding box
  70383. */
  70384. readonly diagonalLength: number;
  70385. /**
  70386. * Checks if a cullable object (mesh...) is in the camera frustum
  70387. * Unlike isInFrustum this cheks the full bounding box
  70388. * @param frustumPlanes Camera near/planes
  70389. * @returns true if the object is in frustum otherwise false
  70390. */
  70391. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70392. /** @hidden */
  70393. _checkCollision(collider: Collider): boolean;
  70394. /**
  70395. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  70396. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  70397. * @param point the point to check intersection with
  70398. * @returns if the point intersects
  70399. */
  70400. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70401. /**
  70402. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  70403. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  70404. * @param boundingInfo the bounding info to check intersection with
  70405. * @param precise if the intersection should be done using OBB
  70406. * @returns if the bounding info intersects
  70407. */
  70408. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  70409. }
  70410. }
  70411. declare module BABYLON {
  70412. /**
  70413. * Extracts minimum and maximum values from a list of indexed positions
  70414. * @param positions defines the positions to use
  70415. * @param indices defines the indices to the positions
  70416. * @param indexStart defines the start index
  70417. * @param indexCount defines the end index
  70418. * @param bias defines bias value to add to the result
  70419. * @return minimum and maximum values
  70420. */
  70421. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  70422. minimum: Vector3;
  70423. maximum: Vector3;
  70424. };
  70425. /**
  70426. * Extracts minimum and maximum values from a list of positions
  70427. * @param positions defines the positions to use
  70428. * @param start defines the start index in the positions array
  70429. * @param count defines the number of positions to handle
  70430. * @param bias defines bias value to add to the result
  70431. * @param stride defines the stride size to use (distance between two positions in the positions array)
  70432. * @return minimum and maximum values
  70433. */
  70434. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  70435. minimum: Vector3;
  70436. maximum: Vector3;
  70437. };
  70438. }
  70439. declare module BABYLON {
  70440. /**
  70441. * Enum that determines the text-wrapping mode to use.
  70442. */
  70443. export enum InspectableType {
  70444. /**
  70445. * Checkbox for booleans
  70446. */
  70447. Checkbox = 0,
  70448. /**
  70449. * Sliders for numbers
  70450. */
  70451. Slider = 1,
  70452. /**
  70453. * Vector3
  70454. */
  70455. Vector3 = 2,
  70456. /**
  70457. * Quaternions
  70458. */
  70459. Quaternion = 3,
  70460. /**
  70461. * Color3
  70462. */
  70463. Color3 = 4,
  70464. /**
  70465. * String
  70466. */
  70467. String = 5
  70468. }
  70469. /**
  70470. * Interface used to define custom inspectable properties.
  70471. * This interface is used by the inspector to display custom property grids
  70472. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70473. */
  70474. export interface IInspectable {
  70475. /**
  70476. * Gets the label to display
  70477. */
  70478. label: string;
  70479. /**
  70480. * Gets the name of the property to edit
  70481. */
  70482. propertyName: string;
  70483. /**
  70484. * Gets the type of the editor to use
  70485. */
  70486. type: InspectableType;
  70487. /**
  70488. * Gets the minimum value of the property when using in "slider" mode
  70489. */
  70490. min?: number;
  70491. /**
  70492. * Gets the maximum value of the property when using in "slider" mode
  70493. */
  70494. max?: number;
  70495. /**
  70496. * Gets the setp to use when using in "slider" mode
  70497. */
  70498. step?: number;
  70499. }
  70500. }
  70501. declare module BABYLON {
  70502. /**
  70503. * Class used to provide helper for timing
  70504. */
  70505. export class TimingTools {
  70506. /**
  70507. * Polyfill for setImmediate
  70508. * @param action defines the action to execute after the current execution block
  70509. */
  70510. static SetImmediate(action: () => void): void;
  70511. }
  70512. }
  70513. declare module BABYLON {
  70514. /**
  70515. * Class used to enable instatition of objects by class name
  70516. */
  70517. export class InstantiationTools {
  70518. /**
  70519. * Use this object to register external classes like custom textures or material
  70520. * to allow the laoders to instantiate them
  70521. */
  70522. static RegisteredExternalClasses: {
  70523. [key: string]: Object;
  70524. };
  70525. /**
  70526. * Tries to instantiate a new object from a given class name
  70527. * @param className defines the class name to instantiate
  70528. * @returns the new object or null if the system was not able to do the instantiation
  70529. */
  70530. static Instantiate(className: string): any;
  70531. }
  70532. }
  70533. declare module BABYLON {
  70534. /**
  70535. * This represents the required contract to create a new type of texture loader.
  70536. */
  70537. export interface IInternalTextureLoader {
  70538. /**
  70539. * Defines wether the loader supports cascade loading the different faces.
  70540. */
  70541. supportCascades: boolean;
  70542. /**
  70543. * This returns if the loader support the current file information.
  70544. * @param extension defines the file extension of the file being loaded
  70545. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70546. * @param fallback defines the fallback internal texture if any
  70547. * @param isBase64 defines whether the texture is encoded as a base64
  70548. * @param isBuffer defines whether the texture data are stored as a buffer
  70549. * @returns true if the loader can load the specified file
  70550. */
  70551. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  70552. /**
  70553. * Transform the url before loading if required.
  70554. * @param rootUrl the url of the texture
  70555. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70556. * @returns the transformed texture
  70557. */
  70558. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  70559. /**
  70560. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  70561. * @param rootUrl the url of the texture
  70562. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70563. * @returns the fallback texture
  70564. */
  70565. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  70566. /**
  70567. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  70568. * @param data contains the texture data
  70569. * @param texture defines the BabylonJS internal texture
  70570. * @param createPolynomials will be true if polynomials have been requested
  70571. * @param onLoad defines the callback to trigger once the texture is ready
  70572. * @param onError defines the callback to trigger in case of error
  70573. */
  70574. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  70575. /**
  70576. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  70577. * @param data contains the texture data
  70578. * @param texture defines the BabylonJS internal texture
  70579. * @param callback defines the method to call once ready to upload
  70580. */
  70581. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  70582. }
  70583. }
  70584. declare module BABYLON {
  70585. interface Engine {
  70586. /**
  70587. * Creates a depth stencil cube texture.
  70588. * This is only available in WebGL 2.
  70589. * @param size The size of face edge in the cube texture.
  70590. * @param options The options defining the cube texture.
  70591. * @returns The cube texture
  70592. */
  70593. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  70594. /**
  70595. * Creates a cube texture
  70596. * @param rootUrl defines the url where the files to load is located
  70597. * @param scene defines the current scene
  70598. * @param files defines the list of files to load (1 per face)
  70599. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70600. * @param onLoad defines an optional callback raised when the texture is loaded
  70601. * @param onError defines an optional callback raised if there is an issue to load the texture
  70602. * @param format defines the format of the data
  70603. * @param forcedExtension defines the extension to use to pick the right loader
  70604. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  70605. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70606. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70607. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  70608. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  70609. * @returns the cube texture as an InternalTexture
  70610. */
  70611. 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;
  70612. /**
  70613. * Creates a cube texture
  70614. * @param rootUrl defines the url where the files to load is located
  70615. * @param scene defines the current scene
  70616. * @param files defines the list of files to load (1 per face)
  70617. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70618. * @param onLoad defines an optional callback raised when the texture is loaded
  70619. * @param onError defines an optional callback raised if there is an issue to load the texture
  70620. * @param format defines the format of the data
  70621. * @param forcedExtension defines the extension to use to pick the right loader
  70622. * @returns the cube texture as an InternalTexture
  70623. */
  70624. 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;
  70625. /**
  70626. * Creates a cube texture
  70627. * @param rootUrl defines the url where the files to load is located
  70628. * @param scene defines the current scene
  70629. * @param files defines the list of files to load (1 per face)
  70630. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70631. * @param onLoad defines an optional callback raised when the texture is loaded
  70632. * @param onError defines an optional callback raised if there is an issue to load the texture
  70633. * @param format defines the format of the data
  70634. * @param forcedExtension defines the extension to use to pick the right loader
  70635. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  70636. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70637. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70638. * @returns the cube texture as an InternalTexture
  70639. */
  70640. 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;
  70641. /** @hidden */
  70642. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  70643. /** @hidden */
  70644. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  70645. /** @hidden */
  70646. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  70647. /** @hidden */
  70648. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  70649. }
  70650. }
  70651. declare module BABYLON {
  70652. /**
  70653. * Class for creating a cube texture
  70654. */
  70655. export class CubeTexture extends BaseTexture {
  70656. private _delayedOnLoad;
  70657. /**
  70658. * The url of the texture
  70659. */
  70660. url: string;
  70661. /**
  70662. * Gets or sets the center of the bounding box associated with the cube texture.
  70663. * It must define where the camera used to render the texture was set
  70664. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  70665. */
  70666. boundingBoxPosition: Vector3;
  70667. private _boundingBoxSize;
  70668. /**
  70669. * Gets or sets the size of the bounding box associated with the cube texture
  70670. * When defined, the cubemap will switch to local mode
  70671. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  70672. * @example https://www.babylonjs-playground.com/#RNASML
  70673. */
  70674. /**
  70675. * Returns the bounding box size
  70676. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  70677. */
  70678. boundingBoxSize: Vector3;
  70679. protected _rotationY: number;
  70680. /**
  70681. * Sets texture matrix rotation angle around Y axis in radians.
  70682. */
  70683. /**
  70684. * Gets texture matrix rotation angle around Y axis radians.
  70685. */
  70686. rotationY: number;
  70687. /**
  70688. * Are mip maps generated for this texture or not.
  70689. */
  70690. readonly noMipmap: boolean;
  70691. private _noMipmap;
  70692. private _files;
  70693. private _extensions;
  70694. private _textureMatrix;
  70695. private _format;
  70696. private _createPolynomials;
  70697. /** @hidden */
  70698. _prefiltered: boolean;
  70699. /**
  70700. * Creates a cube texture from an array of image urls
  70701. * @param files defines an array of image urls
  70702. * @param scene defines the hosting scene
  70703. * @param noMipmap specifies if mip maps are not used
  70704. * @returns a cube texture
  70705. */
  70706. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  70707. /**
  70708. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  70709. * @param url defines the url of the prefiltered texture
  70710. * @param scene defines the scene the texture is attached to
  70711. * @param forcedExtension defines the extension of the file if different from the url
  70712. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  70713. * @return the prefiltered texture
  70714. */
  70715. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  70716. /**
  70717. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  70718. * as prefiltered data.
  70719. * @param rootUrl defines the url of the texture or the root name of the six images
  70720. * @param scene defines the scene the texture is attached to
  70721. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  70722. * @param noMipmap defines if mipmaps should be created or not
  70723. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  70724. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  70725. * @param onError defines a callback triggered in case of error during load
  70726. * @param format defines the internal format to use for the texture once loaded
  70727. * @param prefiltered defines whether or not the texture is created from prefiltered data
  70728. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  70729. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  70730. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70731. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70732. * @return the cube texture
  70733. */
  70734. 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);
  70735. /**
  70736. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  70737. */
  70738. readonly isPrefiltered: boolean;
  70739. /**
  70740. * Get the current class name of the texture useful for serialization or dynamic coding.
  70741. * @returns "CubeTexture"
  70742. */
  70743. getClassName(): string;
  70744. /**
  70745. * Update the url (and optional buffer) of this texture if url was null during construction.
  70746. * @param url the url of the texture
  70747. * @param forcedExtension defines the extension to use
  70748. * @param onLoad callback called when the texture is loaded (defaults to null)
  70749. */
  70750. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  70751. /**
  70752. * Delays loading of the cube texture
  70753. * @param forcedExtension defines the extension to use
  70754. */
  70755. delayLoad(forcedExtension?: string): void;
  70756. /**
  70757. * Returns the reflection texture matrix
  70758. * @returns the reflection texture matrix
  70759. */
  70760. getReflectionTextureMatrix(): Matrix;
  70761. /**
  70762. * Sets the reflection texture matrix
  70763. * @param value Reflection texture matrix
  70764. */
  70765. setReflectionTextureMatrix(value: Matrix): void;
  70766. /**
  70767. * Parses text to create a cube texture
  70768. * @param parsedTexture define the serialized text to read from
  70769. * @param scene defines the hosting scene
  70770. * @param rootUrl defines the root url of the cube texture
  70771. * @returns a cube texture
  70772. */
  70773. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  70774. /**
  70775. * Makes a clone, or deep copy, of the cube texture
  70776. * @returns a new cube texture
  70777. */
  70778. clone(): CubeTexture;
  70779. }
  70780. }
  70781. declare module BABYLON {
  70782. /**
  70783. * Manages the defines for the Material
  70784. */
  70785. export class MaterialDefines {
  70786. /** @hidden */
  70787. protected _keys: string[];
  70788. private _isDirty;
  70789. /** @hidden */
  70790. _renderId: number;
  70791. /** @hidden */
  70792. _areLightsDirty: boolean;
  70793. /** @hidden */
  70794. _areAttributesDirty: boolean;
  70795. /** @hidden */
  70796. _areTexturesDirty: boolean;
  70797. /** @hidden */
  70798. _areFresnelDirty: boolean;
  70799. /** @hidden */
  70800. _areMiscDirty: boolean;
  70801. /** @hidden */
  70802. _areImageProcessingDirty: boolean;
  70803. /** @hidden */
  70804. _normals: boolean;
  70805. /** @hidden */
  70806. _uvs: boolean;
  70807. /** @hidden */
  70808. _needNormals: boolean;
  70809. /** @hidden */
  70810. _needUVs: boolean;
  70811. [id: string]: any;
  70812. /**
  70813. * Specifies if the material needs to be re-calculated
  70814. */
  70815. readonly isDirty: boolean;
  70816. /**
  70817. * Marks the material to indicate that it has been re-calculated
  70818. */
  70819. markAsProcessed(): void;
  70820. /**
  70821. * Marks the material to indicate that it needs to be re-calculated
  70822. */
  70823. markAsUnprocessed(): void;
  70824. /**
  70825. * Marks the material to indicate all of its defines need to be re-calculated
  70826. */
  70827. markAllAsDirty(): void;
  70828. /**
  70829. * Marks the material to indicate that image processing needs to be re-calculated
  70830. */
  70831. markAsImageProcessingDirty(): void;
  70832. /**
  70833. * Marks the material to indicate the lights need to be re-calculated
  70834. */
  70835. markAsLightDirty(): void;
  70836. /**
  70837. * Marks the attribute state as changed
  70838. */
  70839. markAsAttributesDirty(): void;
  70840. /**
  70841. * Marks the texture state as changed
  70842. */
  70843. markAsTexturesDirty(): void;
  70844. /**
  70845. * Marks the fresnel state as changed
  70846. */
  70847. markAsFresnelDirty(): void;
  70848. /**
  70849. * Marks the misc state as changed
  70850. */
  70851. markAsMiscDirty(): void;
  70852. /**
  70853. * Rebuilds the material defines
  70854. */
  70855. rebuild(): void;
  70856. /**
  70857. * Specifies if two material defines are equal
  70858. * @param other - A material define instance to compare to
  70859. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  70860. */
  70861. isEqual(other: MaterialDefines): boolean;
  70862. /**
  70863. * Clones this instance's defines to another instance
  70864. * @param other - material defines to clone values to
  70865. */
  70866. cloneTo(other: MaterialDefines): void;
  70867. /**
  70868. * Resets the material define values
  70869. */
  70870. reset(): void;
  70871. /**
  70872. * Converts the material define values to a string
  70873. * @returns - String of material define information
  70874. */
  70875. toString(): string;
  70876. }
  70877. }
  70878. declare module BABYLON {
  70879. /**
  70880. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  70881. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  70882. * 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;
  70883. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  70884. */
  70885. export class ColorCurves {
  70886. private _dirty;
  70887. private _tempColor;
  70888. private _globalCurve;
  70889. private _highlightsCurve;
  70890. private _midtonesCurve;
  70891. private _shadowsCurve;
  70892. private _positiveCurve;
  70893. private _negativeCurve;
  70894. private _globalHue;
  70895. private _globalDensity;
  70896. private _globalSaturation;
  70897. private _globalExposure;
  70898. /**
  70899. * Gets the global Hue value.
  70900. * 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).
  70901. */
  70902. /**
  70903. * Sets the global Hue value.
  70904. * 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).
  70905. */
  70906. globalHue: number;
  70907. /**
  70908. * Gets the global Density value.
  70909. * 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.
  70910. * Values less than zero provide a filter of opposite hue.
  70911. */
  70912. /**
  70913. * Sets the global Density value.
  70914. * 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.
  70915. * Values less than zero provide a filter of opposite hue.
  70916. */
  70917. globalDensity: number;
  70918. /**
  70919. * Gets the global Saturation value.
  70920. * 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.
  70921. */
  70922. /**
  70923. * Sets the global Saturation value.
  70924. * 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.
  70925. */
  70926. globalSaturation: number;
  70927. /**
  70928. * Gets the global Exposure value.
  70929. * 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.
  70930. */
  70931. /**
  70932. * Sets the global Exposure value.
  70933. * 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.
  70934. */
  70935. globalExposure: number;
  70936. private _highlightsHue;
  70937. private _highlightsDensity;
  70938. private _highlightsSaturation;
  70939. private _highlightsExposure;
  70940. /**
  70941. * Gets the highlights Hue value.
  70942. * 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).
  70943. */
  70944. /**
  70945. * Sets the highlights Hue value.
  70946. * 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).
  70947. */
  70948. highlightsHue: number;
  70949. /**
  70950. * Gets the highlights Density value.
  70951. * 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.
  70952. * Values less than zero provide a filter of opposite hue.
  70953. */
  70954. /**
  70955. * Sets the highlights Density value.
  70956. * 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.
  70957. * Values less than zero provide a filter of opposite hue.
  70958. */
  70959. highlightsDensity: number;
  70960. /**
  70961. * Gets the highlights Saturation value.
  70962. * 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.
  70963. */
  70964. /**
  70965. * Sets the highlights Saturation value.
  70966. * 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.
  70967. */
  70968. highlightsSaturation: number;
  70969. /**
  70970. * Gets the highlights Exposure value.
  70971. * 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.
  70972. */
  70973. /**
  70974. * Sets the highlights Exposure value.
  70975. * 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.
  70976. */
  70977. highlightsExposure: number;
  70978. private _midtonesHue;
  70979. private _midtonesDensity;
  70980. private _midtonesSaturation;
  70981. private _midtonesExposure;
  70982. /**
  70983. * Gets the midtones Hue value.
  70984. * 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).
  70985. */
  70986. /**
  70987. * Sets the midtones Hue value.
  70988. * 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).
  70989. */
  70990. midtonesHue: number;
  70991. /**
  70992. * Gets the midtones Density value.
  70993. * 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.
  70994. * Values less than zero provide a filter of opposite hue.
  70995. */
  70996. /**
  70997. * Sets the midtones Density value.
  70998. * 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.
  70999. * Values less than zero provide a filter of opposite hue.
  71000. */
  71001. midtonesDensity: number;
  71002. /**
  71003. * Gets the midtones Saturation value.
  71004. * 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.
  71005. */
  71006. /**
  71007. * Sets the midtones Saturation value.
  71008. * 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.
  71009. */
  71010. midtonesSaturation: number;
  71011. /**
  71012. * Gets the midtones Exposure value.
  71013. * 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.
  71014. */
  71015. /**
  71016. * Sets the midtones Exposure value.
  71017. * 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.
  71018. */
  71019. midtonesExposure: number;
  71020. private _shadowsHue;
  71021. private _shadowsDensity;
  71022. private _shadowsSaturation;
  71023. private _shadowsExposure;
  71024. /**
  71025. * Gets the shadows Hue value.
  71026. * 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).
  71027. */
  71028. /**
  71029. * Sets the shadows Hue value.
  71030. * 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).
  71031. */
  71032. shadowsHue: number;
  71033. /**
  71034. * Gets the shadows Density value.
  71035. * 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.
  71036. * Values less than zero provide a filter of opposite hue.
  71037. */
  71038. /**
  71039. * Sets the shadows Density value.
  71040. * 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.
  71041. * Values less than zero provide a filter of opposite hue.
  71042. */
  71043. shadowsDensity: number;
  71044. /**
  71045. * Gets the shadows Saturation value.
  71046. * 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.
  71047. */
  71048. /**
  71049. * Sets the shadows Saturation value.
  71050. * 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.
  71051. */
  71052. shadowsSaturation: number;
  71053. /**
  71054. * Gets the shadows Exposure value.
  71055. * 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.
  71056. */
  71057. /**
  71058. * Sets the shadows Exposure value.
  71059. * 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.
  71060. */
  71061. shadowsExposure: number;
  71062. /**
  71063. * Returns the class name
  71064. * @returns The class name
  71065. */
  71066. getClassName(): string;
  71067. /**
  71068. * Binds the color curves to the shader.
  71069. * @param colorCurves The color curve to bind
  71070. * @param effect The effect to bind to
  71071. * @param positiveUniform The positive uniform shader parameter
  71072. * @param neutralUniform The neutral uniform shader parameter
  71073. * @param negativeUniform The negative uniform shader parameter
  71074. */
  71075. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  71076. /**
  71077. * Prepare the list of uniforms associated with the ColorCurves effects.
  71078. * @param uniformsList The list of uniforms used in the effect
  71079. */
  71080. static PrepareUniforms(uniformsList: string[]): void;
  71081. /**
  71082. * Returns color grading data based on a hue, density, saturation and exposure value.
  71083. * @param filterHue The hue of the color filter.
  71084. * @param filterDensity The density of the color filter.
  71085. * @param saturation The saturation.
  71086. * @param exposure The exposure.
  71087. * @param result The result data container.
  71088. */
  71089. private getColorGradingDataToRef;
  71090. /**
  71091. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  71092. * @param value The input slider value in range [-100,100].
  71093. * @returns Adjusted value.
  71094. */
  71095. private static applyColorGradingSliderNonlinear;
  71096. /**
  71097. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  71098. * @param hue The hue (H) input.
  71099. * @param saturation The saturation (S) input.
  71100. * @param brightness The brightness (B) input.
  71101. * @result An RGBA color represented as Vector4.
  71102. */
  71103. private static fromHSBToRef;
  71104. /**
  71105. * Returns a value clamped between min and max
  71106. * @param value The value to clamp
  71107. * @param min The minimum of value
  71108. * @param max The maximum of value
  71109. * @returns The clamped value.
  71110. */
  71111. private static clamp;
  71112. /**
  71113. * Clones the current color curve instance.
  71114. * @return The cloned curves
  71115. */
  71116. clone(): ColorCurves;
  71117. /**
  71118. * Serializes the current color curve instance to a json representation.
  71119. * @return a JSON representation
  71120. */
  71121. serialize(): any;
  71122. /**
  71123. * Parses the color curve from a json representation.
  71124. * @param source the JSON source to parse
  71125. * @return The parsed curves
  71126. */
  71127. static Parse(source: any): ColorCurves;
  71128. }
  71129. }
  71130. declare module BABYLON {
  71131. /**
  71132. * Interface to follow in your material defines to integrate easily the
  71133. * Image proccessing functions.
  71134. * @hidden
  71135. */
  71136. export interface IImageProcessingConfigurationDefines {
  71137. IMAGEPROCESSING: boolean;
  71138. VIGNETTE: boolean;
  71139. VIGNETTEBLENDMODEMULTIPLY: boolean;
  71140. VIGNETTEBLENDMODEOPAQUE: boolean;
  71141. TONEMAPPING: boolean;
  71142. TONEMAPPING_ACES: boolean;
  71143. CONTRAST: boolean;
  71144. EXPOSURE: boolean;
  71145. COLORCURVES: boolean;
  71146. COLORGRADING: boolean;
  71147. COLORGRADING3D: boolean;
  71148. SAMPLER3DGREENDEPTH: boolean;
  71149. SAMPLER3DBGRMAP: boolean;
  71150. IMAGEPROCESSINGPOSTPROCESS: boolean;
  71151. }
  71152. /**
  71153. * @hidden
  71154. */
  71155. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  71156. IMAGEPROCESSING: boolean;
  71157. VIGNETTE: boolean;
  71158. VIGNETTEBLENDMODEMULTIPLY: boolean;
  71159. VIGNETTEBLENDMODEOPAQUE: boolean;
  71160. TONEMAPPING: boolean;
  71161. TONEMAPPING_ACES: boolean;
  71162. CONTRAST: boolean;
  71163. COLORCURVES: boolean;
  71164. COLORGRADING: boolean;
  71165. COLORGRADING3D: boolean;
  71166. SAMPLER3DGREENDEPTH: boolean;
  71167. SAMPLER3DBGRMAP: boolean;
  71168. IMAGEPROCESSINGPOSTPROCESS: boolean;
  71169. EXPOSURE: boolean;
  71170. constructor();
  71171. }
  71172. /**
  71173. * This groups together the common properties used for image processing either in direct forward pass
  71174. * or through post processing effect depending on the use of the image processing pipeline in your scene
  71175. * or not.
  71176. */
  71177. export class ImageProcessingConfiguration {
  71178. /**
  71179. * Default tone mapping applied in BabylonJS.
  71180. */
  71181. static readonly TONEMAPPING_STANDARD: number;
  71182. /**
  71183. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  71184. * to other engines rendering to increase portability.
  71185. */
  71186. static readonly TONEMAPPING_ACES: number;
  71187. /**
  71188. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  71189. */
  71190. colorCurves: Nullable<ColorCurves>;
  71191. private _colorCurvesEnabled;
  71192. /**
  71193. * Gets wether the color curves effect is enabled.
  71194. */
  71195. /**
  71196. * Sets wether the color curves effect is enabled.
  71197. */
  71198. colorCurvesEnabled: boolean;
  71199. private _colorGradingTexture;
  71200. /**
  71201. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  71202. */
  71203. /**
  71204. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  71205. */
  71206. colorGradingTexture: Nullable<BaseTexture>;
  71207. private _colorGradingEnabled;
  71208. /**
  71209. * Gets wether the color grading effect is enabled.
  71210. */
  71211. /**
  71212. * Sets wether the color grading effect is enabled.
  71213. */
  71214. colorGradingEnabled: boolean;
  71215. private _colorGradingWithGreenDepth;
  71216. /**
  71217. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  71218. */
  71219. /**
  71220. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  71221. */
  71222. colorGradingWithGreenDepth: boolean;
  71223. private _colorGradingBGR;
  71224. /**
  71225. * Gets wether the color grading texture contains BGR values.
  71226. */
  71227. /**
  71228. * Sets wether the color grading texture contains BGR values.
  71229. */
  71230. colorGradingBGR: boolean;
  71231. /** @hidden */
  71232. _exposure: number;
  71233. /**
  71234. * Gets the Exposure used in the effect.
  71235. */
  71236. /**
  71237. * Sets the Exposure used in the effect.
  71238. */
  71239. exposure: number;
  71240. private _toneMappingEnabled;
  71241. /**
  71242. * Gets wether the tone mapping effect is enabled.
  71243. */
  71244. /**
  71245. * Sets wether the tone mapping effect is enabled.
  71246. */
  71247. toneMappingEnabled: boolean;
  71248. private _toneMappingType;
  71249. /**
  71250. * Gets the type of tone mapping effect.
  71251. */
  71252. /**
  71253. * Sets the type of tone mapping effect used in BabylonJS.
  71254. */
  71255. toneMappingType: number;
  71256. protected _contrast: number;
  71257. /**
  71258. * Gets the contrast used in the effect.
  71259. */
  71260. /**
  71261. * Sets the contrast used in the effect.
  71262. */
  71263. contrast: number;
  71264. /**
  71265. * Vignette stretch size.
  71266. */
  71267. vignetteStretch: number;
  71268. /**
  71269. * Vignette centre X Offset.
  71270. */
  71271. vignetteCentreX: number;
  71272. /**
  71273. * Vignette centre Y Offset.
  71274. */
  71275. vignetteCentreY: number;
  71276. /**
  71277. * Vignette weight or intensity of the vignette effect.
  71278. */
  71279. vignetteWeight: number;
  71280. /**
  71281. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  71282. * if vignetteEnabled is set to true.
  71283. */
  71284. vignetteColor: Color4;
  71285. /**
  71286. * Camera field of view used by the Vignette effect.
  71287. */
  71288. vignetteCameraFov: number;
  71289. private _vignetteBlendMode;
  71290. /**
  71291. * Gets the vignette blend mode allowing different kind of effect.
  71292. */
  71293. /**
  71294. * Sets the vignette blend mode allowing different kind of effect.
  71295. */
  71296. vignetteBlendMode: number;
  71297. private _vignetteEnabled;
  71298. /**
  71299. * Gets wether the vignette effect is enabled.
  71300. */
  71301. /**
  71302. * Sets wether the vignette effect is enabled.
  71303. */
  71304. vignetteEnabled: boolean;
  71305. private _applyByPostProcess;
  71306. /**
  71307. * Gets wether the image processing is applied through a post process or not.
  71308. */
  71309. /**
  71310. * Sets wether the image processing is applied through a post process or not.
  71311. */
  71312. applyByPostProcess: boolean;
  71313. private _isEnabled;
  71314. /**
  71315. * Gets wether the image processing is enabled or not.
  71316. */
  71317. /**
  71318. * Sets wether the image processing is enabled or not.
  71319. */
  71320. isEnabled: boolean;
  71321. /**
  71322. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  71323. */
  71324. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  71325. /**
  71326. * Method called each time the image processing information changes requires to recompile the effect.
  71327. */
  71328. protected _updateParameters(): void;
  71329. /**
  71330. * Gets the current class name.
  71331. * @return "ImageProcessingConfiguration"
  71332. */
  71333. getClassName(): string;
  71334. /**
  71335. * Prepare the list of uniforms associated with the Image Processing effects.
  71336. * @param uniforms The list of uniforms used in the effect
  71337. * @param defines the list of defines currently in use
  71338. */
  71339. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  71340. /**
  71341. * Prepare the list of samplers associated with the Image Processing effects.
  71342. * @param samplersList The list of uniforms used in the effect
  71343. * @param defines the list of defines currently in use
  71344. */
  71345. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  71346. /**
  71347. * Prepare the list of defines associated to the shader.
  71348. * @param defines the list of defines to complete
  71349. * @param forPostProcess Define if we are currently in post process mode or not
  71350. */
  71351. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  71352. /**
  71353. * Returns true if all the image processing information are ready.
  71354. * @returns True if ready, otherwise, false
  71355. */
  71356. isReady(): boolean;
  71357. /**
  71358. * Binds the image processing to the shader.
  71359. * @param effect The effect to bind to
  71360. * @param aspectRatio Define the current aspect ratio of the effect
  71361. */
  71362. bind(effect: Effect, aspectRatio?: number): void;
  71363. /**
  71364. * Clones the current image processing instance.
  71365. * @return The cloned image processing
  71366. */
  71367. clone(): ImageProcessingConfiguration;
  71368. /**
  71369. * Serializes the current image processing instance to a json representation.
  71370. * @return a JSON representation
  71371. */
  71372. serialize(): any;
  71373. /**
  71374. * Parses the image processing from a json representation.
  71375. * @param source the JSON source to parse
  71376. * @return The parsed image processing
  71377. */
  71378. static Parse(source: any): ImageProcessingConfiguration;
  71379. private static _VIGNETTEMODE_MULTIPLY;
  71380. private static _VIGNETTEMODE_OPAQUE;
  71381. /**
  71382. * Used to apply the vignette as a mix with the pixel color.
  71383. */
  71384. static readonly VIGNETTEMODE_MULTIPLY: number;
  71385. /**
  71386. * Used to apply the vignette as a replacement of the pixel color.
  71387. */
  71388. static readonly VIGNETTEMODE_OPAQUE: number;
  71389. }
  71390. }
  71391. declare module BABYLON {
  71392. /** @hidden */
  71393. export var postprocessVertexShader: {
  71394. name: string;
  71395. shader: string;
  71396. };
  71397. }
  71398. declare module BABYLON {
  71399. /** Defines supported spaces */
  71400. export enum Space {
  71401. /** Local (object) space */
  71402. LOCAL = 0,
  71403. /** World space */
  71404. WORLD = 1,
  71405. /** Bone space */
  71406. BONE = 2
  71407. }
  71408. /** Defines the 3 main axes */
  71409. export class Axis {
  71410. /** X axis */
  71411. static X: Vector3;
  71412. /** Y axis */
  71413. static Y: Vector3;
  71414. /** Z axis */
  71415. static Z: Vector3;
  71416. }
  71417. }
  71418. declare module BABYLON {
  71419. /**
  71420. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  71421. * This is the base of the follow, arc rotate cameras and Free camera
  71422. * @see http://doc.babylonjs.com/features/cameras
  71423. */
  71424. export class TargetCamera extends Camera {
  71425. private static _RigCamTransformMatrix;
  71426. private static _TargetTransformMatrix;
  71427. private static _TargetFocalPoint;
  71428. /**
  71429. * Define the current direction the camera is moving to
  71430. */
  71431. cameraDirection: Vector3;
  71432. /**
  71433. * Define the current rotation the camera is rotating to
  71434. */
  71435. cameraRotation: Vector2;
  71436. /**
  71437. * When set, the up vector of the camera will be updated by the rotation of the camera
  71438. */
  71439. updateUpVectorFromRotation: boolean;
  71440. private _tmpQuaternion;
  71441. /**
  71442. * Define the current rotation of the camera
  71443. */
  71444. rotation: Vector3;
  71445. /**
  71446. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  71447. */
  71448. rotationQuaternion: Quaternion;
  71449. /**
  71450. * Define the current speed of the camera
  71451. */
  71452. speed: number;
  71453. /**
  71454. * Add cconstraint to the camera to prevent it to move freely in all directions and
  71455. * around all axis.
  71456. */
  71457. noRotationConstraint: boolean;
  71458. /**
  71459. * Define the current target of the camera as an object or a position.
  71460. */
  71461. lockedTarget: any;
  71462. /** @hidden */
  71463. _currentTarget: Vector3;
  71464. /** @hidden */
  71465. _initialFocalDistance: number;
  71466. /** @hidden */
  71467. _viewMatrix: Matrix;
  71468. /** @hidden */
  71469. _camMatrix: Matrix;
  71470. /** @hidden */
  71471. _cameraTransformMatrix: Matrix;
  71472. /** @hidden */
  71473. _cameraRotationMatrix: Matrix;
  71474. /** @hidden */
  71475. _referencePoint: Vector3;
  71476. /** @hidden */
  71477. _transformedReferencePoint: Vector3;
  71478. protected _globalCurrentTarget: Vector3;
  71479. protected _globalCurrentUpVector: Vector3;
  71480. /** @hidden */
  71481. _reset: () => void;
  71482. private _defaultUp;
  71483. /**
  71484. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  71485. * This is the base of the follow, arc rotate cameras and Free camera
  71486. * @see http://doc.babylonjs.com/features/cameras
  71487. * @param name Defines the name of the camera in the scene
  71488. * @param position Defines the start position of the camera in the scene
  71489. * @param scene Defines the scene the camera belongs to
  71490. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  71491. */
  71492. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  71493. /**
  71494. * Gets the position in front of the camera at a given distance.
  71495. * @param distance The distance from the camera we want the position to be
  71496. * @returns the position
  71497. */
  71498. getFrontPosition(distance: number): Vector3;
  71499. /** @hidden */
  71500. _getLockedTargetPosition(): Nullable<Vector3>;
  71501. private _storedPosition;
  71502. private _storedRotation;
  71503. private _storedRotationQuaternion;
  71504. /**
  71505. * Store current camera state of the camera (fov, position, rotation, etc..)
  71506. * @returns the camera
  71507. */
  71508. storeState(): Camera;
  71509. /**
  71510. * Restored camera state. You must call storeState() first
  71511. * @returns whether it was successful or not
  71512. * @hidden
  71513. */
  71514. _restoreStateValues(): boolean;
  71515. /** @hidden */
  71516. _initCache(): void;
  71517. /** @hidden */
  71518. _updateCache(ignoreParentClass?: boolean): void;
  71519. /** @hidden */
  71520. _isSynchronizedViewMatrix(): boolean;
  71521. /** @hidden */
  71522. _computeLocalCameraSpeed(): number;
  71523. /**
  71524. * Defines the target the camera should look at.
  71525. * @param target Defines the new target as a Vector or a mesh
  71526. */
  71527. setTarget(target: Vector3): void;
  71528. /**
  71529. * Return the current target position of the camera. This value is expressed in local space.
  71530. * @returns the target position
  71531. */
  71532. getTarget(): Vector3;
  71533. /** @hidden */
  71534. _decideIfNeedsToMove(): boolean;
  71535. /** @hidden */
  71536. _updatePosition(): void;
  71537. /** @hidden */
  71538. _checkInputs(): void;
  71539. protected _updateCameraRotationMatrix(): void;
  71540. /**
  71541. * 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)
  71542. * @returns the current camera
  71543. */
  71544. private _rotateUpVectorWithCameraRotationMatrix;
  71545. private _cachedRotationZ;
  71546. private _cachedQuaternionRotationZ;
  71547. /** @hidden */
  71548. _getViewMatrix(): Matrix;
  71549. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  71550. /**
  71551. * @hidden
  71552. */
  71553. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  71554. /**
  71555. * @hidden
  71556. */
  71557. _updateRigCameras(): void;
  71558. private _getRigCamPositionAndTarget;
  71559. /**
  71560. * Gets the current object class name.
  71561. * @return the class name
  71562. */
  71563. getClassName(): string;
  71564. }
  71565. }
  71566. declare module BABYLON {
  71567. /**
  71568. * Gather the list of keyboard event types as constants.
  71569. */
  71570. export class KeyboardEventTypes {
  71571. /**
  71572. * The keydown event is fired when a key becomes active (pressed).
  71573. */
  71574. static readonly KEYDOWN: number;
  71575. /**
  71576. * The keyup event is fired when a key has been released.
  71577. */
  71578. static readonly KEYUP: number;
  71579. }
  71580. /**
  71581. * This class is used to store keyboard related info for the onKeyboardObservable event.
  71582. */
  71583. export class KeyboardInfo {
  71584. /**
  71585. * Defines the type of event (KeyboardEventTypes)
  71586. */
  71587. type: number;
  71588. /**
  71589. * Defines the related dom event
  71590. */
  71591. event: KeyboardEvent;
  71592. /**
  71593. * Instantiates a new keyboard info.
  71594. * This class is used to store keyboard related info for the onKeyboardObservable event.
  71595. * @param type Defines the type of event (KeyboardEventTypes)
  71596. * @param event Defines the related dom event
  71597. */
  71598. constructor(
  71599. /**
  71600. * Defines the type of event (KeyboardEventTypes)
  71601. */
  71602. type: number,
  71603. /**
  71604. * Defines the related dom event
  71605. */
  71606. event: KeyboardEvent);
  71607. }
  71608. /**
  71609. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  71610. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  71611. */
  71612. export class KeyboardInfoPre extends KeyboardInfo {
  71613. /**
  71614. * Defines the type of event (KeyboardEventTypes)
  71615. */
  71616. type: number;
  71617. /**
  71618. * Defines the related dom event
  71619. */
  71620. event: KeyboardEvent;
  71621. /**
  71622. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  71623. */
  71624. skipOnPointerObservable: boolean;
  71625. /**
  71626. * Instantiates a new keyboard pre info.
  71627. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  71628. * @param type Defines the type of event (KeyboardEventTypes)
  71629. * @param event Defines the related dom event
  71630. */
  71631. constructor(
  71632. /**
  71633. * Defines the type of event (KeyboardEventTypes)
  71634. */
  71635. type: number,
  71636. /**
  71637. * Defines the related dom event
  71638. */
  71639. event: KeyboardEvent);
  71640. }
  71641. }
  71642. declare module BABYLON {
  71643. /**
  71644. * Manage the keyboard inputs to control the movement of a free camera.
  71645. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71646. */
  71647. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  71648. /**
  71649. * Defines the camera the input is attached to.
  71650. */
  71651. camera: FreeCamera;
  71652. /**
  71653. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  71654. */
  71655. keysUp: number[];
  71656. /**
  71657. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  71658. */
  71659. keysDown: number[];
  71660. /**
  71661. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  71662. */
  71663. keysLeft: number[];
  71664. /**
  71665. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  71666. */
  71667. keysRight: number[];
  71668. private _keys;
  71669. private _onCanvasBlurObserver;
  71670. private _onKeyboardObserver;
  71671. private _engine;
  71672. private _scene;
  71673. /**
  71674. * Attach the input controls to a specific dom element to get the input from.
  71675. * @param element Defines the element the controls should be listened from
  71676. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71677. */
  71678. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71679. /**
  71680. * Detach the current controls from the specified dom element.
  71681. * @param element Defines the element to stop listening the inputs from
  71682. */
  71683. detachControl(element: Nullable<HTMLElement>): void;
  71684. /**
  71685. * Update the current camera state depending on the inputs that have been used this frame.
  71686. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71687. */
  71688. checkInputs(): void;
  71689. /**
  71690. * Gets the class name of the current intput.
  71691. * @returns the class name
  71692. */
  71693. getClassName(): string;
  71694. /** @hidden */
  71695. _onLostFocus(): void;
  71696. /**
  71697. * Get the friendly name associated with the input class.
  71698. * @returns the input friendly name
  71699. */
  71700. getSimpleName(): string;
  71701. }
  71702. }
  71703. declare module BABYLON {
  71704. /**
  71705. * Interface describing all the common properties and methods a shadow light needs to implement.
  71706. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  71707. * as well as binding the different shadow properties to the effects.
  71708. */
  71709. export interface IShadowLight extends Light {
  71710. /**
  71711. * The light id in the scene (used in scene.findLighById for instance)
  71712. */
  71713. id: string;
  71714. /**
  71715. * The position the shdow will be casted from.
  71716. */
  71717. position: Vector3;
  71718. /**
  71719. * In 2d mode (needCube being false), the direction used to cast the shadow.
  71720. */
  71721. direction: Vector3;
  71722. /**
  71723. * The transformed position. Position of the light in world space taking parenting in account.
  71724. */
  71725. transformedPosition: Vector3;
  71726. /**
  71727. * The transformed direction. Direction of the light in world space taking parenting in account.
  71728. */
  71729. transformedDirection: Vector3;
  71730. /**
  71731. * The friendly name of the light in the scene.
  71732. */
  71733. name: string;
  71734. /**
  71735. * Defines the shadow projection clipping minimum z value.
  71736. */
  71737. shadowMinZ: number;
  71738. /**
  71739. * Defines the shadow projection clipping maximum z value.
  71740. */
  71741. shadowMaxZ: number;
  71742. /**
  71743. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  71744. * @returns true if the information has been computed, false if it does not need to (no parenting)
  71745. */
  71746. computeTransformedInformation(): boolean;
  71747. /**
  71748. * Gets the scene the light belongs to.
  71749. * @returns The scene
  71750. */
  71751. getScene(): Scene;
  71752. /**
  71753. * Callback defining a custom Projection Matrix Builder.
  71754. * This can be used to override the default projection matrix computation.
  71755. */
  71756. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  71757. /**
  71758. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  71759. * @param matrix The materix to updated with the projection information
  71760. * @param viewMatrix The transform matrix of the light
  71761. * @param renderList The list of mesh to render in the map
  71762. * @returns The current light
  71763. */
  71764. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  71765. /**
  71766. * Gets the current depth scale used in ESM.
  71767. * @returns The scale
  71768. */
  71769. getDepthScale(): number;
  71770. /**
  71771. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  71772. * @returns true if a cube texture needs to be use
  71773. */
  71774. needCube(): boolean;
  71775. /**
  71776. * Detects if the projection matrix requires to be recomputed this frame.
  71777. * @returns true if it requires to be recomputed otherwise, false.
  71778. */
  71779. needProjectionMatrixCompute(): boolean;
  71780. /**
  71781. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  71782. */
  71783. forceProjectionMatrixCompute(): void;
  71784. /**
  71785. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  71786. * @param faceIndex The index of the face we are computed the direction to generate shadow
  71787. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  71788. */
  71789. getShadowDirection(faceIndex?: number): Vector3;
  71790. /**
  71791. * Gets the minZ used for shadow according to both the scene and the light.
  71792. * @param activeCamera The camera we are returning the min for
  71793. * @returns the depth min z
  71794. */
  71795. getDepthMinZ(activeCamera: Camera): number;
  71796. /**
  71797. * Gets the maxZ used for shadow according to both the scene and the light.
  71798. * @param activeCamera The camera we are returning the max for
  71799. * @returns the depth max z
  71800. */
  71801. getDepthMaxZ(activeCamera: Camera): number;
  71802. }
  71803. /**
  71804. * Base implementation IShadowLight
  71805. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  71806. */
  71807. export abstract class ShadowLight extends Light implements IShadowLight {
  71808. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  71809. protected _position: Vector3;
  71810. protected _setPosition(value: Vector3): void;
  71811. /**
  71812. * Sets the position the shadow will be casted from. Also use as the light position for both
  71813. * point and spot lights.
  71814. */
  71815. /**
  71816. * Sets the position the shadow will be casted from. Also use as the light position for both
  71817. * point and spot lights.
  71818. */
  71819. position: Vector3;
  71820. protected _direction: Vector3;
  71821. protected _setDirection(value: Vector3): void;
  71822. /**
  71823. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  71824. * Also use as the light direction on spot and directional lights.
  71825. */
  71826. /**
  71827. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  71828. * Also use as the light direction on spot and directional lights.
  71829. */
  71830. direction: Vector3;
  71831. private _shadowMinZ;
  71832. /**
  71833. * Gets the shadow projection clipping minimum z value.
  71834. */
  71835. /**
  71836. * Sets the shadow projection clipping minimum z value.
  71837. */
  71838. shadowMinZ: number;
  71839. private _shadowMaxZ;
  71840. /**
  71841. * Sets the shadow projection clipping maximum z value.
  71842. */
  71843. /**
  71844. * Gets the shadow projection clipping maximum z value.
  71845. */
  71846. shadowMaxZ: number;
  71847. /**
  71848. * Callback defining a custom Projection Matrix Builder.
  71849. * This can be used to override the default projection matrix computation.
  71850. */
  71851. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  71852. /**
  71853. * The transformed position. Position of the light in world space taking parenting in account.
  71854. */
  71855. transformedPosition: Vector3;
  71856. /**
  71857. * The transformed direction. Direction of the light in world space taking parenting in account.
  71858. */
  71859. transformedDirection: Vector3;
  71860. private _needProjectionMatrixCompute;
  71861. /**
  71862. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  71863. * @returns true if the information has been computed, false if it does not need to (no parenting)
  71864. */
  71865. computeTransformedInformation(): boolean;
  71866. /**
  71867. * Return the depth scale used for the shadow map.
  71868. * @returns the depth scale.
  71869. */
  71870. getDepthScale(): number;
  71871. /**
  71872. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  71873. * @param faceIndex The index of the face we are computed the direction to generate shadow
  71874. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  71875. */
  71876. getShadowDirection(faceIndex?: number): Vector3;
  71877. /**
  71878. * Returns the ShadowLight absolute position in the World.
  71879. * @returns the position vector in world space
  71880. */
  71881. getAbsolutePosition(): Vector3;
  71882. /**
  71883. * Sets the ShadowLight direction toward the passed target.
  71884. * @param target The point to target in local space
  71885. * @returns the updated ShadowLight direction
  71886. */
  71887. setDirectionToTarget(target: Vector3): Vector3;
  71888. /**
  71889. * Returns the light rotation in euler definition.
  71890. * @returns the x y z rotation in local space.
  71891. */
  71892. getRotation(): Vector3;
  71893. /**
  71894. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  71895. * @returns true if a cube texture needs to be use
  71896. */
  71897. needCube(): boolean;
  71898. /**
  71899. * Detects if the projection matrix requires to be recomputed this frame.
  71900. * @returns true if it requires to be recomputed otherwise, false.
  71901. */
  71902. needProjectionMatrixCompute(): boolean;
  71903. /**
  71904. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  71905. */
  71906. forceProjectionMatrixCompute(): void;
  71907. /** @hidden */
  71908. _initCache(): void;
  71909. /** @hidden */
  71910. _isSynchronized(): boolean;
  71911. /**
  71912. * Computes the world matrix of the node
  71913. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  71914. * @returns the world matrix
  71915. */
  71916. computeWorldMatrix(force?: boolean): Matrix;
  71917. /**
  71918. * Gets the minZ used for shadow according to both the scene and the light.
  71919. * @param activeCamera The camera we are returning the min for
  71920. * @returns the depth min z
  71921. */
  71922. getDepthMinZ(activeCamera: Camera): number;
  71923. /**
  71924. * Gets the maxZ used for shadow according to both the scene and the light.
  71925. * @param activeCamera The camera we are returning the max for
  71926. * @returns the depth max z
  71927. */
  71928. getDepthMaxZ(activeCamera: Camera): number;
  71929. /**
  71930. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  71931. * @param matrix The materix to updated with the projection information
  71932. * @param viewMatrix The transform matrix of the light
  71933. * @param renderList The list of mesh to render in the map
  71934. * @returns The current light
  71935. */
  71936. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  71937. }
  71938. }
  71939. declare module BABYLON {
  71940. /**
  71941. * "Static Class" containing the most commonly used helper while dealing with material for
  71942. * rendering purpose.
  71943. *
  71944. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  71945. *
  71946. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  71947. */
  71948. export class MaterialHelper {
  71949. /**
  71950. * Bind the current view position to an effect.
  71951. * @param effect The effect to be bound
  71952. * @param scene The scene the eyes position is used from
  71953. */
  71954. static BindEyePosition(effect: Effect, scene: Scene): void;
  71955. /**
  71956. * Helps preparing the defines values about the UVs in used in the effect.
  71957. * UVs are shared as much as we can accross channels in the shaders.
  71958. * @param texture The texture we are preparing the UVs for
  71959. * @param defines The defines to update
  71960. * @param key The channel key "diffuse", "specular"... used in the shader
  71961. */
  71962. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  71963. /**
  71964. * Binds a texture matrix value to its corrsponding uniform
  71965. * @param texture The texture to bind the matrix for
  71966. * @param uniformBuffer The uniform buffer receivin the data
  71967. * @param key The channel key "diffuse", "specular"... used in the shader
  71968. */
  71969. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  71970. /**
  71971. * Gets the current status of the fog (should it be enabled?)
  71972. * @param mesh defines the mesh to evaluate for fog support
  71973. * @param scene defines the hosting scene
  71974. * @returns true if fog must be enabled
  71975. */
  71976. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  71977. /**
  71978. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  71979. * @param mesh defines the current mesh
  71980. * @param scene defines the current scene
  71981. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  71982. * @param pointsCloud defines if point cloud rendering has to be turned on
  71983. * @param fogEnabled defines if fog has to be turned on
  71984. * @param alphaTest defines if alpha testing has to be turned on
  71985. * @param defines defines the current list of defines
  71986. */
  71987. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  71988. /**
  71989. * Helper used to prepare the list of defines associated with frame values for shader compilation
  71990. * @param scene defines the current scene
  71991. * @param engine defines the current engine
  71992. * @param defines specifies the list of active defines
  71993. * @param useInstances defines if instances have to be turned on
  71994. * @param useClipPlane defines if clip plane have to be turned on
  71995. */
  71996. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  71997. /**
  71998. * Prepares the defines for bones
  71999. * @param mesh The mesh containing the geometry data we will draw
  72000. * @param defines The defines to update
  72001. */
  72002. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  72003. /**
  72004. * Prepares the defines for morph targets
  72005. * @param mesh The mesh containing the geometry data we will draw
  72006. * @param defines The defines to update
  72007. */
  72008. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  72009. /**
  72010. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  72011. * @param mesh The mesh containing the geometry data we will draw
  72012. * @param defines The defines to update
  72013. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  72014. * @param useBones Precise whether bones should be used or not (override mesh info)
  72015. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  72016. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  72017. * @returns false if defines are considered not dirty and have not been checked
  72018. */
  72019. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  72020. /**
  72021. * Prepares the defines related to multiview
  72022. * @param scene The scene we are intending to draw
  72023. * @param defines The defines to update
  72024. */
  72025. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  72026. /**
  72027. * Prepares the defines related to the light information passed in parameter
  72028. * @param scene The scene we are intending to draw
  72029. * @param mesh The mesh the effect is compiling for
  72030. * @param light The light the effect is compiling for
  72031. * @param lightIndex The index of the light
  72032. * @param defines The defines to update
  72033. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  72034. * @param state Defines the current state regarding what is needed (normals, etc...)
  72035. */
  72036. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  72037. needNormals: boolean;
  72038. needRebuild: boolean;
  72039. shadowEnabled: boolean;
  72040. specularEnabled: boolean;
  72041. lightmapMode: boolean;
  72042. }): void;
  72043. /**
  72044. * Prepares the defines related to the light information passed in parameter
  72045. * @param scene The scene we are intending to draw
  72046. * @param mesh The mesh the effect is compiling for
  72047. * @param defines The defines to update
  72048. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  72049. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  72050. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  72051. * @returns true if normals will be required for the rest of the effect
  72052. */
  72053. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  72054. /**
  72055. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  72056. * @param lightIndex defines the light index
  72057. * @param uniformsList The uniform list
  72058. * @param samplersList The sampler list
  72059. * @param projectedLightTexture defines if projected texture must be used
  72060. * @param uniformBuffersList defines an optional list of uniform buffers
  72061. */
  72062. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  72063. /**
  72064. * Prepares the uniforms and samplers list to be used in the effect
  72065. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  72066. * @param samplersList The sampler list
  72067. * @param defines The defines helping in the list generation
  72068. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  72069. */
  72070. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  72071. /**
  72072. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  72073. * @param defines The defines to update while falling back
  72074. * @param fallbacks The authorized effect fallbacks
  72075. * @param maxSimultaneousLights The maximum number of lights allowed
  72076. * @param rank the current rank of the Effect
  72077. * @returns The newly affected rank
  72078. */
  72079. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  72080. private static _TmpMorphInfluencers;
  72081. /**
  72082. * Prepares the list of attributes required for morph targets according to the effect defines.
  72083. * @param attribs The current list of supported attribs
  72084. * @param mesh The mesh to prepare the morph targets attributes for
  72085. * @param influencers The number of influencers
  72086. */
  72087. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  72088. /**
  72089. * Prepares the list of attributes required for morph targets according to the effect defines.
  72090. * @param attribs The current list of supported attribs
  72091. * @param mesh The mesh to prepare the morph targets attributes for
  72092. * @param defines The current Defines of the effect
  72093. */
  72094. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  72095. /**
  72096. * Prepares the list of attributes required for bones according to the effect defines.
  72097. * @param attribs The current list of supported attribs
  72098. * @param mesh The mesh to prepare the bones attributes for
  72099. * @param defines The current Defines of the effect
  72100. * @param fallbacks The current efffect fallback strategy
  72101. */
  72102. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  72103. /**
  72104. * Check and prepare the list of attributes required for instances according to the effect defines.
  72105. * @param attribs The current list of supported attribs
  72106. * @param defines The current MaterialDefines of the effect
  72107. */
  72108. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  72109. /**
  72110. * Add the list of attributes required for instances to the attribs array.
  72111. * @param attribs The current list of supported attribs
  72112. */
  72113. static PushAttributesForInstances(attribs: string[]): void;
  72114. /**
  72115. * Binds the light shadow information to the effect for the given mesh.
  72116. * @param light The light containing the generator
  72117. * @param scene The scene the lights belongs to
  72118. * @param mesh The mesh we are binding the information to render
  72119. * @param lightIndex The light index in the effect used to render the mesh
  72120. * @param effect The effect we are binding the data to
  72121. */
  72122. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  72123. /**
  72124. * Binds the light information to the effect.
  72125. * @param light The light containing the generator
  72126. * @param effect The effect we are binding the data to
  72127. * @param lightIndex The light index in the effect used to render
  72128. */
  72129. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  72130. /**
  72131. * Binds the lights information from the scene to the effect for the given mesh.
  72132. * @param light Light to bind
  72133. * @param lightIndex Light index
  72134. * @param scene The scene where the light belongs to
  72135. * @param mesh The mesh we are binding the information to render
  72136. * @param effect The effect we are binding the data to
  72137. * @param useSpecular Defines if specular is supported
  72138. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  72139. */
  72140. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  72141. /**
  72142. * Binds the lights information from the scene to the effect for the given mesh.
  72143. * @param scene The scene the lights belongs to
  72144. * @param mesh The mesh we are binding the information to render
  72145. * @param effect The effect we are binding the data to
  72146. * @param defines The generated defines for the effect
  72147. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  72148. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  72149. */
  72150. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  72151. private static _tempFogColor;
  72152. /**
  72153. * Binds the fog information from the scene to the effect for the given mesh.
  72154. * @param scene The scene the lights belongs to
  72155. * @param mesh The mesh we are binding the information to render
  72156. * @param effect The effect we are binding the data to
  72157. * @param linearSpace Defines if the fog effect is applied in linear space
  72158. */
  72159. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  72160. /**
  72161. * Binds the bones information from the mesh to the effect.
  72162. * @param mesh The mesh we are binding the information to render
  72163. * @param effect The effect we are binding the data to
  72164. */
  72165. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  72166. /**
  72167. * Binds the morph targets information from the mesh to the effect.
  72168. * @param abstractMesh The mesh we are binding the information to render
  72169. * @param effect The effect we are binding the data to
  72170. */
  72171. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  72172. /**
  72173. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  72174. * @param defines The generated defines used in the effect
  72175. * @param effect The effect we are binding the data to
  72176. * @param scene The scene we are willing to render with logarithmic scale for
  72177. */
  72178. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  72179. /**
  72180. * Binds the clip plane information from the scene to the effect.
  72181. * @param scene The scene the clip plane information are extracted from
  72182. * @param effect The effect we are binding the data to
  72183. */
  72184. static BindClipPlane(effect: Effect, scene: Scene): void;
  72185. }
  72186. }
  72187. declare module BABYLON {
  72188. /** @hidden */
  72189. export var packingFunctions: {
  72190. name: string;
  72191. shader: string;
  72192. };
  72193. }
  72194. declare module BABYLON {
  72195. /** @hidden */
  72196. export var shadowMapPixelShader: {
  72197. name: string;
  72198. shader: string;
  72199. };
  72200. }
  72201. declare module BABYLON {
  72202. /** @hidden */
  72203. export var bonesDeclaration: {
  72204. name: string;
  72205. shader: string;
  72206. };
  72207. }
  72208. declare module BABYLON {
  72209. /** @hidden */
  72210. export var morphTargetsVertexGlobalDeclaration: {
  72211. name: string;
  72212. shader: string;
  72213. };
  72214. }
  72215. declare module BABYLON {
  72216. /** @hidden */
  72217. export var morphTargetsVertexDeclaration: {
  72218. name: string;
  72219. shader: string;
  72220. };
  72221. }
  72222. declare module BABYLON {
  72223. /** @hidden */
  72224. export var instancesDeclaration: {
  72225. name: string;
  72226. shader: string;
  72227. };
  72228. }
  72229. declare module BABYLON {
  72230. /** @hidden */
  72231. export var helperFunctions: {
  72232. name: string;
  72233. shader: string;
  72234. };
  72235. }
  72236. declare module BABYLON {
  72237. /** @hidden */
  72238. export var morphTargetsVertex: {
  72239. name: string;
  72240. shader: string;
  72241. };
  72242. }
  72243. declare module BABYLON {
  72244. /** @hidden */
  72245. export var instancesVertex: {
  72246. name: string;
  72247. shader: string;
  72248. };
  72249. }
  72250. declare module BABYLON {
  72251. /** @hidden */
  72252. export var bonesVertex: {
  72253. name: string;
  72254. shader: string;
  72255. };
  72256. }
  72257. declare module BABYLON {
  72258. /** @hidden */
  72259. export var shadowMapVertexShader: {
  72260. name: string;
  72261. shader: string;
  72262. };
  72263. }
  72264. declare module BABYLON {
  72265. /** @hidden */
  72266. export var depthBoxBlurPixelShader: {
  72267. name: string;
  72268. shader: string;
  72269. };
  72270. }
  72271. declare module BABYLON {
  72272. /**
  72273. * Defines the options associated with the creation of a custom shader for a shadow generator.
  72274. */
  72275. export interface ICustomShaderOptions {
  72276. /**
  72277. * Gets or sets the custom shader name to use
  72278. */
  72279. shaderName: string;
  72280. /**
  72281. * The list of attribute names used in the shader
  72282. */
  72283. attributes?: string[];
  72284. /**
  72285. * The list of unifrom names used in the shader
  72286. */
  72287. uniforms?: string[];
  72288. /**
  72289. * The list of sampler names used in the shader
  72290. */
  72291. samplers?: string[];
  72292. /**
  72293. * The list of defines used in the shader
  72294. */
  72295. defines?: string[];
  72296. }
  72297. /**
  72298. * Interface to implement to create a shadow generator compatible with BJS.
  72299. */
  72300. export interface IShadowGenerator {
  72301. /**
  72302. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  72303. * @returns The render target texture if present otherwise, null
  72304. */
  72305. getShadowMap(): Nullable<RenderTargetTexture>;
  72306. /**
  72307. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  72308. * @returns The render target texture if the shadow map is present otherwise, null
  72309. */
  72310. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  72311. /**
  72312. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  72313. * @param subMesh The submesh we want to render in the shadow map
  72314. * @param useInstances Defines wether will draw in the map using instances
  72315. * @returns true if ready otherwise, false
  72316. */
  72317. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72318. /**
  72319. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  72320. * @param defines Defines of the material we want to update
  72321. * @param lightIndex Index of the light in the enabled light list of the material
  72322. */
  72323. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  72324. /**
  72325. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  72326. * defined in the generator but impacting the effect).
  72327. * It implies the unifroms available on the materials are the standard BJS ones.
  72328. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  72329. * @param effect The effect we are binfing the information for
  72330. */
  72331. bindShadowLight(lightIndex: string, effect: Effect): void;
  72332. /**
  72333. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  72334. * (eq to shadow prjection matrix * light transform matrix)
  72335. * @returns The transform matrix used to create the shadow map
  72336. */
  72337. getTransformMatrix(): Matrix;
  72338. /**
  72339. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  72340. * Cube and 2D textures for instance.
  72341. */
  72342. recreateShadowMap(): void;
  72343. /**
  72344. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  72345. * @param onCompiled Callback triggered at the and of the effects compilation
  72346. * @param options Sets of optional options forcing the compilation with different modes
  72347. */
  72348. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  72349. useInstances: boolean;
  72350. }>): void;
  72351. /**
  72352. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  72353. * @param options Sets of optional options forcing the compilation with different modes
  72354. * @returns A promise that resolves when the compilation completes
  72355. */
  72356. forceCompilationAsync(options?: Partial<{
  72357. useInstances: boolean;
  72358. }>): Promise<void>;
  72359. /**
  72360. * Serializes the shadow generator setup to a json object.
  72361. * @returns The serialized JSON object
  72362. */
  72363. serialize(): any;
  72364. /**
  72365. * Disposes the Shadow map and related Textures and effects.
  72366. */
  72367. dispose(): void;
  72368. }
  72369. /**
  72370. * Default implementation IShadowGenerator.
  72371. * This is the main object responsible of generating shadows in the framework.
  72372. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  72373. */
  72374. export class ShadowGenerator implements IShadowGenerator {
  72375. /**
  72376. * Shadow generator mode None: no filtering applied.
  72377. */
  72378. static readonly FILTER_NONE: number;
  72379. /**
  72380. * Shadow generator mode ESM: Exponential Shadow Mapping.
  72381. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  72382. */
  72383. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  72384. /**
  72385. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  72386. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  72387. */
  72388. static readonly FILTER_POISSONSAMPLING: number;
  72389. /**
  72390. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  72391. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  72392. */
  72393. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  72394. /**
  72395. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  72396. * edge artifacts on steep falloff.
  72397. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  72398. */
  72399. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  72400. /**
  72401. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  72402. * edge artifacts on steep falloff.
  72403. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  72404. */
  72405. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  72406. /**
  72407. * Shadow generator mode PCF: Percentage Closer Filtering
  72408. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  72409. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  72410. */
  72411. static readonly FILTER_PCF: number;
  72412. /**
  72413. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  72414. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  72415. * Contact Hardening
  72416. */
  72417. static readonly FILTER_PCSS: number;
  72418. /**
  72419. * Reserved for PCF and PCSS
  72420. * Highest Quality.
  72421. *
  72422. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  72423. *
  72424. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  72425. */
  72426. static readonly QUALITY_HIGH: number;
  72427. /**
  72428. * Reserved for PCF and PCSS
  72429. * Good tradeoff for quality/perf cross devices
  72430. *
  72431. * Execute PCF on a 3*3 kernel.
  72432. *
  72433. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  72434. */
  72435. static readonly QUALITY_MEDIUM: number;
  72436. /**
  72437. * Reserved for PCF and PCSS
  72438. * The lowest quality but the fastest.
  72439. *
  72440. * Execute PCF on a 1*1 kernel.
  72441. *
  72442. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  72443. */
  72444. static readonly QUALITY_LOW: number;
  72445. /** Gets or sets the custom shader name to use */
  72446. customShaderOptions: ICustomShaderOptions;
  72447. /**
  72448. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  72449. */
  72450. onBeforeShadowMapRenderObservable: Observable<Effect>;
  72451. /**
  72452. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  72453. */
  72454. onAfterShadowMapRenderObservable: Observable<Effect>;
  72455. /**
  72456. * Observable triggered before a mesh is rendered in the shadow map.
  72457. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  72458. */
  72459. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  72460. /**
  72461. * Observable triggered after a mesh is rendered in the shadow map.
  72462. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  72463. */
  72464. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  72465. private _bias;
  72466. /**
  72467. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  72468. */
  72469. /**
  72470. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  72471. */
  72472. bias: number;
  72473. private _normalBias;
  72474. /**
  72475. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  72476. */
  72477. /**
  72478. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  72479. */
  72480. normalBias: number;
  72481. private _blurBoxOffset;
  72482. /**
  72483. * Gets the blur box offset: offset applied during the blur pass.
  72484. * Only useful if useKernelBlur = false
  72485. */
  72486. /**
  72487. * Sets the blur box offset: offset applied during the blur pass.
  72488. * Only useful if useKernelBlur = false
  72489. */
  72490. blurBoxOffset: number;
  72491. private _blurScale;
  72492. /**
  72493. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  72494. * 2 means half of the size.
  72495. */
  72496. /**
  72497. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  72498. * 2 means half of the size.
  72499. */
  72500. blurScale: number;
  72501. private _blurKernel;
  72502. /**
  72503. * Gets the blur kernel: kernel size of the blur pass.
  72504. * Only useful if useKernelBlur = true
  72505. */
  72506. /**
  72507. * Sets the blur kernel: kernel size of the blur pass.
  72508. * Only useful if useKernelBlur = true
  72509. */
  72510. blurKernel: number;
  72511. private _useKernelBlur;
  72512. /**
  72513. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  72514. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  72515. */
  72516. /**
  72517. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  72518. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  72519. */
  72520. useKernelBlur: boolean;
  72521. private _depthScale;
  72522. /**
  72523. * Gets the depth scale used in ESM mode.
  72524. */
  72525. /**
  72526. * Sets the depth scale used in ESM mode.
  72527. * This can override the scale stored on the light.
  72528. */
  72529. depthScale: number;
  72530. private _filter;
  72531. /**
  72532. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  72533. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  72534. */
  72535. /**
  72536. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  72537. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  72538. */
  72539. filter: number;
  72540. /**
  72541. * Gets if the current filter is set to Poisson Sampling.
  72542. */
  72543. /**
  72544. * Sets the current filter to Poisson Sampling.
  72545. */
  72546. usePoissonSampling: boolean;
  72547. /**
  72548. * Gets if the current filter is set to ESM.
  72549. */
  72550. /**
  72551. * Sets the current filter is to ESM.
  72552. */
  72553. useExponentialShadowMap: boolean;
  72554. /**
  72555. * Gets if the current filter is set to filtered ESM.
  72556. */
  72557. /**
  72558. * Gets if the current filter is set to filtered ESM.
  72559. */
  72560. useBlurExponentialShadowMap: boolean;
  72561. /**
  72562. * Gets if the current filter is set to "close ESM" (using the inverse of the
  72563. * exponential to prevent steep falloff artifacts).
  72564. */
  72565. /**
  72566. * Sets the current filter to "close ESM" (using the inverse of the
  72567. * exponential to prevent steep falloff artifacts).
  72568. */
  72569. useCloseExponentialShadowMap: boolean;
  72570. /**
  72571. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  72572. * exponential to prevent steep falloff artifacts).
  72573. */
  72574. /**
  72575. * Sets the current filter to filtered "close ESM" (using the inverse of the
  72576. * exponential to prevent steep falloff artifacts).
  72577. */
  72578. useBlurCloseExponentialShadowMap: boolean;
  72579. /**
  72580. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  72581. */
  72582. /**
  72583. * Sets the current filter to "PCF" (percentage closer filtering).
  72584. */
  72585. usePercentageCloserFiltering: boolean;
  72586. private _filteringQuality;
  72587. /**
  72588. * Gets the PCF or PCSS Quality.
  72589. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  72590. */
  72591. /**
  72592. * Sets the PCF or PCSS Quality.
  72593. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  72594. */
  72595. filteringQuality: number;
  72596. /**
  72597. * Gets if the current filter is set to "PCSS" (contact hardening).
  72598. */
  72599. /**
  72600. * Sets the current filter to "PCSS" (contact hardening).
  72601. */
  72602. useContactHardeningShadow: boolean;
  72603. private _contactHardeningLightSizeUVRatio;
  72604. /**
  72605. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  72606. * Using a ratio helps keeping shape stability independently of the map size.
  72607. *
  72608. * It does not account for the light projection as it was having too much
  72609. * instability during the light setup or during light position changes.
  72610. *
  72611. * Only valid if useContactHardeningShadow is true.
  72612. */
  72613. /**
  72614. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  72615. * Using a ratio helps keeping shape stability independently of the map size.
  72616. *
  72617. * It does not account for the light projection as it was having too much
  72618. * instability during the light setup or during light position changes.
  72619. *
  72620. * Only valid if useContactHardeningShadow is true.
  72621. */
  72622. contactHardeningLightSizeUVRatio: number;
  72623. private _darkness;
  72624. /** Gets or sets the actual darkness of a shadow */
  72625. darkness: number;
  72626. /**
  72627. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  72628. * 0 means strongest and 1 would means no shadow.
  72629. * @returns the darkness.
  72630. */
  72631. getDarkness(): number;
  72632. /**
  72633. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  72634. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  72635. * @returns the shadow generator allowing fluent coding.
  72636. */
  72637. setDarkness(darkness: number): ShadowGenerator;
  72638. private _transparencyShadow;
  72639. /** Gets or sets the ability to have transparent shadow */
  72640. transparencyShadow: boolean;
  72641. /**
  72642. * Sets the ability to have transparent shadow (boolean).
  72643. * @param transparent True if transparent else False
  72644. * @returns the shadow generator allowing fluent coding
  72645. */
  72646. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  72647. private _shadowMap;
  72648. private _shadowMap2;
  72649. /**
  72650. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  72651. * @returns The render target texture if present otherwise, null
  72652. */
  72653. getShadowMap(): Nullable<RenderTargetTexture>;
  72654. /**
  72655. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  72656. * @returns The render target texture if the shadow map is present otherwise, null
  72657. */
  72658. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  72659. /**
  72660. * Gets the class name of that object
  72661. * @returns "ShadowGenerator"
  72662. */
  72663. getClassName(): string;
  72664. /**
  72665. * Helper function to add a mesh and its descendants to the list of shadow casters.
  72666. * @param mesh Mesh to add
  72667. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  72668. * @returns the Shadow Generator itself
  72669. */
  72670. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  72671. /**
  72672. * Helper function to remove a mesh and its descendants from the list of shadow casters
  72673. * @param mesh Mesh to remove
  72674. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  72675. * @returns the Shadow Generator itself
  72676. */
  72677. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  72678. /**
  72679. * Controls the extent to which the shadows fade out at the edge of the frustum
  72680. * Used only by directionals and spots
  72681. */
  72682. frustumEdgeFalloff: number;
  72683. private _light;
  72684. /**
  72685. * Returns the associated light object.
  72686. * @returns the light generating the shadow
  72687. */
  72688. getLight(): IShadowLight;
  72689. /**
  72690. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  72691. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  72692. * It might on the other hand introduce peter panning.
  72693. */
  72694. forceBackFacesOnly: boolean;
  72695. private _scene;
  72696. private _lightDirection;
  72697. private _effect;
  72698. private _viewMatrix;
  72699. private _projectionMatrix;
  72700. private _transformMatrix;
  72701. private _cachedPosition;
  72702. private _cachedDirection;
  72703. private _cachedDefines;
  72704. private _currentRenderID;
  72705. private _boxBlurPostprocess;
  72706. private _kernelBlurXPostprocess;
  72707. private _kernelBlurYPostprocess;
  72708. private _blurPostProcesses;
  72709. private _mapSize;
  72710. private _currentFaceIndex;
  72711. private _currentFaceIndexCache;
  72712. private _textureType;
  72713. private _defaultTextureMatrix;
  72714. /** @hidden */
  72715. static _SceneComponentInitialization: (scene: Scene) => void;
  72716. /**
  72717. * Creates a ShadowGenerator object.
  72718. * A ShadowGenerator is the required tool to use the shadows.
  72719. * Each light casting shadows needs to use its own ShadowGenerator.
  72720. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  72721. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  72722. * @param light The light object generating the shadows.
  72723. * @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.
  72724. */
  72725. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  72726. private _initializeGenerator;
  72727. private _initializeShadowMap;
  72728. private _initializeBlurRTTAndPostProcesses;
  72729. private _renderForShadowMap;
  72730. private _renderSubMeshForShadowMap;
  72731. private _applyFilterValues;
  72732. /**
  72733. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  72734. * @param onCompiled Callback triggered at the and of the effects compilation
  72735. * @param options Sets of optional options forcing the compilation with different modes
  72736. */
  72737. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  72738. useInstances: boolean;
  72739. }>): void;
  72740. /**
  72741. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  72742. * @param options Sets of optional options forcing the compilation with different modes
  72743. * @returns A promise that resolves when the compilation completes
  72744. */
  72745. forceCompilationAsync(options?: Partial<{
  72746. useInstances: boolean;
  72747. }>): Promise<void>;
  72748. /**
  72749. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  72750. * @param subMesh The submesh we want to render in the shadow map
  72751. * @param useInstances Defines wether will draw in the map using instances
  72752. * @returns true if ready otherwise, false
  72753. */
  72754. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72755. /**
  72756. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  72757. * @param defines Defines of the material we want to update
  72758. * @param lightIndex Index of the light in the enabled light list of the material
  72759. */
  72760. prepareDefines(defines: any, lightIndex: number): void;
  72761. /**
  72762. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  72763. * defined in the generator but impacting the effect).
  72764. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  72765. * @param effect The effect we are binfing the information for
  72766. */
  72767. bindShadowLight(lightIndex: string, effect: Effect): void;
  72768. /**
  72769. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  72770. * (eq to shadow prjection matrix * light transform matrix)
  72771. * @returns The transform matrix used to create the shadow map
  72772. */
  72773. getTransformMatrix(): Matrix;
  72774. /**
  72775. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  72776. * Cube and 2D textures for instance.
  72777. */
  72778. recreateShadowMap(): void;
  72779. private _disposeBlurPostProcesses;
  72780. private _disposeRTTandPostProcesses;
  72781. /**
  72782. * Disposes the ShadowGenerator.
  72783. * Returns nothing.
  72784. */
  72785. dispose(): void;
  72786. /**
  72787. * Serializes the shadow generator setup to a json object.
  72788. * @returns The serialized JSON object
  72789. */
  72790. serialize(): any;
  72791. /**
  72792. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  72793. * @param parsedShadowGenerator The JSON object to parse
  72794. * @param scene The scene to create the shadow map for
  72795. * @returns The parsed shadow generator
  72796. */
  72797. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  72798. }
  72799. }
  72800. declare module BABYLON {
  72801. /**
  72802. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  72803. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  72804. * 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.
  72805. */
  72806. export abstract class Light extends Node {
  72807. /**
  72808. * Falloff Default: light is falling off following the material specification:
  72809. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  72810. */
  72811. static readonly FALLOFF_DEFAULT: number;
  72812. /**
  72813. * Falloff Physical: light is falling off following the inverse squared distance law.
  72814. */
  72815. static readonly FALLOFF_PHYSICAL: number;
  72816. /**
  72817. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  72818. * to enhance interoperability with other engines.
  72819. */
  72820. static readonly FALLOFF_GLTF: number;
  72821. /**
  72822. * Falloff Standard: light is falling off like in the standard material
  72823. * to enhance interoperability with other materials.
  72824. */
  72825. static readonly FALLOFF_STANDARD: number;
  72826. /**
  72827. * If every light affecting the material is in this lightmapMode,
  72828. * material.lightmapTexture adds or multiplies
  72829. * (depends on material.useLightmapAsShadowmap)
  72830. * after every other light calculations.
  72831. */
  72832. static readonly LIGHTMAP_DEFAULT: number;
  72833. /**
  72834. * material.lightmapTexture as only diffuse lighting from this light
  72835. * adds only specular lighting from this light
  72836. * adds dynamic shadows
  72837. */
  72838. static readonly LIGHTMAP_SPECULAR: number;
  72839. /**
  72840. * material.lightmapTexture as only lighting
  72841. * no light calculation from this light
  72842. * only adds dynamic shadows from this light
  72843. */
  72844. static readonly LIGHTMAP_SHADOWSONLY: number;
  72845. /**
  72846. * Each light type uses the default quantity according to its type:
  72847. * point/spot lights use luminous intensity
  72848. * directional lights use illuminance
  72849. */
  72850. static readonly INTENSITYMODE_AUTOMATIC: number;
  72851. /**
  72852. * lumen (lm)
  72853. */
  72854. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  72855. /**
  72856. * candela (lm/sr)
  72857. */
  72858. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  72859. /**
  72860. * lux (lm/m^2)
  72861. */
  72862. static readonly INTENSITYMODE_ILLUMINANCE: number;
  72863. /**
  72864. * nit (cd/m^2)
  72865. */
  72866. static readonly INTENSITYMODE_LUMINANCE: number;
  72867. /**
  72868. * Light type const id of the point light.
  72869. */
  72870. static readonly LIGHTTYPEID_POINTLIGHT: number;
  72871. /**
  72872. * Light type const id of the directional light.
  72873. */
  72874. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  72875. /**
  72876. * Light type const id of the spot light.
  72877. */
  72878. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  72879. /**
  72880. * Light type const id of the hemispheric light.
  72881. */
  72882. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  72883. /**
  72884. * Diffuse gives the basic color to an object.
  72885. */
  72886. diffuse: Color3;
  72887. /**
  72888. * Specular produces a highlight color on an object.
  72889. * Note: This is note affecting PBR materials.
  72890. */
  72891. specular: Color3;
  72892. /**
  72893. * Defines the falloff type for this light. This lets overrriding how punctual light are
  72894. * falling off base on range or angle.
  72895. * This can be set to any values in Light.FALLOFF_x.
  72896. *
  72897. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  72898. * other types of materials.
  72899. */
  72900. falloffType: number;
  72901. /**
  72902. * Strength of the light.
  72903. * Note: By default it is define in the framework own unit.
  72904. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  72905. */
  72906. intensity: number;
  72907. private _range;
  72908. protected _inverseSquaredRange: number;
  72909. /**
  72910. * Defines how far from the source the light is impacting in scene units.
  72911. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  72912. */
  72913. /**
  72914. * Defines how far from the source the light is impacting in scene units.
  72915. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  72916. */
  72917. range: number;
  72918. /**
  72919. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  72920. * of light.
  72921. */
  72922. private _photometricScale;
  72923. private _intensityMode;
  72924. /**
  72925. * Gets the photometric scale used to interpret the intensity.
  72926. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  72927. */
  72928. /**
  72929. * Sets the photometric scale used to interpret the intensity.
  72930. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  72931. */
  72932. intensityMode: number;
  72933. private _radius;
  72934. /**
  72935. * Gets the light radius used by PBR Materials to simulate soft area lights.
  72936. */
  72937. /**
  72938. * sets the light radius used by PBR Materials to simulate soft area lights.
  72939. */
  72940. radius: number;
  72941. private _renderPriority;
  72942. /**
  72943. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  72944. * exceeding the number allowed of the materials.
  72945. */
  72946. renderPriority: number;
  72947. private _shadowEnabled;
  72948. /**
  72949. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  72950. * the current shadow generator.
  72951. */
  72952. /**
  72953. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  72954. * the current shadow generator.
  72955. */
  72956. shadowEnabled: boolean;
  72957. private _includedOnlyMeshes;
  72958. /**
  72959. * Gets the only meshes impacted by this light.
  72960. */
  72961. /**
  72962. * Sets the only meshes impacted by this light.
  72963. */
  72964. includedOnlyMeshes: AbstractMesh[];
  72965. private _excludedMeshes;
  72966. /**
  72967. * Gets the meshes not impacted by this light.
  72968. */
  72969. /**
  72970. * Sets the meshes not impacted by this light.
  72971. */
  72972. excludedMeshes: AbstractMesh[];
  72973. private _excludeWithLayerMask;
  72974. /**
  72975. * Gets the layer id use to find what meshes are not impacted by the light.
  72976. * Inactive if 0
  72977. */
  72978. /**
  72979. * Sets the layer id use to find what meshes are not impacted by the light.
  72980. * Inactive if 0
  72981. */
  72982. excludeWithLayerMask: number;
  72983. private _includeOnlyWithLayerMask;
  72984. /**
  72985. * Gets the layer id use to find what meshes are impacted by the light.
  72986. * Inactive if 0
  72987. */
  72988. /**
  72989. * Sets the layer id use to find what meshes are impacted by the light.
  72990. * Inactive if 0
  72991. */
  72992. includeOnlyWithLayerMask: number;
  72993. private _lightmapMode;
  72994. /**
  72995. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  72996. */
  72997. /**
  72998. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  72999. */
  73000. lightmapMode: number;
  73001. /**
  73002. * Shadow generator associted to the light.
  73003. * @hidden Internal use only.
  73004. */
  73005. _shadowGenerator: Nullable<IShadowGenerator>;
  73006. /**
  73007. * @hidden Internal use only.
  73008. */
  73009. _excludedMeshesIds: string[];
  73010. /**
  73011. * @hidden Internal use only.
  73012. */
  73013. _includedOnlyMeshesIds: string[];
  73014. /**
  73015. * The current light unifom buffer.
  73016. * @hidden Internal use only.
  73017. */
  73018. _uniformBuffer: UniformBuffer;
  73019. /**
  73020. * Creates a Light object in the scene.
  73021. * Documentation : https://doc.babylonjs.com/babylon101/lights
  73022. * @param name The firendly name of the light
  73023. * @param scene The scene the light belongs too
  73024. */
  73025. constructor(name: string, scene: Scene);
  73026. protected abstract _buildUniformLayout(): void;
  73027. /**
  73028. * Sets the passed Effect "effect" with the Light information.
  73029. * @param effect The effect to update
  73030. * @param lightIndex The index of the light in the effect to update
  73031. * @returns The light
  73032. */
  73033. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  73034. /**
  73035. * Returns the string "Light".
  73036. * @returns the class name
  73037. */
  73038. getClassName(): string;
  73039. /** @hidden */
  73040. readonly _isLight: boolean;
  73041. /**
  73042. * Converts the light information to a readable string for debug purpose.
  73043. * @param fullDetails Supports for multiple levels of logging within scene loading
  73044. * @returns the human readable light info
  73045. */
  73046. toString(fullDetails?: boolean): string;
  73047. /** @hidden */
  73048. protected _syncParentEnabledState(): void;
  73049. /**
  73050. * Set the enabled state of this node.
  73051. * @param value - the new enabled state
  73052. */
  73053. setEnabled(value: boolean): void;
  73054. /**
  73055. * Returns the Light associated shadow generator if any.
  73056. * @return the associated shadow generator.
  73057. */
  73058. getShadowGenerator(): Nullable<IShadowGenerator>;
  73059. /**
  73060. * Returns a Vector3, the absolute light position in the World.
  73061. * @returns the world space position of the light
  73062. */
  73063. getAbsolutePosition(): Vector3;
  73064. /**
  73065. * Specifies if the light will affect the passed mesh.
  73066. * @param mesh The mesh to test against the light
  73067. * @return true the mesh is affected otherwise, false.
  73068. */
  73069. canAffectMesh(mesh: AbstractMesh): boolean;
  73070. /**
  73071. * Sort function to order lights for rendering.
  73072. * @param a First Light object to compare to second.
  73073. * @param b Second Light object to compare first.
  73074. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  73075. */
  73076. static CompareLightsPriority(a: Light, b: Light): number;
  73077. /**
  73078. * Releases resources associated with this node.
  73079. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  73080. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  73081. */
  73082. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  73083. /**
  73084. * Returns the light type ID (integer).
  73085. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  73086. */
  73087. getTypeID(): number;
  73088. /**
  73089. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  73090. * @returns the scaled intensity in intensity mode unit
  73091. */
  73092. getScaledIntensity(): number;
  73093. /**
  73094. * Returns a new Light object, named "name", from the current one.
  73095. * @param name The name of the cloned light
  73096. * @returns the new created light
  73097. */
  73098. clone(name: string): Nullable<Light>;
  73099. /**
  73100. * Serializes the current light into a Serialization object.
  73101. * @returns the serialized object.
  73102. */
  73103. serialize(): any;
  73104. /**
  73105. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  73106. * This new light is named "name" and added to the passed scene.
  73107. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  73108. * @param name The friendly name of the light
  73109. * @param scene The scene the new light will belong to
  73110. * @returns the constructor function
  73111. */
  73112. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  73113. /**
  73114. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  73115. * @param parsedLight The JSON representation of the light
  73116. * @param scene The scene to create the parsed light in
  73117. * @returns the created light after parsing
  73118. */
  73119. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  73120. private _hookArrayForExcluded;
  73121. private _hookArrayForIncludedOnly;
  73122. private _resyncMeshes;
  73123. /**
  73124. * Forces the meshes to update their light related information in their rendering used effects
  73125. * @hidden Internal Use Only
  73126. */
  73127. _markMeshesAsLightDirty(): void;
  73128. /**
  73129. * Recomputes the cached photometric scale if needed.
  73130. */
  73131. private _computePhotometricScale;
  73132. /**
  73133. * Returns the Photometric Scale according to the light type and intensity mode.
  73134. */
  73135. private _getPhotometricScale;
  73136. /**
  73137. * Reorder the light in the scene according to their defined priority.
  73138. * @hidden Internal Use Only
  73139. */
  73140. _reorderLightsInScene(): void;
  73141. /**
  73142. * Prepares the list of defines specific to the light type.
  73143. * @param defines the list of defines
  73144. * @param lightIndex defines the index of the light for the effect
  73145. */
  73146. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  73147. }
  73148. }
  73149. declare module BABYLON {
  73150. /**
  73151. * Interface used to define Action
  73152. */
  73153. export interface IAction {
  73154. /**
  73155. * Trigger for the action
  73156. */
  73157. trigger: number;
  73158. /** Options of the trigger */
  73159. triggerOptions: any;
  73160. /**
  73161. * Gets the trigger parameters
  73162. * @returns the trigger parameters
  73163. */
  73164. getTriggerParameter(): any;
  73165. /**
  73166. * Internal only - executes current action event
  73167. * @hidden
  73168. */
  73169. _executeCurrent(evt?: ActionEvent): void;
  73170. /**
  73171. * Serialize placeholder for child classes
  73172. * @param parent of child
  73173. * @returns the serialized object
  73174. */
  73175. serialize(parent: any): any;
  73176. /**
  73177. * Internal only
  73178. * @hidden
  73179. */
  73180. _prepare(): void;
  73181. /**
  73182. * Internal only - manager for action
  73183. * @hidden
  73184. */
  73185. _actionManager: AbstractActionManager;
  73186. /**
  73187. * Adds action to chain of actions, may be a DoNothingAction
  73188. * @param action defines the next action to execute
  73189. * @returns The action passed in
  73190. * @see https://www.babylonjs-playground.com/#1T30HR#0
  73191. */
  73192. then(action: IAction): IAction;
  73193. }
  73194. /**
  73195. * The action to be carried out following a trigger
  73196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  73197. */
  73198. export class Action implements IAction {
  73199. /** the trigger, with or without parameters, for the action */
  73200. triggerOptions: any;
  73201. /**
  73202. * Trigger for the action
  73203. */
  73204. trigger: number;
  73205. /**
  73206. * Internal only - manager for action
  73207. * @hidden
  73208. */
  73209. _actionManager: ActionManager;
  73210. private _nextActiveAction;
  73211. private _child;
  73212. private _condition?;
  73213. private _triggerParameter;
  73214. /**
  73215. * An event triggered prior to action being executed.
  73216. */
  73217. onBeforeExecuteObservable: Observable<Action>;
  73218. /**
  73219. * Creates a new Action
  73220. * @param triggerOptions the trigger, with or without parameters, for the action
  73221. * @param condition an optional determinant of action
  73222. */
  73223. constructor(
  73224. /** the trigger, with or without parameters, for the action */
  73225. triggerOptions: any, condition?: Condition);
  73226. /**
  73227. * Internal only
  73228. * @hidden
  73229. */
  73230. _prepare(): void;
  73231. /**
  73232. * Gets the trigger parameters
  73233. * @returns the trigger parameters
  73234. */
  73235. getTriggerParameter(): any;
  73236. /**
  73237. * Internal only - executes current action event
  73238. * @hidden
  73239. */
  73240. _executeCurrent(evt?: ActionEvent): void;
  73241. /**
  73242. * Execute placeholder for child classes
  73243. * @param evt optional action event
  73244. */
  73245. execute(evt?: ActionEvent): void;
  73246. /**
  73247. * Skips to next active action
  73248. */
  73249. skipToNextActiveAction(): void;
  73250. /**
  73251. * Adds action to chain of actions, may be a DoNothingAction
  73252. * @param action defines the next action to execute
  73253. * @returns The action passed in
  73254. * @see https://www.babylonjs-playground.com/#1T30HR#0
  73255. */
  73256. then(action: Action): Action;
  73257. /**
  73258. * Internal only
  73259. * @hidden
  73260. */
  73261. _getProperty(propertyPath: string): string;
  73262. /**
  73263. * Internal only
  73264. * @hidden
  73265. */
  73266. _getEffectiveTarget(target: any, propertyPath: string): any;
  73267. /**
  73268. * Serialize placeholder for child classes
  73269. * @param parent of child
  73270. * @returns the serialized object
  73271. */
  73272. serialize(parent: any): any;
  73273. /**
  73274. * Internal only called by serialize
  73275. * @hidden
  73276. */
  73277. protected _serialize(serializedAction: any, parent?: any): any;
  73278. /**
  73279. * Internal only
  73280. * @hidden
  73281. */
  73282. static _SerializeValueAsString: (value: any) => string;
  73283. /**
  73284. * Internal only
  73285. * @hidden
  73286. */
  73287. static _GetTargetProperty: (target: Node | Scene) => {
  73288. name: string;
  73289. targetType: string;
  73290. value: string;
  73291. };
  73292. }
  73293. }
  73294. declare module BABYLON {
  73295. /**
  73296. * A Condition applied to an Action
  73297. */
  73298. export class Condition {
  73299. /**
  73300. * Internal only - manager for action
  73301. * @hidden
  73302. */
  73303. _actionManager: ActionManager;
  73304. /**
  73305. * Internal only
  73306. * @hidden
  73307. */
  73308. _evaluationId: number;
  73309. /**
  73310. * Internal only
  73311. * @hidden
  73312. */
  73313. _currentResult: boolean;
  73314. /**
  73315. * Creates a new Condition
  73316. * @param actionManager the manager of the action the condition is applied to
  73317. */
  73318. constructor(actionManager: ActionManager);
  73319. /**
  73320. * Check if the current condition is valid
  73321. * @returns a boolean
  73322. */
  73323. isValid(): boolean;
  73324. /**
  73325. * Internal only
  73326. * @hidden
  73327. */
  73328. _getProperty(propertyPath: string): string;
  73329. /**
  73330. * Internal only
  73331. * @hidden
  73332. */
  73333. _getEffectiveTarget(target: any, propertyPath: string): any;
  73334. /**
  73335. * Serialize placeholder for child classes
  73336. * @returns the serialized object
  73337. */
  73338. serialize(): any;
  73339. /**
  73340. * Internal only
  73341. * @hidden
  73342. */
  73343. protected _serialize(serializedCondition: any): any;
  73344. }
  73345. /**
  73346. * Defines specific conditional operators as extensions of Condition
  73347. */
  73348. export class ValueCondition extends Condition {
  73349. /** path to specify the property of the target the conditional operator uses */
  73350. propertyPath: string;
  73351. /** the value compared by the conditional operator against the current value of the property */
  73352. value: any;
  73353. /** the conditional operator, default ValueCondition.IsEqual */
  73354. operator: number;
  73355. /**
  73356. * Internal only
  73357. * @hidden
  73358. */
  73359. private static _IsEqual;
  73360. /**
  73361. * Internal only
  73362. * @hidden
  73363. */
  73364. private static _IsDifferent;
  73365. /**
  73366. * Internal only
  73367. * @hidden
  73368. */
  73369. private static _IsGreater;
  73370. /**
  73371. * Internal only
  73372. * @hidden
  73373. */
  73374. private static _IsLesser;
  73375. /**
  73376. * returns the number for IsEqual
  73377. */
  73378. static readonly IsEqual: number;
  73379. /**
  73380. * Returns the number for IsDifferent
  73381. */
  73382. static readonly IsDifferent: number;
  73383. /**
  73384. * Returns the number for IsGreater
  73385. */
  73386. static readonly IsGreater: number;
  73387. /**
  73388. * Returns the number for IsLesser
  73389. */
  73390. static readonly IsLesser: number;
  73391. /**
  73392. * Internal only The action manager for the condition
  73393. * @hidden
  73394. */
  73395. _actionManager: ActionManager;
  73396. /**
  73397. * Internal only
  73398. * @hidden
  73399. */
  73400. private _target;
  73401. /**
  73402. * Internal only
  73403. * @hidden
  73404. */
  73405. private _effectiveTarget;
  73406. /**
  73407. * Internal only
  73408. * @hidden
  73409. */
  73410. private _property;
  73411. /**
  73412. * Creates a new ValueCondition
  73413. * @param actionManager manager for the action the condition applies to
  73414. * @param target for the action
  73415. * @param propertyPath path to specify the property of the target the conditional operator uses
  73416. * @param value the value compared by the conditional operator against the current value of the property
  73417. * @param operator the conditional operator, default ValueCondition.IsEqual
  73418. */
  73419. constructor(actionManager: ActionManager, target: any,
  73420. /** path to specify the property of the target the conditional operator uses */
  73421. propertyPath: string,
  73422. /** the value compared by the conditional operator against the current value of the property */
  73423. value: any,
  73424. /** the conditional operator, default ValueCondition.IsEqual */
  73425. operator?: number);
  73426. /**
  73427. * Compares the given value with the property value for the specified conditional operator
  73428. * @returns the result of the comparison
  73429. */
  73430. isValid(): boolean;
  73431. /**
  73432. * Serialize the ValueCondition into a JSON compatible object
  73433. * @returns serialization object
  73434. */
  73435. serialize(): any;
  73436. /**
  73437. * Gets the name of the conditional operator for the ValueCondition
  73438. * @param operator the conditional operator
  73439. * @returns the name
  73440. */
  73441. static GetOperatorName(operator: number): string;
  73442. }
  73443. /**
  73444. * Defines a predicate condition as an extension of Condition
  73445. */
  73446. export class PredicateCondition extends Condition {
  73447. /** defines the predicate function used to validate the condition */
  73448. predicate: () => boolean;
  73449. /**
  73450. * Internal only - manager for action
  73451. * @hidden
  73452. */
  73453. _actionManager: ActionManager;
  73454. /**
  73455. * Creates a new PredicateCondition
  73456. * @param actionManager manager for the action the condition applies to
  73457. * @param predicate defines the predicate function used to validate the condition
  73458. */
  73459. constructor(actionManager: ActionManager,
  73460. /** defines the predicate function used to validate the condition */
  73461. predicate: () => boolean);
  73462. /**
  73463. * @returns the validity of the predicate condition
  73464. */
  73465. isValid(): boolean;
  73466. }
  73467. /**
  73468. * Defines a state condition as an extension of Condition
  73469. */
  73470. export class StateCondition extends Condition {
  73471. /** Value to compare with target state */
  73472. value: string;
  73473. /**
  73474. * Internal only - manager for action
  73475. * @hidden
  73476. */
  73477. _actionManager: ActionManager;
  73478. /**
  73479. * Internal only
  73480. * @hidden
  73481. */
  73482. private _target;
  73483. /**
  73484. * Creates a new StateCondition
  73485. * @param actionManager manager for the action the condition applies to
  73486. * @param target of the condition
  73487. * @param value to compare with target state
  73488. */
  73489. constructor(actionManager: ActionManager, target: any,
  73490. /** Value to compare with target state */
  73491. value: string);
  73492. /**
  73493. * Gets a boolean indicating if the current condition is met
  73494. * @returns the validity of the state
  73495. */
  73496. isValid(): boolean;
  73497. /**
  73498. * Serialize the StateCondition into a JSON compatible object
  73499. * @returns serialization object
  73500. */
  73501. serialize(): any;
  73502. }
  73503. }
  73504. declare module BABYLON {
  73505. /**
  73506. * This defines an action responsible to toggle a boolean once triggered.
  73507. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73508. */
  73509. export class SwitchBooleanAction extends Action {
  73510. /**
  73511. * The path to the boolean property in the target object
  73512. */
  73513. propertyPath: string;
  73514. private _target;
  73515. private _effectiveTarget;
  73516. private _property;
  73517. /**
  73518. * Instantiate the action
  73519. * @param triggerOptions defines the trigger options
  73520. * @param target defines the object containing the boolean
  73521. * @param propertyPath defines the path to the boolean property in the target object
  73522. * @param condition defines the trigger related conditions
  73523. */
  73524. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  73525. /** @hidden */
  73526. _prepare(): void;
  73527. /**
  73528. * Execute the action toggle the boolean value.
  73529. */
  73530. execute(): void;
  73531. /**
  73532. * Serializes the actions and its related information.
  73533. * @param parent defines the object to serialize in
  73534. * @returns the serialized object
  73535. */
  73536. serialize(parent: any): any;
  73537. }
  73538. /**
  73539. * This defines an action responsible to set a the state field of the target
  73540. * to a desired value once triggered.
  73541. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73542. */
  73543. export class SetStateAction extends Action {
  73544. /**
  73545. * The value to store in the state field.
  73546. */
  73547. value: string;
  73548. private _target;
  73549. /**
  73550. * Instantiate the action
  73551. * @param triggerOptions defines the trigger options
  73552. * @param target defines the object containing the state property
  73553. * @param value defines the value to store in the state field
  73554. * @param condition defines the trigger related conditions
  73555. */
  73556. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  73557. /**
  73558. * Execute the action and store the value on the target state property.
  73559. */
  73560. execute(): void;
  73561. /**
  73562. * Serializes the actions and its related information.
  73563. * @param parent defines the object to serialize in
  73564. * @returns the serialized object
  73565. */
  73566. serialize(parent: any): any;
  73567. }
  73568. /**
  73569. * This defines an action responsible to set a property of the target
  73570. * to a desired value once triggered.
  73571. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73572. */
  73573. export class SetValueAction extends Action {
  73574. /**
  73575. * The path of the property to set in the target.
  73576. */
  73577. propertyPath: string;
  73578. /**
  73579. * The value to set in the property
  73580. */
  73581. value: any;
  73582. private _target;
  73583. private _effectiveTarget;
  73584. private _property;
  73585. /**
  73586. * Instantiate the action
  73587. * @param triggerOptions defines the trigger options
  73588. * @param target defines the object containing the property
  73589. * @param propertyPath defines the path of the property to set in the target
  73590. * @param value defines the value to set in the property
  73591. * @param condition defines the trigger related conditions
  73592. */
  73593. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  73594. /** @hidden */
  73595. _prepare(): void;
  73596. /**
  73597. * Execute the action and set the targetted property to the desired value.
  73598. */
  73599. execute(): void;
  73600. /**
  73601. * Serializes the actions and its related information.
  73602. * @param parent defines the object to serialize in
  73603. * @returns the serialized object
  73604. */
  73605. serialize(parent: any): any;
  73606. }
  73607. /**
  73608. * This defines an action responsible to increment the target value
  73609. * to a desired value once triggered.
  73610. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73611. */
  73612. export class IncrementValueAction extends Action {
  73613. /**
  73614. * The path of the property to increment in the target.
  73615. */
  73616. propertyPath: string;
  73617. /**
  73618. * The value we should increment the property by.
  73619. */
  73620. value: any;
  73621. private _target;
  73622. private _effectiveTarget;
  73623. private _property;
  73624. /**
  73625. * Instantiate the action
  73626. * @param triggerOptions defines the trigger options
  73627. * @param target defines the object containing the property
  73628. * @param propertyPath defines the path of the property to increment in the target
  73629. * @param value defines the value value we should increment the property by
  73630. * @param condition defines the trigger related conditions
  73631. */
  73632. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  73633. /** @hidden */
  73634. _prepare(): void;
  73635. /**
  73636. * Execute the action and increment the target of the value amount.
  73637. */
  73638. execute(): void;
  73639. /**
  73640. * Serializes the actions and its related information.
  73641. * @param parent defines the object to serialize in
  73642. * @returns the serialized object
  73643. */
  73644. serialize(parent: any): any;
  73645. }
  73646. /**
  73647. * This defines an action responsible to start an animation once triggered.
  73648. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73649. */
  73650. export class PlayAnimationAction extends Action {
  73651. /**
  73652. * Where the animation should start (animation frame)
  73653. */
  73654. from: number;
  73655. /**
  73656. * Where the animation should stop (animation frame)
  73657. */
  73658. to: number;
  73659. /**
  73660. * Define if the animation should loop or stop after the first play.
  73661. */
  73662. loop?: boolean;
  73663. private _target;
  73664. /**
  73665. * Instantiate the action
  73666. * @param triggerOptions defines the trigger options
  73667. * @param target defines the target animation or animation name
  73668. * @param from defines from where the animation should start (animation frame)
  73669. * @param end defines where the animation should stop (animation frame)
  73670. * @param loop defines if the animation should loop or stop after the first play
  73671. * @param condition defines the trigger related conditions
  73672. */
  73673. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  73674. /** @hidden */
  73675. _prepare(): void;
  73676. /**
  73677. * Execute the action and play the animation.
  73678. */
  73679. execute(): void;
  73680. /**
  73681. * Serializes the actions and its related information.
  73682. * @param parent defines the object to serialize in
  73683. * @returns the serialized object
  73684. */
  73685. serialize(parent: any): any;
  73686. }
  73687. /**
  73688. * This defines an action responsible to stop an animation once triggered.
  73689. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73690. */
  73691. export class StopAnimationAction extends Action {
  73692. private _target;
  73693. /**
  73694. * Instantiate the action
  73695. * @param triggerOptions defines the trigger options
  73696. * @param target defines the target animation or animation name
  73697. * @param condition defines the trigger related conditions
  73698. */
  73699. constructor(triggerOptions: any, target: any, condition?: Condition);
  73700. /** @hidden */
  73701. _prepare(): void;
  73702. /**
  73703. * Execute the action and stop the animation.
  73704. */
  73705. execute(): void;
  73706. /**
  73707. * Serializes the actions and its related information.
  73708. * @param parent defines the object to serialize in
  73709. * @returns the serialized object
  73710. */
  73711. serialize(parent: any): any;
  73712. }
  73713. /**
  73714. * This defines an action responsible that does nothing once triggered.
  73715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73716. */
  73717. export class DoNothingAction extends Action {
  73718. /**
  73719. * Instantiate the action
  73720. * @param triggerOptions defines the trigger options
  73721. * @param condition defines the trigger related conditions
  73722. */
  73723. constructor(triggerOptions?: any, condition?: Condition);
  73724. /**
  73725. * Execute the action and do nothing.
  73726. */
  73727. execute(): void;
  73728. /**
  73729. * Serializes the actions and its related information.
  73730. * @param parent defines the object to serialize in
  73731. * @returns the serialized object
  73732. */
  73733. serialize(parent: any): any;
  73734. }
  73735. /**
  73736. * This defines an action responsible to trigger several actions once triggered.
  73737. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73738. */
  73739. export class CombineAction extends Action {
  73740. /**
  73741. * The list of aggregated animations to run.
  73742. */
  73743. children: Action[];
  73744. /**
  73745. * Instantiate the action
  73746. * @param triggerOptions defines the trigger options
  73747. * @param children defines the list of aggregated animations to run
  73748. * @param condition defines the trigger related conditions
  73749. */
  73750. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  73751. /** @hidden */
  73752. _prepare(): void;
  73753. /**
  73754. * Execute the action and executes all the aggregated actions.
  73755. */
  73756. execute(evt: ActionEvent): void;
  73757. /**
  73758. * Serializes the actions and its related information.
  73759. * @param parent defines the object to serialize in
  73760. * @returns the serialized object
  73761. */
  73762. serialize(parent: any): any;
  73763. }
  73764. /**
  73765. * This defines an action responsible to run code (external event) once triggered.
  73766. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73767. */
  73768. export class ExecuteCodeAction extends Action {
  73769. /**
  73770. * The callback function to run.
  73771. */
  73772. func: (evt: ActionEvent) => void;
  73773. /**
  73774. * Instantiate the action
  73775. * @param triggerOptions defines the trigger options
  73776. * @param func defines the callback function to run
  73777. * @param condition defines the trigger related conditions
  73778. */
  73779. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  73780. /**
  73781. * Execute the action and run the attached code.
  73782. */
  73783. execute(evt: ActionEvent): void;
  73784. }
  73785. /**
  73786. * This defines an action responsible to set the parent property of the target once triggered.
  73787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73788. */
  73789. export class SetParentAction extends Action {
  73790. private _parent;
  73791. private _target;
  73792. /**
  73793. * Instantiate the action
  73794. * @param triggerOptions defines the trigger options
  73795. * @param target defines the target containing the parent property
  73796. * @param parent defines from where the animation should start (animation frame)
  73797. * @param condition defines the trigger related conditions
  73798. */
  73799. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  73800. /** @hidden */
  73801. _prepare(): void;
  73802. /**
  73803. * Execute the action and set the parent property.
  73804. */
  73805. execute(): void;
  73806. /**
  73807. * Serializes the actions and its related information.
  73808. * @param parent defines the object to serialize in
  73809. * @returns the serialized object
  73810. */
  73811. serialize(parent: any): any;
  73812. }
  73813. }
  73814. declare module BABYLON {
  73815. /**
  73816. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  73817. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  73818. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73819. */
  73820. export class ActionManager extends AbstractActionManager {
  73821. /**
  73822. * Nothing
  73823. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73824. */
  73825. static readonly NothingTrigger: number;
  73826. /**
  73827. * On pick
  73828. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73829. */
  73830. static readonly OnPickTrigger: number;
  73831. /**
  73832. * On left pick
  73833. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73834. */
  73835. static readonly OnLeftPickTrigger: number;
  73836. /**
  73837. * On right pick
  73838. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73839. */
  73840. static readonly OnRightPickTrigger: number;
  73841. /**
  73842. * On center pick
  73843. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73844. */
  73845. static readonly OnCenterPickTrigger: number;
  73846. /**
  73847. * On pick down
  73848. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73849. */
  73850. static readonly OnPickDownTrigger: number;
  73851. /**
  73852. * On double pick
  73853. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73854. */
  73855. static readonly OnDoublePickTrigger: number;
  73856. /**
  73857. * On pick up
  73858. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73859. */
  73860. static readonly OnPickUpTrigger: number;
  73861. /**
  73862. * On pick out.
  73863. * This trigger will only be raised if you also declared a OnPickDown
  73864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73865. */
  73866. static readonly OnPickOutTrigger: number;
  73867. /**
  73868. * On long press
  73869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73870. */
  73871. static readonly OnLongPressTrigger: number;
  73872. /**
  73873. * On pointer over
  73874. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73875. */
  73876. static readonly OnPointerOverTrigger: number;
  73877. /**
  73878. * On pointer out
  73879. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73880. */
  73881. static readonly OnPointerOutTrigger: number;
  73882. /**
  73883. * On every frame
  73884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73885. */
  73886. static readonly OnEveryFrameTrigger: number;
  73887. /**
  73888. * On intersection enter
  73889. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73890. */
  73891. static readonly OnIntersectionEnterTrigger: number;
  73892. /**
  73893. * On intersection exit
  73894. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73895. */
  73896. static readonly OnIntersectionExitTrigger: number;
  73897. /**
  73898. * On key down
  73899. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73900. */
  73901. static readonly OnKeyDownTrigger: number;
  73902. /**
  73903. * On key up
  73904. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73905. */
  73906. static readonly OnKeyUpTrigger: number;
  73907. private _scene;
  73908. /**
  73909. * Creates a new action manager
  73910. * @param scene defines the hosting scene
  73911. */
  73912. constructor(scene: Scene);
  73913. /**
  73914. * Releases all associated resources
  73915. */
  73916. dispose(): void;
  73917. /**
  73918. * Gets hosting scene
  73919. * @returns the hosting scene
  73920. */
  73921. getScene(): Scene;
  73922. /**
  73923. * Does this action manager handles actions of any of the given triggers
  73924. * @param triggers defines the triggers to be tested
  73925. * @return a boolean indicating whether one (or more) of the triggers is handled
  73926. */
  73927. hasSpecificTriggers(triggers: number[]): boolean;
  73928. /**
  73929. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  73930. * speed.
  73931. * @param triggerA defines the trigger to be tested
  73932. * @param triggerB defines the trigger to be tested
  73933. * @return a boolean indicating whether one (or more) of the triggers is handled
  73934. */
  73935. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  73936. /**
  73937. * Does this action manager handles actions of a given trigger
  73938. * @param trigger defines the trigger to be tested
  73939. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  73940. * @return whether the trigger is handled
  73941. */
  73942. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  73943. /**
  73944. * Does this action manager has pointer triggers
  73945. */
  73946. readonly hasPointerTriggers: boolean;
  73947. /**
  73948. * Does this action manager has pick triggers
  73949. */
  73950. readonly hasPickTriggers: boolean;
  73951. /**
  73952. * Registers an action to this action manager
  73953. * @param action defines the action to be registered
  73954. * @return the action amended (prepared) after registration
  73955. */
  73956. registerAction(action: IAction): Nullable<IAction>;
  73957. /**
  73958. * Unregisters an action to this action manager
  73959. * @param action defines the action to be unregistered
  73960. * @return a boolean indicating whether the action has been unregistered
  73961. */
  73962. unregisterAction(action: IAction): Boolean;
  73963. /**
  73964. * Process a specific trigger
  73965. * @param trigger defines the trigger to process
  73966. * @param evt defines the event details to be processed
  73967. */
  73968. processTrigger(trigger: number, evt?: IActionEvent): void;
  73969. /** @hidden */
  73970. _getEffectiveTarget(target: any, propertyPath: string): any;
  73971. /** @hidden */
  73972. _getProperty(propertyPath: string): string;
  73973. /**
  73974. * Serialize this manager to a JSON object
  73975. * @param name defines the property name to store this manager
  73976. * @returns a JSON representation of this manager
  73977. */
  73978. serialize(name: string): any;
  73979. /**
  73980. * Creates a new ActionManager from a JSON data
  73981. * @param parsedActions defines the JSON data to read from
  73982. * @param object defines the hosting mesh
  73983. * @param scene defines the hosting scene
  73984. */
  73985. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  73986. /**
  73987. * Get a trigger name by index
  73988. * @param trigger defines the trigger index
  73989. * @returns a trigger name
  73990. */
  73991. static GetTriggerName(trigger: number): string;
  73992. }
  73993. }
  73994. declare module BABYLON {
  73995. /**
  73996. * Class representing a ray with position and direction
  73997. */
  73998. export class Ray {
  73999. /** origin point */
  74000. origin: Vector3;
  74001. /** direction */
  74002. direction: Vector3;
  74003. /** length of the ray */
  74004. length: number;
  74005. private static readonly TmpVector3;
  74006. private _tmpRay;
  74007. /**
  74008. * Creates a new ray
  74009. * @param origin origin point
  74010. * @param direction direction
  74011. * @param length length of the ray
  74012. */
  74013. constructor(
  74014. /** origin point */
  74015. origin: Vector3,
  74016. /** direction */
  74017. direction: Vector3,
  74018. /** length of the ray */
  74019. length?: number);
  74020. /**
  74021. * Checks if the ray intersects a box
  74022. * @param minimum bound of the box
  74023. * @param maximum bound of the box
  74024. * @param intersectionTreshold extra extend to be added to the box in all direction
  74025. * @returns if the box was hit
  74026. */
  74027. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  74028. /**
  74029. * Checks if the ray intersects a box
  74030. * @param box the bounding box to check
  74031. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  74032. * @returns if the box was hit
  74033. */
  74034. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  74035. /**
  74036. * If the ray hits a sphere
  74037. * @param sphere the bounding sphere to check
  74038. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  74039. * @returns true if it hits the sphere
  74040. */
  74041. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  74042. /**
  74043. * If the ray hits a triange
  74044. * @param vertex0 triangle vertex
  74045. * @param vertex1 triangle vertex
  74046. * @param vertex2 triangle vertex
  74047. * @returns intersection information if hit
  74048. */
  74049. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  74050. /**
  74051. * Checks if ray intersects a plane
  74052. * @param plane the plane to check
  74053. * @returns the distance away it was hit
  74054. */
  74055. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  74056. /**
  74057. * Calculate the intercept of a ray on a given axis
  74058. * @param axis to check 'x' | 'y' | 'z'
  74059. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  74060. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  74061. */
  74062. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  74063. /**
  74064. * Checks if ray intersects a mesh
  74065. * @param mesh the mesh to check
  74066. * @param fastCheck if only the bounding box should checked
  74067. * @returns picking info of the intersecton
  74068. */
  74069. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  74070. /**
  74071. * Checks if ray intersects a mesh
  74072. * @param meshes the meshes to check
  74073. * @param fastCheck if only the bounding box should checked
  74074. * @param results array to store result in
  74075. * @returns Array of picking infos
  74076. */
  74077. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  74078. private _comparePickingInfo;
  74079. private static smallnum;
  74080. private static rayl;
  74081. /**
  74082. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  74083. * @param sega the first point of the segment to test the intersection against
  74084. * @param segb the second point of the segment to test the intersection against
  74085. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  74086. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  74087. */
  74088. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  74089. /**
  74090. * Update the ray from viewport position
  74091. * @param x position
  74092. * @param y y position
  74093. * @param viewportWidth viewport width
  74094. * @param viewportHeight viewport height
  74095. * @param world world matrix
  74096. * @param view view matrix
  74097. * @param projection projection matrix
  74098. * @returns this ray updated
  74099. */
  74100. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  74101. /**
  74102. * Creates a ray with origin and direction of 0,0,0
  74103. * @returns the new ray
  74104. */
  74105. static Zero(): Ray;
  74106. /**
  74107. * Creates a new ray from screen space and viewport
  74108. * @param x position
  74109. * @param y y position
  74110. * @param viewportWidth viewport width
  74111. * @param viewportHeight viewport height
  74112. * @param world world matrix
  74113. * @param view view matrix
  74114. * @param projection projection matrix
  74115. * @returns new ray
  74116. */
  74117. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  74118. /**
  74119. * 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
  74120. * transformed to the given world matrix.
  74121. * @param origin The origin point
  74122. * @param end The end point
  74123. * @param world a matrix to transform the ray to. Default is the identity matrix.
  74124. * @returns the new ray
  74125. */
  74126. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  74127. /**
  74128. * Transforms a ray by a matrix
  74129. * @param ray ray to transform
  74130. * @param matrix matrix to apply
  74131. * @returns the resulting new ray
  74132. */
  74133. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  74134. /**
  74135. * Transforms a ray by a matrix
  74136. * @param ray ray to transform
  74137. * @param matrix matrix to apply
  74138. * @param result ray to store result in
  74139. */
  74140. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  74141. /**
  74142. * Unproject a ray from screen space to object space
  74143. * @param sourceX defines the screen space x coordinate to use
  74144. * @param sourceY defines the screen space y coordinate to use
  74145. * @param viewportWidth defines the current width of the viewport
  74146. * @param viewportHeight defines the current height of the viewport
  74147. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  74148. * @param view defines the view matrix to use
  74149. * @param projection defines the projection matrix to use
  74150. */
  74151. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  74152. }
  74153. /**
  74154. * Type used to define predicate used to select faces when a mesh intersection is detected
  74155. */
  74156. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  74157. interface Scene {
  74158. /** @hidden */
  74159. _tempPickingRay: Nullable<Ray>;
  74160. /** @hidden */
  74161. _cachedRayForTransform: Ray;
  74162. /** @hidden */
  74163. _pickWithRayInverseMatrix: Matrix;
  74164. /** @hidden */
  74165. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  74166. /** @hidden */
  74167. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  74168. }
  74169. }
  74170. declare module BABYLON {
  74171. /**
  74172. * Groups all the scene component constants in one place to ease maintenance.
  74173. * @hidden
  74174. */
  74175. export class SceneComponentConstants {
  74176. static readonly NAME_EFFECTLAYER: string;
  74177. static readonly NAME_LAYER: string;
  74178. static readonly NAME_LENSFLARESYSTEM: string;
  74179. static readonly NAME_BOUNDINGBOXRENDERER: string;
  74180. static readonly NAME_PARTICLESYSTEM: string;
  74181. static readonly NAME_GAMEPAD: string;
  74182. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  74183. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  74184. static readonly NAME_DEPTHRENDERER: string;
  74185. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  74186. static readonly NAME_SPRITE: string;
  74187. static readonly NAME_OUTLINERENDERER: string;
  74188. static readonly NAME_PROCEDURALTEXTURE: string;
  74189. static readonly NAME_SHADOWGENERATOR: string;
  74190. static readonly NAME_OCTREE: string;
  74191. static readonly NAME_PHYSICSENGINE: string;
  74192. static readonly NAME_AUDIO: string;
  74193. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  74194. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  74195. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  74196. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  74197. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  74198. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  74199. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  74200. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  74201. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  74202. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  74203. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  74204. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  74205. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  74206. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  74207. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  74208. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  74209. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  74210. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  74211. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  74212. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  74213. static readonly STEP_AFTERRENDER_AUDIO: number;
  74214. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  74215. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  74216. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  74217. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  74218. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  74219. static readonly STEP_POINTERMOVE_SPRITE: number;
  74220. static readonly STEP_POINTERDOWN_SPRITE: number;
  74221. static readonly STEP_POINTERUP_SPRITE: number;
  74222. }
  74223. /**
  74224. * This represents a scene component.
  74225. *
  74226. * This is used to decouple the dependency the scene is having on the different workloads like
  74227. * layers, post processes...
  74228. */
  74229. export interface ISceneComponent {
  74230. /**
  74231. * The name of the component. Each component must have a unique name.
  74232. */
  74233. name: string;
  74234. /**
  74235. * The scene the component belongs to.
  74236. */
  74237. scene: Scene;
  74238. /**
  74239. * Register the component to one instance of a scene.
  74240. */
  74241. register(): void;
  74242. /**
  74243. * Rebuilds the elements related to this component in case of
  74244. * context lost for instance.
  74245. */
  74246. rebuild(): void;
  74247. /**
  74248. * Disposes the component and the associated ressources.
  74249. */
  74250. dispose(): void;
  74251. }
  74252. /**
  74253. * This represents a SERIALIZABLE scene component.
  74254. *
  74255. * This extends Scene Component to add Serialization methods on top.
  74256. */
  74257. export interface ISceneSerializableComponent extends ISceneComponent {
  74258. /**
  74259. * Adds all the elements from the container to the scene
  74260. * @param container the container holding the elements
  74261. */
  74262. addFromContainer(container: AbstractScene): void;
  74263. /**
  74264. * Removes all the elements in the container from the scene
  74265. * @param container contains the elements to remove
  74266. * @param dispose if the removed element should be disposed (default: false)
  74267. */
  74268. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  74269. /**
  74270. * Serializes the component data to the specified json object
  74271. * @param serializationObject The object to serialize to
  74272. */
  74273. serialize(serializationObject: any): void;
  74274. }
  74275. /**
  74276. * Strong typing of a Mesh related stage step action
  74277. */
  74278. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  74279. /**
  74280. * Strong typing of a Evaluate Sub Mesh related stage step action
  74281. */
  74282. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  74283. /**
  74284. * Strong typing of a Active Mesh related stage step action
  74285. */
  74286. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  74287. /**
  74288. * Strong typing of a Camera related stage step action
  74289. */
  74290. export type CameraStageAction = (camera: Camera) => void;
  74291. /**
  74292. * Strong typing of a Camera Frame buffer related stage step action
  74293. */
  74294. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  74295. /**
  74296. * Strong typing of a Render Target related stage step action
  74297. */
  74298. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  74299. /**
  74300. * Strong typing of a RenderingGroup related stage step action
  74301. */
  74302. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  74303. /**
  74304. * Strong typing of a Mesh Render related stage step action
  74305. */
  74306. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  74307. /**
  74308. * Strong typing of a simple stage step action
  74309. */
  74310. export type SimpleStageAction = () => void;
  74311. /**
  74312. * Strong typing of a render target action.
  74313. */
  74314. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  74315. /**
  74316. * Strong typing of a pointer move action.
  74317. */
  74318. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  74319. /**
  74320. * Strong typing of a pointer up/down action.
  74321. */
  74322. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  74323. /**
  74324. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  74325. * @hidden
  74326. */
  74327. export class Stage<T extends Function> extends Array<{
  74328. index: number;
  74329. component: ISceneComponent;
  74330. action: T;
  74331. }> {
  74332. /**
  74333. * Hide ctor from the rest of the world.
  74334. * @param items The items to add.
  74335. */
  74336. private constructor();
  74337. /**
  74338. * Creates a new Stage.
  74339. * @returns A new instance of a Stage
  74340. */
  74341. static Create<T extends Function>(): Stage<T>;
  74342. /**
  74343. * Registers a step in an ordered way in the targeted stage.
  74344. * @param index Defines the position to register the step in
  74345. * @param component Defines the component attached to the step
  74346. * @param action Defines the action to launch during the step
  74347. */
  74348. registerStep(index: number, component: ISceneComponent, action: T): void;
  74349. /**
  74350. * Clears all the steps from the stage.
  74351. */
  74352. clear(): void;
  74353. }
  74354. }
  74355. declare module BABYLON {
  74356. interface Scene {
  74357. /** @hidden */
  74358. _pointerOverSprite: Nullable<Sprite>;
  74359. /** @hidden */
  74360. _pickedDownSprite: Nullable<Sprite>;
  74361. /** @hidden */
  74362. _tempSpritePickingRay: Nullable<Ray>;
  74363. /**
  74364. * All of the sprite managers added to this scene
  74365. * @see http://doc.babylonjs.com/babylon101/sprites
  74366. */
  74367. spriteManagers: Array<ISpriteManager>;
  74368. /**
  74369. * An event triggered when sprites rendering is about to start
  74370. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  74371. */
  74372. onBeforeSpritesRenderingObservable: Observable<Scene>;
  74373. /**
  74374. * An event triggered when sprites rendering is done
  74375. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  74376. */
  74377. onAfterSpritesRenderingObservable: Observable<Scene>;
  74378. /** @hidden */
  74379. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  74380. /** Launch a ray to try to pick a sprite in the scene
  74381. * @param x position on screen
  74382. * @param y position on screen
  74383. * @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
  74384. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  74385. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  74386. * @returns a PickingInfo
  74387. */
  74388. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  74389. /** Use the given ray to pick a sprite in the scene
  74390. * @param ray The ray (in world space) to use to pick meshes
  74391. * @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
  74392. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  74393. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  74394. * @returns a PickingInfo
  74395. */
  74396. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  74397. /**
  74398. * Force the sprite under the pointer
  74399. * @param sprite defines the sprite to use
  74400. */
  74401. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  74402. /**
  74403. * Gets the sprite under the pointer
  74404. * @returns a Sprite or null if no sprite is under the pointer
  74405. */
  74406. getPointerOverSprite(): Nullable<Sprite>;
  74407. }
  74408. /**
  74409. * Defines the sprite scene component responsible to manage sprites
  74410. * in a given scene.
  74411. */
  74412. export class SpriteSceneComponent implements ISceneComponent {
  74413. /**
  74414. * The component name helpfull to identify the component in the list of scene components.
  74415. */
  74416. readonly name: string;
  74417. /**
  74418. * The scene the component belongs to.
  74419. */
  74420. scene: Scene;
  74421. /** @hidden */
  74422. private _spritePredicate;
  74423. /**
  74424. * Creates a new instance of the component for the given scene
  74425. * @param scene Defines the scene to register the component in
  74426. */
  74427. constructor(scene: Scene);
  74428. /**
  74429. * Registers the component in a given scene
  74430. */
  74431. register(): void;
  74432. /**
  74433. * Rebuilds the elements related to this component in case of
  74434. * context lost for instance.
  74435. */
  74436. rebuild(): void;
  74437. /**
  74438. * Disposes the component and the associated ressources.
  74439. */
  74440. dispose(): void;
  74441. private _pickSpriteButKeepRay;
  74442. private _pointerMove;
  74443. private _pointerDown;
  74444. private _pointerUp;
  74445. }
  74446. }
  74447. declare module BABYLON {
  74448. /** @hidden */
  74449. export var fogFragmentDeclaration: {
  74450. name: string;
  74451. shader: string;
  74452. };
  74453. }
  74454. declare module BABYLON {
  74455. /** @hidden */
  74456. export var fogFragment: {
  74457. name: string;
  74458. shader: string;
  74459. };
  74460. }
  74461. declare module BABYLON {
  74462. /** @hidden */
  74463. export var spritesPixelShader: {
  74464. name: string;
  74465. shader: string;
  74466. };
  74467. }
  74468. declare module BABYLON {
  74469. /** @hidden */
  74470. export var fogVertexDeclaration: {
  74471. name: string;
  74472. shader: string;
  74473. };
  74474. }
  74475. declare module BABYLON {
  74476. /** @hidden */
  74477. export var spritesVertexShader: {
  74478. name: string;
  74479. shader: string;
  74480. };
  74481. }
  74482. declare module BABYLON {
  74483. /**
  74484. * Defines the minimum interface to fullfil in order to be a sprite manager.
  74485. */
  74486. export interface ISpriteManager extends IDisposable {
  74487. /**
  74488. * Restricts the camera to viewing objects with the same layerMask.
  74489. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  74490. */
  74491. layerMask: number;
  74492. /**
  74493. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  74494. */
  74495. isPickable: boolean;
  74496. /**
  74497. * Specifies the rendering group id for this mesh (0 by default)
  74498. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  74499. */
  74500. renderingGroupId: number;
  74501. /**
  74502. * Defines the list of sprites managed by the manager.
  74503. */
  74504. sprites: Array<Sprite>;
  74505. /**
  74506. * Tests the intersection of a sprite with a specific ray.
  74507. * @param ray The ray we are sending to test the collision
  74508. * @param camera The camera space we are sending rays in
  74509. * @param predicate A predicate allowing excluding sprites from the list of object to test
  74510. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  74511. * @returns picking info or null.
  74512. */
  74513. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  74514. /**
  74515. * Renders the list of sprites on screen.
  74516. */
  74517. render(): void;
  74518. }
  74519. /**
  74520. * Class used to manage multiple sprites on the same spritesheet
  74521. * @see http://doc.babylonjs.com/babylon101/sprites
  74522. */
  74523. export class SpriteManager implements ISpriteManager {
  74524. /** defines the manager's name */
  74525. name: string;
  74526. /** Gets the list of sprites */
  74527. sprites: Sprite[];
  74528. /** Gets or sets the rendering group id (0 by default) */
  74529. renderingGroupId: number;
  74530. /** Gets or sets camera layer mask */
  74531. layerMask: number;
  74532. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  74533. fogEnabled: boolean;
  74534. /** Gets or sets a boolean indicating if the sprites are pickable */
  74535. isPickable: boolean;
  74536. /** Defines the default width of a cell in the spritesheet */
  74537. cellWidth: number;
  74538. /** Defines the default height of a cell in the spritesheet */
  74539. cellHeight: number;
  74540. /**
  74541. * An event triggered when the manager is disposed.
  74542. */
  74543. onDisposeObservable: Observable<SpriteManager>;
  74544. private _onDisposeObserver;
  74545. /**
  74546. * Callback called when the manager is disposed
  74547. */
  74548. onDispose: () => void;
  74549. private _capacity;
  74550. private _spriteTexture;
  74551. private _epsilon;
  74552. private _scene;
  74553. private _vertexData;
  74554. private _buffer;
  74555. private _vertexBuffers;
  74556. private _indexBuffer;
  74557. private _effectBase;
  74558. private _effectFog;
  74559. /**
  74560. * Gets or sets the spritesheet texture
  74561. */
  74562. texture: Texture;
  74563. /**
  74564. * Creates a new sprite manager
  74565. * @param name defines the manager's name
  74566. * @param imgUrl defines the sprite sheet url
  74567. * @param capacity defines the maximum allowed number of sprites
  74568. * @param cellSize defines the size of a sprite cell
  74569. * @param scene defines the hosting scene
  74570. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  74571. * @param samplingMode defines the smapling mode to use with spritesheet
  74572. */
  74573. constructor(
  74574. /** defines the manager's name */
  74575. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  74576. private _appendSpriteVertex;
  74577. /**
  74578. * Intersects the sprites with a ray
  74579. * @param ray defines the ray to intersect with
  74580. * @param camera defines the current active camera
  74581. * @param predicate defines a predicate used to select candidate sprites
  74582. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  74583. * @returns null if no hit or a PickingInfo
  74584. */
  74585. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  74586. /**
  74587. * Render all child sprites
  74588. */
  74589. render(): void;
  74590. /**
  74591. * Release associated resources
  74592. */
  74593. dispose(): void;
  74594. }
  74595. }
  74596. declare module BABYLON {
  74597. /**
  74598. * Class used to represent a sprite
  74599. * @see http://doc.babylonjs.com/babylon101/sprites
  74600. */
  74601. export class Sprite {
  74602. /** defines the name */
  74603. name: string;
  74604. /** Gets or sets the current world position */
  74605. position: Vector3;
  74606. /** Gets or sets the main color */
  74607. color: Color4;
  74608. /** Gets or sets the width */
  74609. width: number;
  74610. /** Gets or sets the height */
  74611. height: number;
  74612. /** Gets or sets rotation angle */
  74613. angle: number;
  74614. /** Gets or sets the cell index in the sprite sheet */
  74615. cellIndex: number;
  74616. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  74617. invertU: number;
  74618. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  74619. invertV: number;
  74620. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  74621. disposeWhenFinishedAnimating: boolean;
  74622. /** Gets the list of attached animations */
  74623. animations: Animation[];
  74624. /** Gets or sets a boolean indicating if the sprite can be picked */
  74625. isPickable: boolean;
  74626. /**
  74627. * Gets or sets the associated action manager
  74628. */
  74629. actionManager: Nullable<ActionManager>;
  74630. private _animationStarted;
  74631. private _loopAnimation;
  74632. private _fromIndex;
  74633. private _toIndex;
  74634. private _delay;
  74635. private _direction;
  74636. private _manager;
  74637. private _time;
  74638. private _onAnimationEnd;
  74639. /**
  74640. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  74641. */
  74642. isVisible: boolean;
  74643. /**
  74644. * Gets or sets the sprite size
  74645. */
  74646. size: number;
  74647. /**
  74648. * Creates a new Sprite
  74649. * @param name defines the name
  74650. * @param manager defines the manager
  74651. */
  74652. constructor(
  74653. /** defines the name */
  74654. name: string, manager: ISpriteManager);
  74655. /**
  74656. * Starts an animation
  74657. * @param from defines the initial key
  74658. * @param to defines the end key
  74659. * @param loop defines if the animation must loop
  74660. * @param delay defines the start delay (in ms)
  74661. * @param onAnimationEnd defines a callback to call when animation ends
  74662. */
  74663. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  74664. /** Stops current animation (if any) */
  74665. stopAnimation(): void;
  74666. /** @hidden */
  74667. _animate(deltaTime: number): void;
  74668. /** Release associated resources */
  74669. dispose(): void;
  74670. }
  74671. }
  74672. declare module BABYLON {
  74673. /**
  74674. * Information about the result of picking within a scene
  74675. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  74676. */
  74677. export class PickingInfo {
  74678. /** @hidden */
  74679. _pickingUnavailable: boolean;
  74680. /**
  74681. * If the pick collided with an object
  74682. */
  74683. hit: boolean;
  74684. /**
  74685. * Distance away where the pick collided
  74686. */
  74687. distance: number;
  74688. /**
  74689. * The location of pick collision
  74690. */
  74691. pickedPoint: Nullable<Vector3>;
  74692. /**
  74693. * The mesh corresponding the the pick collision
  74694. */
  74695. pickedMesh: Nullable<AbstractMesh>;
  74696. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  74697. bu: number;
  74698. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  74699. bv: number;
  74700. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  74701. faceId: number;
  74702. /** Id of the the submesh that was picked */
  74703. subMeshId: number;
  74704. /** If a sprite was picked, this will be the sprite the pick collided with */
  74705. pickedSprite: Nullable<Sprite>;
  74706. /**
  74707. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  74708. */
  74709. originMesh: Nullable<AbstractMesh>;
  74710. /**
  74711. * The ray that was used to perform the picking.
  74712. */
  74713. ray: Nullable<Ray>;
  74714. /**
  74715. * Gets the normal correspodning to the face the pick collided with
  74716. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  74717. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  74718. * @returns The normal correspodning to the face the pick collided with
  74719. */
  74720. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  74721. /**
  74722. * Gets the texture coordinates of where the pick occured
  74723. * @returns the vector containing the coordnates of the texture
  74724. */
  74725. getTextureCoordinates(): Nullable<Vector2>;
  74726. }
  74727. }
  74728. declare module BABYLON {
  74729. /**
  74730. * Gather the list of pointer event types as constants.
  74731. */
  74732. export class PointerEventTypes {
  74733. /**
  74734. * 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.
  74735. */
  74736. static readonly POINTERDOWN: number;
  74737. /**
  74738. * The pointerup event is fired when a pointer is no longer active.
  74739. */
  74740. static readonly POINTERUP: number;
  74741. /**
  74742. * The pointermove event is fired when a pointer changes coordinates.
  74743. */
  74744. static readonly POINTERMOVE: number;
  74745. /**
  74746. * The pointerwheel event is fired when a mouse wheel has been rotated.
  74747. */
  74748. static readonly POINTERWHEEL: number;
  74749. /**
  74750. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  74751. */
  74752. static readonly POINTERPICK: number;
  74753. /**
  74754. * The pointertap event is fired when a the object has been touched and released without drag.
  74755. */
  74756. static readonly POINTERTAP: number;
  74757. /**
  74758. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  74759. */
  74760. static readonly POINTERDOUBLETAP: number;
  74761. }
  74762. /**
  74763. * Base class of pointer info types.
  74764. */
  74765. export class PointerInfoBase {
  74766. /**
  74767. * Defines the type of event (PointerEventTypes)
  74768. */
  74769. type: number;
  74770. /**
  74771. * Defines the related dom event
  74772. */
  74773. event: PointerEvent | MouseWheelEvent;
  74774. /**
  74775. * Instantiates the base class of pointers info.
  74776. * @param type Defines the type of event (PointerEventTypes)
  74777. * @param event Defines the related dom event
  74778. */
  74779. constructor(
  74780. /**
  74781. * Defines the type of event (PointerEventTypes)
  74782. */
  74783. type: number,
  74784. /**
  74785. * Defines the related dom event
  74786. */
  74787. event: PointerEvent | MouseWheelEvent);
  74788. }
  74789. /**
  74790. * This class is used to store pointer related info for the onPrePointerObservable event.
  74791. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  74792. */
  74793. export class PointerInfoPre extends PointerInfoBase {
  74794. /**
  74795. * Ray from a pointer if availible (eg. 6dof controller)
  74796. */
  74797. ray: Nullable<Ray>;
  74798. /**
  74799. * Defines the local position of the pointer on the canvas.
  74800. */
  74801. localPosition: Vector2;
  74802. /**
  74803. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  74804. */
  74805. skipOnPointerObservable: boolean;
  74806. /**
  74807. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  74808. * @param type Defines the type of event (PointerEventTypes)
  74809. * @param event Defines the related dom event
  74810. * @param localX Defines the local x coordinates of the pointer when the event occured
  74811. * @param localY Defines the local y coordinates of the pointer when the event occured
  74812. */
  74813. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  74814. }
  74815. /**
  74816. * This type contains all the data related to a pointer event in Babylon.js.
  74817. * 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.
  74818. */
  74819. export class PointerInfo extends PointerInfoBase {
  74820. /**
  74821. * Defines the picking info associated to the info (if any)\
  74822. */
  74823. pickInfo: Nullable<PickingInfo>;
  74824. /**
  74825. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  74826. * @param type Defines the type of event (PointerEventTypes)
  74827. * @param event Defines the related dom event
  74828. * @param pickInfo Defines the picking info associated to the info (if any)\
  74829. */
  74830. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  74831. /**
  74832. * Defines the picking info associated to the info (if any)\
  74833. */
  74834. pickInfo: Nullable<PickingInfo>);
  74835. }
  74836. /**
  74837. * Data relating to a touch event on the screen.
  74838. */
  74839. export interface PointerTouch {
  74840. /**
  74841. * X coordinate of touch.
  74842. */
  74843. x: number;
  74844. /**
  74845. * Y coordinate of touch.
  74846. */
  74847. y: number;
  74848. /**
  74849. * Id of touch. Unique for each finger.
  74850. */
  74851. pointerId: number;
  74852. /**
  74853. * Event type passed from DOM.
  74854. */
  74855. type: any;
  74856. }
  74857. }
  74858. declare module BABYLON {
  74859. /**
  74860. * Manage the mouse inputs to control the movement of a free camera.
  74861. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74862. */
  74863. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  74864. /**
  74865. * Define if touch is enabled in the mouse input
  74866. */
  74867. touchEnabled: boolean;
  74868. /**
  74869. * Defines the camera the input is attached to.
  74870. */
  74871. camera: FreeCamera;
  74872. /**
  74873. * Defines the buttons associated with the input to handle camera move.
  74874. */
  74875. buttons: number[];
  74876. /**
  74877. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  74878. */
  74879. angularSensibility: number;
  74880. private _pointerInput;
  74881. private _onMouseMove;
  74882. private _observer;
  74883. private previousPosition;
  74884. /**
  74885. * Observable for when a pointer move event occurs containing the move offset
  74886. */
  74887. onPointerMovedObservable: Observable<{
  74888. offsetX: number;
  74889. offsetY: number;
  74890. }>;
  74891. /**
  74892. * @hidden
  74893. * If the camera should be rotated automatically based on pointer movement
  74894. */
  74895. _allowCameraRotation: boolean;
  74896. /**
  74897. * Manage the mouse inputs to control the movement of a free camera.
  74898. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74899. * @param touchEnabled Defines if touch is enabled or not
  74900. */
  74901. constructor(
  74902. /**
  74903. * Define if touch is enabled in the mouse input
  74904. */
  74905. touchEnabled?: boolean);
  74906. /**
  74907. * Attach the input controls to a specific dom element to get the input from.
  74908. * @param element Defines the element the controls should be listened from
  74909. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74910. */
  74911. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74912. /**
  74913. * Called on JS contextmenu event.
  74914. * Override this method to provide functionality.
  74915. */
  74916. protected onContextMenu(evt: PointerEvent): void;
  74917. /**
  74918. * Detach the current controls from the specified dom element.
  74919. * @param element Defines the element to stop listening the inputs from
  74920. */
  74921. detachControl(element: Nullable<HTMLElement>): void;
  74922. /**
  74923. * Gets the class name of the current intput.
  74924. * @returns the class name
  74925. */
  74926. getClassName(): string;
  74927. /**
  74928. * Get the friendly name associated with the input class.
  74929. * @returns the input friendly name
  74930. */
  74931. getSimpleName(): string;
  74932. }
  74933. }
  74934. declare module BABYLON {
  74935. /**
  74936. * Manage the touch inputs to control the movement of a free camera.
  74937. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74938. */
  74939. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  74940. /**
  74941. * Defines the camera the input is attached to.
  74942. */
  74943. camera: FreeCamera;
  74944. /**
  74945. * Defines the touch sensibility for rotation.
  74946. * The higher the faster.
  74947. */
  74948. touchAngularSensibility: number;
  74949. /**
  74950. * Defines the touch sensibility for move.
  74951. * The higher the faster.
  74952. */
  74953. touchMoveSensibility: number;
  74954. private _offsetX;
  74955. private _offsetY;
  74956. private _pointerPressed;
  74957. private _pointerInput;
  74958. private _observer;
  74959. private _onLostFocus;
  74960. /**
  74961. * Attach the input controls to a specific dom element to get the input from.
  74962. * @param element Defines the element the controls should be listened from
  74963. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74964. */
  74965. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74966. /**
  74967. * Detach the current controls from the specified dom element.
  74968. * @param element Defines the element to stop listening the inputs from
  74969. */
  74970. detachControl(element: Nullable<HTMLElement>): void;
  74971. /**
  74972. * Update the current camera state depending on the inputs that have been used this frame.
  74973. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74974. */
  74975. checkInputs(): void;
  74976. /**
  74977. * Gets the class name of the current intput.
  74978. * @returns the class name
  74979. */
  74980. getClassName(): string;
  74981. /**
  74982. * Get the friendly name associated with the input class.
  74983. * @returns the input friendly name
  74984. */
  74985. getSimpleName(): string;
  74986. }
  74987. }
  74988. declare module BABYLON {
  74989. /**
  74990. * Default Inputs manager for the FreeCamera.
  74991. * It groups all the default supported inputs for ease of use.
  74992. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74993. */
  74994. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  74995. /**
  74996. * @hidden
  74997. */
  74998. _mouseInput: Nullable<FreeCameraMouseInput>;
  74999. /**
  75000. * Instantiates a new FreeCameraInputsManager.
  75001. * @param camera Defines the camera the inputs belong to
  75002. */
  75003. constructor(camera: FreeCamera);
  75004. /**
  75005. * Add keyboard input support to the input manager.
  75006. * @returns the current input manager
  75007. */
  75008. addKeyboard(): FreeCameraInputsManager;
  75009. /**
  75010. * Add mouse input support to the input manager.
  75011. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  75012. * @returns the current input manager
  75013. */
  75014. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  75015. /**
  75016. * Removes the mouse input support from the manager
  75017. * @returns the current input manager
  75018. */
  75019. removeMouse(): FreeCameraInputsManager;
  75020. /**
  75021. * Add touch input support to the input manager.
  75022. * @returns the current input manager
  75023. */
  75024. addTouch(): FreeCameraInputsManager;
  75025. /**
  75026. * Remove all attached input methods from a camera
  75027. */
  75028. clear(): void;
  75029. }
  75030. }
  75031. declare module BABYLON {
  75032. /**
  75033. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  75034. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  75035. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  75036. */
  75037. export class FreeCamera extends TargetCamera {
  75038. /**
  75039. * Define the collision ellipsoid of the camera.
  75040. * This is helpful to simulate a camera body like the player body around the camera
  75041. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  75042. */
  75043. ellipsoid: Vector3;
  75044. /**
  75045. * Define an offset for the position of the ellipsoid around the camera.
  75046. * This can be helpful to determine the center of the body near the gravity center of the body
  75047. * instead of its head.
  75048. */
  75049. ellipsoidOffset: Vector3;
  75050. /**
  75051. * Enable or disable collisions of the camera with the rest of the scene objects.
  75052. */
  75053. checkCollisions: boolean;
  75054. /**
  75055. * Enable or disable gravity on the camera.
  75056. */
  75057. applyGravity: boolean;
  75058. /**
  75059. * Define the input manager associated to the camera.
  75060. */
  75061. inputs: FreeCameraInputsManager;
  75062. /**
  75063. * Gets the input sensibility for a mouse input. (default is 2000.0)
  75064. * Higher values reduce sensitivity.
  75065. */
  75066. /**
  75067. * Sets the input sensibility for a mouse input. (default is 2000.0)
  75068. * Higher values reduce sensitivity.
  75069. */
  75070. angularSensibility: number;
  75071. /**
  75072. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  75073. */
  75074. keysUp: number[];
  75075. /**
  75076. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  75077. */
  75078. keysDown: number[];
  75079. /**
  75080. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  75081. */
  75082. keysLeft: number[];
  75083. /**
  75084. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  75085. */
  75086. keysRight: number[];
  75087. /**
  75088. * Event raised when the camera collide with a mesh in the scene.
  75089. */
  75090. onCollide: (collidedMesh: AbstractMesh) => void;
  75091. private _collider;
  75092. private _needMoveForGravity;
  75093. private _oldPosition;
  75094. private _diffPosition;
  75095. private _newPosition;
  75096. /** @hidden */
  75097. _localDirection: Vector3;
  75098. /** @hidden */
  75099. _transformedDirection: Vector3;
  75100. /**
  75101. * Instantiates a Free Camera.
  75102. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  75103. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  75104. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  75105. * @param name Define the name of the camera in the scene
  75106. * @param position Define the start position of the camera in the scene
  75107. * @param scene Define the scene the camera belongs to
  75108. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  75109. */
  75110. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  75111. /**
  75112. * Attached controls to the current camera.
  75113. * @param element Defines the element the controls should be listened from
  75114. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75115. */
  75116. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75117. /**
  75118. * Detach the current controls from the camera.
  75119. * The camera will stop reacting to inputs.
  75120. * @param element Defines the element to stop listening the inputs from
  75121. */
  75122. detachControl(element: HTMLElement): void;
  75123. private _collisionMask;
  75124. /**
  75125. * Define a collision mask to limit the list of object the camera can collide with
  75126. */
  75127. collisionMask: number;
  75128. /** @hidden */
  75129. _collideWithWorld(displacement: Vector3): void;
  75130. private _onCollisionPositionChange;
  75131. /** @hidden */
  75132. _checkInputs(): void;
  75133. /** @hidden */
  75134. _decideIfNeedsToMove(): boolean;
  75135. /** @hidden */
  75136. _updatePosition(): void;
  75137. /**
  75138. * Destroy the camera and release the current resources hold by it.
  75139. */
  75140. dispose(): void;
  75141. /**
  75142. * Gets the current object class name.
  75143. * @return the class name
  75144. */
  75145. getClassName(): string;
  75146. }
  75147. }
  75148. declare module BABYLON {
  75149. /**
  75150. * Represents a gamepad control stick position
  75151. */
  75152. export class StickValues {
  75153. /**
  75154. * The x component of the control stick
  75155. */
  75156. x: number;
  75157. /**
  75158. * The y component of the control stick
  75159. */
  75160. y: number;
  75161. /**
  75162. * Initializes the gamepad x and y control stick values
  75163. * @param x The x component of the gamepad control stick value
  75164. * @param y The y component of the gamepad control stick value
  75165. */
  75166. constructor(
  75167. /**
  75168. * The x component of the control stick
  75169. */
  75170. x: number,
  75171. /**
  75172. * The y component of the control stick
  75173. */
  75174. y: number);
  75175. }
  75176. /**
  75177. * An interface which manages callbacks for gamepad button changes
  75178. */
  75179. export interface GamepadButtonChanges {
  75180. /**
  75181. * Called when a gamepad has been changed
  75182. */
  75183. changed: boolean;
  75184. /**
  75185. * Called when a gamepad press event has been triggered
  75186. */
  75187. pressChanged: boolean;
  75188. /**
  75189. * Called when a touch event has been triggered
  75190. */
  75191. touchChanged: boolean;
  75192. /**
  75193. * Called when a value has changed
  75194. */
  75195. valueChanged: boolean;
  75196. }
  75197. /**
  75198. * Represents a gamepad
  75199. */
  75200. export class Gamepad {
  75201. /**
  75202. * The id of the gamepad
  75203. */
  75204. id: string;
  75205. /**
  75206. * The index of the gamepad
  75207. */
  75208. index: number;
  75209. /**
  75210. * The browser gamepad
  75211. */
  75212. browserGamepad: any;
  75213. /**
  75214. * Specifies what type of gamepad this represents
  75215. */
  75216. type: number;
  75217. private _leftStick;
  75218. private _rightStick;
  75219. /** @hidden */
  75220. _isConnected: boolean;
  75221. private _leftStickAxisX;
  75222. private _leftStickAxisY;
  75223. private _rightStickAxisX;
  75224. private _rightStickAxisY;
  75225. /**
  75226. * Triggered when the left control stick has been changed
  75227. */
  75228. private _onleftstickchanged;
  75229. /**
  75230. * Triggered when the right control stick has been changed
  75231. */
  75232. private _onrightstickchanged;
  75233. /**
  75234. * Represents a gamepad controller
  75235. */
  75236. static GAMEPAD: number;
  75237. /**
  75238. * Represents a generic controller
  75239. */
  75240. static GENERIC: number;
  75241. /**
  75242. * Represents an XBox controller
  75243. */
  75244. static XBOX: number;
  75245. /**
  75246. * Represents a pose-enabled controller
  75247. */
  75248. static POSE_ENABLED: number;
  75249. /**
  75250. * Specifies whether the left control stick should be Y-inverted
  75251. */
  75252. protected _invertLeftStickY: boolean;
  75253. /**
  75254. * Specifies if the gamepad has been connected
  75255. */
  75256. readonly isConnected: boolean;
  75257. /**
  75258. * Initializes the gamepad
  75259. * @param id The id of the gamepad
  75260. * @param index The index of the gamepad
  75261. * @param browserGamepad The browser gamepad
  75262. * @param leftStickX The x component of the left joystick
  75263. * @param leftStickY The y component of the left joystick
  75264. * @param rightStickX The x component of the right joystick
  75265. * @param rightStickY The y component of the right joystick
  75266. */
  75267. constructor(
  75268. /**
  75269. * The id of the gamepad
  75270. */
  75271. id: string,
  75272. /**
  75273. * The index of the gamepad
  75274. */
  75275. index: number,
  75276. /**
  75277. * The browser gamepad
  75278. */
  75279. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  75280. /**
  75281. * Callback triggered when the left joystick has changed
  75282. * @param callback
  75283. */
  75284. onleftstickchanged(callback: (values: StickValues) => void): void;
  75285. /**
  75286. * Callback triggered when the right joystick has changed
  75287. * @param callback
  75288. */
  75289. onrightstickchanged(callback: (values: StickValues) => void): void;
  75290. /**
  75291. * Gets the left joystick
  75292. */
  75293. /**
  75294. * Sets the left joystick values
  75295. */
  75296. leftStick: StickValues;
  75297. /**
  75298. * Gets the right joystick
  75299. */
  75300. /**
  75301. * Sets the right joystick value
  75302. */
  75303. rightStick: StickValues;
  75304. /**
  75305. * Updates the gamepad joystick positions
  75306. */
  75307. update(): void;
  75308. /**
  75309. * Disposes the gamepad
  75310. */
  75311. dispose(): void;
  75312. }
  75313. /**
  75314. * Represents a generic gamepad
  75315. */
  75316. export class GenericPad extends Gamepad {
  75317. private _buttons;
  75318. private _onbuttondown;
  75319. private _onbuttonup;
  75320. /**
  75321. * Observable triggered when a button has been pressed
  75322. */
  75323. onButtonDownObservable: Observable<number>;
  75324. /**
  75325. * Observable triggered when a button has been released
  75326. */
  75327. onButtonUpObservable: Observable<number>;
  75328. /**
  75329. * Callback triggered when a button has been pressed
  75330. * @param callback Called when a button has been pressed
  75331. */
  75332. onbuttondown(callback: (buttonPressed: number) => void): void;
  75333. /**
  75334. * Callback triggered when a button has been released
  75335. * @param callback Called when a button has been released
  75336. */
  75337. onbuttonup(callback: (buttonReleased: number) => void): void;
  75338. /**
  75339. * Initializes the generic gamepad
  75340. * @param id The id of the generic gamepad
  75341. * @param index The index of the generic gamepad
  75342. * @param browserGamepad The browser gamepad
  75343. */
  75344. constructor(id: string, index: number, browserGamepad: any);
  75345. private _setButtonValue;
  75346. /**
  75347. * Updates the generic gamepad
  75348. */
  75349. update(): void;
  75350. /**
  75351. * Disposes the generic gamepad
  75352. */
  75353. dispose(): void;
  75354. }
  75355. }
  75356. declare module BABYLON {
  75357. interface Engine {
  75358. /**
  75359. * Creates a raw texture
  75360. * @param data defines the data to store in the texture
  75361. * @param width defines the width of the texture
  75362. * @param height defines the height of the texture
  75363. * @param format defines the format of the data
  75364. * @param generateMipMaps defines if the engine should generate the mip levels
  75365. * @param invertY defines if data must be stored with Y axis inverted
  75366. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  75367. * @param compression defines the compression used (null by default)
  75368. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75369. * @returns the raw texture inside an InternalTexture
  75370. */
  75371. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  75372. /**
  75373. * Update a raw texture
  75374. * @param texture defines the texture to update
  75375. * @param data defines the data to store in the texture
  75376. * @param format defines the format of the data
  75377. * @param invertY defines if data must be stored with Y axis inverted
  75378. */
  75379. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  75380. /**
  75381. * Update a raw texture
  75382. * @param texture defines the texture to update
  75383. * @param data defines the data to store in the texture
  75384. * @param format defines the format of the data
  75385. * @param invertY defines if data must be stored with Y axis inverted
  75386. * @param compression defines the compression used (null by default)
  75387. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75388. */
  75389. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  75390. /**
  75391. * Creates a new raw cube texture
  75392. * @param data defines the array of data to use to create each face
  75393. * @param size defines the size of the textures
  75394. * @param format defines the format of the data
  75395. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  75396. * @param generateMipMaps defines if the engine should generate the mip levels
  75397. * @param invertY defines if data must be stored with Y axis inverted
  75398. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  75399. * @param compression defines the compression used (null by default)
  75400. * @returns the cube texture as an InternalTexture
  75401. */
  75402. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  75403. /**
  75404. * Update a raw cube texture
  75405. * @param texture defines the texture to udpdate
  75406. * @param data defines the data to store
  75407. * @param format defines the data format
  75408. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75409. * @param invertY defines if data must be stored with Y axis inverted
  75410. */
  75411. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  75412. /**
  75413. * Update a raw cube texture
  75414. * @param texture defines the texture to udpdate
  75415. * @param data defines the data to store
  75416. * @param format defines the data format
  75417. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75418. * @param invertY defines if data must be stored with Y axis inverted
  75419. * @param compression defines the compression used (null by default)
  75420. */
  75421. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  75422. /**
  75423. * Update a raw cube texture
  75424. * @param texture defines the texture to udpdate
  75425. * @param data defines the data to store
  75426. * @param format defines the data format
  75427. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75428. * @param invertY defines if data must be stored with Y axis inverted
  75429. * @param compression defines the compression used (null by default)
  75430. * @param level defines which level of the texture to update
  75431. */
  75432. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  75433. /**
  75434. * Creates a new raw cube texture from a specified url
  75435. * @param url defines the url where the data is located
  75436. * @param scene defines the current scene
  75437. * @param size defines the size of the textures
  75438. * @param format defines the format of the data
  75439. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  75440. * @param noMipmap defines if the engine should avoid generating the mip levels
  75441. * @param callback defines a callback used to extract texture data from loaded data
  75442. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  75443. * @param onLoad defines a callback called when texture is loaded
  75444. * @param onError defines a callback called if there is an error
  75445. * @returns the cube texture as an InternalTexture
  75446. */
  75447. 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;
  75448. /**
  75449. * Creates a new raw cube texture from a specified url
  75450. * @param url defines the url where the data is located
  75451. * @param scene defines the current scene
  75452. * @param size defines the size of the textures
  75453. * @param format defines the format of the data
  75454. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  75455. * @param noMipmap defines if the engine should avoid generating the mip levels
  75456. * @param callback defines a callback used to extract texture data from loaded data
  75457. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  75458. * @param onLoad defines a callback called when texture is loaded
  75459. * @param onError defines a callback called if there is an error
  75460. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  75461. * @param invertY defines if data must be stored with Y axis inverted
  75462. * @returns the cube texture as an InternalTexture
  75463. */
  75464. 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;
  75465. /**
  75466. * Creates a new raw 3D texture
  75467. * @param data defines the data used to create the texture
  75468. * @param width defines the width of the texture
  75469. * @param height defines the height of the texture
  75470. * @param depth defines the depth of the texture
  75471. * @param format defines the format of the texture
  75472. * @param generateMipMaps defines if the engine must generate mip levels
  75473. * @param invertY defines if data must be stored with Y axis inverted
  75474. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  75475. * @param compression defines the compressed used (can be null)
  75476. * @param textureType defines the compressed used (can be null)
  75477. * @returns a new raw 3D texture (stored in an InternalTexture)
  75478. */
  75479. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  75480. /**
  75481. * Update a raw 3D texture
  75482. * @param texture defines the texture to update
  75483. * @param data defines the data to store
  75484. * @param format defines the data format
  75485. * @param invertY defines if data must be stored with Y axis inverted
  75486. */
  75487. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  75488. /**
  75489. * Update a raw 3D texture
  75490. * @param texture defines the texture to update
  75491. * @param data defines the data to store
  75492. * @param format defines the data format
  75493. * @param invertY defines if data must be stored with Y axis inverted
  75494. * @param compression defines the used compression (can be null)
  75495. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  75496. */
  75497. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  75498. }
  75499. }
  75500. declare module BABYLON {
  75501. /**
  75502. * Raw texture can help creating a texture directly from an array of data.
  75503. * This can be super useful if you either get the data from an uncompressed source or
  75504. * if you wish to create your texture pixel by pixel.
  75505. */
  75506. export class RawTexture extends Texture {
  75507. /**
  75508. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75509. */
  75510. format: number;
  75511. private _engine;
  75512. /**
  75513. * Instantiates a new RawTexture.
  75514. * Raw texture can help creating a texture directly from an array of data.
  75515. * This can be super useful if you either get the data from an uncompressed source or
  75516. * if you wish to create your texture pixel by pixel.
  75517. * @param data define the array of data to use to create the texture
  75518. * @param width define the width of the texture
  75519. * @param height define the height of the texture
  75520. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75521. * @param scene define the scene the texture belongs to
  75522. * @param generateMipMaps define whether mip maps should be generated or not
  75523. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75524. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75525. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75526. */
  75527. constructor(data: ArrayBufferView, width: number, height: number,
  75528. /**
  75529. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75530. */
  75531. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  75532. /**
  75533. * Updates the texture underlying data.
  75534. * @param data Define the new data of the texture
  75535. */
  75536. update(data: ArrayBufferView): void;
  75537. /**
  75538. * Creates a luminance texture from some data.
  75539. * @param data Define the texture data
  75540. * @param width Define the width of the texture
  75541. * @param height Define the height of the texture
  75542. * @param scene Define the scene the texture belongs to
  75543. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75544. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75545. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75546. * @returns the luminance texture
  75547. */
  75548. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75549. /**
  75550. * Creates a luminance alpha texture from some data.
  75551. * @param data Define the texture data
  75552. * @param width Define the width of the texture
  75553. * @param height Define the height of the texture
  75554. * @param scene Define the scene the texture belongs to
  75555. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75556. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75557. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75558. * @returns the luminance alpha texture
  75559. */
  75560. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75561. /**
  75562. * Creates an alpha texture from some data.
  75563. * @param data Define the texture data
  75564. * @param width Define the width of the texture
  75565. * @param height Define the height of the texture
  75566. * @param scene Define the scene the texture belongs to
  75567. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75568. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75569. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75570. * @returns the alpha texture
  75571. */
  75572. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75573. /**
  75574. * Creates a RGB texture from some data.
  75575. * @param data Define the texture data
  75576. * @param width Define the width of the texture
  75577. * @param height Define the height of the texture
  75578. * @param scene Define the scene the texture belongs to
  75579. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75580. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75581. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75582. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75583. * @returns the RGB alpha texture
  75584. */
  75585. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75586. /**
  75587. * Creates a RGBA texture from some data.
  75588. * @param data Define the texture data
  75589. * @param width Define the width of the texture
  75590. * @param height Define the height of the texture
  75591. * @param scene Define the scene the texture belongs to
  75592. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75593. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75594. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75595. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75596. * @returns the RGBA texture
  75597. */
  75598. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75599. /**
  75600. * Creates a R texture from some data.
  75601. * @param data Define the texture data
  75602. * @param width Define the width of the texture
  75603. * @param height Define the height of the texture
  75604. * @param scene Define the scene the texture belongs to
  75605. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75606. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75607. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75608. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75609. * @returns the R texture
  75610. */
  75611. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75612. }
  75613. }
  75614. declare module BABYLON {
  75615. /**
  75616. * Interface for the size containing width and height
  75617. */
  75618. export interface ISize {
  75619. /**
  75620. * Width
  75621. */
  75622. width: number;
  75623. /**
  75624. * Heighht
  75625. */
  75626. height: number;
  75627. }
  75628. /**
  75629. * Size containing widht and height
  75630. */
  75631. export class Size implements ISize {
  75632. /**
  75633. * Width
  75634. */
  75635. width: number;
  75636. /**
  75637. * Height
  75638. */
  75639. height: number;
  75640. /**
  75641. * Creates a Size object from the given width and height (floats).
  75642. * @param width width of the new size
  75643. * @param height height of the new size
  75644. */
  75645. constructor(width: number, height: number);
  75646. /**
  75647. * Returns a string with the Size width and height
  75648. * @returns a string with the Size width and height
  75649. */
  75650. toString(): string;
  75651. /**
  75652. * "Size"
  75653. * @returns the string "Size"
  75654. */
  75655. getClassName(): string;
  75656. /**
  75657. * Returns the Size hash code.
  75658. * @returns a hash code for a unique width and height
  75659. */
  75660. getHashCode(): number;
  75661. /**
  75662. * Updates the current size from the given one.
  75663. * @param src the given size
  75664. */
  75665. copyFrom(src: Size): void;
  75666. /**
  75667. * Updates in place the current Size from the given floats.
  75668. * @param width width of the new size
  75669. * @param height height of the new size
  75670. * @returns the updated Size.
  75671. */
  75672. copyFromFloats(width: number, height: number): Size;
  75673. /**
  75674. * Updates in place the current Size from the given floats.
  75675. * @param width width to set
  75676. * @param height height to set
  75677. * @returns the updated Size.
  75678. */
  75679. set(width: number, height: number): Size;
  75680. /**
  75681. * Multiplies the width and height by numbers
  75682. * @param w factor to multiple the width by
  75683. * @param h factor to multiple the height by
  75684. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  75685. */
  75686. multiplyByFloats(w: number, h: number): Size;
  75687. /**
  75688. * Clones the size
  75689. * @returns a new Size copied from the given one.
  75690. */
  75691. clone(): Size;
  75692. /**
  75693. * True if the current Size and the given one width and height are strictly equal.
  75694. * @param other the other size to compare against
  75695. * @returns True if the current Size and the given one width and height are strictly equal.
  75696. */
  75697. equals(other: Size): boolean;
  75698. /**
  75699. * The surface of the Size : width * height (float).
  75700. */
  75701. readonly surface: number;
  75702. /**
  75703. * Create a new size of zero
  75704. * @returns a new Size set to (0.0, 0.0)
  75705. */
  75706. static Zero(): Size;
  75707. /**
  75708. * Sums the width and height of two sizes
  75709. * @param otherSize size to add to this size
  75710. * @returns a new Size set as the addition result of the current Size and the given one.
  75711. */
  75712. add(otherSize: Size): Size;
  75713. /**
  75714. * Subtracts the width and height of two
  75715. * @param otherSize size to subtract to this size
  75716. * @returns a new Size set as the subtraction result of the given one from the current Size.
  75717. */
  75718. subtract(otherSize: Size): Size;
  75719. /**
  75720. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  75721. * @param start starting size to lerp between
  75722. * @param end end size to lerp between
  75723. * @param amount amount to lerp between the start and end values
  75724. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  75725. */
  75726. static Lerp(start: Size, end: Size, amount: number): Size;
  75727. }
  75728. }
  75729. declare module BABYLON {
  75730. /**
  75731. * Defines a runtime animation
  75732. */
  75733. export class RuntimeAnimation {
  75734. private _events;
  75735. /**
  75736. * The current frame of the runtime animation
  75737. */
  75738. private _currentFrame;
  75739. /**
  75740. * The animation used by the runtime animation
  75741. */
  75742. private _animation;
  75743. /**
  75744. * The target of the runtime animation
  75745. */
  75746. private _target;
  75747. /**
  75748. * The initiating animatable
  75749. */
  75750. private _host;
  75751. /**
  75752. * The original value of the runtime animation
  75753. */
  75754. private _originalValue;
  75755. /**
  75756. * The original blend value of the runtime animation
  75757. */
  75758. private _originalBlendValue;
  75759. /**
  75760. * The offsets cache of the runtime animation
  75761. */
  75762. private _offsetsCache;
  75763. /**
  75764. * The high limits cache of the runtime animation
  75765. */
  75766. private _highLimitsCache;
  75767. /**
  75768. * Specifies if the runtime animation has been stopped
  75769. */
  75770. private _stopped;
  75771. /**
  75772. * The blending factor of the runtime animation
  75773. */
  75774. private _blendingFactor;
  75775. /**
  75776. * The BabylonJS scene
  75777. */
  75778. private _scene;
  75779. /**
  75780. * The current value of the runtime animation
  75781. */
  75782. private _currentValue;
  75783. /** @hidden */
  75784. _animationState: _IAnimationState;
  75785. /**
  75786. * The active target of the runtime animation
  75787. */
  75788. private _activeTargets;
  75789. private _currentActiveTarget;
  75790. private _directTarget;
  75791. /**
  75792. * The target path of the runtime animation
  75793. */
  75794. private _targetPath;
  75795. /**
  75796. * The weight of the runtime animation
  75797. */
  75798. private _weight;
  75799. /**
  75800. * The ratio offset of the runtime animation
  75801. */
  75802. private _ratioOffset;
  75803. /**
  75804. * The previous delay of the runtime animation
  75805. */
  75806. private _previousDelay;
  75807. /**
  75808. * The previous ratio of the runtime animation
  75809. */
  75810. private _previousRatio;
  75811. private _enableBlending;
  75812. private _keys;
  75813. private _minFrame;
  75814. private _maxFrame;
  75815. private _minValue;
  75816. private _maxValue;
  75817. private _targetIsArray;
  75818. /**
  75819. * Gets the current frame of the runtime animation
  75820. */
  75821. readonly currentFrame: number;
  75822. /**
  75823. * Gets the weight of the runtime animation
  75824. */
  75825. readonly weight: number;
  75826. /**
  75827. * Gets the current value of the runtime animation
  75828. */
  75829. readonly currentValue: any;
  75830. /**
  75831. * Gets the target path of the runtime animation
  75832. */
  75833. readonly targetPath: string;
  75834. /**
  75835. * Gets the actual target of the runtime animation
  75836. */
  75837. readonly target: any;
  75838. /** @hidden */
  75839. _onLoop: () => void;
  75840. /**
  75841. * Create a new RuntimeAnimation object
  75842. * @param target defines the target of the animation
  75843. * @param animation defines the source animation object
  75844. * @param scene defines the hosting scene
  75845. * @param host defines the initiating Animatable
  75846. */
  75847. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  75848. private _preparePath;
  75849. /**
  75850. * Gets the animation from the runtime animation
  75851. */
  75852. readonly animation: Animation;
  75853. /**
  75854. * Resets the runtime animation to the beginning
  75855. * @param restoreOriginal defines whether to restore the target property to the original value
  75856. */
  75857. reset(restoreOriginal?: boolean): void;
  75858. /**
  75859. * Specifies if the runtime animation is stopped
  75860. * @returns Boolean specifying if the runtime animation is stopped
  75861. */
  75862. isStopped(): boolean;
  75863. /**
  75864. * Disposes of the runtime animation
  75865. */
  75866. dispose(): void;
  75867. /**
  75868. * Apply the interpolated value to the target
  75869. * @param currentValue defines the value computed by the animation
  75870. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  75871. */
  75872. setValue(currentValue: any, weight: number): void;
  75873. private _getOriginalValues;
  75874. private _setValue;
  75875. /**
  75876. * Gets the loop pmode of the runtime animation
  75877. * @returns Loop Mode
  75878. */
  75879. private _getCorrectLoopMode;
  75880. /**
  75881. * Move the current animation to a given frame
  75882. * @param frame defines the frame to move to
  75883. */
  75884. goToFrame(frame: number): void;
  75885. /**
  75886. * @hidden Internal use only
  75887. */
  75888. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  75889. /**
  75890. * Execute the current animation
  75891. * @param delay defines the delay to add to the current frame
  75892. * @param from defines the lower bound of the animation range
  75893. * @param to defines the upper bound of the animation range
  75894. * @param loop defines if the current animation must loop
  75895. * @param speedRatio defines the current speed ratio
  75896. * @param weight defines the weight of the animation (default is -1 so no weight)
  75897. * @param onLoop optional callback called when animation loops
  75898. * @returns a boolean indicating if the animation is running
  75899. */
  75900. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  75901. }
  75902. }
  75903. declare module BABYLON {
  75904. /**
  75905. * Class used to store an actual running animation
  75906. */
  75907. export class Animatable {
  75908. /** defines the target object */
  75909. target: any;
  75910. /** defines the starting frame number (default is 0) */
  75911. fromFrame: number;
  75912. /** defines the ending frame number (default is 100) */
  75913. toFrame: number;
  75914. /** defines if the animation must loop (default is false) */
  75915. loopAnimation: boolean;
  75916. /** defines a callback to call when animation ends if it is not looping */
  75917. onAnimationEnd?: (() => void) | null | undefined;
  75918. /** defines a callback to call when animation loops */
  75919. onAnimationLoop?: (() => void) | null | undefined;
  75920. private _localDelayOffset;
  75921. private _pausedDelay;
  75922. private _runtimeAnimations;
  75923. private _paused;
  75924. private _scene;
  75925. private _speedRatio;
  75926. private _weight;
  75927. private _syncRoot;
  75928. /**
  75929. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  75930. * This will only apply for non looping animation (default is true)
  75931. */
  75932. disposeOnEnd: boolean;
  75933. /**
  75934. * Gets a boolean indicating if the animation has started
  75935. */
  75936. animationStarted: boolean;
  75937. /**
  75938. * Observer raised when the animation ends
  75939. */
  75940. onAnimationEndObservable: Observable<Animatable>;
  75941. /**
  75942. * Observer raised when the animation loops
  75943. */
  75944. onAnimationLoopObservable: Observable<Animatable>;
  75945. /**
  75946. * Gets the root Animatable used to synchronize and normalize animations
  75947. */
  75948. readonly syncRoot: Nullable<Animatable>;
  75949. /**
  75950. * Gets the current frame of the first RuntimeAnimation
  75951. * Used to synchronize Animatables
  75952. */
  75953. readonly masterFrame: number;
  75954. /**
  75955. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  75956. */
  75957. weight: number;
  75958. /**
  75959. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  75960. */
  75961. speedRatio: number;
  75962. /**
  75963. * Creates a new Animatable
  75964. * @param scene defines the hosting scene
  75965. * @param target defines the target object
  75966. * @param fromFrame defines the starting frame number (default is 0)
  75967. * @param toFrame defines the ending frame number (default is 100)
  75968. * @param loopAnimation defines if the animation must loop (default is false)
  75969. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  75970. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  75971. * @param animations defines a group of animation to add to the new Animatable
  75972. * @param onAnimationLoop defines a callback to call when animation loops
  75973. */
  75974. constructor(scene: Scene,
  75975. /** defines the target object */
  75976. target: any,
  75977. /** defines the starting frame number (default is 0) */
  75978. fromFrame?: number,
  75979. /** defines the ending frame number (default is 100) */
  75980. toFrame?: number,
  75981. /** defines if the animation must loop (default is false) */
  75982. loopAnimation?: boolean, speedRatio?: number,
  75983. /** defines a callback to call when animation ends if it is not looping */
  75984. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  75985. /** defines a callback to call when animation loops */
  75986. onAnimationLoop?: (() => void) | null | undefined);
  75987. /**
  75988. * Synchronize and normalize current Animatable with a source Animatable
  75989. * This is useful when using animation weights and when animations are not of the same length
  75990. * @param root defines the root Animatable to synchronize with
  75991. * @returns the current Animatable
  75992. */
  75993. syncWith(root: Animatable): Animatable;
  75994. /**
  75995. * Gets the list of runtime animations
  75996. * @returns an array of RuntimeAnimation
  75997. */
  75998. getAnimations(): RuntimeAnimation[];
  75999. /**
  76000. * Adds more animations to the current animatable
  76001. * @param target defines the target of the animations
  76002. * @param animations defines the new animations to add
  76003. */
  76004. appendAnimations(target: any, animations: Animation[]): void;
  76005. /**
  76006. * Gets the source animation for a specific property
  76007. * @param property defines the propertyu to look for
  76008. * @returns null or the source animation for the given property
  76009. */
  76010. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  76011. /**
  76012. * Gets the runtime animation for a specific property
  76013. * @param property defines the propertyu to look for
  76014. * @returns null or the runtime animation for the given property
  76015. */
  76016. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  76017. /**
  76018. * Resets the animatable to its original state
  76019. */
  76020. reset(): void;
  76021. /**
  76022. * Allows the animatable to blend with current running animations
  76023. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76024. * @param blendingSpeed defines the blending speed to use
  76025. */
  76026. enableBlending(blendingSpeed: number): void;
  76027. /**
  76028. * Disable animation blending
  76029. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76030. */
  76031. disableBlending(): void;
  76032. /**
  76033. * Jump directly to a given frame
  76034. * @param frame defines the frame to jump to
  76035. */
  76036. goToFrame(frame: number): void;
  76037. /**
  76038. * Pause the animation
  76039. */
  76040. pause(): void;
  76041. /**
  76042. * Restart the animation
  76043. */
  76044. restart(): void;
  76045. private _raiseOnAnimationEnd;
  76046. /**
  76047. * Stop and delete the current animation
  76048. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  76049. * @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)
  76050. */
  76051. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  76052. /**
  76053. * Wait asynchronously for the animation to end
  76054. * @returns a promise which will be fullfilled when the animation ends
  76055. */
  76056. waitAsync(): Promise<Animatable>;
  76057. /** @hidden */
  76058. _animate(delay: number): boolean;
  76059. }
  76060. interface Scene {
  76061. /** @hidden */
  76062. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  76063. /** @hidden */
  76064. _processLateAnimationBindingsForMatrices(holder: {
  76065. totalWeight: number;
  76066. animations: RuntimeAnimation[];
  76067. originalValue: Matrix;
  76068. }): any;
  76069. /** @hidden */
  76070. _processLateAnimationBindingsForQuaternions(holder: {
  76071. totalWeight: number;
  76072. animations: RuntimeAnimation[];
  76073. originalValue: Quaternion;
  76074. }, refQuaternion: Quaternion): Quaternion;
  76075. /** @hidden */
  76076. _processLateAnimationBindings(): void;
  76077. /**
  76078. * Will start the animation sequence of a given target
  76079. * @param target defines the target
  76080. * @param from defines from which frame should animation start
  76081. * @param to defines until which frame should animation run.
  76082. * @param weight defines the weight to apply to the animation (1.0 by default)
  76083. * @param loop defines if the animation loops
  76084. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76085. * @param onAnimationEnd defines the function to be executed when the animation ends
  76086. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76087. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  76088. * @param onAnimationLoop defines the callback to call when an animation loops
  76089. * @returns the animatable object created for this animation
  76090. */
  76091. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  76092. /**
  76093. * Will start the animation sequence of a given target
  76094. * @param target defines the target
  76095. * @param from defines from which frame should animation start
  76096. * @param to defines until which frame should animation run.
  76097. * @param loop defines if the animation loops
  76098. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76099. * @param onAnimationEnd defines the function to be executed when the animation ends
  76100. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76101. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  76102. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  76103. * @param onAnimationLoop defines the callback to call when an animation loops
  76104. * @returns the animatable object created for this animation
  76105. */
  76106. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  76107. /**
  76108. * Will start the animation sequence of a given target and its hierarchy
  76109. * @param target defines the target
  76110. * @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.
  76111. * @param from defines from which frame should animation start
  76112. * @param to defines until which frame should animation run.
  76113. * @param loop defines if the animation loops
  76114. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76115. * @param onAnimationEnd defines the function to be executed when the animation ends
  76116. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76117. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  76118. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  76119. * @param onAnimationLoop defines the callback to call when an animation loops
  76120. * @returns the list of created animatables
  76121. */
  76122. 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[];
  76123. /**
  76124. * Begin a new animation on a given node
  76125. * @param target defines the target where the animation will take place
  76126. * @param animations defines the list of animations to start
  76127. * @param from defines the initial value
  76128. * @param to defines the final value
  76129. * @param loop defines if you want animation to loop (off by default)
  76130. * @param speedRatio defines the speed ratio to apply to all animations
  76131. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  76132. * @param onAnimationLoop defines the callback to call when an animation loops
  76133. * @returns the list of created animatables
  76134. */
  76135. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  76136. /**
  76137. * Begin a new animation on a given node and its hierarchy
  76138. * @param target defines the root node where the animation will take place
  76139. * @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.
  76140. * @param animations defines the list of animations to start
  76141. * @param from defines the initial value
  76142. * @param to defines the final value
  76143. * @param loop defines if you want animation to loop (off by default)
  76144. * @param speedRatio defines the speed ratio to apply to all animations
  76145. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  76146. * @param onAnimationLoop defines the callback to call when an animation loops
  76147. * @returns the list of animatables created for all nodes
  76148. */
  76149. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  76150. /**
  76151. * Gets the animatable associated with a specific target
  76152. * @param target defines the target of the animatable
  76153. * @returns the required animatable if found
  76154. */
  76155. getAnimatableByTarget(target: any): Nullable<Animatable>;
  76156. /**
  76157. * Gets all animatables associated with a given target
  76158. * @param target defines the target to look animatables for
  76159. * @returns an array of Animatables
  76160. */
  76161. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  76162. /**
  76163. * Stops and removes all animations that have been applied to the scene
  76164. */
  76165. stopAllAnimations(): void;
  76166. }
  76167. interface Bone {
  76168. /**
  76169. * Copy an animation range from another bone
  76170. * @param source defines the source bone
  76171. * @param rangeName defines the range name to copy
  76172. * @param frameOffset defines the frame offset
  76173. * @param rescaleAsRequired defines if rescaling must be applied if required
  76174. * @param skelDimensionsRatio defines the scaling ratio
  76175. * @returns true if operation was successful
  76176. */
  76177. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  76178. }
  76179. }
  76180. declare module BABYLON {
  76181. /**
  76182. * Class used to override all child animations of a given target
  76183. */
  76184. export class AnimationPropertiesOverride {
  76185. /**
  76186. * Gets or sets a value indicating if animation blending must be used
  76187. */
  76188. enableBlending: boolean;
  76189. /**
  76190. * Gets or sets the blending speed to use when enableBlending is true
  76191. */
  76192. blendingSpeed: number;
  76193. /**
  76194. * Gets or sets the default loop mode to use
  76195. */
  76196. loopMode: number;
  76197. }
  76198. }
  76199. declare module BABYLON {
  76200. /**
  76201. * Class used to handle skinning animations
  76202. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  76203. */
  76204. export class Skeleton implements IAnimatable {
  76205. /** defines the skeleton name */
  76206. name: string;
  76207. /** defines the skeleton Id */
  76208. id: string;
  76209. /**
  76210. * Defines the list of child bones
  76211. */
  76212. bones: Bone[];
  76213. /**
  76214. * Defines an estimate of the dimension of the skeleton at rest
  76215. */
  76216. dimensionsAtRest: Vector3;
  76217. /**
  76218. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  76219. */
  76220. needInitialSkinMatrix: boolean;
  76221. /**
  76222. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  76223. */
  76224. overrideMesh: Nullable<AbstractMesh>;
  76225. /**
  76226. * Gets the list of animations attached to this skeleton
  76227. */
  76228. animations: Array<Animation>;
  76229. private _scene;
  76230. private _isDirty;
  76231. private _transformMatrices;
  76232. private _transformMatrixTexture;
  76233. private _meshesWithPoseMatrix;
  76234. private _animatables;
  76235. private _identity;
  76236. private _synchronizedWithMesh;
  76237. private _ranges;
  76238. private _lastAbsoluteTransformsUpdateId;
  76239. private _canUseTextureForBones;
  76240. private _uniqueId;
  76241. /** @hidden */
  76242. _numBonesWithLinkedTransformNode: number;
  76243. /** @hidden */
  76244. _hasWaitingData: Nullable<boolean>;
  76245. /**
  76246. * Specifies if the skeleton should be serialized
  76247. */
  76248. doNotSerialize: boolean;
  76249. private _useTextureToStoreBoneMatrices;
  76250. /**
  76251. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  76252. * Please note that this option is not available if the hardware does not support it
  76253. */
  76254. useTextureToStoreBoneMatrices: boolean;
  76255. private _animationPropertiesOverride;
  76256. /**
  76257. * Gets or sets the animation properties override
  76258. */
  76259. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  76260. /**
  76261. * List of inspectable custom properties (used by the Inspector)
  76262. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  76263. */
  76264. inspectableCustomProperties: IInspectable[];
  76265. /**
  76266. * An observable triggered before computing the skeleton's matrices
  76267. */
  76268. onBeforeComputeObservable: Observable<Skeleton>;
  76269. /**
  76270. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  76271. */
  76272. readonly isUsingTextureForMatrices: boolean;
  76273. /**
  76274. * Gets the unique ID of this skeleton
  76275. */
  76276. readonly uniqueId: number;
  76277. /**
  76278. * Creates a new skeleton
  76279. * @param name defines the skeleton name
  76280. * @param id defines the skeleton Id
  76281. * @param scene defines the hosting scene
  76282. */
  76283. constructor(
  76284. /** defines the skeleton name */
  76285. name: string,
  76286. /** defines the skeleton Id */
  76287. id: string, scene: Scene);
  76288. /**
  76289. * Gets the current object class name.
  76290. * @return the class name
  76291. */
  76292. getClassName(): string;
  76293. /**
  76294. * Returns an array containing the root bones
  76295. * @returns an array containing the root bones
  76296. */
  76297. getChildren(): Array<Bone>;
  76298. /**
  76299. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  76300. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  76301. * @returns a Float32Array containing matrices data
  76302. */
  76303. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  76304. /**
  76305. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  76306. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  76307. * @returns a raw texture containing the data
  76308. */
  76309. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  76310. /**
  76311. * Gets the current hosting scene
  76312. * @returns a scene object
  76313. */
  76314. getScene(): Scene;
  76315. /**
  76316. * Gets a string representing the current skeleton data
  76317. * @param fullDetails defines a boolean indicating if we want a verbose version
  76318. * @returns a string representing the current skeleton data
  76319. */
  76320. toString(fullDetails?: boolean): string;
  76321. /**
  76322. * Get bone's index searching by name
  76323. * @param name defines bone's name to search for
  76324. * @return the indice of the bone. Returns -1 if not found
  76325. */
  76326. getBoneIndexByName(name: string): number;
  76327. /**
  76328. * Creater a new animation range
  76329. * @param name defines the name of the range
  76330. * @param from defines the start key
  76331. * @param to defines the end key
  76332. */
  76333. createAnimationRange(name: string, from: number, to: number): void;
  76334. /**
  76335. * Delete a specific animation range
  76336. * @param name defines the name of the range
  76337. * @param deleteFrames defines if frames must be removed as well
  76338. */
  76339. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  76340. /**
  76341. * Gets a specific animation range
  76342. * @param name defines the name of the range to look for
  76343. * @returns the requested animation range or null if not found
  76344. */
  76345. getAnimationRange(name: string): Nullable<AnimationRange>;
  76346. /**
  76347. * Gets the list of all animation ranges defined on this skeleton
  76348. * @returns an array
  76349. */
  76350. getAnimationRanges(): Nullable<AnimationRange>[];
  76351. /**
  76352. * Copy animation range from a source skeleton.
  76353. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  76354. * @param source defines the source skeleton
  76355. * @param name defines the name of the range to copy
  76356. * @param rescaleAsRequired defines if rescaling must be applied if required
  76357. * @returns true if operation was successful
  76358. */
  76359. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  76360. /**
  76361. * Forces the skeleton to go to rest pose
  76362. */
  76363. returnToRest(): void;
  76364. private _getHighestAnimationFrame;
  76365. /**
  76366. * Begin a specific animation range
  76367. * @param name defines the name of the range to start
  76368. * @param loop defines if looping must be turned on (false by default)
  76369. * @param speedRatio defines the speed ratio to apply (1 by default)
  76370. * @param onAnimationEnd defines a callback which will be called when animation will end
  76371. * @returns a new animatable
  76372. */
  76373. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  76374. /** @hidden */
  76375. _markAsDirty(): void;
  76376. /** @hidden */
  76377. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  76378. /** @hidden */
  76379. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  76380. private _computeTransformMatrices;
  76381. /**
  76382. * Build all resources required to render a skeleton
  76383. */
  76384. prepare(): void;
  76385. /**
  76386. * Gets the list of animatables currently running for this skeleton
  76387. * @returns an array of animatables
  76388. */
  76389. getAnimatables(): IAnimatable[];
  76390. /**
  76391. * Clone the current skeleton
  76392. * @param name defines the name of the new skeleton
  76393. * @param id defines the id of the new skeleton
  76394. * @returns the new skeleton
  76395. */
  76396. clone(name: string, id: string): Skeleton;
  76397. /**
  76398. * Enable animation blending for this skeleton
  76399. * @param blendingSpeed defines the blending speed to apply
  76400. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76401. */
  76402. enableBlending(blendingSpeed?: number): void;
  76403. /**
  76404. * Releases all resources associated with the current skeleton
  76405. */
  76406. dispose(): void;
  76407. /**
  76408. * Serialize the skeleton in a JSON object
  76409. * @returns a JSON object
  76410. */
  76411. serialize(): any;
  76412. /**
  76413. * Creates a new skeleton from serialized data
  76414. * @param parsedSkeleton defines the serialized data
  76415. * @param scene defines the hosting scene
  76416. * @returns a new skeleton
  76417. */
  76418. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  76419. /**
  76420. * Compute all node absolute transforms
  76421. * @param forceUpdate defines if computation must be done even if cache is up to date
  76422. */
  76423. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  76424. /**
  76425. * Gets the root pose matrix
  76426. * @returns a matrix
  76427. */
  76428. getPoseMatrix(): Nullable<Matrix>;
  76429. /**
  76430. * Sorts bones per internal index
  76431. */
  76432. sortBones(): void;
  76433. private _sortBones;
  76434. }
  76435. }
  76436. declare module BABYLON {
  76437. /**
  76438. * Class used to store bone information
  76439. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  76440. */
  76441. export class Bone extends Node {
  76442. /**
  76443. * defines the bone name
  76444. */
  76445. name: string;
  76446. private static _tmpVecs;
  76447. private static _tmpQuat;
  76448. private static _tmpMats;
  76449. /**
  76450. * Gets the list of child bones
  76451. */
  76452. children: Bone[];
  76453. /** Gets the animations associated with this bone */
  76454. animations: Animation[];
  76455. /**
  76456. * Gets or sets bone length
  76457. */
  76458. length: number;
  76459. /**
  76460. * @hidden Internal only
  76461. * Set this value to map this bone to a different index in the transform matrices
  76462. * Set this value to -1 to exclude the bone from the transform matrices
  76463. */
  76464. _index: Nullable<number>;
  76465. private _skeleton;
  76466. private _localMatrix;
  76467. private _restPose;
  76468. private _baseMatrix;
  76469. private _absoluteTransform;
  76470. private _invertedAbsoluteTransform;
  76471. private _parent;
  76472. private _scalingDeterminant;
  76473. private _worldTransform;
  76474. private _localScaling;
  76475. private _localRotation;
  76476. private _localPosition;
  76477. private _needToDecompose;
  76478. private _needToCompose;
  76479. /** @hidden */
  76480. _linkedTransformNode: Nullable<TransformNode>;
  76481. /** @hidden */
  76482. _waitingTransformNodeId: Nullable<string>;
  76483. /** @hidden */
  76484. /** @hidden */
  76485. _matrix: Matrix;
  76486. /**
  76487. * Create a new bone
  76488. * @param name defines the bone name
  76489. * @param skeleton defines the parent skeleton
  76490. * @param parentBone defines the parent (can be null if the bone is the root)
  76491. * @param localMatrix defines the local matrix
  76492. * @param restPose defines the rest pose matrix
  76493. * @param baseMatrix defines the base matrix
  76494. * @param index defines index of the bone in the hiearchy
  76495. */
  76496. constructor(
  76497. /**
  76498. * defines the bone name
  76499. */
  76500. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  76501. /**
  76502. * Gets the current object class name.
  76503. * @return the class name
  76504. */
  76505. getClassName(): string;
  76506. /**
  76507. * Gets the parent skeleton
  76508. * @returns a skeleton
  76509. */
  76510. getSkeleton(): Skeleton;
  76511. /**
  76512. * Gets parent bone
  76513. * @returns a bone or null if the bone is the root of the bone hierarchy
  76514. */
  76515. getParent(): Nullable<Bone>;
  76516. /**
  76517. * Returns an array containing the root bones
  76518. * @returns an array containing the root bones
  76519. */
  76520. getChildren(): Array<Bone>;
  76521. /**
  76522. * Sets the parent bone
  76523. * @param parent defines the parent (can be null if the bone is the root)
  76524. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  76525. */
  76526. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  76527. /**
  76528. * Gets the local matrix
  76529. * @returns a matrix
  76530. */
  76531. getLocalMatrix(): Matrix;
  76532. /**
  76533. * Gets the base matrix (initial matrix which remains unchanged)
  76534. * @returns a matrix
  76535. */
  76536. getBaseMatrix(): Matrix;
  76537. /**
  76538. * Gets the rest pose matrix
  76539. * @returns a matrix
  76540. */
  76541. getRestPose(): Matrix;
  76542. /**
  76543. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  76544. */
  76545. getWorldMatrix(): Matrix;
  76546. /**
  76547. * Sets the local matrix to rest pose matrix
  76548. */
  76549. returnToRest(): void;
  76550. /**
  76551. * Gets the inverse of the absolute transform matrix.
  76552. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  76553. * @returns a matrix
  76554. */
  76555. getInvertedAbsoluteTransform(): Matrix;
  76556. /**
  76557. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  76558. * @returns a matrix
  76559. */
  76560. getAbsoluteTransform(): Matrix;
  76561. /**
  76562. * Links with the given transform node.
  76563. * The local matrix of this bone is copied from the transform node every frame.
  76564. * @param transformNode defines the transform node to link to
  76565. */
  76566. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  76567. /** Gets or sets current position (in local space) */
  76568. position: Vector3;
  76569. /** Gets or sets current rotation (in local space) */
  76570. rotation: Vector3;
  76571. /** Gets or sets current rotation quaternion (in local space) */
  76572. rotationQuaternion: Quaternion;
  76573. /** Gets or sets current scaling (in local space) */
  76574. scaling: Vector3;
  76575. /**
  76576. * Gets the animation properties override
  76577. */
  76578. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  76579. private _decompose;
  76580. private _compose;
  76581. /**
  76582. * Update the base and local matrices
  76583. * @param matrix defines the new base or local matrix
  76584. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  76585. * @param updateLocalMatrix defines if the local matrix should be updated
  76586. */
  76587. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  76588. /** @hidden */
  76589. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  76590. /**
  76591. * Flag the bone as dirty (Forcing it to update everything)
  76592. */
  76593. markAsDirty(): void;
  76594. /** @hidden */
  76595. _markAsDirtyAndCompose(): void;
  76596. private _markAsDirtyAndDecompose;
  76597. /**
  76598. * Translate the bone in local or world space
  76599. * @param vec The amount to translate the bone
  76600. * @param space The space that the translation is in
  76601. * @param mesh The mesh that this bone is attached to. This is only used in world space
  76602. */
  76603. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  76604. /**
  76605. * Set the postion of the bone in local or world space
  76606. * @param position The position to set the bone
  76607. * @param space The space that the position is in
  76608. * @param mesh The mesh that this bone is attached to. This is only used in world space
  76609. */
  76610. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  76611. /**
  76612. * Set the absolute position of the bone (world space)
  76613. * @param position The position to set the bone
  76614. * @param mesh The mesh that this bone is attached to
  76615. */
  76616. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  76617. /**
  76618. * Scale the bone on the x, y and z axes (in local space)
  76619. * @param x The amount to scale the bone on the x axis
  76620. * @param y The amount to scale the bone on the y axis
  76621. * @param z The amount to scale the bone on the z axis
  76622. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  76623. */
  76624. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  76625. /**
  76626. * Set the bone scaling in local space
  76627. * @param scale defines the scaling vector
  76628. */
  76629. setScale(scale: Vector3): void;
  76630. /**
  76631. * Gets the current scaling in local space
  76632. * @returns the current scaling vector
  76633. */
  76634. getScale(): Vector3;
  76635. /**
  76636. * Gets the current scaling in local space and stores it in a target vector
  76637. * @param result defines the target vector
  76638. */
  76639. getScaleToRef(result: Vector3): void;
  76640. /**
  76641. * Set the yaw, pitch, and roll of the bone in local or world space
  76642. * @param yaw The rotation of the bone on the y axis
  76643. * @param pitch The rotation of the bone on the x axis
  76644. * @param roll The rotation of the bone on the z axis
  76645. * @param space The space that the axes of rotation are in
  76646. * @param mesh The mesh that this bone is attached to. This is only used in world space
  76647. */
  76648. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  76649. /**
  76650. * Add a rotation to the bone on an axis in local or world space
  76651. * @param axis The axis to rotate the bone on
  76652. * @param amount The amount to rotate the bone
  76653. * @param space The space that the axis is in
  76654. * @param mesh The mesh that this bone is attached to. This is only used in world space
  76655. */
  76656. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  76657. /**
  76658. * Set the rotation of the bone to a particular axis angle in local or world space
  76659. * @param axis The axis to rotate the bone on
  76660. * @param angle The angle that the bone should be rotated to
  76661. * @param space The space that the axis is in
  76662. * @param mesh The mesh that this bone is attached to. This is only used in world space
  76663. */
  76664. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  76665. /**
  76666. * Set the euler rotation of the bone in local of world space
  76667. * @param rotation The euler rotation that the bone should be set to
  76668. * @param space The space that the rotation is in
  76669. * @param mesh The mesh that this bone is attached to. This is only used in world space
  76670. */
  76671. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  76672. /**
  76673. * Set the quaternion rotation of the bone in local of world space
  76674. * @param quat The quaternion rotation that the bone should be set to
  76675. * @param space The space that the rotation is in
  76676. * @param mesh The mesh that this bone is attached to. This is only used in world space
  76677. */
  76678. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  76679. /**
  76680. * Set the rotation matrix of the bone in local of world space
  76681. * @param rotMat The rotation matrix that the bone should be set to
  76682. * @param space The space that the rotation is in
  76683. * @param mesh The mesh that this bone is attached to. This is only used in world space
  76684. */
  76685. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  76686. private _rotateWithMatrix;
  76687. private _getNegativeRotationToRef;
  76688. /**
  76689. * Get the position of the bone in local or world space
  76690. * @param space The space that the returned position is in
  76691. * @param mesh The mesh that this bone is attached to. This is only used in world space
  76692. * @returns The position of the bone
  76693. */
  76694. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  76695. /**
  76696. * Copy the position of the bone to a vector3 in local or world space
  76697. * @param space The space that the returned position is in
  76698. * @param mesh The mesh that this bone is attached to. This is only used in world space
  76699. * @param result The vector3 to copy the position to
  76700. */
  76701. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  76702. /**
  76703. * Get the absolute position of the bone (world space)
  76704. * @param mesh The mesh that this bone is attached to
  76705. * @returns The absolute position of the bone
  76706. */
  76707. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  76708. /**
  76709. * Copy the absolute position of the bone (world space) to the result param
  76710. * @param mesh The mesh that this bone is attached to
  76711. * @param result The vector3 to copy the absolute position to
  76712. */
  76713. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  76714. /**
  76715. * Compute the absolute transforms of this bone and its children
  76716. */
  76717. computeAbsoluteTransforms(): void;
  76718. /**
  76719. * Get the world direction from an axis that is in the local space of the bone
  76720. * @param localAxis The local direction that is used to compute the world direction
  76721. * @param mesh The mesh that this bone is attached to
  76722. * @returns The world direction
  76723. */
  76724. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  76725. /**
  76726. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  76727. * @param localAxis The local direction that is used to compute the world direction
  76728. * @param mesh The mesh that this bone is attached to
  76729. * @param result The vector3 that the world direction will be copied to
  76730. */
  76731. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  76732. /**
  76733. * Get the euler rotation of the bone in local or world space
  76734. * @param space The space that the rotation should be in
  76735. * @param mesh The mesh that this bone is attached to. This is only used in world space
  76736. * @returns The euler rotation
  76737. */
  76738. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  76739. /**
  76740. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  76741. * @param space The space that the rotation should be in
  76742. * @param mesh The mesh that this bone is attached to. This is only used in world space
  76743. * @param result The vector3 that the rotation should be copied to
  76744. */
  76745. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  76746. /**
  76747. * Get the quaternion rotation of the bone in either local or world space
  76748. * @param space The space that the rotation should be in
  76749. * @param mesh The mesh that this bone is attached to. This is only used in world space
  76750. * @returns The quaternion rotation
  76751. */
  76752. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  76753. /**
  76754. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  76755. * @param space The space that the rotation should be in
  76756. * @param mesh The mesh that this bone is attached to. This is only used in world space
  76757. * @param result The quaternion that the rotation should be copied to
  76758. */
  76759. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  76760. /**
  76761. * Get the rotation matrix of the bone in local or world space
  76762. * @param space The space that the rotation should be in
  76763. * @param mesh The mesh that this bone is attached to. This is only used in world space
  76764. * @returns The rotation matrix
  76765. */
  76766. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  76767. /**
  76768. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  76769. * @param space The space that the rotation should be in
  76770. * @param mesh The mesh that this bone is attached to. This is only used in world space
  76771. * @param result The quaternion that the rotation should be copied to
  76772. */
  76773. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  76774. /**
  76775. * Get the world position of a point that is in the local space of the bone
  76776. * @param position The local position
  76777. * @param mesh The mesh that this bone is attached to
  76778. * @returns The world position
  76779. */
  76780. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  76781. /**
  76782. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  76783. * @param position The local position
  76784. * @param mesh The mesh that this bone is attached to
  76785. * @param result The vector3 that the world position should be copied to
  76786. */
  76787. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  76788. /**
  76789. * Get the local position of a point that is in world space
  76790. * @param position The world position
  76791. * @param mesh The mesh that this bone is attached to
  76792. * @returns The local position
  76793. */
  76794. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  76795. /**
  76796. * Get the local position of a point that is in world space and copy it to the result param
  76797. * @param position The world position
  76798. * @param mesh The mesh that this bone is attached to
  76799. * @param result The vector3 that the local position should be copied to
  76800. */
  76801. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  76802. }
  76803. }
  76804. declare module BABYLON {
  76805. /**
  76806. * 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.
  76807. * @see https://doc.babylonjs.com/how_to/transformnode
  76808. */
  76809. export class TransformNode extends Node {
  76810. /**
  76811. * Object will not rotate to face the camera
  76812. */
  76813. static BILLBOARDMODE_NONE: number;
  76814. /**
  76815. * Object will rotate to face the camera but only on the x axis
  76816. */
  76817. static BILLBOARDMODE_X: number;
  76818. /**
  76819. * Object will rotate to face the camera but only on the y axis
  76820. */
  76821. static BILLBOARDMODE_Y: number;
  76822. /**
  76823. * Object will rotate to face the camera but only on the z axis
  76824. */
  76825. static BILLBOARDMODE_Z: number;
  76826. /**
  76827. * Object will rotate to face the camera
  76828. */
  76829. static BILLBOARDMODE_ALL: number;
  76830. private _forward;
  76831. private _forwardInverted;
  76832. private _up;
  76833. private _right;
  76834. private _rightInverted;
  76835. private _position;
  76836. private _rotation;
  76837. private _rotationQuaternion;
  76838. protected _scaling: Vector3;
  76839. protected _isDirty: boolean;
  76840. private _transformToBoneReferal;
  76841. private _billboardMode;
  76842. /**
  76843. * Gets or sets the billboard mode. Default is 0.
  76844. *
  76845. * | Value | Type | Description |
  76846. * | --- | --- | --- |
  76847. * | 0 | BILLBOARDMODE_NONE | |
  76848. * | 1 | BILLBOARDMODE_X | |
  76849. * | 2 | BILLBOARDMODE_Y | |
  76850. * | 4 | BILLBOARDMODE_Z | |
  76851. * | 7 | BILLBOARDMODE_ALL | |
  76852. *
  76853. */
  76854. billboardMode: number;
  76855. private _preserveParentRotationForBillboard;
  76856. /**
  76857. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  76858. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  76859. */
  76860. preserveParentRotationForBillboard: boolean;
  76861. /**
  76862. * 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
  76863. */
  76864. scalingDeterminant: number;
  76865. private _infiniteDistance;
  76866. /**
  76867. * Gets or sets the distance of the object to max, often used by skybox
  76868. */
  76869. infiniteDistance: boolean;
  76870. /**
  76871. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  76872. * By default the system will update normals to compensate
  76873. */
  76874. ignoreNonUniformScaling: boolean;
  76875. /**
  76876. * 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
  76877. */
  76878. reIntegrateRotationIntoRotationQuaternion: boolean;
  76879. /** @hidden */
  76880. _poseMatrix: Nullable<Matrix>;
  76881. /** @hidden */
  76882. _localMatrix: Matrix;
  76883. private _usePivotMatrix;
  76884. private _absolutePosition;
  76885. private _pivotMatrix;
  76886. private _pivotMatrixInverse;
  76887. protected _postMultiplyPivotMatrix: boolean;
  76888. protected _isWorldMatrixFrozen: boolean;
  76889. /** @hidden */
  76890. _indexInSceneTransformNodesArray: number;
  76891. /**
  76892. * An event triggered after the world matrix is updated
  76893. */
  76894. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  76895. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  76896. /**
  76897. * Gets a string identifying the name of the class
  76898. * @returns "TransformNode" string
  76899. */
  76900. getClassName(): string;
  76901. /**
  76902. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  76903. */
  76904. position: Vector3;
  76905. /**
  76906. * 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)).
  76907. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  76908. */
  76909. rotation: Vector3;
  76910. /**
  76911. * 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)).
  76912. */
  76913. scaling: Vector3;
  76914. /**
  76915. * 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).
  76916. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  76917. */
  76918. rotationQuaternion: Nullable<Quaternion>;
  76919. /**
  76920. * The forward direction of that transform in world space.
  76921. */
  76922. readonly forward: Vector3;
  76923. /**
  76924. * The up direction of that transform in world space.
  76925. */
  76926. readonly up: Vector3;
  76927. /**
  76928. * The right direction of that transform in world space.
  76929. */
  76930. readonly right: Vector3;
  76931. /**
  76932. * Copies the parameter passed Matrix into the mesh Pose matrix.
  76933. * @param matrix the matrix to copy the pose from
  76934. * @returns this TransformNode.
  76935. */
  76936. updatePoseMatrix(matrix: Matrix): TransformNode;
  76937. /**
  76938. * Returns the mesh Pose matrix.
  76939. * @returns the pose matrix
  76940. */
  76941. getPoseMatrix(): Matrix;
  76942. /** @hidden */
  76943. _isSynchronized(): boolean;
  76944. /** @hidden */
  76945. _initCache(): void;
  76946. /**
  76947. * Flag the transform node as dirty (Forcing it to update everything)
  76948. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  76949. * @returns this transform node
  76950. */
  76951. markAsDirty(property: string): TransformNode;
  76952. /**
  76953. * Returns the current mesh absolute position.
  76954. * Returns a Vector3.
  76955. */
  76956. readonly absolutePosition: Vector3;
  76957. /**
  76958. * Sets a new matrix to apply before all other transformation
  76959. * @param matrix defines the transform matrix
  76960. * @returns the current TransformNode
  76961. */
  76962. setPreTransformMatrix(matrix: Matrix): TransformNode;
  76963. /**
  76964. * Sets a new pivot matrix to the current node
  76965. * @param matrix defines the new pivot matrix to use
  76966. * @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
  76967. * @returns the current TransformNode
  76968. */
  76969. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  76970. /**
  76971. * Returns the mesh pivot matrix.
  76972. * Default : Identity.
  76973. * @returns the matrix
  76974. */
  76975. getPivotMatrix(): Matrix;
  76976. /**
  76977. * Prevents the World matrix to be computed any longer.
  76978. * @returns the TransformNode.
  76979. */
  76980. freezeWorldMatrix(): TransformNode;
  76981. /**
  76982. * Allows back the World matrix computation.
  76983. * @returns the TransformNode.
  76984. */
  76985. unfreezeWorldMatrix(): this;
  76986. /**
  76987. * True if the World matrix has been frozen.
  76988. */
  76989. readonly isWorldMatrixFrozen: boolean;
  76990. /**
  76991. * Retuns the mesh absolute position in the World.
  76992. * @returns a Vector3.
  76993. */
  76994. getAbsolutePosition(): Vector3;
  76995. /**
  76996. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  76997. * @param absolutePosition the absolute position to set
  76998. * @returns the TransformNode.
  76999. */
  77000. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  77001. /**
  77002. * Sets the mesh position in its local space.
  77003. * @param vector3 the position to set in localspace
  77004. * @returns the TransformNode.
  77005. */
  77006. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  77007. /**
  77008. * Returns the mesh position in the local space from the current World matrix values.
  77009. * @returns a new Vector3.
  77010. */
  77011. getPositionExpressedInLocalSpace(): Vector3;
  77012. /**
  77013. * Translates the mesh along the passed Vector3 in its local space.
  77014. * @param vector3 the distance to translate in localspace
  77015. * @returns the TransformNode.
  77016. */
  77017. locallyTranslate(vector3: Vector3): TransformNode;
  77018. private static _lookAtVectorCache;
  77019. /**
  77020. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  77021. * @param targetPoint the position (must be in same space as current mesh) to look at
  77022. * @param yawCor optional yaw (y-axis) correction in radians
  77023. * @param pitchCor optional pitch (x-axis) correction in radians
  77024. * @param rollCor optional roll (z-axis) correction in radians
  77025. * @param space the choosen space of the target
  77026. * @returns the TransformNode.
  77027. */
  77028. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  77029. /**
  77030. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  77031. * This Vector3 is expressed in the World space.
  77032. * @param localAxis axis to rotate
  77033. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  77034. */
  77035. getDirection(localAxis: Vector3): Vector3;
  77036. /**
  77037. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  77038. * localAxis is expressed in the mesh local space.
  77039. * result is computed in the Wordl space from the mesh World matrix.
  77040. * @param localAxis axis to rotate
  77041. * @param result the resulting transformnode
  77042. * @returns this TransformNode.
  77043. */
  77044. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  77045. /**
  77046. * Sets this transform node rotation to the given local axis.
  77047. * @param localAxis the axis in local space
  77048. * @param yawCor optional yaw (y-axis) correction in radians
  77049. * @param pitchCor optional pitch (x-axis) correction in radians
  77050. * @param rollCor optional roll (z-axis) correction in radians
  77051. * @returns this TransformNode
  77052. */
  77053. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  77054. /**
  77055. * Sets a new pivot point to the current node
  77056. * @param point defines the new pivot point to use
  77057. * @param space defines if the point is in world or local space (local by default)
  77058. * @returns the current TransformNode
  77059. */
  77060. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  77061. /**
  77062. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  77063. * @returns the pivot point
  77064. */
  77065. getPivotPoint(): Vector3;
  77066. /**
  77067. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  77068. * @param result the vector3 to store the result
  77069. * @returns this TransformNode.
  77070. */
  77071. getPivotPointToRef(result: Vector3): TransformNode;
  77072. /**
  77073. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  77074. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  77075. */
  77076. getAbsolutePivotPoint(): Vector3;
  77077. /**
  77078. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  77079. * @param result vector3 to store the result
  77080. * @returns this TransformNode.
  77081. */
  77082. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  77083. /**
  77084. * Defines the passed node as the parent of the current node.
  77085. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  77086. * @see https://doc.babylonjs.com/how_to/parenting
  77087. * @param node the node ot set as the parent
  77088. * @returns this TransformNode.
  77089. */
  77090. setParent(node: Nullable<Node>): TransformNode;
  77091. private _nonUniformScaling;
  77092. /**
  77093. * True if the scaling property of this object is non uniform eg. (1,2,1)
  77094. */
  77095. readonly nonUniformScaling: boolean;
  77096. /** @hidden */
  77097. _updateNonUniformScalingState(value: boolean): boolean;
  77098. /**
  77099. * Attach the current TransformNode to another TransformNode associated with a bone
  77100. * @param bone Bone affecting the TransformNode
  77101. * @param affectedTransformNode TransformNode associated with the bone
  77102. * @returns this object
  77103. */
  77104. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  77105. /**
  77106. * Detach the transform node if its associated with a bone
  77107. * @returns this object
  77108. */
  77109. detachFromBone(): TransformNode;
  77110. private static _rotationAxisCache;
  77111. /**
  77112. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  77113. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  77114. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  77115. * The passed axis is also normalized.
  77116. * @param axis the axis to rotate around
  77117. * @param amount the amount to rotate in radians
  77118. * @param space Space to rotate in (Default: local)
  77119. * @returns the TransformNode.
  77120. */
  77121. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  77122. /**
  77123. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  77124. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  77125. * The passed axis is also normalized. .
  77126. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  77127. * @param point the point to rotate around
  77128. * @param axis the axis to rotate around
  77129. * @param amount the amount to rotate in radians
  77130. * @returns the TransformNode
  77131. */
  77132. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  77133. /**
  77134. * Translates the mesh along the axis vector for the passed distance in the given space.
  77135. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  77136. * @param axis the axis to translate in
  77137. * @param distance the distance to translate
  77138. * @param space Space to rotate in (Default: local)
  77139. * @returns the TransformNode.
  77140. */
  77141. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  77142. /**
  77143. * Adds a rotation step to the mesh current rotation.
  77144. * x, y, z are Euler angles expressed in radians.
  77145. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  77146. * This means this rotation is made in the mesh local space only.
  77147. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  77148. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  77149. * ```javascript
  77150. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  77151. * ```
  77152. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  77153. * 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.
  77154. * @param x Rotation to add
  77155. * @param y Rotation to add
  77156. * @param z Rotation to add
  77157. * @returns the TransformNode.
  77158. */
  77159. addRotation(x: number, y: number, z: number): TransformNode;
  77160. /**
  77161. * @hidden
  77162. */
  77163. protected _getEffectiveParent(): Nullable<Node>;
  77164. /**
  77165. * Computes the world matrix of the node
  77166. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  77167. * @returns the world matrix
  77168. */
  77169. computeWorldMatrix(force?: boolean): Matrix;
  77170. protected _afterComputeWorldMatrix(): void;
  77171. /**
  77172. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  77173. * @param func callback function to add
  77174. *
  77175. * @returns the TransformNode.
  77176. */
  77177. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  77178. /**
  77179. * Removes a registered callback function.
  77180. * @param func callback function to remove
  77181. * @returns the TransformNode.
  77182. */
  77183. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  77184. /**
  77185. * Gets the position of the current mesh in camera space
  77186. * @param camera defines the camera to use
  77187. * @returns a position
  77188. */
  77189. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  77190. /**
  77191. * Returns the distance from the mesh to the active camera
  77192. * @param camera defines the camera to use
  77193. * @returns the distance
  77194. */
  77195. getDistanceToCamera(camera?: Nullable<Camera>): number;
  77196. /**
  77197. * Clone the current transform node
  77198. * @param name Name of the new clone
  77199. * @param newParent New parent for the clone
  77200. * @param doNotCloneChildren Do not clone children hierarchy
  77201. * @returns the new transform node
  77202. */
  77203. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  77204. /**
  77205. * Serializes the objects information.
  77206. * @param currentSerializationObject defines the object to serialize in
  77207. * @returns the serialized object
  77208. */
  77209. serialize(currentSerializationObject?: any): any;
  77210. /**
  77211. * Returns a new TransformNode object parsed from the source provided.
  77212. * @param parsedTransformNode is the source.
  77213. * @param scene the scne the object belongs to
  77214. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  77215. * @returns a new TransformNode object parsed from the source provided.
  77216. */
  77217. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  77218. /**
  77219. * Get all child-transformNodes of this node
  77220. * @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
  77221. * @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
  77222. * @returns an array of TransformNode
  77223. */
  77224. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  77225. /**
  77226. * Releases resources associated with this transform node.
  77227. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  77228. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  77229. */
  77230. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  77231. /**
  77232. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  77233. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  77234. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  77235. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  77236. * @returns the current mesh
  77237. */
  77238. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  77239. }
  77240. }
  77241. declare module BABYLON {
  77242. /**
  77243. * Defines the types of pose enabled controllers that are supported
  77244. */
  77245. export enum PoseEnabledControllerType {
  77246. /**
  77247. * HTC Vive
  77248. */
  77249. VIVE = 0,
  77250. /**
  77251. * Oculus Rift
  77252. */
  77253. OCULUS = 1,
  77254. /**
  77255. * Windows mixed reality
  77256. */
  77257. WINDOWS = 2,
  77258. /**
  77259. * Samsung gear VR
  77260. */
  77261. GEAR_VR = 3,
  77262. /**
  77263. * Google Daydream
  77264. */
  77265. DAYDREAM = 4,
  77266. /**
  77267. * Generic
  77268. */
  77269. GENERIC = 5
  77270. }
  77271. /**
  77272. * Defines the MutableGamepadButton interface for the state of a gamepad button
  77273. */
  77274. export interface MutableGamepadButton {
  77275. /**
  77276. * Value of the button/trigger
  77277. */
  77278. value: number;
  77279. /**
  77280. * If the button/trigger is currently touched
  77281. */
  77282. touched: boolean;
  77283. /**
  77284. * If the button/trigger is currently pressed
  77285. */
  77286. pressed: boolean;
  77287. }
  77288. /**
  77289. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  77290. * @hidden
  77291. */
  77292. export interface ExtendedGamepadButton extends GamepadButton {
  77293. /**
  77294. * If the button/trigger is currently pressed
  77295. */
  77296. readonly pressed: boolean;
  77297. /**
  77298. * If the button/trigger is currently touched
  77299. */
  77300. readonly touched: boolean;
  77301. /**
  77302. * Value of the button/trigger
  77303. */
  77304. readonly value: number;
  77305. }
  77306. /** @hidden */
  77307. export interface _GamePadFactory {
  77308. /**
  77309. * Returns wether or not the current gamepad can be created for this type of controller.
  77310. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  77311. * @returns true if it can be created, otherwise false
  77312. */
  77313. canCreate(gamepadInfo: any): boolean;
  77314. /**
  77315. * Creates a new instance of the Gamepad.
  77316. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  77317. * @returns the new gamepad instance
  77318. */
  77319. create(gamepadInfo: any): Gamepad;
  77320. }
  77321. /**
  77322. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  77323. */
  77324. export class PoseEnabledControllerHelper {
  77325. /** @hidden */
  77326. static _ControllerFactories: _GamePadFactory[];
  77327. /** @hidden */
  77328. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  77329. /**
  77330. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  77331. * @param vrGamepad the gamepad to initialized
  77332. * @returns a vr controller of the type the gamepad identified as
  77333. */
  77334. static InitiateController(vrGamepad: any): Gamepad;
  77335. }
  77336. /**
  77337. * Defines the PoseEnabledController object that contains state of a vr capable controller
  77338. */
  77339. export class PoseEnabledController extends Gamepad implements PoseControlled {
  77340. /**
  77341. * If the controller is used in a webXR session
  77342. */
  77343. isXR: boolean;
  77344. private _deviceRoomPosition;
  77345. private _deviceRoomRotationQuaternion;
  77346. /**
  77347. * The device position in babylon space
  77348. */
  77349. devicePosition: Vector3;
  77350. /**
  77351. * The device rotation in babylon space
  77352. */
  77353. deviceRotationQuaternion: Quaternion;
  77354. /**
  77355. * The scale factor of the device in babylon space
  77356. */
  77357. deviceScaleFactor: number;
  77358. /**
  77359. * (Likely devicePosition should be used instead) The device position in its room space
  77360. */
  77361. position: Vector3;
  77362. /**
  77363. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  77364. */
  77365. rotationQuaternion: Quaternion;
  77366. /**
  77367. * The type of controller (Eg. Windows mixed reality)
  77368. */
  77369. controllerType: PoseEnabledControllerType;
  77370. protected _calculatedPosition: Vector3;
  77371. private _calculatedRotation;
  77372. /**
  77373. * The raw pose from the device
  77374. */
  77375. rawPose: DevicePose;
  77376. private _trackPosition;
  77377. private _maxRotationDistFromHeadset;
  77378. private _draggedRoomRotation;
  77379. /**
  77380. * @hidden
  77381. */
  77382. _disableTrackPosition(fixedPosition: Vector3): void;
  77383. /**
  77384. * Internal, the mesh attached to the controller
  77385. * @hidden
  77386. */
  77387. _mesh: Nullable<AbstractMesh>;
  77388. private _poseControlledCamera;
  77389. private _leftHandSystemQuaternion;
  77390. /**
  77391. * Internal, matrix used to convert room space to babylon space
  77392. * @hidden
  77393. */
  77394. _deviceToWorld: Matrix;
  77395. /**
  77396. * Node to be used when casting a ray from the controller
  77397. * @hidden
  77398. */
  77399. _pointingPoseNode: Nullable<TransformNode>;
  77400. /**
  77401. * Name of the child mesh that can be used to cast a ray from the controller
  77402. */
  77403. static readonly POINTING_POSE: string;
  77404. /**
  77405. * Creates a new PoseEnabledController from a gamepad
  77406. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  77407. */
  77408. constructor(browserGamepad: any);
  77409. private _workingMatrix;
  77410. /**
  77411. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  77412. */
  77413. update(): void;
  77414. /**
  77415. * Updates only the pose device and mesh without doing any button event checking
  77416. */
  77417. protected _updatePoseAndMesh(): void;
  77418. /**
  77419. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  77420. * @param poseData raw pose fromthe device
  77421. */
  77422. updateFromDevice(poseData: DevicePose): void;
  77423. /**
  77424. * @hidden
  77425. */
  77426. _meshAttachedObservable: Observable<AbstractMesh>;
  77427. /**
  77428. * Attaches a mesh to the controller
  77429. * @param mesh the mesh to be attached
  77430. */
  77431. attachToMesh(mesh: AbstractMesh): void;
  77432. /**
  77433. * Attaches the controllers mesh to a camera
  77434. * @param camera the camera the mesh should be attached to
  77435. */
  77436. attachToPoseControlledCamera(camera: TargetCamera): void;
  77437. /**
  77438. * Disposes of the controller
  77439. */
  77440. dispose(): void;
  77441. /**
  77442. * The mesh that is attached to the controller
  77443. */
  77444. readonly mesh: Nullable<AbstractMesh>;
  77445. /**
  77446. * Gets the ray of the controller in the direction the controller is pointing
  77447. * @param length the length the resulting ray should be
  77448. * @returns a ray in the direction the controller is pointing
  77449. */
  77450. getForwardRay(length?: number): Ray;
  77451. }
  77452. }
  77453. declare module BABYLON {
  77454. /**
  77455. * Defines the WebVRController object that represents controllers tracked in 3D space
  77456. */
  77457. export abstract class WebVRController extends PoseEnabledController {
  77458. /**
  77459. * Internal, the default controller model for the controller
  77460. */
  77461. protected _defaultModel: AbstractMesh;
  77462. /**
  77463. * Fired when the trigger state has changed
  77464. */
  77465. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  77466. /**
  77467. * Fired when the main button state has changed
  77468. */
  77469. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  77470. /**
  77471. * Fired when the secondary button state has changed
  77472. */
  77473. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  77474. /**
  77475. * Fired when the pad state has changed
  77476. */
  77477. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  77478. /**
  77479. * Fired when controllers stick values have changed
  77480. */
  77481. onPadValuesChangedObservable: Observable<StickValues>;
  77482. /**
  77483. * Array of button availible on the controller
  77484. */
  77485. protected _buttons: Array<MutableGamepadButton>;
  77486. private _onButtonStateChange;
  77487. /**
  77488. * Fired when a controller button's state has changed
  77489. * @param callback the callback containing the button that was modified
  77490. */
  77491. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  77492. /**
  77493. * X and Y axis corresponding to the controllers joystick
  77494. */
  77495. pad: StickValues;
  77496. /**
  77497. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  77498. */
  77499. hand: string;
  77500. /**
  77501. * The default controller model for the controller
  77502. */
  77503. readonly defaultModel: AbstractMesh;
  77504. /**
  77505. * Creates a new WebVRController from a gamepad
  77506. * @param vrGamepad the gamepad that the WebVRController should be created from
  77507. */
  77508. constructor(vrGamepad: any);
  77509. /**
  77510. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  77511. */
  77512. update(): void;
  77513. /**
  77514. * Function to be called when a button is modified
  77515. */
  77516. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  77517. /**
  77518. * Loads a mesh and attaches it to the controller
  77519. * @param scene the scene the mesh should be added to
  77520. * @param meshLoaded callback for when the mesh has been loaded
  77521. */
  77522. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  77523. private _setButtonValue;
  77524. private _changes;
  77525. private _checkChanges;
  77526. /**
  77527. * Disposes of th webVRCOntroller
  77528. */
  77529. dispose(): void;
  77530. }
  77531. }
  77532. declare module BABYLON {
  77533. /**
  77534. * The HemisphericLight simulates the ambient environment light,
  77535. * so the passed direction is the light reflection direction, not the incoming direction.
  77536. */
  77537. export class HemisphericLight extends Light {
  77538. /**
  77539. * The groundColor is the light in the opposite direction to the one specified during creation.
  77540. * 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.
  77541. */
  77542. groundColor: Color3;
  77543. /**
  77544. * The light reflection direction, not the incoming direction.
  77545. */
  77546. direction: Vector3;
  77547. /**
  77548. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  77549. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  77550. * The HemisphericLight can't cast shadows.
  77551. * Documentation : https://doc.babylonjs.com/babylon101/lights
  77552. * @param name The friendly name of the light
  77553. * @param direction The direction of the light reflection
  77554. * @param scene The scene the light belongs to
  77555. */
  77556. constructor(name: string, direction: Vector3, scene: Scene);
  77557. protected _buildUniformLayout(): void;
  77558. /**
  77559. * Returns the string "HemisphericLight".
  77560. * @return The class name
  77561. */
  77562. getClassName(): string;
  77563. /**
  77564. * Sets the HemisphericLight direction towards the passed target (Vector3).
  77565. * Returns the updated direction.
  77566. * @param target The target the direction should point to
  77567. * @return The computed direction
  77568. */
  77569. setDirectionToTarget(target: Vector3): Vector3;
  77570. /**
  77571. * Returns the shadow generator associated to the light.
  77572. * @returns Always null for hemispheric lights because it does not support shadows.
  77573. */
  77574. getShadowGenerator(): Nullable<IShadowGenerator>;
  77575. /**
  77576. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  77577. * @param effect The effect to update
  77578. * @param lightIndex The index of the light in the effect to update
  77579. * @returns The hemispheric light
  77580. */
  77581. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  77582. /**
  77583. * Computes the world matrix of the node
  77584. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  77585. * @param useWasUpdatedFlag defines a reserved property
  77586. * @returns the world matrix
  77587. */
  77588. computeWorldMatrix(): Matrix;
  77589. /**
  77590. * Returns the integer 3.
  77591. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  77592. */
  77593. getTypeID(): number;
  77594. /**
  77595. * Prepares the list of defines specific to the light type.
  77596. * @param defines the list of defines
  77597. * @param lightIndex defines the index of the light for the effect
  77598. */
  77599. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  77600. }
  77601. }
  77602. declare module BABYLON {
  77603. /** @hidden */
  77604. export var vrMultiviewToSingleviewPixelShader: {
  77605. name: string;
  77606. shader: string;
  77607. };
  77608. }
  77609. declare module BABYLON {
  77610. /**
  77611. * Renders to multiple views with a single draw call
  77612. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  77613. */
  77614. export class MultiviewRenderTarget extends RenderTargetTexture {
  77615. /**
  77616. * Creates a multiview render target
  77617. * @param scene scene used with the render target
  77618. * @param size the size of the render target (used for each view)
  77619. */
  77620. constructor(scene: Scene, size?: number | {
  77621. width: number;
  77622. height: number;
  77623. } | {
  77624. ratio: number;
  77625. });
  77626. /**
  77627. * @hidden
  77628. * @param faceIndex the face index, if its a cube texture
  77629. */
  77630. _bindFrameBuffer(faceIndex?: number): void;
  77631. /**
  77632. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  77633. * @returns the view count
  77634. */
  77635. getViewCount(): number;
  77636. }
  77637. }
  77638. declare module BABYLON {
  77639. /**
  77640. * Reprasents a camera frustum
  77641. */
  77642. export class Frustum {
  77643. /**
  77644. * Gets the planes representing the frustum
  77645. * @param transform matrix to be applied to the returned planes
  77646. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  77647. */
  77648. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  77649. /**
  77650. * Gets the near frustum plane transformed by the transform matrix
  77651. * @param transform transformation matrix to be applied to the resulting frustum plane
  77652. * @param frustumPlane the resuling frustum plane
  77653. */
  77654. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  77655. /**
  77656. * Gets the far frustum plane transformed by the transform matrix
  77657. * @param transform transformation matrix to be applied to the resulting frustum plane
  77658. * @param frustumPlane the resuling frustum plane
  77659. */
  77660. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  77661. /**
  77662. * Gets the left frustum plane transformed by the transform matrix
  77663. * @param transform transformation matrix to be applied to the resulting frustum plane
  77664. * @param frustumPlane the resuling frustum plane
  77665. */
  77666. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  77667. /**
  77668. * Gets the right frustum plane transformed by the transform matrix
  77669. * @param transform transformation matrix to be applied to the resulting frustum plane
  77670. * @param frustumPlane the resuling frustum plane
  77671. */
  77672. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  77673. /**
  77674. * Gets the top frustum plane transformed by the transform matrix
  77675. * @param transform transformation matrix to be applied to the resulting frustum plane
  77676. * @param frustumPlane the resuling frustum plane
  77677. */
  77678. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  77679. /**
  77680. * Gets the bottom frustum plane transformed by the transform matrix
  77681. * @param transform transformation matrix to be applied to the resulting frustum plane
  77682. * @param frustumPlane the resuling frustum plane
  77683. */
  77684. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  77685. /**
  77686. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  77687. * @param transform transformation matrix to be applied to the resulting frustum planes
  77688. * @param frustumPlanes the resuling frustum planes
  77689. */
  77690. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  77691. }
  77692. }
  77693. declare module BABYLON {
  77694. interface Engine {
  77695. /**
  77696. * Creates a new multiview render target
  77697. * @param width defines the width of the texture
  77698. * @param height defines the height of the texture
  77699. * @returns the created multiview texture
  77700. */
  77701. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  77702. /**
  77703. * Binds a multiview framebuffer to be drawn to
  77704. * @param multiviewTexture texture to bind
  77705. */
  77706. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  77707. }
  77708. interface Camera {
  77709. /**
  77710. * @hidden
  77711. * 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)
  77712. */
  77713. _useMultiviewToSingleView: boolean;
  77714. /**
  77715. * @hidden
  77716. * 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)
  77717. */
  77718. _multiviewTexture: Nullable<RenderTargetTexture>;
  77719. /**
  77720. * @hidden
  77721. * ensures the multiview texture of the camera exists and has the specified width/height
  77722. * @param width height to set on the multiview texture
  77723. * @param height width to set on the multiview texture
  77724. */
  77725. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  77726. }
  77727. interface Scene {
  77728. /** @hidden */
  77729. _transformMatrixR: Matrix;
  77730. /** @hidden */
  77731. _multiviewSceneUbo: Nullable<UniformBuffer>;
  77732. /** @hidden */
  77733. _createMultiviewUbo(): void;
  77734. /** @hidden */
  77735. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  77736. /** @hidden */
  77737. _renderMultiviewToSingleView(camera: Camera): void;
  77738. }
  77739. }
  77740. declare module BABYLON {
  77741. /**
  77742. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  77743. * This will not be used for webXR as it supports displaying texture arrays directly
  77744. */
  77745. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  77746. /**
  77747. * Initializes a VRMultiviewToSingleview
  77748. * @param name name of the post process
  77749. * @param camera camera to be applied to
  77750. * @param scaleFactor scaling factor to the size of the output texture
  77751. */
  77752. constructor(name: string, camera: Camera, scaleFactor: number);
  77753. }
  77754. }
  77755. declare module BABYLON {
  77756. interface Engine {
  77757. /** @hidden */
  77758. _vrDisplay: any;
  77759. /** @hidden */
  77760. _vrSupported: boolean;
  77761. /** @hidden */
  77762. _oldSize: Size;
  77763. /** @hidden */
  77764. _oldHardwareScaleFactor: number;
  77765. /** @hidden */
  77766. _vrExclusivePointerMode: boolean;
  77767. /** @hidden */
  77768. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  77769. /** @hidden */
  77770. _onVRDisplayPointerRestricted: () => void;
  77771. /** @hidden */
  77772. _onVRDisplayPointerUnrestricted: () => void;
  77773. /** @hidden */
  77774. _onVrDisplayConnect: Nullable<(display: any) => void>;
  77775. /** @hidden */
  77776. _onVrDisplayDisconnect: Nullable<() => void>;
  77777. /** @hidden */
  77778. _onVrDisplayPresentChange: Nullable<() => void>;
  77779. /**
  77780. * Observable signaled when VR display mode changes
  77781. */
  77782. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  77783. /**
  77784. * Observable signaled when VR request present is complete
  77785. */
  77786. onVRRequestPresentComplete: Observable<boolean>;
  77787. /**
  77788. * Observable signaled when VR request present starts
  77789. */
  77790. onVRRequestPresentStart: Observable<Engine>;
  77791. /**
  77792. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  77793. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  77794. */
  77795. isInVRExclusivePointerMode: boolean;
  77796. /**
  77797. * Gets a boolean indicating if a webVR device was detected
  77798. * @returns true if a webVR device was detected
  77799. */
  77800. isVRDevicePresent(): boolean;
  77801. /**
  77802. * Gets the current webVR device
  77803. * @returns the current webVR device (or null)
  77804. */
  77805. getVRDevice(): any;
  77806. /**
  77807. * Initializes a webVR display and starts listening to display change events
  77808. * The onVRDisplayChangedObservable will be notified upon these changes
  77809. * @returns A promise containing a VRDisplay and if vr is supported
  77810. */
  77811. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  77812. /** @hidden */
  77813. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  77814. /**
  77815. * Call this function to switch to webVR mode
  77816. * Will do nothing if webVR is not supported or if there is no webVR device
  77817. * @see http://doc.babylonjs.com/how_to/webvr_camera
  77818. */
  77819. enableVR(): void;
  77820. /** @hidden */
  77821. _onVRFullScreenTriggered(): void;
  77822. }
  77823. }
  77824. declare module BABYLON {
  77825. /**
  77826. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  77827. * IMPORTANT!! The data is right-hand data.
  77828. * @export
  77829. * @interface DevicePose
  77830. */
  77831. export interface DevicePose {
  77832. /**
  77833. * The position of the device, values in array are [x,y,z].
  77834. */
  77835. readonly position: Nullable<Float32Array>;
  77836. /**
  77837. * The linearVelocity of the device, values in array are [x,y,z].
  77838. */
  77839. readonly linearVelocity: Nullable<Float32Array>;
  77840. /**
  77841. * The linearAcceleration of the device, values in array are [x,y,z].
  77842. */
  77843. readonly linearAcceleration: Nullable<Float32Array>;
  77844. /**
  77845. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  77846. */
  77847. readonly orientation: Nullable<Float32Array>;
  77848. /**
  77849. * The angularVelocity of the device, values in array are [x,y,z].
  77850. */
  77851. readonly angularVelocity: Nullable<Float32Array>;
  77852. /**
  77853. * The angularAcceleration of the device, values in array are [x,y,z].
  77854. */
  77855. readonly angularAcceleration: Nullable<Float32Array>;
  77856. }
  77857. /**
  77858. * Interface representing a pose controlled object in Babylon.
  77859. * A pose controlled object has both regular pose values as well as pose values
  77860. * from an external device such as a VR head mounted display
  77861. */
  77862. export interface PoseControlled {
  77863. /**
  77864. * The position of the object in babylon space.
  77865. */
  77866. position: Vector3;
  77867. /**
  77868. * The rotation quaternion of the object in babylon space.
  77869. */
  77870. rotationQuaternion: Quaternion;
  77871. /**
  77872. * The position of the device in babylon space.
  77873. */
  77874. devicePosition?: Vector3;
  77875. /**
  77876. * The rotation quaternion of the device in babylon space.
  77877. */
  77878. deviceRotationQuaternion: Quaternion;
  77879. /**
  77880. * The raw pose coming from the device.
  77881. */
  77882. rawPose: Nullable<DevicePose>;
  77883. /**
  77884. * The scale of the device to be used when translating from device space to babylon space.
  77885. */
  77886. deviceScaleFactor: number;
  77887. /**
  77888. * Updates the poseControlled values based on the input device pose.
  77889. * @param poseData the pose data to update the object with
  77890. */
  77891. updateFromDevice(poseData: DevicePose): void;
  77892. }
  77893. /**
  77894. * Set of options to customize the webVRCamera
  77895. */
  77896. export interface WebVROptions {
  77897. /**
  77898. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  77899. */
  77900. trackPosition?: boolean;
  77901. /**
  77902. * Sets the scale of the vrDevice in babylon space. (default: 1)
  77903. */
  77904. positionScale?: number;
  77905. /**
  77906. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  77907. */
  77908. displayName?: string;
  77909. /**
  77910. * Should the native controller meshes be initialized. (default: true)
  77911. */
  77912. controllerMeshes?: boolean;
  77913. /**
  77914. * Creating a default HemiLight only on controllers. (default: true)
  77915. */
  77916. defaultLightingOnControllers?: boolean;
  77917. /**
  77918. * If you don't want to use the default VR button of the helper. (default: false)
  77919. */
  77920. useCustomVRButton?: boolean;
  77921. /**
  77922. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  77923. */
  77924. customVRButton?: HTMLButtonElement;
  77925. /**
  77926. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  77927. */
  77928. rayLength?: number;
  77929. /**
  77930. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  77931. */
  77932. defaultHeight?: number;
  77933. /**
  77934. * If multiview should be used if availible (default: false)
  77935. */
  77936. useMultiview?: boolean;
  77937. }
  77938. /**
  77939. * This represents a WebVR camera.
  77940. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  77941. * @example http://doc.babylonjs.com/how_to/webvr_camera
  77942. */
  77943. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  77944. private webVROptions;
  77945. /**
  77946. * @hidden
  77947. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  77948. */
  77949. _vrDevice: any;
  77950. /**
  77951. * The rawPose of the vrDevice.
  77952. */
  77953. rawPose: Nullable<DevicePose>;
  77954. private _onVREnabled;
  77955. private _specsVersion;
  77956. private _attached;
  77957. private _frameData;
  77958. protected _descendants: Array<Node>;
  77959. private _deviceRoomPosition;
  77960. /** @hidden */
  77961. _deviceRoomRotationQuaternion: Quaternion;
  77962. private _standingMatrix;
  77963. /**
  77964. * Represents device position in babylon space.
  77965. */
  77966. devicePosition: Vector3;
  77967. /**
  77968. * Represents device rotation in babylon space.
  77969. */
  77970. deviceRotationQuaternion: Quaternion;
  77971. /**
  77972. * The scale of the device to be used when translating from device space to babylon space.
  77973. */
  77974. deviceScaleFactor: number;
  77975. private _deviceToWorld;
  77976. private _worldToDevice;
  77977. /**
  77978. * References to the webVR controllers for the vrDevice.
  77979. */
  77980. controllers: Array<WebVRController>;
  77981. /**
  77982. * Emits an event when a controller is attached.
  77983. */
  77984. onControllersAttachedObservable: Observable<WebVRController[]>;
  77985. /**
  77986. * Emits an event when a controller's mesh has been loaded;
  77987. */
  77988. onControllerMeshLoadedObservable: Observable<WebVRController>;
  77989. /**
  77990. * Emits an event when the HMD's pose has been updated.
  77991. */
  77992. onPoseUpdatedFromDeviceObservable: Observable<any>;
  77993. private _poseSet;
  77994. /**
  77995. * If the rig cameras be used as parent instead of this camera.
  77996. */
  77997. rigParenting: boolean;
  77998. private _lightOnControllers;
  77999. private _defaultHeight?;
  78000. /**
  78001. * Instantiates a WebVRFreeCamera.
  78002. * @param name The name of the WebVRFreeCamera
  78003. * @param position The starting anchor position for the camera
  78004. * @param scene The scene the camera belongs to
  78005. * @param webVROptions a set of customizable options for the webVRCamera
  78006. */
  78007. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  78008. /**
  78009. * Gets the device distance from the ground in meters.
  78010. * @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.
  78011. */
  78012. deviceDistanceToRoomGround(): number;
  78013. /**
  78014. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  78015. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  78016. */
  78017. useStandingMatrix(callback?: (bool: boolean) => void): void;
  78018. /**
  78019. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  78020. * @returns A promise with a boolean set to if the standing matrix is supported.
  78021. */
  78022. useStandingMatrixAsync(): Promise<boolean>;
  78023. /**
  78024. * Disposes the camera
  78025. */
  78026. dispose(): void;
  78027. /**
  78028. * Gets a vrController by name.
  78029. * @param name The name of the controller to retreive
  78030. * @returns the controller matching the name specified or null if not found
  78031. */
  78032. getControllerByName(name: string): Nullable<WebVRController>;
  78033. private _leftController;
  78034. /**
  78035. * The controller corresponding to the users left hand.
  78036. */
  78037. readonly leftController: Nullable<WebVRController>;
  78038. private _rightController;
  78039. /**
  78040. * The controller corresponding to the users right hand.
  78041. */
  78042. readonly rightController: Nullable<WebVRController>;
  78043. /**
  78044. * Casts a ray forward from the vrCamera's gaze.
  78045. * @param length Length of the ray (default: 100)
  78046. * @returns the ray corresponding to the gaze
  78047. */
  78048. getForwardRay(length?: number): Ray;
  78049. /**
  78050. * @hidden
  78051. * Updates the camera based on device's frame data
  78052. */
  78053. _checkInputs(): void;
  78054. /**
  78055. * Updates the poseControlled values based on the input device pose.
  78056. * @param poseData Pose coming from the device
  78057. */
  78058. updateFromDevice(poseData: DevicePose): void;
  78059. private _htmlElementAttached;
  78060. private _detachIfAttached;
  78061. /**
  78062. * WebVR's attach control will start broadcasting frames to the device.
  78063. * Note that in certain browsers (chrome for example) this function must be called
  78064. * within a user-interaction callback. Example:
  78065. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  78066. *
  78067. * @param element html element to attach the vrDevice to
  78068. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  78069. */
  78070. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78071. /**
  78072. * Detaches the camera from the html element and disables VR
  78073. *
  78074. * @param element html element to detach from
  78075. */
  78076. detachControl(element: HTMLElement): void;
  78077. /**
  78078. * @returns the name of this class
  78079. */
  78080. getClassName(): string;
  78081. /**
  78082. * Calls resetPose on the vrDisplay
  78083. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  78084. */
  78085. resetToCurrentRotation(): void;
  78086. /**
  78087. * @hidden
  78088. * Updates the rig cameras (left and right eye)
  78089. */
  78090. _updateRigCameras(): void;
  78091. private _workingVector;
  78092. private _oneVector;
  78093. private _workingMatrix;
  78094. private updateCacheCalled;
  78095. private _correctPositionIfNotTrackPosition;
  78096. /**
  78097. * @hidden
  78098. * Updates the cached values of the camera
  78099. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  78100. */
  78101. _updateCache(ignoreParentClass?: boolean): void;
  78102. /**
  78103. * @hidden
  78104. * Get current device position in babylon world
  78105. */
  78106. _computeDevicePosition(): void;
  78107. /**
  78108. * Updates the current device position and rotation in the babylon world
  78109. */
  78110. update(): void;
  78111. /**
  78112. * @hidden
  78113. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  78114. * @returns an identity matrix
  78115. */
  78116. _getViewMatrix(): Matrix;
  78117. private _tmpMatrix;
  78118. /**
  78119. * This function is called by the two RIG cameras.
  78120. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  78121. * @hidden
  78122. */
  78123. _getWebVRViewMatrix(): Matrix;
  78124. /** @hidden */
  78125. _getWebVRProjectionMatrix(): Matrix;
  78126. private _onGamepadConnectedObserver;
  78127. private _onGamepadDisconnectedObserver;
  78128. private _updateCacheWhenTrackingDisabledObserver;
  78129. /**
  78130. * Initializes the controllers and their meshes
  78131. */
  78132. initControllers(): void;
  78133. }
  78134. }
  78135. declare module BABYLON {
  78136. /**
  78137. * Size options for a post process
  78138. */
  78139. export type PostProcessOptions = {
  78140. width: number;
  78141. height: number;
  78142. };
  78143. /**
  78144. * PostProcess can be used to apply a shader to a texture after it has been rendered
  78145. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  78146. */
  78147. export class PostProcess {
  78148. /** Name of the PostProcess. */
  78149. name: string;
  78150. /**
  78151. * Gets or sets the unique id of the post process
  78152. */
  78153. uniqueId: number;
  78154. /**
  78155. * Width of the texture to apply the post process on
  78156. */
  78157. width: number;
  78158. /**
  78159. * Height of the texture to apply the post process on
  78160. */
  78161. height: number;
  78162. /**
  78163. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  78164. * @hidden
  78165. */
  78166. _outputTexture: Nullable<InternalTexture>;
  78167. /**
  78168. * Sampling mode used by the shader
  78169. * See https://doc.babylonjs.com/classes/3.1/texture
  78170. */
  78171. renderTargetSamplingMode: number;
  78172. /**
  78173. * Clear color to use when screen clearing
  78174. */
  78175. clearColor: Color4;
  78176. /**
  78177. * If the buffer needs to be cleared before applying the post process. (default: true)
  78178. * Should be set to false if shader will overwrite all previous pixels.
  78179. */
  78180. autoClear: boolean;
  78181. /**
  78182. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  78183. */
  78184. alphaMode: number;
  78185. /**
  78186. * Sets the setAlphaBlendConstants of the babylon engine
  78187. */
  78188. alphaConstants: Color4;
  78189. /**
  78190. * Animations to be used for the post processing
  78191. */
  78192. animations: Animation[];
  78193. /**
  78194. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  78195. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  78196. */
  78197. enablePixelPerfectMode: boolean;
  78198. /**
  78199. * Force the postprocess to be applied without taking in account viewport
  78200. */
  78201. forceFullscreenViewport: boolean;
  78202. /**
  78203. * List of inspectable custom properties (used by the Inspector)
  78204. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78205. */
  78206. inspectableCustomProperties: IInspectable[];
  78207. /**
  78208. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  78209. *
  78210. * | Value | Type | Description |
  78211. * | ----- | ----------------------------------- | ----------- |
  78212. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  78213. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  78214. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  78215. *
  78216. */
  78217. scaleMode: number;
  78218. /**
  78219. * Force textures to be a power of two (default: false)
  78220. */
  78221. alwaysForcePOT: boolean;
  78222. private _samples;
  78223. /**
  78224. * Number of sample textures (default: 1)
  78225. */
  78226. samples: number;
  78227. /**
  78228. * Modify the scale of the post process to be the same as the viewport (default: false)
  78229. */
  78230. adaptScaleToCurrentViewport: boolean;
  78231. private _camera;
  78232. private _scene;
  78233. private _engine;
  78234. private _options;
  78235. private _reusable;
  78236. private _textureType;
  78237. /**
  78238. * Smart array of input and output textures for the post process.
  78239. * @hidden
  78240. */
  78241. _textures: SmartArray<InternalTexture>;
  78242. /**
  78243. * The index in _textures that corresponds to the output texture.
  78244. * @hidden
  78245. */
  78246. _currentRenderTextureInd: number;
  78247. private _effect;
  78248. private _samplers;
  78249. private _fragmentUrl;
  78250. private _vertexUrl;
  78251. private _parameters;
  78252. private _scaleRatio;
  78253. protected _indexParameters: any;
  78254. private _shareOutputWithPostProcess;
  78255. private _texelSize;
  78256. private _forcedOutputTexture;
  78257. /**
  78258. * Returns the fragment url or shader name used in the post process.
  78259. * @returns the fragment url or name in the shader store.
  78260. */
  78261. getEffectName(): string;
  78262. /**
  78263. * An event triggered when the postprocess is activated.
  78264. */
  78265. onActivateObservable: Observable<Camera>;
  78266. private _onActivateObserver;
  78267. /**
  78268. * A function that is added to the onActivateObservable
  78269. */
  78270. onActivate: Nullable<(camera: Camera) => void>;
  78271. /**
  78272. * An event triggered when the postprocess changes its size.
  78273. */
  78274. onSizeChangedObservable: Observable<PostProcess>;
  78275. private _onSizeChangedObserver;
  78276. /**
  78277. * A function that is added to the onSizeChangedObservable
  78278. */
  78279. onSizeChanged: (postProcess: PostProcess) => void;
  78280. /**
  78281. * An event triggered when the postprocess applies its effect.
  78282. */
  78283. onApplyObservable: Observable<Effect>;
  78284. private _onApplyObserver;
  78285. /**
  78286. * A function that is added to the onApplyObservable
  78287. */
  78288. onApply: (effect: Effect) => void;
  78289. /**
  78290. * An event triggered before rendering the postprocess
  78291. */
  78292. onBeforeRenderObservable: Observable<Effect>;
  78293. private _onBeforeRenderObserver;
  78294. /**
  78295. * A function that is added to the onBeforeRenderObservable
  78296. */
  78297. onBeforeRender: (effect: Effect) => void;
  78298. /**
  78299. * An event triggered after rendering the postprocess
  78300. */
  78301. onAfterRenderObservable: Observable<Effect>;
  78302. private _onAfterRenderObserver;
  78303. /**
  78304. * A function that is added to the onAfterRenderObservable
  78305. */
  78306. onAfterRender: (efect: Effect) => void;
  78307. /**
  78308. * 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
  78309. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  78310. */
  78311. inputTexture: InternalTexture;
  78312. /**
  78313. * Gets the camera which post process is applied to.
  78314. * @returns The camera the post process is applied to.
  78315. */
  78316. getCamera(): Camera;
  78317. /**
  78318. * Gets the texel size of the postprocess.
  78319. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  78320. */
  78321. readonly texelSize: Vector2;
  78322. /**
  78323. * Creates a new instance PostProcess
  78324. * @param name The name of the PostProcess.
  78325. * @param fragmentUrl The url of the fragment shader to be used.
  78326. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  78327. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  78328. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  78329. * @param camera The camera to apply the render pass to.
  78330. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  78331. * @param engine The engine which the post process will be applied. (default: current engine)
  78332. * @param reusable If the post process can be reused on the same frame. (default: false)
  78333. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  78334. * @param textureType Type of textures used when performing the post process. (default: 0)
  78335. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  78336. * @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
  78337. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  78338. */
  78339. constructor(
  78340. /** Name of the PostProcess. */
  78341. 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);
  78342. /**
  78343. * Gets a string idenfifying the name of the class
  78344. * @returns "PostProcess" string
  78345. */
  78346. getClassName(): string;
  78347. /**
  78348. * Gets the engine which this post process belongs to.
  78349. * @returns The engine the post process was enabled with.
  78350. */
  78351. getEngine(): Engine;
  78352. /**
  78353. * The effect that is created when initializing the post process.
  78354. * @returns The created effect corresponding the the postprocess.
  78355. */
  78356. getEffect(): Effect;
  78357. /**
  78358. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  78359. * @param postProcess The post process to share the output with.
  78360. * @returns This post process.
  78361. */
  78362. shareOutputWith(postProcess: PostProcess): PostProcess;
  78363. /**
  78364. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  78365. * This should be called if the post process that shares output with this post process is disabled/disposed.
  78366. */
  78367. useOwnOutput(): void;
  78368. /**
  78369. * Updates the effect with the current post process compile time values and recompiles the shader.
  78370. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  78371. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  78372. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  78373. * @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
  78374. * @param onCompiled Called when the shader has been compiled.
  78375. * @param onError Called if there is an error when compiling a shader.
  78376. */
  78377. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  78378. /**
  78379. * The post process is reusable if it can be used multiple times within one frame.
  78380. * @returns If the post process is reusable
  78381. */
  78382. isReusable(): boolean;
  78383. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  78384. markTextureDirty(): void;
  78385. /**
  78386. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  78387. * 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.
  78388. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  78389. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  78390. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  78391. * @returns The target texture that was bound to be written to.
  78392. */
  78393. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  78394. /**
  78395. * If the post process is supported.
  78396. */
  78397. readonly isSupported: boolean;
  78398. /**
  78399. * The aspect ratio of the output texture.
  78400. */
  78401. readonly aspectRatio: number;
  78402. /**
  78403. * Get a value indicating if the post-process is ready to be used
  78404. * @returns true if the post-process is ready (shader is compiled)
  78405. */
  78406. isReady(): boolean;
  78407. /**
  78408. * Binds all textures and uniforms to the shader, this will be run on every pass.
  78409. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  78410. */
  78411. apply(): Nullable<Effect>;
  78412. private _disposeTextures;
  78413. /**
  78414. * Disposes the post process.
  78415. * @param camera The camera to dispose the post process on.
  78416. */
  78417. dispose(camera?: Camera): void;
  78418. }
  78419. }
  78420. declare module BABYLON {
  78421. /** @hidden */
  78422. export var kernelBlurVaryingDeclaration: {
  78423. name: string;
  78424. shader: string;
  78425. };
  78426. }
  78427. declare module BABYLON {
  78428. /** @hidden */
  78429. export var kernelBlurFragment: {
  78430. name: string;
  78431. shader: string;
  78432. };
  78433. }
  78434. declare module BABYLON {
  78435. /** @hidden */
  78436. export var kernelBlurFragment2: {
  78437. name: string;
  78438. shader: string;
  78439. };
  78440. }
  78441. declare module BABYLON {
  78442. /** @hidden */
  78443. export var kernelBlurPixelShader: {
  78444. name: string;
  78445. shader: string;
  78446. };
  78447. }
  78448. declare module BABYLON {
  78449. /** @hidden */
  78450. export var kernelBlurVertex: {
  78451. name: string;
  78452. shader: string;
  78453. };
  78454. }
  78455. declare module BABYLON {
  78456. /** @hidden */
  78457. export var kernelBlurVertexShader: {
  78458. name: string;
  78459. shader: string;
  78460. };
  78461. }
  78462. declare module BABYLON {
  78463. /**
  78464. * The Blur Post Process which blurs an image based on a kernel and direction.
  78465. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  78466. */
  78467. export class BlurPostProcess extends PostProcess {
  78468. /** The direction in which to blur the image. */
  78469. direction: Vector2;
  78470. private blockCompilation;
  78471. protected _kernel: number;
  78472. protected _idealKernel: number;
  78473. protected _packedFloat: boolean;
  78474. private _staticDefines;
  78475. /**
  78476. * Sets the length in pixels of the blur sample region
  78477. */
  78478. /**
  78479. * Gets the length in pixels of the blur sample region
  78480. */
  78481. kernel: number;
  78482. /**
  78483. * Sets wether or not the blur needs to unpack/repack floats
  78484. */
  78485. /**
  78486. * Gets wether or not the blur is unpacking/repacking floats
  78487. */
  78488. packedFloat: boolean;
  78489. /**
  78490. * Creates a new instance BlurPostProcess
  78491. * @param name The name of the effect.
  78492. * @param direction The direction in which to blur the image.
  78493. * @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.
  78494. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  78495. * @param camera The camera to apply the render pass to.
  78496. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  78497. * @param engine The engine which the post process will be applied. (default: current engine)
  78498. * @param reusable If the post process can be reused on the same frame. (default: false)
  78499. * @param textureType Type of textures used when performing the post process. (default: 0)
  78500. * @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)
  78501. */
  78502. constructor(name: string,
  78503. /** The direction in which to blur the image. */
  78504. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  78505. /**
  78506. * Updates the effect with the current post process compile time values and recompiles the shader.
  78507. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  78508. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  78509. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  78510. * @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
  78511. * @param onCompiled Called when the shader has been compiled.
  78512. * @param onError Called if there is an error when compiling a shader.
  78513. */
  78514. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  78515. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  78516. /**
  78517. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  78518. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  78519. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  78520. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  78521. * The gaps between physical kernels are compensated for in the weighting of the samples
  78522. * @param idealKernel Ideal blur kernel.
  78523. * @return Nearest best kernel.
  78524. */
  78525. protected _nearestBestKernel(idealKernel: number): number;
  78526. /**
  78527. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  78528. * @param x The point on the Gaussian distribution to sample.
  78529. * @return the value of the Gaussian function at x.
  78530. */
  78531. protected _gaussianWeight(x: number): number;
  78532. /**
  78533. * Generates a string that can be used as a floating point number in GLSL.
  78534. * @param x Value to print.
  78535. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  78536. * @return GLSL float string.
  78537. */
  78538. protected _glslFloat(x: number, decimalFigures?: number): string;
  78539. }
  78540. }
  78541. declare module BABYLON {
  78542. /**
  78543. * Mirror texture can be used to simulate the view from a mirror in a scene.
  78544. * It will dynamically be rendered every frame to adapt to the camera point of view.
  78545. * You can then easily use it as a reflectionTexture on a flat surface.
  78546. * In case the surface is not a plane, please consider relying on reflection probes.
  78547. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  78548. */
  78549. export class MirrorTexture extends RenderTargetTexture {
  78550. private scene;
  78551. /**
  78552. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  78553. * 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.
  78554. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  78555. */
  78556. mirrorPlane: Plane;
  78557. /**
  78558. * Define the blur ratio used to blur the reflection if needed.
  78559. */
  78560. blurRatio: number;
  78561. /**
  78562. * Define the adaptive blur kernel used to blur the reflection if needed.
  78563. * This will autocompute the closest best match for the `blurKernel`
  78564. */
  78565. adaptiveBlurKernel: number;
  78566. /**
  78567. * Define the blur kernel used to blur the reflection if needed.
  78568. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  78569. */
  78570. blurKernel: number;
  78571. /**
  78572. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  78573. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  78574. */
  78575. blurKernelX: number;
  78576. /**
  78577. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  78578. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  78579. */
  78580. blurKernelY: number;
  78581. private _autoComputeBlurKernel;
  78582. protected _onRatioRescale(): void;
  78583. private _updateGammaSpace;
  78584. private _imageProcessingConfigChangeObserver;
  78585. private _transformMatrix;
  78586. private _mirrorMatrix;
  78587. private _savedViewMatrix;
  78588. private _blurX;
  78589. private _blurY;
  78590. private _adaptiveBlurKernel;
  78591. private _blurKernelX;
  78592. private _blurKernelY;
  78593. private _blurRatio;
  78594. /**
  78595. * Instantiates a Mirror Texture.
  78596. * Mirror texture can be used to simulate the view from a mirror in a scene.
  78597. * It will dynamically be rendered every frame to adapt to the camera point of view.
  78598. * You can then easily use it as a reflectionTexture on a flat surface.
  78599. * In case the surface is not a plane, please consider relying on reflection probes.
  78600. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  78601. * @param name
  78602. * @param size
  78603. * @param scene
  78604. * @param generateMipMaps
  78605. * @param type
  78606. * @param samplingMode
  78607. * @param generateDepthBuffer
  78608. */
  78609. constructor(name: string, size: number | {
  78610. width: number;
  78611. height: number;
  78612. } | {
  78613. ratio: number;
  78614. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  78615. private _preparePostProcesses;
  78616. /**
  78617. * Clone the mirror texture.
  78618. * @returns the cloned texture
  78619. */
  78620. clone(): MirrorTexture;
  78621. /**
  78622. * Serialize the texture to a JSON representation you could use in Parse later on
  78623. * @returns the serialized JSON representation
  78624. */
  78625. serialize(): any;
  78626. /**
  78627. * Dispose the texture and release its associated resources.
  78628. */
  78629. dispose(): void;
  78630. }
  78631. }
  78632. declare module BABYLON {
  78633. /**
  78634. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  78635. * @see http://doc.babylonjs.com/babylon101/materials#texture
  78636. */
  78637. export class Texture extends BaseTexture {
  78638. /** @hidden */
  78639. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  78640. /** @hidden */
  78641. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  78642. /** @hidden */
  78643. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  78644. /** nearest is mag = nearest and min = nearest and mip = linear */
  78645. static readonly NEAREST_SAMPLINGMODE: number;
  78646. /** nearest is mag = nearest and min = nearest and mip = linear */
  78647. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  78648. /** Bilinear is mag = linear and min = linear and mip = nearest */
  78649. static readonly BILINEAR_SAMPLINGMODE: number;
  78650. /** Bilinear is mag = linear and min = linear and mip = nearest */
  78651. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  78652. /** Trilinear is mag = linear and min = linear and mip = linear */
  78653. static readonly TRILINEAR_SAMPLINGMODE: number;
  78654. /** Trilinear is mag = linear and min = linear and mip = linear */
  78655. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  78656. /** mag = nearest and min = nearest and mip = nearest */
  78657. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  78658. /** mag = nearest and min = linear and mip = nearest */
  78659. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  78660. /** mag = nearest and min = linear and mip = linear */
  78661. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  78662. /** mag = nearest and min = linear and mip = none */
  78663. static readonly NEAREST_LINEAR: number;
  78664. /** mag = nearest and min = nearest and mip = none */
  78665. static readonly NEAREST_NEAREST: number;
  78666. /** mag = linear and min = nearest and mip = nearest */
  78667. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  78668. /** mag = linear and min = nearest and mip = linear */
  78669. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  78670. /** mag = linear and min = linear and mip = none */
  78671. static readonly LINEAR_LINEAR: number;
  78672. /** mag = linear and min = nearest and mip = none */
  78673. static readonly LINEAR_NEAREST: number;
  78674. /** Explicit coordinates mode */
  78675. static readonly EXPLICIT_MODE: number;
  78676. /** Spherical coordinates mode */
  78677. static readonly SPHERICAL_MODE: number;
  78678. /** Planar coordinates mode */
  78679. static readonly PLANAR_MODE: number;
  78680. /** Cubic coordinates mode */
  78681. static readonly CUBIC_MODE: number;
  78682. /** Projection coordinates mode */
  78683. static readonly PROJECTION_MODE: number;
  78684. /** Inverse Cubic coordinates mode */
  78685. static readonly SKYBOX_MODE: number;
  78686. /** Inverse Cubic coordinates mode */
  78687. static readonly INVCUBIC_MODE: number;
  78688. /** Equirectangular coordinates mode */
  78689. static readonly EQUIRECTANGULAR_MODE: number;
  78690. /** Equirectangular Fixed coordinates mode */
  78691. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  78692. /** Equirectangular Fixed Mirrored coordinates mode */
  78693. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  78694. /** Texture is not repeating outside of 0..1 UVs */
  78695. static readonly CLAMP_ADDRESSMODE: number;
  78696. /** Texture is repeating outside of 0..1 UVs */
  78697. static readonly WRAP_ADDRESSMODE: number;
  78698. /** Texture is repeating and mirrored */
  78699. static readonly MIRROR_ADDRESSMODE: number;
  78700. /**
  78701. * 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
  78702. */
  78703. static UseSerializedUrlIfAny: boolean;
  78704. /**
  78705. * Define the url of the texture.
  78706. */
  78707. url: Nullable<string>;
  78708. /**
  78709. * Define an offset on the texture to offset the u coordinates of the UVs
  78710. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  78711. */
  78712. uOffset: number;
  78713. /**
  78714. * Define an offset on the texture to offset the v coordinates of the UVs
  78715. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  78716. */
  78717. vOffset: number;
  78718. /**
  78719. * Define an offset on the texture to scale the u coordinates of the UVs
  78720. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  78721. */
  78722. uScale: number;
  78723. /**
  78724. * Define an offset on the texture to scale the v coordinates of the UVs
  78725. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  78726. */
  78727. vScale: number;
  78728. /**
  78729. * Define an offset on the texture to rotate around the u coordinates of the UVs
  78730. * @see http://doc.babylonjs.com/how_to/more_materials
  78731. */
  78732. uAng: number;
  78733. /**
  78734. * Define an offset on the texture to rotate around the v coordinates of the UVs
  78735. * @see http://doc.babylonjs.com/how_to/more_materials
  78736. */
  78737. vAng: number;
  78738. /**
  78739. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  78740. * @see http://doc.babylonjs.com/how_to/more_materials
  78741. */
  78742. wAng: number;
  78743. /**
  78744. * Defines the center of rotation (U)
  78745. */
  78746. uRotationCenter: number;
  78747. /**
  78748. * Defines the center of rotation (V)
  78749. */
  78750. vRotationCenter: number;
  78751. /**
  78752. * Defines the center of rotation (W)
  78753. */
  78754. wRotationCenter: number;
  78755. /**
  78756. * Are mip maps generated for this texture or not.
  78757. */
  78758. readonly noMipmap: boolean;
  78759. /**
  78760. * List of inspectable custom properties (used by the Inspector)
  78761. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78762. */
  78763. inspectableCustomProperties: Nullable<IInspectable[]>;
  78764. private _noMipmap;
  78765. /** @hidden */
  78766. _invertY: boolean;
  78767. private _rowGenerationMatrix;
  78768. private _cachedTextureMatrix;
  78769. private _projectionModeMatrix;
  78770. private _t0;
  78771. private _t1;
  78772. private _t2;
  78773. private _cachedUOffset;
  78774. private _cachedVOffset;
  78775. private _cachedUScale;
  78776. private _cachedVScale;
  78777. private _cachedUAng;
  78778. private _cachedVAng;
  78779. private _cachedWAng;
  78780. private _cachedProjectionMatrixId;
  78781. private _cachedCoordinatesMode;
  78782. /** @hidden */
  78783. protected _initialSamplingMode: number;
  78784. /** @hidden */
  78785. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  78786. private _deleteBuffer;
  78787. protected _format: Nullable<number>;
  78788. private _delayedOnLoad;
  78789. private _delayedOnError;
  78790. /**
  78791. * Observable triggered once the texture has been loaded.
  78792. */
  78793. onLoadObservable: Observable<Texture>;
  78794. protected _isBlocking: boolean;
  78795. /**
  78796. * Is the texture preventing material to render while loading.
  78797. * If false, a default texture will be used instead of the loading one during the preparation step.
  78798. */
  78799. isBlocking: boolean;
  78800. /**
  78801. * Get the current sampling mode associated with the texture.
  78802. */
  78803. readonly samplingMode: number;
  78804. /**
  78805. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  78806. */
  78807. readonly invertY: boolean;
  78808. /**
  78809. * Instantiates a new texture.
  78810. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  78811. * @see http://doc.babylonjs.com/babylon101/materials#texture
  78812. * @param url define the url of the picture to load as a texture
  78813. * @param scene define the scene or engine the texture will belong to
  78814. * @param noMipmap define if the texture will require mip maps or not
  78815. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78816. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78817. * @param onLoad define a callback triggered when the texture has been loaded
  78818. * @param onError define a callback triggered when an error occurred during the loading session
  78819. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  78820. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  78821. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78822. */
  78823. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  78824. /**
  78825. * Update the url (and optional buffer) of this texture if url was null during construction.
  78826. * @param url the url of the texture
  78827. * @param buffer the buffer of the texture (defaults to null)
  78828. * @param onLoad callback called when the texture is loaded (defaults to null)
  78829. */
  78830. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  78831. /**
  78832. * Finish the loading sequence of a texture flagged as delayed load.
  78833. * @hidden
  78834. */
  78835. delayLoad(): void;
  78836. private _prepareRowForTextureGeneration;
  78837. /**
  78838. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  78839. * @returns the transform matrix of the texture.
  78840. */
  78841. getTextureMatrix(): Matrix;
  78842. /**
  78843. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  78844. * @returns The reflection texture transform
  78845. */
  78846. getReflectionTextureMatrix(): Matrix;
  78847. /**
  78848. * Clones the texture.
  78849. * @returns the cloned texture
  78850. */
  78851. clone(): Texture;
  78852. /**
  78853. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  78854. * @returns The JSON representation of the texture
  78855. */
  78856. serialize(): any;
  78857. /**
  78858. * Get the current class name of the texture useful for serialization or dynamic coding.
  78859. * @returns "Texture"
  78860. */
  78861. getClassName(): string;
  78862. /**
  78863. * Dispose the texture and release its associated resources.
  78864. */
  78865. dispose(): void;
  78866. /**
  78867. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  78868. * @param parsedTexture Define the JSON representation of the texture
  78869. * @param scene Define the scene the parsed texture should be instantiated in
  78870. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  78871. * @returns The parsed texture if successful
  78872. */
  78873. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  78874. /**
  78875. * Creates a texture from its base 64 representation.
  78876. * @param data Define the base64 payload without the data: prefix
  78877. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  78878. * @param scene Define the scene the texture should belong to
  78879. * @param noMipmap Forces the texture to not create mip map information if true
  78880. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78881. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78882. * @param onLoad define a callback triggered when the texture has been loaded
  78883. * @param onError define a callback triggered when an error occurred during the loading session
  78884. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78885. * @returns the created texture
  78886. */
  78887. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  78888. /**
  78889. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  78890. * @param data Define the base64 payload without the data: prefix
  78891. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  78892. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  78893. * @param scene Define the scene the texture should belong to
  78894. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  78895. * @param noMipmap Forces the texture to not create mip map information if true
  78896. * @param invertY define if the texture needs to be inverted on the y axis during loading
  78897. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  78898. * @param onLoad define a callback triggered when the texture has been loaded
  78899. * @param onError define a callback triggered when an error occurred during the loading session
  78900. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  78901. * @returns the created texture
  78902. */
  78903. 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;
  78904. }
  78905. }
  78906. declare module BABYLON {
  78907. /**
  78908. * PostProcessManager is used to manage one or more post processes or post process pipelines
  78909. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  78910. */
  78911. export class PostProcessManager {
  78912. private _scene;
  78913. private _indexBuffer;
  78914. private _vertexBuffers;
  78915. /**
  78916. * Creates a new instance PostProcess
  78917. * @param scene The scene that the post process is associated with.
  78918. */
  78919. constructor(scene: Scene);
  78920. private _prepareBuffers;
  78921. private _buildIndexBuffer;
  78922. /**
  78923. * Rebuilds the vertex buffers of the manager.
  78924. * @hidden
  78925. */
  78926. _rebuild(): void;
  78927. /**
  78928. * Prepares a frame to be run through a post process.
  78929. * @param sourceTexture The input texture to the post procesess. (default: null)
  78930. * @param postProcesses An array of post processes to be run. (default: null)
  78931. * @returns True if the post processes were able to be run.
  78932. * @hidden
  78933. */
  78934. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  78935. /**
  78936. * Manually render a set of post processes to a texture.
  78937. * @param postProcesses An array of post processes to be run.
  78938. * @param targetTexture The target texture to render to.
  78939. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  78940. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  78941. * @param lodLevel defines which lod of the texture to render to
  78942. */
  78943. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  78944. /**
  78945. * Finalize the result of the output of the postprocesses.
  78946. * @param doNotPresent If true the result will not be displayed to the screen.
  78947. * @param targetTexture The target texture to render to.
  78948. * @param faceIndex The index of the face to bind the target texture to.
  78949. * @param postProcesses The array of post processes to render.
  78950. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  78951. * @hidden
  78952. */
  78953. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  78954. /**
  78955. * Disposes of the post process manager.
  78956. */
  78957. dispose(): void;
  78958. }
  78959. }
  78960. declare module BABYLON {
  78961. /** Interface used by value gradients (color, factor, ...) */
  78962. export interface IValueGradient {
  78963. /**
  78964. * Gets or sets the gradient value (between 0 and 1)
  78965. */
  78966. gradient: number;
  78967. }
  78968. /** Class used to store color4 gradient */
  78969. export class ColorGradient implements IValueGradient {
  78970. /**
  78971. * Gets or sets the gradient value (between 0 and 1)
  78972. */
  78973. gradient: number;
  78974. /**
  78975. * Gets or sets first associated color
  78976. */
  78977. color1: Color4;
  78978. /**
  78979. * Gets or sets second associated color
  78980. */
  78981. color2?: Color4;
  78982. /**
  78983. * Will get a color picked randomly between color1 and color2.
  78984. * If color2 is undefined then color1 will be used
  78985. * @param result defines the target Color4 to store the result in
  78986. */
  78987. getColorToRef(result: Color4): void;
  78988. }
  78989. /** Class used to store color 3 gradient */
  78990. export class Color3Gradient implements IValueGradient {
  78991. /**
  78992. * Gets or sets the gradient value (between 0 and 1)
  78993. */
  78994. gradient: number;
  78995. /**
  78996. * Gets or sets the associated color
  78997. */
  78998. color: Color3;
  78999. }
  79000. /** Class used to store factor gradient */
  79001. export class FactorGradient implements IValueGradient {
  79002. /**
  79003. * Gets or sets the gradient value (between 0 and 1)
  79004. */
  79005. gradient: number;
  79006. /**
  79007. * Gets or sets first associated factor
  79008. */
  79009. factor1: number;
  79010. /**
  79011. * Gets or sets second associated factor
  79012. */
  79013. factor2?: number;
  79014. /**
  79015. * Will get a number picked randomly between factor1 and factor2.
  79016. * If factor2 is undefined then factor1 will be used
  79017. * @returns the picked number
  79018. */
  79019. getFactor(): number;
  79020. }
  79021. /**
  79022. * Helper used to simplify some generic gradient tasks
  79023. */
  79024. export class GradientHelper {
  79025. /**
  79026. * Gets the current gradient from an array of IValueGradient
  79027. * @param ratio defines the current ratio to get
  79028. * @param gradients defines the array of IValueGradient
  79029. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  79030. */
  79031. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  79032. }
  79033. }
  79034. declare module BABYLON {
  79035. interface AbstractScene {
  79036. /**
  79037. * The list of procedural textures added to the scene
  79038. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  79039. */
  79040. proceduralTextures: Array<ProceduralTexture>;
  79041. }
  79042. /**
  79043. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  79044. * in a given scene.
  79045. */
  79046. export class ProceduralTextureSceneComponent implements ISceneComponent {
  79047. /**
  79048. * The component name helpfull to identify the component in the list of scene components.
  79049. */
  79050. readonly name: string;
  79051. /**
  79052. * The scene the component belongs to.
  79053. */
  79054. scene: Scene;
  79055. /**
  79056. * Creates a new instance of the component for the given scene
  79057. * @param scene Defines the scene to register the component in
  79058. */
  79059. constructor(scene: Scene);
  79060. /**
  79061. * Registers the component in a given scene
  79062. */
  79063. register(): void;
  79064. /**
  79065. * Rebuilds the elements related to this component in case of
  79066. * context lost for instance.
  79067. */
  79068. rebuild(): void;
  79069. /**
  79070. * Disposes the component and the associated ressources.
  79071. */
  79072. dispose(): void;
  79073. private _beforeClear;
  79074. }
  79075. }
  79076. declare module BABYLON {
  79077. interface Engine {
  79078. /**
  79079. * Creates a new render target cube texture
  79080. * @param size defines the size of the texture
  79081. * @param options defines the options used to create the texture
  79082. * @returns a new render target cube texture stored in an InternalTexture
  79083. */
  79084. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  79085. }
  79086. }
  79087. declare module BABYLON {
  79088. /** @hidden */
  79089. export var proceduralVertexShader: {
  79090. name: string;
  79091. shader: string;
  79092. };
  79093. }
  79094. declare module BABYLON {
  79095. /**
  79096. * 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.
  79097. * This is the base class of any Procedural texture and contains most of the shareable code.
  79098. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  79099. */
  79100. export class ProceduralTexture extends Texture {
  79101. isCube: boolean;
  79102. /**
  79103. * Define if the texture is enabled or not (disabled texture will not render)
  79104. */
  79105. isEnabled: boolean;
  79106. /**
  79107. * Define if the texture must be cleared before rendering (default is true)
  79108. */
  79109. autoClear: boolean;
  79110. /**
  79111. * Callback called when the texture is generated
  79112. */
  79113. onGenerated: () => void;
  79114. /**
  79115. * Event raised when the texture is generated
  79116. */
  79117. onGeneratedObservable: Observable<ProceduralTexture>;
  79118. /** @hidden */
  79119. _generateMipMaps: boolean;
  79120. /** @hidden **/
  79121. _effect: Effect;
  79122. /** @hidden */
  79123. _textures: {
  79124. [key: string]: Texture;
  79125. };
  79126. private _size;
  79127. private _currentRefreshId;
  79128. private _refreshRate;
  79129. private _vertexBuffers;
  79130. private _indexBuffer;
  79131. private _uniforms;
  79132. private _samplers;
  79133. private _fragment;
  79134. private _floats;
  79135. private _ints;
  79136. private _floatsArrays;
  79137. private _colors3;
  79138. private _colors4;
  79139. private _vectors2;
  79140. private _vectors3;
  79141. private _matrices;
  79142. private _fallbackTexture;
  79143. private _fallbackTextureUsed;
  79144. private _engine;
  79145. private _cachedDefines;
  79146. private _contentUpdateId;
  79147. private _contentData;
  79148. /**
  79149. * Instantiates a new procedural texture.
  79150. * 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.
  79151. * This is the base class of any Procedural texture and contains most of the shareable code.
  79152. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  79153. * @param name Define the name of the texture
  79154. * @param size Define the size of the texture to create
  79155. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  79156. * @param scene Define the scene the texture belongs to
  79157. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  79158. * @param generateMipMaps Define if the texture should creates mip maps or not
  79159. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  79160. */
  79161. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  79162. /**
  79163. * The effect that is created when initializing the post process.
  79164. * @returns The created effect corresponding the the postprocess.
  79165. */
  79166. getEffect(): Effect;
  79167. /**
  79168. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  79169. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  79170. */
  79171. getContent(): Nullable<ArrayBufferView>;
  79172. private _createIndexBuffer;
  79173. /** @hidden */
  79174. _rebuild(): void;
  79175. /**
  79176. * Resets the texture in order to recreate its associated resources.
  79177. * This can be called in case of context loss
  79178. */
  79179. reset(): void;
  79180. protected _getDefines(): string;
  79181. /**
  79182. * Is the texture ready to be used ? (rendered at least once)
  79183. * @returns true if ready, otherwise, false.
  79184. */
  79185. isReady(): boolean;
  79186. /**
  79187. * Resets the refresh counter of the texture and start bak from scratch.
  79188. * Could be useful to regenerate the texture if it is setup to render only once.
  79189. */
  79190. resetRefreshCounter(): void;
  79191. /**
  79192. * Set the fragment shader to use in order to render the texture.
  79193. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  79194. */
  79195. setFragment(fragment: any): void;
  79196. /**
  79197. * Define the refresh rate of the texture or the rendering frequency.
  79198. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  79199. */
  79200. refreshRate: number;
  79201. /** @hidden */
  79202. _shouldRender(): boolean;
  79203. /**
  79204. * Get the size the texture is rendering at.
  79205. * @returns the size (texture is always squared)
  79206. */
  79207. getRenderSize(): number;
  79208. /**
  79209. * Resize the texture to new value.
  79210. * @param size Define the new size the texture should have
  79211. * @param generateMipMaps Define whether the new texture should create mip maps
  79212. */
  79213. resize(size: number, generateMipMaps: boolean): void;
  79214. private _checkUniform;
  79215. /**
  79216. * Set a texture in the shader program used to render.
  79217. * @param name Define the name of the uniform samplers as defined in the shader
  79218. * @param texture Define the texture to bind to this sampler
  79219. * @return the texture itself allowing "fluent" like uniform updates
  79220. */
  79221. setTexture(name: string, texture: Texture): ProceduralTexture;
  79222. /**
  79223. * Set a float in the shader.
  79224. * @param name Define the name of the uniform as defined in the shader
  79225. * @param value Define the value to give to the uniform
  79226. * @return the texture itself allowing "fluent" like uniform updates
  79227. */
  79228. setFloat(name: string, value: number): ProceduralTexture;
  79229. /**
  79230. * Set a int in the shader.
  79231. * @param name Define the name of the uniform as defined in the shader
  79232. * @param value Define the value to give to the uniform
  79233. * @return the texture itself allowing "fluent" like uniform updates
  79234. */
  79235. setInt(name: string, value: number): ProceduralTexture;
  79236. /**
  79237. * Set an array of floats in the shader.
  79238. * @param name Define the name of the uniform as defined in the shader
  79239. * @param value Define the value to give to the uniform
  79240. * @return the texture itself allowing "fluent" like uniform updates
  79241. */
  79242. setFloats(name: string, value: number[]): ProceduralTexture;
  79243. /**
  79244. * Set a vec3 in the shader from a Color3.
  79245. * @param name Define the name of the uniform as defined in the shader
  79246. * @param value Define the value to give to the uniform
  79247. * @return the texture itself allowing "fluent" like uniform updates
  79248. */
  79249. setColor3(name: string, value: Color3): ProceduralTexture;
  79250. /**
  79251. * Set a vec4 in the shader from a Color4.
  79252. * @param name Define the name of the uniform as defined in the shader
  79253. * @param value Define the value to give to the uniform
  79254. * @return the texture itself allowing "fluent" like uniform updates
  79255. */
  79256. setColor4(name: string, value: Color4): ProceduralTexture;
  79257. /**
  79258. * Set a vec2 in the shader from a Vector2.
  79259. * @param name Define the name of the uniform as defined in the shader
  79260. * @param value Define the value to give to the uniform
  79261. * @return the texture itself allowing "fluent" like uniform updates
  79262. */
  79263. setVector2(name: string, value: Vector2): ProceduralTexture;
  79264. /**
  79265. * Set a vec3 in the shader from a Vector3.
  79266. * @param name Define the name of the uniform as defined in the shader
  79267. * @param value Define the value to give to the uniform
  79268. * @return the texture itself allowing "fluent" like uniform updates
  79269. */
  79270. setVector3(name: string, value: Vector3): ProceduralTexture;
  79271. /**
  79272. * Set a mat4 in the shader from a MAtrix.
  79273. * @param name Define the name of the uniform as defined in the shader
  79274. * @param value Define the value to give to the uniform
  79275. * @return the texture itself allowing "fluent" like uniform updates
  79276. */
  79277. setMatrix(name: string, value: Matrix): ProceduralTexture;
  79278. /**
  79279. * Render the texture to its associated render target.
  79280. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  79281. */
  79282. render(useCameraPostProcess?: boolean): void;
  79283. /**
  79284. * Clone the texture.
  79285. * @returns the cloned texture
  79286. */
  79287. clone(): ProceduralTexture;
  79288. /**
  79289. * Dispose the texture and release its asoociated resources.
  79290. */
  79291. dispose(): void;
  79292. }
  79293. }
  79294. declare module BABYLON {
  79295. /**
  79296. * This represents the base class for particle system in Babylon.
  79297. * 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.
  79298. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  79299. * @example https://doc.babylonjs.com/babylon101/particles
  79300. */
  79301. export class BaseParticleSystem {
  79302. /**
  79303. * Source color is added to the destination color without alpha affecting the result
  79304. */
  79305. static BLENDMODE_ONEONE: number;
  79306. /**
  79307. * Blend current color and particle color using particle’s alpha
  79308. */
  79309. static BLENDMODE_STANDARD: number;
  79310. /**
  79311. * Add current color and particle color multiplied by particle’s alpha
  79312. */
  79313. static BLENDMODE_ADD: number;
  79314. /**
  79315. * Multiply current color with particle color
  79316. */
  79317. static BLENDMODE_MULTIPLY: number;
  79318. /**
  79319. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  79320. */
  79321. static BLENDMODE_MULTIPLYADD: number;
  79322. /**
  79323. * List of animations used by the particle system.
  79324. */
  79325. animations: Animation[];
  79326. /**
  79327. * The id of the Particle system.
  79328. */
  79329. id: string;
  79330. /**
  79331. * The friendly name of the Particle system.
  79332. */
  79333. name: string;
  79334. /**
  79335. * The rendering group used by the Particle system to chose when to render.
  79336. */
  79337. renderingGroupId: number;
  79338. /**
  79339. * The emitter represents the Mesh or position we are attaching the particle system to.
  79340. */
  79341. emitter: Nullable<AbstractMesh | Vector3>;
  79342. /**
  79343. * The maximum number of particles to emit per frame
  79344. */
  79345. emitRate: number;
  79346. /**
  79347. * If you want to launch only a few particles at once, that can be done, as well.
  79348. */
  79349. manualEmitCount: number;
  79350. /**
  79351. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  79352. */
  79353. updateSpeed: number;
  79354. /**
  79355. * The amount of time the particle system is running (depends of the overall update speed).
  79356. */
  79357. targetStopDuration: number;
  79358. /**
  79359. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  79360. */
  79361. disposeOnStop: boolean;
  79362. /**
  79363. * Minimum power of emitting particles.
  79364. */
  79365. minEmitPower: number;
  79366. /**
  79367. * Maximum power of emitting particles.
  79368. */
  79369. maxEmitPower: number;
  79370. /**
  79371. * Minimum life time of emitting particles.
  79372. */
  79373. minLifeTime: number;
  79374. /**
  79375. * Maximum life time of emitting particles.
  79376. */
  79377. maxLifeTime: number;
  79378. /**
  79379. * Minimum Size of emitting particles.
  79380. */
  79381. minSize: number;
  79382. /**
  79383. * Maximum Size of emitting particles.
  79384. */
  79385. maxSize: number;
  79386. /**
  79387. * Minimum scale of emitting particles on X axis.
  79388. */
  79389. minScaleX: number;
  79390. /**
  79391. * Maximum scale of emitting particles on X axis.
  79392. */
  79393. maxScaleX: number;
  79394. /**
  79395. * Minimum scale of emitting particles on Y axis.
  79396. */
  79397. minScaleY: number;
  79398. /**
  79399. * Maximum scale of emitting particles on Y axis.
  79400. */
  79401. maxScaleY: number;
  79402. /**
  79403. * Gets or sets the minimal initial rotation in radians.
  79404. */
  79405. minInitialRotation: number;
  79406. /**
  79407. * Gets or sets the maximal initial rotation in radians.
  79408. */
  79409. maxInitialRotation: number;
  79410. /**
  79411. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  79412. */
  79413. minAngularSpeed: number;
  79414. /**
  79415. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  79416. */
  79417. maxAngularSpeed: number;
  79418. /**
  79419. * The texture used to render each particle. (this can be a spritesheet)
  79420. */
  79421. particleTexture: Nullable<Texture>;
  79422. /**
  79423. * The layer mask we are rendering the particles through.
  79424. */
  79425. layerMask: number;
  79426. /**
  79427. * This can help using your own shader to render the particle system.
  79428. * The according effect will be created
  79429. */
  79430. customShader: any;
  79431. /**
  79432. * By default particle system starts as soon as they are created. This prevents the
  79433. * automatic start to happen and let you decide when to start emitting particles.
  79434. */
  79435. preventAutoStart: boolean;
  79436. private _noiseTexture;
  79437. /**
  79438. * Gets or sets a texture used to add random noise to particle positions
  79439. */
  79440. noiseTexture: Nullable<ProceduralTexture>;
  79441. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  79442. noiseStrength: Vector3;
  79443. /**
  79444. * Callback triggered when the particle animation is ending.
  79445. */
  79446. onAnimationEnd: Nullable<() => void>;
  79447. /**
  79448. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  79449. */
  79450. blendMode: number;
  79451. /**
  79452. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  79453. * to override the particles.
  79454. */
  79455. forceDepthWrite: boolean;
  79456. /** 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 */
  79457. preWarmCycles: number;
  79458. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  79459. preWarmStepOffset: number;
  79460. /**
  79461. * 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)
  79462. */
  79463. spriteCellChangeSpeed: number;
  79464. /**
  79465. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  79466. */
  79467. startSpriteCellID: number;
  79468. /**
  79469. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  79470. */
  79471. endSpriteCellID: number;
  79472. /**
  79473. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  79474. */
  79475. spriteCellWidth: number;
  79476. /**
  79477. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  79478. */
  79479. spriteCellHeight: number;
  79480. /**
  79481. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  79482. */
  79483. spriteRandomStartCell: boolean;
  79484. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  79485. translationPivot: Vector2;
  79486. /** @hidden */
  79487. protected _isAnimationSheetEnabled: boolean;
  79488. /**
  79489. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  79490. */
  79491. beginAnimationOnStart: boolean;
  79492. /**
  79493. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  79494. */
  79495. beginAnimationFrom: number;
  79496. /**
  79497. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  79498. */
  79499. beginAnimationTo: number;
  79500. /**
  79501. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  79502. */
  79503. beginAnimationLoop: boolean;
  79504. /**
  79505. * Gets or sets a world offset applied to all particles
  79506. */
  79507. worldOffset: Vector3;
  79508. /**
  79509. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  79510. */
  79511. isAnimationSheetEnabled: boolean;
  79512. /**
  79513. * Get hosting scene
  79514. * @returns the scene
  79515. */
  79516. getScene(): Scene;
  79517. /**
  79518. * You can use gravity if you want to give an orientation to your particles.
  79519. */
  79520. gravity: Vector3;
  79521. protected _colorGradients: Nullable<Array<ColorGradient>>;
  79522. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  79523. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  79524. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  79525. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  79526. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  79527. protected _dragGradients: Nullable<Array<FactorGradient>>;
  79528. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  79529. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  79530. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  79531. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  79532. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  79533. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  79534. /**
  79535. * Defines the delay in milliseconds before starting the system (0 by default)
  79536. */
  79537. startDelay: number;
  79538. /**
  79539. * Gets the current list of drag gradients.
  79540. * You must use addDragGradient and removeDragGradient to udpate this list
  79541. * @returns the list of drag gradients
  79542. */
  79543. getDragGradients(): Nullable<Array<FactorGradient>>;
  79544. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  79545. limitVelocityDamping: number;
  79546. /**
  79547. * Gets the current list of limit velocity gradients.
  79548. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  79549. * @returns the list of limit velocity gradients
  79550. */
  79551. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  79552. /**
  79553. * Gets the current list of color gradients.
  79554. * You must use addColorGradient and removeColorGradient to udpate this list
  79555. * @returns the list of color gradients
  79556. */
  79557. getColorGradients(): Nullable<Array<ColorGradient>>;
  79558. /**
  79559. * Gets the current list of size gradients.
  79560. * You must use addSizeGradient and removeSizeGradient to udpate this list
  79561. * @returns the list of size gradients
  79562. */
  79563. getSizeGradients(): Nullable<Array<FactorGradient>>;
  79564. /**
  79565. * Gets the current list of color remap gradients.
  79566. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  79567. * @returns the list of color remap gradients
  79568. */
  79569. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  79570. /**
  79571. * Gets the current list of alpha remap gradients.
  79572. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  79573. * @returns the list of alpha remap gradients
  79574. */
  79575. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  79576. /**
  79577. * Gets the current list of life time gradients.
  79578. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  79579. * @returns the list of life time gradients
  79580. */
  79581. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  79582. /**
  79583. * Gets the current list of angular speed gradients.
  79584. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  79585. * @returns the list of angular speed gradients
  79586. */
  79587. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  79588. /**
  79589. * Gets the current list of velocity gradients.
  79590. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  79591. * @returns the list of velocity gradients
  79592. */
  79593. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  79594. /**
  79595. * Gets the current list of start size gradients.
  79596. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  79597. * @returns the list of start size gradients
  79598. */
  79599. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  79600. /**
  79601. * Gets the current list of emit rate gradients.
  79602. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  79603. * @returns the list of emit rate gradients
  79604. */
  79605. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  79606. /**
  79607. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  79608. * This only works when particleEmitterTyps is a BoxParticleEmitter
  79609. */
  79610. direction1: Vector3;
  79611. /**
  79612. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  79613. * This only works when particleEmitterTyps is a BoxParticleEmitter
  79614. */
  79615. direction2: Vector3;
  79616. /**
  79617. * 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.
  79618. * This only works when particleEmitterTyps is a BoxParticleEmitter
  79619. */
  79620. minEmitBox: Vector3;
  79621. /**
  79622. * 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.
  79623. * This only works when particleEmitterTyps is a BoxParticleEmitter
  79624. */
  79625. maxEmitBox: Vector3;
  79626. /**
  79627. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  79628. */
  79629. color1: Color4;
  79630. /**
  79631. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  79632. */
  79633. color2: Color4;
  79634. /**
  79635. * Color the particle will have at the end of its lifetime
  79636. */
  79637. colorDead: Color4;
  79638. /**
  79639. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  79640. */
  79641. textureMask: Color4;
  79642. /**
  79643. * The particle emitter type defines the emitter used by the particle system.
  79644. * It can be for example box, sphere, or cone...
  79645. */
  79646. particleEmitterType: IParticleEmitterType;
  79647. /** @hidden */
  79648. _isSubEmitter: boolean;
  79649. /**
  79650. * Gets or sets the billboard mode to use when isBillboardBased = true.
  79651. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  79652. */
  79653. billboardMode: number;
  79654. protected _isBillboardBased: boolean;
  79655. /**
  79656. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  79657. */
  79658. isBillboardBased: boolean;
  79659. /**
  79660. * The scene the particle system belongs to.
  79661. */
  79662. protected _scene: Scene;
  79663. /**
  79664. * Local cache of defines for image processing.
  79665. */
  79666. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  79667. /**
  79668. * Default configuration related to image processing available in the standard Material.
  79669. */
  79670. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  79671. /**
  79672. * Gets the image processing configuration used either in this material.
  79673. */
  79674. /**
  79675. * Sets the Default image processing configuration used either in the this material.
  79676. *
  79677. * If sets to null, the scene one is in use.
  79678. */
  79679. imageProcessingConfiguration: ImageProcessingConfiguration;
  79680. /**
  79681. * Attaches a new image processing configuration to the Standard Material.
  79682. * @param configuration
  79683. */
  79684. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  79685. /** @hidden */
  79686. protected _reset(): void;
  79687. /** @hidden */
  79688. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  79689. /**
  79690. * Instantiates a particle system.
  79691. * 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.
  79692. * @param name The name of the particle system
  79693. */
  79694. constructor(name: string);
  79695. /**
  79696. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  79697. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  79698. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  79699. * @returns the emitter
  79700. */
  79701. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  79702. /**
  79703. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  79704. * @param radius The radius of the hemisphere to emit from
  79705. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  79706. * @returns the emitter
  79707. */
  79708. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  79709. /**
  79710. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  79711. * @param radius The radius of the sphere to emit from
  79712. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  79713. * @returns the emitter
  79714. */
  79715. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  79716. /**
  79717. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  79718. * @param radius The radius of the sphere to emit from
  79719. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  79720. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  79721. * @returns the emitter
  79722. */
  79723. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  79724. /**
  79725. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  79726. * @param radius The radius of the emission cylinder
  79727. * @param height The height of the emission cylinder
  79728. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  79729. * @param directionRandomizer How much to randomize the particle direction [0-1]
  79730. * @returns the emitter
  79731. */
  79732. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  79733. /**
  79734. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  79735. * @param radius The radius of the cylinder to emit from
  79736. * @param height The height of the emission cylinder
  79737. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  79738. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  79739. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  79740. * @returns the emitter
  79741. */
  79742. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  79743. /**
  79744. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  79745. * @param radius The radius of the cone to emit from
  79746. * @param angle The base angle of the cone
  79747. * @returns the emitter
  79748. */
  79749. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  79750. /**
  79751. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  79752. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  79753. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  79754. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  79755. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  79756. * @returns the emitter
  79757. */
  79758. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  79759. }
  79760. }
  79761. declare module BABYLON {
  79762. /**
  79763. * Type of sub emitter
  79764. */
  79765. export enum SubEmitterType {
  79766. /**
  79767. * Attached to the particle over it's lifetime
  79768. */
  79769. ATTACHED = 0,
  79770. /**
  79771. * Created when the particle dies
  79772. */
  79773. END = 1
  79774. }
  79775. /**
  79776. * Sub emitter class used to emit particles from an existing particle
  79777. */
  79778. export class SubEmitter {
  79779. /**
  79780. * the particle system to be used by the sub emitter
  79781. */
  79782. particleSystem: ParticleSystem;
  79783. /**
  79784. * Type of the submitter (Default: END)
  79785. */
  79786. type: SubEmitterType;
  79787. /**
  79788. * 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)
  79789. * Note: This only is supported when using an emitter of type Mesh
  79790. */
  79791. inheritDirection: boolean;
  79792. /**
  79793. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  79794. */
  79795. inheritedVelocityAmount: number;
  79796. /**
  79797. * Creates a sub emitter
  79798. * @param particleSystem the particle system to be used by the sub emitter
  79799. */
  79800. constructor(
  79801. /**
  79802. * the particle system to be used by the sub emitter
  79803. */
  79804. particleSystem: ParticleSystem);
  79805. /**
  79806. * Clones the sub emitter
  79807. * @returns the cloned sub emitter
  79808. */
  79809. clone(): SubEmitter;
  79810. /**
  79811. * Serialize current object to a JSON object
  79812. * @returns the serialized object
  79813. */
  79814. serialize(): any;
  79815. /** @hidden */
  79816. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  79817. /**
  79818. * Creates a new SubEmitter from a serialized JSON version
  79819. * @param serializationObject defines the JSON object to read from
  79820. * @param scene defines the hosting scene
  79821. * @param rootUrl defines the rootUrl for data loading
  79822. * @returns a new SubEmitter
  79823. */
  79824. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  79825. /** Release associated resources */
  79826. dispose(): void;
  79827. }
  79828. }
  79829. declare module BABYLON {
  79830. /** @hidden */
  79831. export var clipPlaneFragmentDeclaration: {
  79832. name: string;
  79833. shader: string;
  79834. };
  79835. }
  79836. declare module BABYLON {
  79837. /** @hidden */
  79838. export var imageProcessingDeclaration: {
  79839. name: string;
  79840. shader: string;
  79841. };
  79842. }
  79843. declare module BABYLON {
  79844. /** @hidden */
  79845. export var imageProcessingFunctions: {
  79846. name: string;
  79847. shader: string;
  79848. };
  79849. }
  79850. declare module BABYLON {
  79851. /** @hidden */
  79852. export var clipPlaneFragment: {
  79853. name: string;
  79854. shader: string;
  79855. };
  79856. }
  79857. declare module BABYLON {
  79858. /** @hidden */
  79859. export var particlesPixelShader: {
  79860. name: string;
  79861. shader: string;
  79862. };
  79863. }
  79864. declare module BABYLON {
  79865. /** @hidden */
  79866. export var clipPlaneVertexDeclaration: {
  79867. name: string;
  79868. shader: string;
  79869. };
  79870. }
  79871. declare module BABYLON {
  79872. /** @hidden */
  79873. export var clipPlaneVertex: {
  79874. name: string;
  79875. shader: string;
  79876. };
  79877. }
  79878. declare module BABYLON {
  79879. /** @hidden */
  79880. export var particlesVertexShader: {
  79881. name: string;
  79882. shader: string;
  79883. };
  79884. }
  79885. declare module BABYLON {
  79886. /**
  79887. * This represents a particle system in Babylon.
  79888. * 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.
  79889. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  79890. * @example https://doc.babylonjs.com/babylon101/particles
  79891. */
  79892. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  79893. /**
  79894. * Billboard mode will only apply to Y axis
  79895. */
  79896. static readonly BILLBOARDMODE_Y: number;
  79897. /**
  79898. * Billboard mode will apply to all axes
  79899. */
  79900. static readonly BILLBOARDMODE_ALL: number;
  79901. /**
  79902. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  79903. */
  79904. static readonly BILLBOARDMODE_STRETCHED: number;
  79905. /**
  79906. * This function can be defined to provide custom update for active particles.
  79907. * This function will be called instead of regular update (age, position, color, etc.).
  79908. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  79909. */
  79910. updateFunction: (particles: Particle[]) => void;
  79911. private _emitterWorldMatrix;
  79912. /**
  79913. * This function can be defined to specify initial direction for every new particle.
  79914. * It by default use the emitterType defined function
  79915. */
  79916. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  79917. /**
  79918. * This function can be defined to specify initial position for every new particle.
  79919. * It by default use the emitterType defined function
  79920. */
  79921. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  79922. /**
  79923. * @hidden
  79924. */
  79925. _inheritedVelocityOffset: Vector3;
  79926. /**
  79927. * An event triggered when the system is disposed
  79928. */
  79929. onDisposeObservable: Observable<ParticleSystem>;
  79930. private _onDisposeObserver;
  79931. /**
  79932. * Sets a callback that will be triggered when the system is disposed
  79933. */
  79934. onDispose: () => void;
  79935. private _particles;
  79936. private _epsilon;
  79937. private _capacity;
  79938. private _stockParticles;
  79939. private _newPartsExcess;
  79940. private _vertexData;
  79941. private _vertexBuffer;
  79942. private _vertexBuffers;
  79943. private _spriteBuffer;
  79944. private _indexBuffer;
  79945. private _effect;
  79946. private _customEffect;
  79947. private _cachedDefines;
  79948. private _scaledColorStep;
  79949. private _colorDiff;
  79950. private _scaledDirection;
  79951. private _scaledGravity;
  79952. private _currentRenderId;
  79953. private _alive;
  79954. private _useInstancing;
  79955. private _started;
  79956. private _stopped;
  79957. private _actualFrame;
  79958. private _scaledUpdateSpeed;
  79959. private _vertexBufferSize;
  79960. /** @hidden */
  79961. _currentEmitRateGradient: Nullable<FactorGradient>;
  79962. /** @hidden */
  79963. _currentEmitRate1: number;
  79964. /** @hidden */
  79965. _currentEmitRate2: number;
  79966. /** @hidden */
  79967. _currentStartSizeGradient: Nullable<FactorGradient>;
  79968. /** @hidden */
  79969. _currentStartSize1: number;
  79970. /** @hidden */
  79971. _currentStartSize2: number;
  79972. private readonly _rawTextureWidth;
  79973. private _rampGradientsTexture;
  79974. private _useRampGradients;
  79975. /** Gets or sets a boolean indicating that ramp gradients must be used
  79976. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  79977. */
  79978. useRampGradients: boolean;
  79979. /**
  79980. * 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.
  79981. * 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: [])
  79982. */
  79983. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  79984. private _subEmitters;
  79985. /**
  79986. * @hidden
  79987. * If the particle systems emitter should be disposed when the particle system is disposed
  79988. */
  79989. _disposeEmitterOnDispose: boolean;
  79990. /**
  79991. * The current active Sub-systems, this property is used by the root particle system only.
  79992. */
  79993. activeSubSystems: Array<ParticleSystem>;
  79994. private _rootParticleSystem;
  79995. /**
  79996. * Gets the current list of active particles
  79997. */
  79998. readonly particles: Particle[];
  79999. /**
  80000. * Returns the string "ParticleSystem"
  80001. * @returns a string containing the class name
  80002. */
  80003. getClassName(): string;
  80004. /**
  80005. * Instantiates a particle system.
  80006. * 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.
  80007. * @param name The name of the particle system
  80008. * @param capacity The max number of particles alive at the same time
  80009. * @param scene The scene the particle system belongs to
  80010. * @param customEffect a custom effect used to change the way particles are rendered by default
  80011. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  80012. * @param epsilon Offset used to render the particles
  80013. */
  80014. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  80015. private _addFactorGradient;
  80016. private _removeFactorGradient;
  80017. /**
  80018. * Adds a new life time gradient
  80019. * @param gradient defines the gradient to use (between 0 and 1)
  80020. * @param factor defines the life time factor to affect to the specified gradient
  80021. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80022. * @returns the current particle system
  80023. */
  80024. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80025. /**
  80026. * Remove a specific life time gradient
  80027. * @param gradient defines the gradient to remove
  80028. * @returns the current particle system
  80029. */
  80030. removeLifeTimeGradient(gradient: number): IParticleSystem;
  80031. /**
  80032. * Adds a new size gradient
  80033. * @param gradient defines the gradient to use (between 0 and 1)
  80034. * @param factor defines the size factor to affect to the specified gradient
  80035. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80036. * @returns the current particle system
  80037. */
  80038. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80039. /**
  80040. * Remove a specific size gradient
  80041. * @param gradient defines the gradient to remove
  80042. * @returns the current particle system
  80043. */
  80044. removeSizeGradient(gradient: number): IParticleSystem;
  80045. /**
  80046. * Adds a new color remap gradient
  80047. * @param gradient defines the gradient to use (between 0 and 1)
  80048. * @param min defines the color remap minimal range
  80049. * @param max defines the color remap maximal range
  80050. * @returns the current particle system
  80051. */
  80052. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  80053. /**
  80054. * Remove a specific color remap gradient
  80055. * @param gradient defines the gradient to remove
  80056. * @returns the current particle system
  80057. */
  80058. removeColorRemapGradient(gradient: number): IParticleSystem;
  80059. /**
  80060. * Adds a new alpha remap gradient
  80061. * @param gradient defines the gradient to use (between 0 and 1)
  80062. * @param min defines the alpha remap minimal range
  80063. * @param max defines the alpha remap maximal range
  80064. * @returns the current particle system
  80065. */
  80066. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  80067. /**
  80068. * Remove a specific alpha remap gradient
  80069. * @param gradient defines the gradient to remove
  80070. * @returns the current particle system
  80071. */
  80072. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  80073. /**
  80074. * Adds a new angular speed gradient
  80075. * @param gradient defines the gradient to use (between 0 and 1)
  80076. * @param factor defines the angular speed to affect to the specified gradient
  80077. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80078. * @returns the current particle system
  80079. */
  80080. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80081. /**
  80082. * Remove a specific angular speed gradient
  80083. * @param gradient defines the gradient to remove
  80084. * @returns the current particle system
  80085. */
  80086. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  80087. /**
  80088. * Adds a new velocity gradient
  80089. * @param gradient defines the gradient to use (between 0 and 1)
  80090. * @param factor defines the velocity to affect to the specified gradient
  80091. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80092. * @returns the current particle system
  80093. */
  80094. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80095. /**
  80096. * Remove a specific velocity gradient
  80097. * @param gradient defines the gradient to remove
  80098. * @returns the current particle system
  80099. */
  80100. removeVelocityGradient(gradient: number): IParticleSystem;
  80101. /**
  80102. * Adds a new limit velocity gradient
  80103. * @param gradient defines the gradient to use (between 0 and 1)
  80104. * @param factor defines the limit velocity value to affect to the specified gradient
  80105. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80106. * @returns the current particle system
  80107. */
  80108. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80109. /**
  80110. * Remove a specific limit velocity gradient
  80111. * @param gradient defines the gradient to remove
  80112. * @returns the current particle system
  80113. */
  80114. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  80115. /**
  80116. * Adds a new drag gradient
  80117. * @param gradient defines the gradient to use (between 0 and 1)
  80118. * @param factor defines the drag value to affect to the specified gradient
  80119. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80120. * @returns the current particle system
  80121. */
  80122. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80123. /**
  80124. * Remove a specific drag gradient
  80125. * @param gradient defines the gradient to remove
  80126. * @returns the current particle system
  80127. */
  80128. removeDragGradient(gradient: number): IParticleSystem;
  80129. /**
  80130. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  80131. * @param gradient defines the gradient to use (between 0 and 1)
  80132. * @param factor defines the emit rate value to affect to the specified gradient
  80133. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80134. * @returns the current particle system
  80135. */
  80136. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80137. /**
  80138. * Remove a specific emit rate gradient
  80139. * @param gradient defines the gradient to remove
  80140. * @returns the current particle system
  80141. */
  80142. removeEmitRateGradient(gradient: number): IParticleSystem;
  80143. /**
  80144. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  80145. * @param gradient defines the gradient to use (between 0 and 1)
  80146. * @param factor defines the start size value to affect to the specified gradient
  80147. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80148. * @returns the current particle system
  80149. */
  80150. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80151. /**
  80152. * Remove a specific start size gradient
  80153. * @param gradient defines the gradient to remove
  80154. * @returns the current particle system
  80155. */
  80156. removeStartSizeGradient(gradient: number): IParticleSystem;
  80157. private _createRampGradientTexture;
  80158. /**
  80159. * Gets the current list of ramp gradients.
  80160. * You must use addRampGradient and removeRampGradient to udpate this list
  80161. * @returns the list of ramp gradients
  80162. */
  80163. getRampGradients(): Nullable<Array<Color3Gradient>>;
  80164. /**
  80165. * Adds a new ramp gradient used to remap particle colors
  80166. * @param gradient defines the gradient to use (between 0 and 1)
  80167. * @param color defines the color to affect to the specified gradient
  80168. * @returns the current particle system
  80169. */
  80170. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  80171. /**
  80172. * Remove a specific ramp gradient
  80173. * @param gradient defines the gradient to remove
  80174. * @returns the current particle system
  80175. */
  80176. removeRampGradient(gradient: number): ParticleSystem;
  80177. /**
  80178. * Adds a new color gradient
  80179. * @param gradient defines the gradient to use (between 0 and 1)
  80180. * @param color1 defines the color to affect to the specified gradient
  80181. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  80182. * @returns this particle system
  80183. */
  80184. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  80185. /**
  80186. * Remove a specific color gradient
  80187. * @param gradient defines the gradient to remove
  80188. * @returns this particle system
  80189. */
  80190. removeColorGradient(gradient: number): IParticleSystem;
  80191. private _fetchR;
  80192. protected _reset(): void;
  80193. private _resetEffect;
  80194. private _createVertexBuffers;
  80195. private _createIndexBuffer;
  80196. /**
  80197. * Gets the maximum number of particles active at the same time.
  80198. * @returns The max number of active particles.
  80199. */
  80200. getCapacity(): number;
  80201. /**
  80202. * Gets whether there are still active particles in the system.
  80203. * @returns True if it is alive, otherwise false.
  80204. */
  80205. isAlive(): boolean;
  80206. /**
  80207. * Gets if the system has been started. (Note: this will still be true after stop is called)
  80208. * @returns True if it has been started, otherwise false.
  80209. */
  80210. isStarted(): boolean;
  80211. private _prepareSubEmitterInternalArray;
  80212. /**
  80213. * Starts the particle system and begins to emit
  80214. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  80215. */
  80216. start(delay?: number): void;
  80217. /**
  80218. * Stops the particle system.
  80219. * @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.
  80220. */
  80221. stop(stopSubEmitters?: boolean): void;
  80222. /**
  80223. * Remove all active particles
  80224. */
  80225. reset(): void;
  80226. /**
  80227. * @hidden (for internal use only)
  80228. */
  80229. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  80230. /**
  80231. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  80232. * Its lifetime will start back at 0.
  80233. */
  80234. recycleParticle: (particle: Particle) => void;
  80235. private _stopSubEmitters;
  80236. private _createParticle;
  80237. private _removeFromRoot;
  80238. private _emitFromParticle;
  80239. private _update;
  80240. /** @hidden */
  80241. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  80242. /** @hidden */
  80243. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  80244. /** @hidden */
  80245. private _getEffect;
  80246. /**
  80247. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  80248. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  80249. */
  80250. animate(preWarmOnly?: boolean): void;
  80251. private _appendParticleVertices;
  80252. /**
  80253. * Rebuilds the particle system.
  80254. */
  80255. rebuild(): void;
  80256. /**
  80257. * Is this system ready to be used/rendered
  80258. * @return true if the system is ready
  80259. */
  80260. isReady(): boolean;
  80261. private _render;
  80262. /**
  80263. * Renders the particle system in its current state.
  80264. * @returns the current number of particles
  80265. */
  80266. render(): number;
  80267. /**
  80268. * Disposes the particle system and free the associated resources
  80269. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  80270. */
  80271. dispose(disposeTexture?: boolean): void;
  80272. /**
  80273. * Clones the particle system.
  80274. * @param name The name of the cloned object
  80275. * @param newEmitter The new emitter to use
  80276. * @returns the cloned particle system
  80277. */
  80278. clone(name: string, newEmitter: any): ParticleSystem;
  80279. /**
  80280. * Serializes the particle system to a JSON object.
  80281. * @returns the JSON object
  80282. */
  80283. serialize(): any;
  80284. /** @hidden */
  80285. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  80286. /** @hidden */
  80287. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  80288. /**
  80289. * Parses a JSON object to create a particle system.
  80290. * @param parsedParticleSystem The JSON object to parse
  80291. * @param scene The scene to create the particle system in
  80292. * @param rootUrl The root url to use to load external dependencies like texture
  80293. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  80294. * @returns the Parsed particle system
  80295. */
  80296. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  80297. }
  80298. }
  80299. declare module BABYLON {
  80300. /**
  80301. * A particle represents one of the element emitted by a particle system.
  80302. * This is mainly define by its coordinates, direction, velocity and age.
  80303. */
  80304. export class Particle {
  80305. /**
  80306. * The particle system the particle belongs to.
  80307. */
  80308. particleSystem: ParticleSystem;
  80309. private static _Count;
  80310. /**
  80311. * Unique ID of the particle
  80312. */
  80313. id: number;
  80314. /**
  80315. * The world position of the particle in the scene.
  80316. */
  80317. position: Vector3;
  80318. /**
  80319. * The world direction of the particle in the scene.
  80320. */
  80321. direction: Vector3;
  80322. /**
  80323. * The color of the particle.
  80324. */
  80325. color: Color4;
  80326. /**
  80327. * The color change of the particle per step.
  80328. */
  80329. colorStep: Color4;
  80330. /**
  80331. * Defines how long will the life of the particle be.
  80332. */
  80333. lifeTime: number;
  80334. /**
  80335. * The current age of the particle.
  80336. */
  80337. age: number;
  80338. /**
  80339. * The current size of the particle.
  80340. */
  80341. size: number;
  80342. /**
  80343. * The current scale of the particle.
  80344. */
  80345. scale: Vector2;
  80346. /**
  80347. * The current angle of the particle.
  80348. */
  80349. angle: number;
  80350. /**
  80351. * Defines how fast is the angle changing.
  80352. */
  80353. angularSpeed: number;
  80354. /**
  80355. * Defines the cell index used by the particle to be rendered from a sprite.
  80356. */
  80357. cellIndex: number;
  80358. /**
  80359. * The information required to support color remapping
  80360. */
  80361. remapData: Vector4;
  80362. /** @hidden */
  80363. _randomCellOffset?: number;
  80364. /** @hidden */
  80365. _initialDirection: Nullable<Vector3>;
  80366. /** @hidden */
  80367. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  80368. /** @hidden */
  80369. _initialStartSpriteCellID: number;
  80370. /** @hidden */
  80371. _initialEndSpriteCellID: number;
  80372. /** @hidden */
  80373. _currentColorGradient: Nullable<ColorGradient>;
  80374. /** @hidden */
  80375. _currentColor1: Color4;
  80376. /** @hidden */
  80377. _currentColor2: Color4;
  80378. /** @hidden */
  80379. _currentSizeGradient: Nullable<FactorGradient>;
  80380. /** @hidden */
  80381. _currentSize1: number;
  80382. /** @hidden */
  80383. _currentSize2: number;
  80384. /** @hidden */
  80385. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  80386. /** @hidden */
  80387. _currentAngularSpeed1: number;
  80388. /** @hidden */
  80389. _currentAngularSpeed2: number;
  80390. /** @hidden */
  80391. _currentVelocityGradient: Nullable<FactorGradient>;
  80392. /** @hidden */
  80393. _currentVelocity1: number;
  80394. /** @hidden */
  80395. _currentVelocity2: number;
  80396. /** @hidden */
  80397. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  80398. /** @hidden */
  80399. _currentLimitVelocity1: number;
  80400. /** @hidden */
  80401. _currentLimitVelocity2: number;
  80402. /** @hidden */
  80403. _currentDragGradient: Nullable<FactorGradient>;
  80404. /** @hidden */
  80405. _currentDrag1: number;
  80406. /** @hidden */
  80407. _currentDrag2: number;
  80408. /** @hidden */
  80409. _randomNoiseCoordinates1: Vector3;
  80410. /** @hidden */
  80411. _randomNoiseCoordinates2: Vector3;
  80412. /**
  80413. * Creates a new instance Particle
  80414. * @param particleSystem the particle system the particle belongs to
  80415. */
  80416. constructor(
  80417. /**
  80418. * The particle system the particle belongs to.
  80419. */
  80420. particleSystem: ParticleSystem);
  80421. private updateCellInfoFromSystem;
  80422. /**
  80423. * Defines how the sprite cell index is updated for the particle
  80424. */
  80425. updateCellIndex(): void;
  80426. /** @hidden */
  80427. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  80428. /** @hidden */
  80429. _inheritParticleInfoToSubEmitters(): void;
  80430. /** @hidden */
  80431. _reset(): void;
  80432. /**
  80433. * Copy the properties of particle to another one.
  80434. * @param other the particle to copy the information to.
  80435. */
  80436. copyTo(other: Particle): void;
  80437. }
  80438. }
  80439. declare module BABYLON {
  80440. /**
  80441. * Particle emitter represents a volume emitting particles.
  80442. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  80443. */
  80444. export interface IParticleEmitterType {
  80445. /**
  80446. * Called by the particle System when the direction is computed for the created particle.
  80447. * @param worldMatrix is the world matrix of the particle system
  80448. * @param directionToUpdate is the direction vector to update with the result
  80449. * @param particle is the particle we are computed the direction for
  80450. */
  80451. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  80452. /**
  80453. * Called by the particle System when the position is computed for the created particle.
  80454. * @param worldMatrix is the world matrix of the particle system
  80455. * @param positionToUpdate is the position vector to update with the result
  80456. * @param particle is the particle we are computed the position for
  80457. */
  80458. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  80459. /**
  80460. * Clones the current emitter and returns a copy of it
  80461. * @returns the new emitter
  80462. */
  80463. clone(): IParticleEmitterType;
  80464. /**
  80465. * Called by the GPUParticleSystem to setup the update shader
  80466. * @param effect defines the update shader
  80467. */
  80468. applyToShader(effect: Effect): void;
  80469. /**
  80470. * Returns a string to use to update the GPU particles update shader
  80471. * @returns the effect defines string
  80472. */
  80473. getEffectDefines(): string;
  80474. /**
  80475. * Returns a string representing the class name
  80476. * @returns a string containing the class name
  80477. */
  80478. getClassName(): string;
  80479. /**
  80480. * Serializes the particle system to a JSON object.
  80481. * @returns the JSON object
  80482. */
  80483. serialize(): any;
  80484. /**
  80485. * Parse properties from a JSON object
  80486. * @param serializationObject defines the JSON object
  80487. */
  80488. parse(serializationObject: any): void;
  80489. }
  80490. }
  80491. declare module BABYLON {
  80492. /**
  80493. * Particle emitter emitting particles from the inside of a box.
  80494. * It emits the particles randomly between 2 given directions.
  80495. */
  80496. export class BoxParticleEmitter implements IParticleEmitterType {
  80497. /**
  80498. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  80499. */
  80500. direction1: Vector3;
  80501. /**
  80502. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  80503. */
  80504. direction2: Vector3;
  80505. /**
  80506. * 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.
  80507. */
  80508. minEmitBox: Vector3;
  80509. /**
  80510. * 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.
  80511. */
  80512. maxEmitBox: Vector3;
  80513. /**
  80514. * Creates a new instance BoxParticleEmitter
  80515. */
  80516. constructor();
  80517. /**
  80518. * Called by the particle System when the direction is computed for the created particle.
  80519. * @param worldMatrix is the world matrix of the particle system
  80520. * @param directionToUpdate is the direction vector to update with the result
  80521. * @param particle is the particle we are computed the direction for
  80522. */
  80523. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  80524. /**
  80525. * Called by the particle System when the position is computed for the created particle.
  80526. * @param worldMatrix is the world matrix of the particle system
  80527. * @param positionToUpdate is the position vector to update with the result
  80528. * @param particle is the particle we are computed the position for
  80529. */
  80530. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  80531. /**
  80532. * Clones the current emitter and returns a copy of it
  80533. * @returns the new emitter
  80534. */
  80535. clone(): BoxParticleEmitter;
  80536. /**
  80537. * Called by the GPUParticleSystem to setup the update shader
  80538. * @param effect defines the update shader
  80539. */
  80540. applyToShader(effect: Effect): void;
  80541. /**
  80542. * Returns a string to use to update the GPU particles update shader
  80543. * @returns a string containng the defines string
  80544. */
  80545. getEffectDefines(): string;
  80546. /**
  80547. * Returns the string "BoxParticleEmitter"
  80548. * @returns a string containing the class name
  80549. */
  80550. getClassName(): string;
  80551. /**
  80552. * Serializes the particle system to a JSON object.
  80553. * @returns the JSON object
  80554. */
  80555. serialize(): any;
  80556. /**
  80557. * Parse properties from a JSON object
  80558. * @param serializationObject defines the JSON object
  80559. */
  80560. parse(serializationObject: any): void;
  80561. }
  80562. }
  80563. declare module BABYLON {
  80564. /**
  80565. * Particle emitter emitting particles from the inside of a cone.
  80566. * It emits the particles alongside the cone volume from the base to the particle.
  80567. * The emission direction might be randomized.
  80568. */
  80569. export class ConeParticleEmitter implements IParticleEmitterType {
  80570. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  80571. directionRandomizer: number;
  80572. private _radius;
  80573. private _angle;
  80574. private _height;
  80575. /**
  80576. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  80577. */
  80578. radiusRange: number;
  80579. /**
  80580. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  80581. */
  80582. heightRange: number;
  80583. /**
  80584. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  80585. */
  80586. emitFromSpawnPointOnly: boolean;
  80587. /**
  80588. * Gets or sets the radius of the emission cone
  80589. */
  80590. radius: number;
  80591. /**
  80592. * Gets or sets the angle of the emission cone
  80593. */
  80594. angle: number;
  80595. private _buildHeight;
  80596. /**
  80597. * Creates a new instance ConeParticleEmitter
  80598. * @param radius the radius of the emission cone (1 by default)
  80599. * @param angle the cone base angle (PI by default)
  80600. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  80601. */
  80602. constructor(radius?: number, angle?: number,
  80603. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  80604. directionRandomizer?: number);
  80605. /**
  80606. * Called by the particle System when the direction is computed for the created particle.
  80607. * @param worldMatrix is the world matrix of the particle system
  80608. * @param directionToUpdate is the direction vector to update with the result
  80609. * @param particle is the particle we are computed the direction for
  80610. */
  80611. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  80612. /**
  80613. * Called by the particle System when the position is computed for the created particle.
  80614. * @param worldMatrix is the world matrix of the particle system
  80615. * @param positionToUpdate is the position vector to update with the result
  80616. * @param particle is the particle we are computed the position for
  80617. */
  80618. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  80619. /**
  80620. * Clones the current emitter and returns a copy of it
  80621. * @returns the new emitter
  80622. */
  80623. clone(): ConeParticleEmitter;
  80624. /**
  80625. * Called by the GPUParticleSystem to setup the update shader
  80626. * @param effect defines the update shader
  80627. */
  80628. applyToShader(effect: Effect): void;
  80629. /**
  80630. * Returns a string to use to update the GPU particles update shader
  80631. * @returns a string containng the defines string
  80632. */
  80633. getEffectDefines(): string;
  80634. /**
  80635. * Returns the string "ConeParticleEmitter"
  80636. * @returns a string containing the class name
  80637. */
  80638. getClassName(): string;
  80639. /**
  80640. * Serializes the particle system to a JSON object.
  80641. * @returns the JSON object
  80642. */
  80643. serialize(): any;
  80644. /**
  80645. * Parse properties from a JSON object
  80646. * @param serializationObject defines the JSON object
  80647. */
  80648. parse(serializationObject: any): void;
  80649. }
  80650. }
  80651. declare module BABYLON {
  80652. /**
  80653. * Particle emitter emitting particles from the inside of a cylinder.
  80654. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  80655. */
  80656. export class CylinderParticleEmitter implements IParticleEmitterType {
  80657. /**
  80658. * The radius of the emission cylinder.
  80659. */
  80660. radius: number;
  80661. /**
  80662. * The height of the emission cylinder.
  80663. */
  80664. height: number;
  80665. /**
  80666. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  80667. */
  80668. radiusRange: number;
  80669. /**
  80670. * How much to randomize the particle direction [0-1].
  80671. */
  80672. directionRandomizer: number;
  80673. /**
  80674. * Creates a new instance CylinderParticleEmitter
  80675. * @param radius the radius of the emission cylinder (1 by default)
  80676. * @param height the height of the emission cylinder (1 by default)
  80677. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  80678. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  80679. */
  80680. constructor(
  80681. /**
  80682. * The radius of the emission cylinder.
  80683. */
  80684. radius?: number,
  80685. /**
  80686. * The height of the emission cylinder.
  80687. */
  80688. height?: number,
  80689. /**
  80690. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  80691. */
  80692. radiusRange?: number,
  80693. /**
  80694. * How much to randomize the particle direction [0-1].
  80695. */
  80696. directionRandomizer?: number);
  80697. /**
  80698. * Called by the particle System when the direction is computed for the created particle.
  80699. * @param worldMatrix is the world matrix of the particle system
  80700. * @param directionToUpdate is the direction vector to update with the result
  80701. * @param particle is the particle we are computed the direction for
  80702. */
  80703. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  80704. /**
  80705. * Called by the particle System when the position is computed for the created particle.
  80706. * @param worldMatrix is the world matrix of the particle system
  80707. * @param positionToUpdate is the position vector to update with the result
  80708. * @param particle is the particle we are computed the position for
  80709. */
  80710. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  80711. /**
  80712. * Clones the current emitter and returns a copy of it
  80713. * @returns the new emitter
  80714. */
  80715. clone(): CylinderParticleEmitter;
  80716. /**
  80717. * Called by the GPUParticleSystem to setup the update shader
  80718. * @param effect defines the update shader
  80719. */
  80720. applyToShader(effect: Effect): void;
  80721. /**
  80722. * Returns a string to use to update the GPU particles update shader
  80723. * @returns a string containng the defines string
  80724. */
  80725. getEffectDefines(): string;
  80726. /**
  80727. * Returns the string "CylinderParticleEmitter"
  80728. * @returns a string containing the class name
  80729. */
  80730. getClassName(): string;
  80731. /**
  80732. * Serializes the particle system to a JSON object.
  80733. * @returns the JSON object
  80734. */
  80735. serialize(): any;
  80736. /**
  80737. * Parse properties from a JSON object
  80738. * @param serializationObject defines the JSON object
  80739. */
  80740. parse(serializationObject: any): void;
  80741. }
  80742. /**
  80743. * Particle emitter emitting particles from the inside of a cylinder.
  80744. * It emits the particles randomly between two vectors.
  80745. */
  80746. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  80747. /**
  80748. * The min limit of the emission direction.
  80749. */
  80750. direction1: Vector3;
  80751. /**
  80752. * The max limit of the emission direction.
  80753. */
  80754. direction2: Vector3;
  80755. /**
  80756. * Creates a new instance CylinderDirectedParticleEmitter
  80757. * @param radius the radius of the emission cylinder (1 by default)
  80758. * @param height the height of the emission cylinder (1 by default)
  80759. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  80760. * @param direction1 the min limit of the emission direction (up vector by default)
  80761. * @param direction2 the max limit of the emission direction (up vector by default)
  80762. */
  80763. constructor(radius?: number, height?: number, radiusRange?: number,
  80764. /**
  80765. * The min limit of the emission direction.
  80766. */
  80767. direction1?: Vector3,
  80768. /**
  80769. * The max limit of the emission direction.
  80770. */
  80771. direction2?: Vector3);
  80772. /**
  80773. * Called by the particle System when the direction is computed for the created particle.
  80774. * @param worldMatrix is the world matrix of the particle system
  80775. * @param directionToUpdate is the direction vector to update with the result
  80776. * @param particle is the particle we are computed the direction for
  80777. */
  80778. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  80779. /**
  80780. * Clones the current emitter and returns a copy of it
  80781. * @returns the new emitter
  80782. */
  80783. clone(): CylinderDirectedParticleEmitter;
  80784. /**
  80785. * Called by the GPUParticleSystem to setup the update shader
  80786. * @param effect defines the update shader
  80787. */
  80788. applyToShader(effect: Effect): void;
  80789. /**
  80790. * Returns a string to use to update the GPU particles update shader
  80791. * @returns a string containng the defines string
  80792. */
  80793. getEffectDefines(): string;
  80794. /**
  80795. * Returns the string "CylinderDirectedParticleEmitter"
  80796. * @returns a string containing the class name
  80797. */
  80798. getClassName(): string;
  80799. /**
  80800. * Serializes the particle system to a JSON object.
  80801. * @returns the JSON object
  80802. */
  80803. serialize(): any;
  80804. /**
  80805. * Parse properties from a JSON object
  80806. * @param serializationObject defines the JSON object
  80807. */
  80808. parse(serializationObject: any): void;
  80809. }
  80810. }
  80811. declare module BABYLON {
  80812. /**
  80813. * Particle emitter emitting particles from the inside of a hemisphere.
  80814. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  80815. */
  80816. export class HemisphericParticleEmitter implements IParticleEmitterType {
  80817. /**
  80818. * The radius of the emission hemisphere.
  80819. */
  80820. radius: number;
  80821. /**
  80822. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  80823. */
  80824. radiusRange: number;
  80825. /**
  80826. * How much to randomize the particle direction [0-1].
  80827. */
  80828. directionRandomizer: number;
  80829. /**
  80830. * Creates a new instance HemisphericParticleEmitter
  80831. * @param radius the radius of the emission hemisphere (1 by default)
  80832. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  80833. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  80834. */
  80835. constructor(
  80836. /**
  80837. * The radius of the emission hemisphere.
  80838. */
  80839. radius?: number,
  80840. /**
  80841. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  80842. */
  80843. radiusRange?: number,
  80844. /**
  80845. * How much to randomize the particle direction [0-1].
  80846. */
  80847. directionRandomizer?: number);
  80848. /**
  80849. * Called by the particle System when the direction is computed for the created particle.
  80850. * @param worldMatrix is the world matrix of the particle system
  80851. * @param directionToUpdate is the direction vector to update with the result
  80852. * @param particle is the particle we are computed the direction for
  80853. */
  80854. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  80855. /**
  80856. * Called by the particle System when the position is computed for the created particle.
  80857. * @param worldMatrix is the world matrix of the particle system
  80858. * @param positionToUpdate is the position vector to update with the result
  80859. * @param particle is the particle we are computed the position for
  80860. */
  80861. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  80862. /**
  80863. * Clones the current emitter and returns a copy of it
  80864. * @returns the new emitter
  80865. */
  80866. clone(): HemisphericParticleEmitter;
  80867. /**
  80868. * Called by the GPUParticleSystem to setup the update shader
  80869. * @param effect defines the update shader
  80870. */
  80871. applyToShader(effect: Effect): void;
  80872. /**
  80873. * Returns a string to use to update the GPU particles update shader
  80874. * @returns a string containng the defines string
  80875. */
  80876. getEffectDefines(): string;
  80877. /**
  80878. * Returns the string "HemisphericParticleEmitter"
  80879. * @returns a string containing the class name
  80880. */
  80881. getClassName(): string;
  80882. /**
  80883. * Serializes the particle system to a JSON object.
  80884. * @returns the JSON object
  80885. */
  80886. serialize(): any;
  80887. /**
  80888. * Parse properties from a JSON object
  80889. * @param serializationObject defines the JSON object
  80890. */
  80891. parse(serializationObject: any): void;
  80892. }
  80893. }
  80894. declare module BABYLON {
  80895. /**
  80896. * Particle emitter emitting particles from a point.
  80897. * It emits the particles randomly between 2 given directions.
  80898. */
  80899. export class PointParticleEmitter implements IParticleEmitterType {
  80900. /**
  80901. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  80902. */
  80903. direction1: Vector3;
  80904. /**
  80905. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  80906. */
  80907. direction2: Vector3;
  80908. /**
  80909. * Creates a new instance PointParticleEmitter
  80910. */
  80911. constructor();
  80912. /**
  80913. * Called by the particle System when the direction is computed for the created particle.
  80914. * @param worldMatrix is the world matrix of the particle system
  80915. * @param directionToUpdate is the direction vector to update with the result
  80916. * @param particle is the particle we are computed the direction for
  80917. */
  80918. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  80919. /**
  80920. * Called by the particle System when the position is computed for the created particle.
  80921. * @param worldMatrix is the world matrix of the particle system
  80922. * @param positionToUpdate is the position vector to update with the result
  80923. * @param particle is the particle we are computed the position for
  80924. */
  80925. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  80926. /**
  80927. * Clones the current emitter and returns a copy of it
  80928. * @returns the new emitter
  80929. */
  80930. clone(): PointParticleEmitter;
  80931. /**
  80932. * Called by the GPUParticleSystem to setup the update shader
  80933. * @param effect defines the update shader
  80934. */
  80935. applyToShader(effect: Effect): void;
  80936. /**
  80937. * Returns a string to use to update the GPU particles update shader
  80938. * @returns a string containng the defines string
  80939. */
  80940. getEffectDefines(): string;
  80941. /**
  80942. * Returns the string "PointParticleEmitter"
  80943. * @returns a string containing the class name
  80944. */
  80945. getClassName(): string;
  80946. /**
  80947. * Serializes the particle system to a JSON object.
  80948. * @returns the JSON object
  80949. */
  80950. serialize(): any;
  80951. /**
  80952. * Parse properties from a JSON object
  80953. * @param serializationObject defines the JSON object
  80954. */
  80955. parse(serializationObject: any): void;
  80956. }
  80957. }
  80958. declare module BABYLON {
  80959. /**
  80960. * Particle emitter emitting particles from the inside of a sphere.
  80961. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  80962. */
  80963. export class SphereParticleEmitter implements IParticleEmitterType {
  80964. /**
  80965. * The radius of the emission sphere.
  80966. */
  80967. radius: number;
  80968. /**
  80969. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  80970. */
  80971. radiusRange: number;
  80972. /**
  80973. * How much to randomize the particle direction [0-1].
  80974. */
  80975. directionRandomizer: number;
  80976. /**
  80977. * Creates a new instance SphereParticleEmitter
  80978. * @param radius the radius of the emission sphere (1 by default)
  80979. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  80980. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  80981. */
  80982. constructor(
  80983. /**
  80984. * The radius of the emission sphere.
  80985. */
  80986. radius?: number,
  80987. /**
  80988. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  80989. */
  80990. radiusRange?: number,
  80991. /**
  80992. * How much to randomize the particle direction [0-1].
  80993. */
  80994. directionRandomizer?: number);
  80995. /**
  80996. * Called by the particle System when the direction is computed for the created particle.
  80997. * @param worldMatrix is the world matrix of the particle system
  80998. * @param directionToUpdate is the direction vector to update with the result
  80999. * @param particle is the particle we are computed the direction for
  81000. */
  81001. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81002. /**
  81003. * Called by the particle System when the position is computed for the created particle.
  81004. * @param worldMatrix is the world matrix of the particle system
  81005. * @param positionToUpdate is the position vector to update with the result
  81006. * @param particle is the particle we are computed the position for
  81007. */
  81008. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81009. /**
  81010. * Clones the current emitter and returns a copy of it
  81011. * @returns the new emitter
  81012. */
  81013. clone(): SphereParticleEmitter;
  81014. /**
  81015. * Called by the GPUParticleSystem to setup the update shader
  81016. * @param effect defines the update shader
  81017. */
  81018. applyToShader(effect: Effect): void;
  81019. /**
  81020. * Returns a string to use to update the GPU particles update shader
  81021. * @returns a string containng the defines string
  81022. */
  81023. getEffectDefines(): string;
  81024. /**
  81025. * Returns the string "SphereParticleEmitter"
  81026. * @returns a string containing the class name
  81027. */
  81028. getClassName(): string;
  81029. /**
  81030. * Serializes the particle system to a JSON object.
  81031. * @returns the JSON object
  81032. */
  81033. serialize(): any;
  81034. /**
  81035. * Parse properties from a JSON object
  81036. * @param serializationObject defines the JSON object
  81037. */
  81038. parse(serializationObject: any): void;
  81039. }
  81040. /**
  81041. * Particle emitter emitting particles from the inside of a sphere.
  81042. * It emits the particles randomly between two vectors.
  81043. */
  81044. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  81045. /**
  81046. * The min limit of the emission direction.
  81047. */
  81048. direction1: Vector3;
  81049. /**
  81050. * The max limit of the emission direction.
  81051. */
  81052. direction2: Vector3;
  81053. /**
  81054. * Creates a new instance SphereDirectedParticleEmitter
  81055. * @param radius the radius of the emission sphere (1 by default)
  81056. * @param direction1 the min limit of the emission direction (up vector by default)
  81057. * @param direction2 the max limit of the emission direction (up vector by default)
  81058. */
  81059. constructor(radius?: number,
  81060. /**
  81061. * The min limit of the emission direction.
  81062. */
  81063. direction1?: Vector3,
  81064. /**
  81065. * The max limit of the emission direction.
  81066. */
  81067. direction2?: Vector3);
  81068. /**
  81069. * Called by the particle System when the direction is computed for the created particle.
  81070. * @param worldMatrix is the world matrix of the particle system
  81071. * @param directionToUpdate is the direction vector to update with the result
  81072. * @param particle is the particle we are computed the direction for
  81073. */
  81074. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81075. /**
  81076. * Clones the current emitter and returns a copy of it
  81077. * @returns the new emitter
  81078. */
  81079. clone(): SphereDirectedParticleEmitter;
  81080. /**
  81081. * Called by the GPUParticleSystem to setup the update shader
  81082. * @param effect defines the update shader
  81083. */
  81084. applyToShader(effect: Effect): void;
  81085. /**
  81086. * Returns a string to use to update the GPU particles update shader
  81087. * @returns a string containng the defines string
  81088. */
  81089. getEffectDefines(): string;
  81090. /**
  81091. * Returns the string "SphereDirectedParticleEmitter"
  81092. * @returns a string containing the class name
  81093. */
  81094. getClassName(): string;
  81095. /**
  81096. * Serializes the particle system to a JSON object.
  81097. * @returns the JSON object
  81098. */
  81099. serialize(): any;
  81100. /**
  81101. * Parse properties from a JSON object
  81102. * @param serializationObject defines the JSON object
  81103. */
  81104. parse(serializationObject: any): void;
  81105. }
  81106. }
  81107. declare module BABYLON {
  81108. /**
  81109. * Interface representing a particle system in Babylon.js.
  81110. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  81111. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  81112. */
  81113. export interface IParticleSystem {
  81114. /**
  81115. * List of animations used by the particle system.
  81116. */
  81117. animations: Animation[];
  81118. /**
  81119. * The id of the Particle system.
  81120. */
  81121. id: string;
  81122. /**
  81123. * The name of the Particle system.
  81124. */
  81125. name: string;
  81126. /**
  81127. * The emitter represents the Mesh or position we are attaching the particle system to.
  81128. */
  81129. emitter: Nullable<AbstractMesh | Vector3>;
  81130. /**
  81131. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  81132. */
  81133. isBillboardBased: boolean;
  81134. /**
  81135. * The rendering group used by the Particle system to chose when to render.
  81136. */
  81137. renderingGroupId: number;
  81138. /**
  81139. * The layer mask we are rendering the particles through.
  81140. */
  81141. layerMask: number;
  81142. /**
  81143. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  81144. */
  81145. updateSpeed: number;
  81146. /**
  81147. * The amount of time the particle system is running (depends of the overall update speed).
  81148. */
  81149. targetStopDuration: number;
  81150. /**
  81151. * The texture used to render each particle. (this can be a spritesheet)
  81152. */
  81153. particleTexture: Nullable<Texture>;
  81154. /**
  81155. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  81156. */
  81157. blendMode: number;
  81158. /**
  81159. * Minimum life time of emitting particles.
  81160. */
  81161. minLifeTime: number;
  81162. /**
  81163. * Maximum life time of emitting particles.
  81164. */
  81165. maxLifeTime: number;
  81166. /**
  81167. * Minimum Size of emitting particles.
  81168. */
  81169. minSize: number;
  81170. /**
  81171. * Maximum Size of emitting particles.
  81172. */
  81173. maxSize: number;
  81174. /**
  81175. * Minimum scale of emitting particles on X axis.
  81176. */
  81177. minScaleX: number;
  81178. /**
  81179. * Maximum scale of emitting particles on X axis.
  81180. */
  81181. maxScaleX: number;
  81182. /**
  81183. * Minimum scale of emitting particles on Y axis.
  81184. */
  81185. minScaleY: number;
  81186. /**
  81187. * Maximum scale of emitting particles on Y axis.
  81188. */
  81189. maxScaleY: number;
  81190. /**
  81191. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  81192. */
  81193. color1: Color4;
  81194. /**
  81195. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  81196. */
  81197. color2: Color4;
  81198. /**
  81199. * Color the particle will have at the end of its lifetime.
  81200. */
  81201. colorDead: Color4;
  81202. /**
  81203. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  81204. */
  81205. emitRate: number;
  81206. /**
  81207. * You can use gravity if you want to give an orientation to your particles.
  81208. */
  81209. gravity: Vector3;
  81210. /**
  81211. * Minimum power of emitting particles.
  81212. */
  81213. minEmitPower: number;
  81214. /**
  81215. * Maximum power of emitting particles.
  81216. */
  81217. maxEmitPower: number;
  81218. /**
  81219. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  81220. */
  81221. minAngularSpeed: number;
  81222. /**
  81223. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  81224. */
  81225. maxAngularSpeed: number;
  81226. /**
  81227. * Gets or sets the minimal initial rotation in radians.
  81228. */
  81229. minInitialRotation: number;
  81230. /**
  81231. * Gets or sets the maximal initial rotation in radians.
  81232. */
  81233. maxInitialRotation: number;
  81234. /**
  81235. * The particle emitter type defines the emitter used by the particle system.
  81236. * It can be for example box, sphere, or cone...
  81237. */
  81238. particleEmitterType: Nullable<IParticleEmitterType>;
  81239. /**
  81240. * Defines the delay in milliseconds before starting the system (0 by default)
  81241. */
  81242. startDelay: number;
  81243. /**
  81244. * 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
  81245. */
  81246. preWarmCycles: number;
  81247. /**
  81248. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  81249. */
  81250. preWarmStepOffset: number;
  81251. /**
  81252. * 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)
  81253. */
  81254. spriteCellChangeSpeed: number;
  81255. /**
  81256. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  81257. */
  81258. startSpriteCellID: number;
  81259. /**
  81260. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  81261. */
  81262. endSpriteCellID: number;
  81263. /**
  81264. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  81265. */
  81266. spriteCellWidth: number;
  81267. /**
  81268. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  81269. */
  81270. spriteCellHeight: number;
  81271. /**
  81272. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  81273. */
  81274. spriteRandomStartCell: boolean;
  81275. /**
  81276. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  81277. */
  81278. isAnimationSheetEnabled: boolean;
  81279. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  81280. translationPivot: Vector2;
  81281. /**
  81282. * Gets or sets a texture used to add random noise to particle positions
  81283. */
  81284. noiseTexture: Nullable<BaseTexture>;
  81285. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  81286. noiseStrength: Vector3;
  81287. /**
  81288. * Gets or sets the billboard mode to use when isBillboardBased = true.
  81289. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  81290. */
  81291. billboardMode: number;
  81292. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  81293. limitVelocityDamping: number;
  81294. /**
  81295. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  81296. */
  81297. beginAnimationOnStart: boolean;
  81298. /**
  81299. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  81300. */
  81301. beginAnimationFrom: number;
  81302. /**
  81303. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  81304. */
  81305. beginAnimationTo: number;
  81306. /**
  81307. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  81308. */
  81309. beginAnimationLoop: boolean;
  81310. /**
  81311. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  81312. */
  81313. disposeOnStop: boolean;
  81314. /**
  81315. * Gets the maximum number of particles active at the same time.
  81316. * @returns The max number of active particles.
  81317. */
  81318. getCapacity(): number;
  81319. /**
  81320. * Gets if the system has been started. (Note: this will still be true after stop is called)
  81321. * @returns True if it has been started, otherwise false.
  81322. */
  81323. isStarted(): boolean;
  81324. /**
  81325. * Animates the particle system for this frame.
  81326. */
  81327. animate(): void;
  81328. /**
  81329. * Renders the particle system in its current state.
  81330. * @returns the current number of particles
  81331. */
  81332. render(): number;
  81333. /**
  81334. * Dispose the particle system and frees its associated resources.
  81335. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  81336. */
  81337. dispose(disposeTexture?: boolean): void;
  81338. /**
  81339. * Clones the particle system.
  81340. * @param name The name of the cloned object
  81341. * @param newEmitter The new emitter to use
  81342. * @returns the cloned particle system
  81343. */
  81344. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  81345. /**
  81346. * Serializes the particle system to a JSON object.
  81347. * @returns the JSON object
  81348. */
  81349. serialize(): any;
  81350. /**
  81351. * Rebuild the particle system
  81352. */
  81353. rebuild(): void;
  81354. /**
  81355. * Starts the particle system and begins to emit
  81356. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  81357. */
  81358. start(delay?: number): void;
  81359. /**
  81360. * Stops the particle system.
  81361. */
  81362. stop(): void;
  81363. /**
  81364. * Remove all active particles
  81365. */
  81366. reset(): void;
  81367. /**
  81368. * Is this system ready to be used/rendered
  81369. * @return true if the system is ready
  81370. */
  81371. isReady(): boolean;
  81372. /**
  81373. * Adds a new color gradient
  81374. * @param gradient defines the gradient to use (between 0 and 1)
  81375. * @param color1 defines the color to affect to the specified gradient
  81376. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  81377. * @returns the current particle system
  81378. */
  81379. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  81380. /**
  81381. * Remove a specific color gradient
  81382. * @param gradient defines the gradient to remove
  81383. * @returns the current particle system
  81384. */
  81385. removeColorGradient(gradient: number): IParticleSystem;
  81386. /**
  81387. * Adds a new size gradient
  81388. * @param gradient defines the gradient to use (between 0 and 1)
  81389. * @param factor defines the size factor to affect to the specified gradient
  81390. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81391. * @returns the current particle system
  81392. */
  81393. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81394. /**
  81395. * Remove a specific size gradient
  81396. * @param gradient defines the gradient to remove
  81397. * @returns the current particle system
  81398. */
  81399. removeSizeGradient(gradient: number): IParticleSystem;
  81400. /**
  81401. * Gets the current list of color gradients.
  81402. * You must use addColorGradient and removeColorGradient to udpate this list
  81403. * @returns the list of color gradients
  81404. */
  81405. getColorGradients(): Nullable<Array<ColorGradient>>;
  81406. /**
  81407. * Gets the current list of size gradients.
  81408. * You must use addSizeGradient and removeSizeGradient to udpate this list
  81409. * @returns the list of size gradients
  81410. */
  81411. getSizeGradients(): Nullable<Array<FactorGradient>>;
  81412. /**
  81413. * Gets the current list of angular speed gradients.
  81414. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  81415. * @returns the list of angular speed gradients
  81416. */
  81417. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  81418. /**
  81419. * Adds a new angular speed gradient
  81420. * @param gradient defines the gradient to use (between 0 and 1)
  81421. * @param factor defines the angular speed to affect to the specified gradient
  81422. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81423. * @returns the current particle system
  81424. */
  81425. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81426. /**
  81427. * Remove a specific angular speed gradient
  81428. * @param gradient defines the gradient to remove
  81429. * @returns the current particle system
  81430. */
  81431. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  81432. /**
  81433. * Gets the current list of velocity gradients.
  81434. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  81435. * @returns the list of velocity gradients
  81436. */
  81437. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  81438. /**
  81439. * Adds a new velocity gradient
  81440. * @param gradient defines the gradient to use (between 0 and 1)
  81441. * @param factor defines the velocity to affect to the specified gradient
  81442. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81443. * @returns the current particle system
  81444. */
  81445. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81446. /**
  81447. * Remove a specific velocity gradient
  81448. * @param gradient defines the gradient to remove
  81449. * @returns the current particle system
  81450. */
  81451. removeVelocityGradient(gradient: number): IParticleSystem;
  81452. /**
  81453. * Gets the current list of limit velocity gradients.
  81454. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  81455. * @returns the list of limit velocity gradients
  81456. */
  81457. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  81458. /**
  81459. * Adds a new limit velocity gradient
  81460. * @param gradient defines the gradient to use (between 0 and 1)
  81461. * @param factor defines the limit velocity to affect to the specified gradient
  81462. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81463. * @returns the current particle system
  81464. */
  81465. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81466. /**
  81467. * Remove a specific limit velocity gradient
  81468. * @param gradient defines the gradient to remove
  81469. * @returns the current particle system
  81470. */
  81471. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  81472. /**
  81473. * Adds a new drag gradient
  81474. * @param gradient defines the gradient to use (between 0 and 1)
  81475. * @param factor defines the drag to affect to the specified gradient
  81476. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81477. * @returns the current particle system
  81478. */
  81479. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81480. /**
  81481. * Remove a specific drag gradient
  81482. * @param gradient defines the gradient to remove
  81483. * @returns the current particle system
  81484. */
  81485. removeDragGradient(gradient: number): IParticleSystem;
  81486. /**
  81487. * Gets the current list of drag gradients.
  81488. * You must use addDragGradient and removeDragGradient to udpate this list
  81489. * @returns the list of drag gradients
  81490. */
  81491. getDragGradients(): Nullable<Array<FactorGradient>>;
  81492. /**
  81493. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  81494. * @param gradient defines the gradient to use (between 0 and 1)
  81495. * @param factor defines the emit rate to affect to the specified gradient
  81496. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81497. * @returns the current particle system
  81498. */
  81499. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81500. /**
  81501. * Remove a specific emit rate gradient
  81502. * @param gradient defines the gradient to remove
  81503. * @returns the current particle system
  81504. */
  81505. removeEmitRateGradient(gradient: number): IParticleSystem;
  81506. /**
  81507. * Gets the current list of emit rate gradients.
  81508. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  81509. * @returns the list of emit rate gradients
  81510. */
  81511. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  81512. /**
  81513. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  81514. * @param gradient defines the gradient to use (between 0 and 1)
  81515. * @param factor defines the start size to affect to the specified gradient
  81516. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81517. * @returns the current particle system
  81518. */
  81519. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81520. /**
  81521. * Remove a specific start size gradient
  81522. * @param gradient defines the gradient to remove
  81523. * @returns the current particle system
  81524. */
  81525. removeStartSizeGradient(gradient: number): IParticleSystem;
  81526. /**
  81527. * Gets the current list of start size gradients.
  81528. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  81529. * @returns the list of start size gradients
  81530. */
  81531. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  81532. /**
  81533. * Adds a new life time gradient
  81534. * @param gradient defines the gradient to use (between 0 and 1)
  81535. * @param factor defines the life time factor to affect to the specified gradient
  81536. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81537. * @returns the current particle system
  81538. */
  81539. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81540. /**
  81541. * Remove a specific life time gradient
  81542. * @param gradient defines the gradient to remove
  81543. * @returns the current particle system
  81544. */
  81545. removeLifeTimeGradient(gradient: number): IParticleSystem;
  81546. /**
  81547. * Gets the current list of life time gradients.
  81548. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  81549. * @returns the list of life time gradients
  81550. */
  81551. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  81552. /**
  81553. * Gets the current list of color gradients.
  81554. * You must use addColorGradient and removeColorGradient to udpate this list
  81555. * @returns the list of color gradients
  81556. */
  81557. getColorGradients(): Nullable<Array<ColorGradient>>;
  81558. /**
  81559. * Adds a new ramp gradient used to remap particle colors
  81560. * @param gradient defines the gradient to use (between 0 and 1)
  81561. * @param color defines the color to affect to the specified gradient
  81562. * @returns the current particle system
  81563. */
  81564. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  81565. /**
  81566. * Gets the current list of ramp gradients.
  81567. * You must use addRampGradient and removeRampGradient to udpate this list
  81568. * @returns the list of ramp gradients
  81569. */
  81570. getRampGradients(): Nullable<Array<Color3Gradient>>;
  81571. /** Gets or sets a boolean indicating that ramp gradients must be used
  81572. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  81573. */
  81574. useRampGradients: boolean;
  81575. /**
  81576. * Adds a new color remap gradient
  81577. * @param gradient defines the gradient to use (between 0 and 1)
  81578. * @param min defines the color remap minimal range
  81579. * @param max defines the color remap maximal range
  81580. * @returns the current particle system
  81581. */
  81582. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  81583. /**
  81584. * Gets the current list of color remap gradients.
  81585. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  81586. * @returns the list of color remap gradients
  81587. */
  81588. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  81589. /**
  81590. * Adds a new alpha remap gradient
  81591. * @param gradient defines the gradient to use (between 0 and 1)
  81592. * @param min defines the alpha remap minimal range
  81593. * @param max defines the alpha remap maximal range
  81594. * @returns the current particle system
  81595. */
  81596. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  81597. /**
  81598. * Gets the current list of alpha remap gradients.
  81599. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  81600. * @returns the list of alpha remap gradients
  81601. */
  81602. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  81603. /**
  81604. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  81605. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  81606. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  81607. * @returns the emitter
  81608. */
  81609. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  81610. /**
  81611. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  81612. * @param radius The radius of the hemisphere to emit from
  81613. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  81614. * @returns the emitter
  81615. */
  81616. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  81617. /**
  81618. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  81619. * @param radius The radius of the sphere to emit from
  81620. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  81621. * @returns the emitter
  81622. */
  81623. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  81624. /**
  81625. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  81626. * @param radius The radius of the sphere to emit from
  81627. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  81628. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  81629. * @returns the emitter
  81630. */
  81631. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  81632. /**
  81633. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  81634. * @param radius The radius of the emission cylinder
  81635. * @param height The height of the emission cylinder
  81636. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  81637. * @param directionRandomizer How much to randomize the particle direction [0-1]
  81638. * @returns the emitter
  81639. */
  81640. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  81641. /**
  81642. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  81643. * @param radius The radius of the cylinder to emit from
  81644. * @param height The height of the emission cylinder
  81645. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81646. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  81647. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  81648. * @returns the emitter
  81649. */
  81650. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  81651. /**
  81652. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  81653. * @param radius The radius of the cone to emit from
  81654. * @param angle The base angle of the cone
  81655. * @returns the emitter
  81656. */
  81657. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  81658. /**
  81659. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  81660. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  81661. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  81662. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  81663. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  81664. * @returns the emitter
  81665. */
  81666. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  81667. /**
  81668. * Get hosting scene
  81669. * @returns the scene
  81670. */
  81671. getScene(): Scene;
  81672. }
  81673. }
  81674. declare module BABYLON {
  81675. /**
  81676. * Creates an instance based on a source mesh.
  81677. */
  81678. export class InstancedMesh extends AbstractMesh {
  81679. private _sourceMesh;
  81680. private _currentLOD;
  81681. /** @hidden */
  81682. _indexInSourceMeshInstanceArray: number;
  81683. constructor(name: string, source: Mesh);
  81684. /**
  81685. * Returns the string "InstancedMesh".
  81686. */
  81687. getClassName(): string;
  81688. /** Gets the list of lights affecting that mesh */
  81689. readonly lightSources: Light[];
  81690. _resyncLightSources(): void;
  81691. _resyncLighSource(light: Light): void;
  81692. _removeLightSource(light: Light): void;
  81693. /**
  81694. * If the source mesh receives shadows
  81695. */
  81696. readonly receiveShadows: boolean;
  81697. /**
  81698. * The material of the source mesh
  81699. */
  81700. readonly material: Nullable<Material>;
  81701. /**
  81702. * Visibility of the source mesh
  81703. */
  81704. readonly visibility: number;
  81705. /**
  81706. * Skeleton of the source mesh
  81707. */
  81708. readonly skeleton: Nullable<Skeleton>;
  81709. /**
  81710. * Rendering ground id of the source mesh
  81711. */
  81712. renderingGroupId: number;
  81713. /**
  81714. * Returns the total number of vertices (integer).
  81715. */
  81716. getTotalVertices(): number;
  81717. /**
  81718. * Returns a positive integer : the total number of indices in this mesh geometry.
  81719. * @returns the numner of indices or zero if the mesh has no geometry.
  81720. */
  81721. getTotalIndices(): number;
  81722. /**
  81723. * The source mesh of the instance
  81724. */
  81725. readonly sourceMesh: Mesh;
  81726. /**
  81727. * Is this node ready to be used/rendered
  81728. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  81729. * @return {boolean} is it ready
  81730. */
  81731. isReady(completeCheck?: boolean): boolean;
  81732. /**
  81733. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  81734. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  81735. * @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.
  81736. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  81737. */
  81738. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  81739. /**
  81740. * Sets the vertex data of the mesh geometry for the requested `kind`.
  81741. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  81742. * The `data` are either a numeric array either a Float32Array.
  81743. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  81744. * 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).
  81745. * Note that a new underlying VertexBuffer object is created each call.
  81746. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  81747. *
  81748. * Possible `kind` values :
  81749. * - VertexBuffer.PositionKind
  81750. * - VertexBuffer.UVKind
  81751. * - VertexBuffer.UV2Kind
  81752. * - VertexBuffer.UV3Kind
  81753. * - VertexBuffer.UV4Kind
  81754. * - VertexBuffer.UV5Kind
  81755. * - VertexBuffer.UV6Kind
  81756. * - VertexBuffer.ColorKind
  81757. * - VertexBuffer.MatricesIndicesKind
  81758. * - VertexBuffer.MatricesIndicesExtraKind
  81759. * - VertexBuffer.MatricesWeightsKind
  81760. * - VertexBuffer.MatricesWeightsExtraKind
  81761. *
  81762. * Returns the Mesh.
  81763. */
  81764. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  81765. /**
  81766. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  81767. * If the mesh has no geometry, it is simply returned as it is.
  81768. * The `data` are either a numeric array either a Float32Array.
  81769. * No new underlying VertexBuffer object is created.
  81770. * 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.
  81771. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  81772. *
  81773. * Possible `kind` values :
  81774. * - VertexBuffer.PositionKind
  81775. * - VertexBuffer.UVKind
  81776. * - VertexBuffer.UV2Kind
  81777. * - VertexBuffer.UV3Kind
  81778. * - VertexBuffer.UV4Kind
  81779. * - VertexBuffer.UV5Kind
  81780. * - VertexBuffer.UV6Kind
  81781. * - VertexBuffer.ColorKind
  81782. * - VertexBuffer.MatricesIndicesKind
  81783. * - VertexBuffer.MatricesIndicesExtraKind
  81784. * - VertexBuffer.MatricesWeightsKind
  81785. * - VertexBuffer.MatricesWeightsExtraKind
  81786. *
  81787. * Returns the Mesh.
  81788. */
  81789. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  81790. /**
  81791. * Sets the mesh indices.
  81792. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  81793. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  81794. * This method creates a new index buffer each call.
  81795. * Returns the Mesh.
  81796. */
  81797. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  81798. /**
  81799. * Boolean : True if the mesh owns the requested kind of data.
  81800. */
  81801. isVerticesDataPresent(kind: string): boolean;
  81802. /**
  81803. * Returns an array of indices (IndicesArray).
  81804. */
  81805. getIndices(): Nullable<IndicesArray>;
  81806. readonly _positions: Nullable<Vector3[]>;
  81807. /**
  81808. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  81809. * This means the mesh underlying bounding box and sphere are recomputed.
  81810. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  81811. * @returns the current mesh
  81812. */
  81813. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  81814. /** @hidden */
  81815. _preActivate(): InstancedMesh;
  81816. /** @hidden */
  81817. _activate(renderId: number, intermediateRendering: boolean): boolean;
  81818. /** @hidden */
  81819. _postActivate(): void;
  81820. getWorldMatrix(): Matrix;
  81821. readonly isAnInstance: boolean;
  81822. /**
  81823. * Returns the current associated LOD AbstractMesh.
  81824. */
  81825. getLOD(camera: Camera): AbstractMesh;
  81826. /** @hidden */
  81827. _syncSubMeshes(): InstancedMesh;
  81828. /** @hidden */
  81829. _generatePointsArray(): boolean;
  81830. /**
  81831. * Creates a new InstancedMesh from the current mesh.
  81832. * - name (string) : the cloned mesh name
  81833. * - newParent (optional Node) : the optional Node to parent the clone to.
  81834. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  81835. *
  81836. * Returns the clone.
  81837. */
  81838. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  81839. /**
  81840. * Disposes the InstancedMesh.
  81841. * Returns nothing.
  81842. */
  81843. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81844. }
  81845. }
  81846. declare module BABYLON {
  81847. /**
  81848. * Defines the options associated with the creation of a shader material.
  81849. */
  81850. export interface IShaderMaterialOptions {
  81851. /**
  81852. * Does the material work in alpha blend mode
  81853. */
  81854. needAlphaBlending: boolean;
  81855. /**
  81856. * Does the material work in alpha test mode
  81857. */
  81858. needAlphaTesting: boolean;
  81859. /**
  81860. * The list of attribute names used in the shader
  81861. */
  81862. attributes: string[];
  81863. /**
  81864. * The list of unifrom names used in the shader
  81865. */
  81866. uniforms: string[];
  81867. /**
  81868. * The list of UBO names used in the shader
  81869. */
  81870. uniformBuffers: string[];
  81871. /**
  81872. * The list of sampler names used in the shader
  81873. */
  81874. samplers: string[];
  81875. /**
  81876. * The list of defines used in the shader
  81877. */
  81878. defines: string[];
  81879. }
  81880. /**
  81881. * 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.
  81882. *
  81883. * This returned material effects how the mesh will look based on the code in the shaders.
  81884. *
  81885. * @see http://doc.babylonjs.com/how_to/shader_material
  81886. */
  81887. export class ShaderMaterial extends Material {
  81888. private _shaderPath;
  81889. private _options;
  81890. private _textures;
  81891. private _textureArrays;
  81892. private _floats;
  81893. private _ints;
  81894. private _floatsArrays;
  81895. private _colors3;
  81896. private _colors3Arrays;
  81897. private _colors4;
  81898. private _colors4Arrays;
  81899. private _vectors2;
  81900. private _vectors3;
  81901. private _vectors4;
  81902. private _matrices;
  81903. private _matrices3x3;
  81904. private _matrices2x2;
  81905. private _vectors2Arrays;
  81906. private _vectors3Arrays;
  81907. private _vectors4Arrays;
  81908. private _cachedWorldViewMatrix;
  81909. private _cachedWorldViewProjectionMatrix;
  81910. private _renderId;
  81911. /**
  81912. * Instantiate a new shader material.
  81913. * 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.
  81914. * This returned material effects how the mesh will look based on the code in the shaders.
  81915. * @see http://doc.babylonjs.com/how_to/shader_material
  81916. * @param name Define the name of the material in the scene
  81917. * @param scene Define the scene the material belongs to
  81918. * @param shaderPath Defines the route to the shader code in one of three ways:
  81919. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  81920. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  81921. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  81922. * @param options Define the options used to create the shader
  81923. */
  81924. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  81925. /**
  81926. * Gets the options used to compile the shader.
  81927. * They can be modified to trigger a new compilation
  81928. */
  81929. readonly options: IShaderMaterialOptions;
  81930. /**
  81931. * Gets the current class name of the material e.g. "ShaderMaterial"
  81932. * Mainly use in serialization.
  81933. * @returns the class name
  81934. */
  81935. getClassName(): string;
  81936. /**
  81937. * Specifies if the material will require alpha blending
  81938. * @returns a boolean specifying if alpha blending is needed
  81939. */
  81940. needAlphaBlending(): boolean;
  81941. /**
  81942. * Specifies if this material should be rendered in alpha test mode
  81943. * @returns a boolean specifying if an alpha test is needed.
  81944. */
  81945. needAlphaTesting(): boolean;
  81946. private _checkUniform;
  81947. /**
  81948. * Set a texture in the shader.
  81949. * @param name Define the name of the uniform samplers as defined in the shader
  81950. * @param texture Define the texture to bind to this sampler
  81951. * @return the material itself allowing "fluent" like uniform updates
  81952. */
  81953. setTexture(name: string, texture: Texture): ShaderMaterial;
  81954. /**
  81955. * Set a texture array in the shader.
  81956. * @param name Define the name of the uniform sampler array as defined in the shader
  81957. * @param textures Define the list of textures to bind to this sampler
  81958. * @return the material itself allowing "fluent" like uniform updates
  81959. */
  81960. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  81961. /**
  81962. * Set a float in the shader.
  81963. * @param name Define the name of the uniform as defined in the shader
  81964. * @param value Define the value to give to the uniform
  81965. * @return the material itself allowing "fluent" like uniform updates
  81966. */
  81967. setFloat(name: string, value: number): ShaderMaterial;
  81968. /**
  81969. * Set a int in the shader.
  81970. * @param name Define the name of the uniform as defined in the shader
  81971. * @param value Define the value to give to the uniform
  81972. * @return the material itself allowing "fluent" like uniform updates
  81973. */
  81974. setInt(name: string, value: number): ShaderMaterial;
  81975. /**
  81976. * Set an array of floats in the shader.
  81977. * @param name Define the name of the uniform as defined in the shader
  81978. * @param value Define the value to give to the uniform
  81979. * @return the material itself allowing "fluent" like uniform updates
  81980. */
  81981. setFloats(name: string, value: number[]): ShaderMaterial;
  81982. /**
  81983. * Set a vec3 in the shader from a Color3.
  81984. * @param name Define the name of the uniform as defined in the shader
  81985. * @param value Define the value to give to the uniform
  81986. * @return the material itself allowing "fluent" like uniform updates
  81987. */
  81988. setColor3(name: string, value: Color3): ShaderMaterial;
  81989. /**
  81990. * Set a vec3 array in the shader from a Color3 array.
  81991. * @param name Define the name of the uniform as defined in the shader
  81992. * @param value Define the value to give to the uniform
  81993. * @return the material itself allowing "fluent" like uniform updates
  81994. */
  81995. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  81996. /**
  81997. * Set a vec4 in the shader from a Color4.
  81998. * @param name Define the name of the uniform as defined in the shader
  81999. * @param value Define the value to give to the uniform
  82000. * @return the material itself allowing "fluent" like uniform updates
  82001. */
  82002. setColor4(name: string, value: Color4): ShaderMaterial;
  82003. /**
  82004. * Set a vec4 array in the shader from a Color4 array.
  82005. * @param name Define the name of the uniform as defined in the shader
  82006. * @param value Define the value to give to the uniform
  82007. * @return the material itself allowing "fluent" like uniform updates
  82008. */
  82009. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  82010. /**
  82011. * Set a vec2 in the shader from a Vector2.
  82012. * @param name Define the name of the uniform as defined in the shader
  82013. * @param value Define the value to give to the uniform
  82014. * @return the material itself allowing "fluent" like uniform updates
  82015. */
  82016. setVector2(name: string, value: Vector2): ShaderMaterial;
  82017. /**
  82018. * Set a vec3 in the shader from a Vector3.
  82019. * @param name Define the name of the uniform as defined in the shader
  82020. * @param value Define the value to give to the uniform
  82021. * @return the material itself allowing "fluent" like uniform updates
  82022. */
  82023. setVector3(name: string, value: Vector3): ShaderMaterial;
  82024. /**
  82025. * Set a vec4 in the shader from a Vector4.
  82026. * @param name Define the name of the uniform as defined in the shader
  82027. * @param value Define the value to give to the uniform
  82028. * @return the material itself allowing "fluent" like uniform updates
  82029. */
  82030. setVector4(name: string, value: Vector4): ShaderMaterial;
  82031. /**
  82032. * Set a mat4 in the shader from a Matrix.
  82033. * @param name Define the name of the uniform as defined in the shader
  82034. * @param value Define the value to give to the uniform
  82035. * @return the material itself allowing "fluent" like uniform updates
  82036. */
  82037. setMatrix(name: string, value: Matrix): ShaderMaterial;
  82038. /**
  82039. * Set a mat3 in the shader from a Float32Array.
  82040. * @param name Define the name of the uniform as defined in the shader
  82041. * @param value Define the value to give to the uniform
  82042. * @return the material itself allowing "fluent" like uniform updates
  82043. */
  82044. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  82045. /**
  82046. * Set a mat2 in the shader from a Float32Array.
  82047. * @param name Define the name of the uniform as defined in the shader
  82048. * @param value Define the value to give to the uniform
  82049. * @return the material itself allowing "fluent" like uniform updates
  82050. */
  82051. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  82052. /**
  82053. * Set a vec2 array in the shader from a number array.
  82054. * @param name Define the name of the uniform as defined in the shader
  82055. * @param value Define the value to give to the uniform
  82056. * @return the material itself allowing "fluent" like uniform updates
  82057. */
  82058. setArray2(name: string, value: number[]): ShaderMaterial;
  82059. /**
  82060. * Set a vec3 array in the shader from a number array.
  82061. * @param name Define the name of the uniform as defined in the shader
  82062. * @param value Define the value to give to the uniform
  82063. * @return the material itself allowing "fluent" like uniform updates
  82064. */
  82065. setArray3(name: string, value: number[]): ShaderMaterial;
  82066. /**
  82067. * Set a vec4 array in the shader from a number array.
  82068. * @param name Define the name of the uniform as defined in the shader
  82069. * @param value Define the value to give to the uniform
  82070. * @return the material itself allowing "fluent" like uniform updates
  82071. */
  82072. setArray4(name: string, value: number[]): ShaderMaterial;
  82073. private _checkCache;
  82074. /**
  82075. * Specifies that the submesh is ready to be used
  82076. * @param mesh defines the mesh to check
  82077. * @param subMesh defines which submesh to check
  82078. * @param useInstances specifies that instances should be used
  82079. * @returns a boolean indicating that the submesh is ready or not
  82080. */
  82081. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  82082. /**
  82083. * Checks if the material is ready to render the requested mesh
  82084. * @param mesh Define the mesh to render
  82085. * @param useInstances Define whether or not the material is used with instances
  82086. * @returns true if ready, otherwise false
  82087. */
  82088. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  82089. /**
  82090. * Binds the world matrix to the material
  82091. * @param world defines the world transformation matrix
  82092. */
  82093. bindOnlyWorldMatrix(world: Matrix): void;
  82094. /**
  82095. * Binds the material to the mesh
  82096. * @param world defines the world transformation matrix
  82097. * @param mesh defines the mesh to bind the material to
  82098. */
  82099. bind(world: Matrix, mesh?: Mesh): void;
  82100. /**
  82101. * Gets the active textures from the material
  82102. * @returns an array of textures
  82103. */
  82104. getActiveTextures(): BaseTexture[];
  82105. /**
  82106. * Specifies if the material uses a texture
  82107. * @param texture defines the texture to check against the material
  82108. * @returns a boolean specifying if the material uses the texture
  82109. */
  82110. hasTexture(texture: BaseTexture): boolean;
  82111. /**
  82112. * Makes a duplicate of the material, and gives it a new name
  82113. * @param name defines the new name for the duplicated material
  82114. * @returns the cloned material
  82115. */
  82116. clone(name: string): ShaderMaterial;
  82117. /**
  82118. * Disposes the material
  82119. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  82120. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  82121. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  82122. */
  82123. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  82124. /**
  82125. * Serializes this material in a JSON representation
  82126. * @returns the serialized material object
  82127. */
  82128. serialize(): any;
  82129. /**
  82130. * Creates a shader material from parsed shader material data
  82131. * @param source defines the JSON represnetation of the material
  82132. * @param scene defines the hosting scene
  82133. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  82134. * @returns a new material
  82135. */
  82136. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  82137. }
  82138. }
  82139. declare module BABYLON {
  82140. /** @hidden */
  82141. export var colorPixelShader: {
  82142. name: string;
  82143. shader: string;
  82144. };
  82145. }
  82146. declare module BABYLON {
  82147. /** @hidden */
  82148. export var colorVertexShader: {
  82149. name: string;
  82150. shader: string;
  82151. };
  82152. }
  82153. declare module BABYLON {
  82154. /**
  82155. * Line mesh
  82156. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  82157. */
  82158. export class LinesMesh extends Mesh {
  82159. /**
  82160. * If vertex color should be applied to the mesh
  82161. */
  82162. readonly useVertexColor?: boolean | undefined;
  82163. /**
  82164. * If vertex alpha should be applied to the mesh
  82165. */
  82166. readonly useVertexAlpha?: boolean | undefined;
  82167. /**
  82168. * Color of the line (Default: White)
  82169. */
  82170. color: Color3;
  82171. /**
  82172. * Alpha of the line (Default: 1)
  82173. */
  82174. alpha: number;
  82175. /**
  82176. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  82177. * This margin is expressed in world space coordinates, so its value may vary.
  82178. * Default value is 0.1
  82179. */
  82180. intersectionThreshold: number;
  82181. private _colorShader;
  82182. private color4;
  82183. /**
  82184. * Creates a new LinesMesh
  82185. * @param name defines the name
  82186. * @param scene defines the hosting scene
  82187. * @param parent defines the parent mesh if any
  82188. * @param source defines the optional source LinesMesh used to clone data from
  82189. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  82190. * When false, achieved by calling a clone(), also passing False.
  82191. * This will make creation of children, recursive.
  82192. * @param useVertexColor defines if this LinesMesh supports vertex color
  82193. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  82194. */
  82195. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  82196. /**
  82197. * If vertex color should be applied to the mesh
  82198. */
  82199. useVertexColor?: boolean | undefined,
  82200. /**
  82201. * If vertex alpha should be applied to the mesh
  82202. */
  82203. useVertexAlpha?: boolean | undefined);
  82204. private _addClipPlaneDefine;
  82205. private _removeClipPlaneDefine;
  82206. isReady(): boolean;
  82207. /**
  82208. * Returns the string "LineMesh"
  82209. */
  82210. getClassName(): string;
  82211. /**
  82212. * @hidden
  82213. */
  82214. /**
  82215. * @hidden
  82216. */
  82217. material: Material;
  82218. /**
  82219. * @hidden
  82220. */
  82221. readonly checkCollisions: boolean;
  82222. /** @hidden */
  82223. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  82224. /** @hidden */
  82225. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  82226. /**
  82227. * Disposes of the line mesh
  82228. * @param doNotRecurse If children should be disposed
  82229. */
  82230. dispose(doNotRecurse?: boolean): void;
  82231. /**
  82232. * Returns a new LineMesh object cloned from the current one.
  82233. */
  82234. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  82235. /**
  82236. * Creates a new InstancedLinesMesh object from the mesh model.
  82237. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  82238. * @param name defines the name of the new instance
  82239. * @returns a new InstancedLinesMesh
  82240. */
  82241. createInstance(name: string): InstancedLinesMesh;
  82242. }
  82243. /**
  82244. * Creates an instance based on a source LinesMesh
  82245. */
  82246. export class InstancedLinesMesh extends InstancedMesh {
  82247. /**
  82248. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  82249. * This margin is expressed in world space coordinates, so its value may vary.
  82250. * Initilized with the intersectionThreshold value of the source LinesMesh
  82251. */
  82252. intersectionThreshold: number;
  82253. constructor(name: string, source: LinesMesh);
  82254. /**
  82255. * Returns the string "InstancedLinesMesh".
  82256. */
  82257. getClassName(): string;
  82258. }
  82259. }
  82260. declare module BABYLON {
  82261. /** @hidden */
  82262. export var linePixelShader: {
  82263. name: string;
  82264. shader: string;
  82265. };
  82266. }
  82267. declare module BABYLON {
  82268. /** @hidden */
  82269. export var lineVertexShader: {
  82270. name: string;
  82271. shader: string;
  82272. };
  82273. }
  82274. declare module BABYLON {
  82275. interface AbstractMesh {
  82276. /**
  82277. * Gets the edgesRenderer associated with the mesh
  82278. */
  82279. edgesRenderer: Nullable<EdgesRenderer>;
  82280. }
  82281. interface LinesMesh {
  82282. /**
  82283. * Enables the edge rendering mode on the mesh.
  82284. * This mode makes the mesh edges visible
  82285. * @param epsilon defines the maximal distance between two angles to detect a face
  82286. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  82287. * @returns the currentAbstractMesh
  82288. * @see https://www.babylonjs-playground.com/#19O9TU#0
  82289. */
  82290. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  82291. }
  82292. interface InstancedLinesMesh {
  82293. /**
  82294. * Enables the edge rendering mode on the mesh.
  82295. * This mode makes the mesh edges visible
  82296. * @param epsilon defines the maximal distance between two angles to detect a face
  82297. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  82298. * @returns the current InstancedLinesMesh
  82299. * @see https://www.babylonjs-playground.com/#19O9TU#0
  82300. */
  82301. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  82302. }
  82303. /**
  82304. * Defines the minimum contract an Edges renderer should follow.
  82305. */
  82306. export interface IEdgesRenderer extends IDisposable {
  82307. /**
  82308. * Gets or sets a boolean indicating if the edgesRenderer is active
  82309. */
  82310. isEnabled: boolean;
  82311. /**
  82312. * Renders the edges of the attached mesh,
  82313. */
  82314. render(): void;
  82315. /**
  82316. * Checks wether or not the edges renderer is ready to render.
  82317. * @return true if ready, otherwise false.
  82318. */
  82319. isReady(): boolean;
  82320. }
  82321. /**
  82322. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  82323. */
  82324. export class EdgesRenderer implements IEdgesRenderer {
  82325. /**
  82326. * Define the size of the edges with an orthographic camera
  82327. */
  82328. edgesWidthScalerForOrthographic: number;
  82329. /**
  82330. * Define the size of the edges with a perspective camera
  82331. */
  82332. edgesWidthScalerForPerspective: number;
  82333. protected _source: AbstractMesh;
  82334. protected _linesPositions: number[];
  82335. protected _linesNormals: number[];
  82336. protected _linesIndices: number[];
  82337. protected _epsilon: number;
  82338. protected _indicesCount: number;
  82339. protected _lineShader: ShaderMaterial;
  82340. protected _ib: DataBuffer;
  82341. protected _buffers: {
  82342. [key: string]: Nullable<VertexBuffer>;
  82343. };
  82344. protected _checkVerticesInsteadOfIndices: boolean;
  82345. private _meshRebuildObserver;
  82346. private _meshDisposeObserver;
  82347. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  82348. isEnabled: boolean;
  82349. /**
  82350. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  82351. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  82352. * @param source Mesh used to create edges
  82353. * @param epsilon sum of angles in adjacency to check for edge
  82354. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  82355. * @param generateEdgesLines - should generate Lines or only prepare resources.
  82356. */
  82357. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  82358. protected _prepareRessources(): void;
  82359. /** @hidden */
  82360. _rebuild(): void;
  82361. /**
  82362. * Releases the required resources for the edges renderer
  82363. */
  82364. dispose(): void;
  82365. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  82366. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  82367. /**
  82368. * Checks if the pair of p0 and p1 is en edge
  82369. * @param faceIndex
  82370. * @param edge
  82371. * @param faceNormals
  82372. * @param p0
  82373. * @param p1
  82374. * @private
  82375. */
  82376. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  82377. /**
  82378. * push line into the position, normal and index buffer
  82379. * @protected
  82380. */
  82381. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  82382. /**
  82383. * Generates lines edges from adjacencjes
  82384. * @private
  82385. */
  82386. _generateEdgesLines(): void;
  82387. /**
  82388. * Checks wether or not the edges renderer is ready to render.
  82389. * @return true if ready, otherwise false.
  82390. */
  82391. isReady(): boolean;
  82392. /**
  82393. * Renders the edges of the attached mesh,
  82394. */
  82395. render(): void;
  82396. }
  82397. /**
  82398. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  82399. */
  82400. export class LineEdgesRenderer extends EdgesRenderer {
  82401. /**
  82402. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  82403. * @param source LineMesh used to generate edges
  82404. * @param epsilon not important (specified angle for edge detection)
  82405. * @param checkVerticesInsteadOfIndices not important for LineMesh
  82406. */
  82407. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  82408. /**
  82409. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  82410. */
  82411. _generateEdgesLines(): void;
  82412. }
  82413. }
  82414. declare module BABYLON {
  82415. /**
  82416. * This represents the object necessary to create a rendering group.
  82417. * This is exclusively used and created by the rendering manager.
  82418. * To modify the behavior, you use the available helpers in your scene or meshes.
  82419. * @hidden
  82420. */
  82421. export class RenderingGroup {
  82422. index: number;
  82423. private static _zeroVector;
  82424. private _scene;
  82425. private _opaqueSubMeshes;
  82426. private _transparentSubMeshes;
  82427. private _alphaTestSubMeshes;
  82428. private _depthOnlySubMeshes;
  82429. private _particleSystems;
  82430. private _spriteManagers;
  82431. private _opaqueSortCompareFn;
  82432. private _alphaTestSortCompareFn;
  82433. private _transparentSortCompareFn;
  82434. private _renderOpaque;
  82435. private _renderAlphaTest;
  82436. private _renderTransparent;
  82437. /** @hidden */
  82438. _edgesRenderers: SmartArray<IEdgesRenderer>;
  82439. onBeforeTransparentRendering: () => void;
  82440. /**
  82441. * Set the opaque sort comparison function.
  82442. * If null the sub meshes will be render in the order they were created
  82443. */
  82444. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  82445. /**
  82446. * Set the alpha test sort comparison function.
  82447. * If null the sub meshes will be render in the order they were created
  82448. */
  82449. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  82450. /**
  82451. * Set the transparent sort comparison function.
  82452. * If null the sub meshes will be render in the order they were created
  82453. */
  82454. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  82455. /**
  82456. * Creates a new rendering group.
  82457. * @param index The rendering group index
  82458. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  82459. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  82460. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  82461. */
  82462. 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>);
  82463. /**
  82464. * Render all the sub meshes contained in the group.
  82465. * @param customRenderFunction Used to override the default render behaviour of the group.
  82466. * @returns true if rendered some submeshes.
  82467. */
  82468. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  82469. /**
  82470. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  82471. * @param subMeshes The submeshes to render
  82472. */
  82473. private renderOpaqueSorted;
  82474. /**
  82475. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  82476. * @param subMeshes The submeshes to render
  82477. */
  82478. private renderAlphaTestSorted;
  82479. /**
  82480. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  82481. * @param subMeshes The submeshes to render
  82482. */
  82483. private renderTransparentSorted;
  82484. /**
  82485. * Renders the submeshes in a specified order.
  82486. * @param subMeshes The submeshes to sort before render
  82487. * @param sortCompareFn The comparison function use to sort
  82488. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  82489. * @param transparent Specifies to activate blending if true
  82490. */
  82491. private static renderSorted;
  82492. /**
  82493. * Renders the submeshes in the order they were dispatched (no sort applied).
  82494. * @param subMeshes The submeshes to render
  82495. */
  82496. private static renderUnsorted;
  82497. /**
  82498. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  82499. * are rendered back to front if in the same alpha index.
  82500. *
  82501. * @param a The first submesh
  82502. * @param b The second submesh
  82503. * @returns The result of the comparison
  82504. */
  82505. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  82506. /**
  82507. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  82508. * are rendered back to front.
  82509. *
  82510. * @param a The first submesh
  82511. * @param b The second submesh
  82512. * @returns The result of the comparison
  82513. */
  82514. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  82515. /**
  82516. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  82517. * are rendered front to back (prevent overdraw).
  82518. *
  82519. * @param a The first submesh
  82520. * @param b The second submesh
  82521. * @returns The result of the comparison
  82522. */
  82523. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  82524. /**
  82525. * Resets the different lists of submeshes to prepare a new frame.
  82526. */
  82527. prepare(): void;
  82528. dispose(): void;
  82529. /**
  82530. * Inserts the submesh in its correct queue depending on its material.
  82531. * @param subMesh The submesh to dispatch
  82532. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  82533. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  82534. */
  82535. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  82536. dispatchSprites(spriteManager: ISpriteManager): void;
  82537. dispatchParticles(particleSystem: IParticleSystem): void;
  82538. private _renderParticles;
  82539. private _renderSprites;
  82540. }
  82541. }
  82542. declare module BABYLON {
  82543. /**
  82544. * Interface describing the different options available in the rendering manager
  82545. * regarding Auto Clear between groups.
  82546. */
  82547. export interface IRenderingManagerAutoClearSetup {
  82548. /**
  82549. * Defines whether or not autoclear is enable.
  82550. */
  82551. autoClear: boolean;
  82552. /**
  82553. * Defines whether or not to autoclear the depth buffer.
  82554. */
  82555. depth: boolean;
  82556. /**
  82557. * Defines whether or not to autoclear the stencil buffer.
  82558. */
  82559. stencil: boolean;
  82560. }
  82561. /**
  82562. * This class is used by the onRenderingGroupObservable
  82563. */
  82564. export class RenderingGroupInfo {
  82565. /**
  82566. * The Scene that being rendered
  82567. */
  82568. scene: Scene;
  82569. /**
  82570. * The camera currently used for the rendering pass
  82571. */
  82572. camera: Nullable<Camera>;
  82573. /**
  82574. * The ID of the renderingGroup being processed
  82575. */
  82576. renderingGroupId: number;
  82577. }
  82578. /**
  82579. * This is the manager responsible of all the rendering for meshes sprites and particles.
  82580. * It is enable to manage the different groups as well as the different necessary sort functions.
  82581. * This should not be used directly aside of the few static configurations
  82582. */
  82583. export class RenderingManager {
  82584. /**
  82585. * The max id used for rendering groups (not included)
  82586. */
  82587. static MAX_RENDERINGGROUPS: number;
  82588. /**
  82589. * The min id used for rendering groups (included)
  82590. */
  82591. static MIN_RENDERINGGROUPS: number;
  82592. /**
  82593. * Used to globally prevent autoclearing scenes.
  82594. */
  82595. static AUTOCLEAR: boolean;
  82596. /**
  82597. * @hidden
  82598. */
  82599. _useSceneAutoClearSetup: boolean;
  82600. private _scene;
  82601. private _renderingGroups;
  82602. private _depthStencilBufferAlreadyCleaned;
  82603. private _autoClearDepthStencil;
  82604. private _customOpaqueSortCompareFn;
  82605. private _customAlphaTestSortCompareFn;
  82606. private _customTransparentSortCompareFn;
  82607. private _renderingGroupInfo;
  82608. /**
  82609. * Instantiates a new rendering group for a particular scene
  82610. * @param scene Defines the scene the groups belongs to
  82611. */
  82612. constructor(scene: Scene);
  82613. private _clearDepthStencilBuffer;
  82614. /**
  82615. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  82616. * @hidden
  82617. */
  82618. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  82619. /**
  82620. * Resets the different information of the group to prepare a new frame
  82621. * @hidden
  82622. */
  82623. reset(): void;
  82624. /**
  82625. * Dispose and release the group and its associated resources.
  82626. * @hidden
  82627. */
  82628. dispose(): void;
  82629. /**
  82630. * Clear the info related to rendering groups preventing retention points during dispose.
  82631. */
  82632. freeRenderingGroups(): void;
  82633. private _prepareRenderingGroup;
  82634. /**
  82635. * Add a sprite manager to the rendering manager in order to render it this frame.
  82636. * @param spriteManager Define the sprite manager to render
  82637. */
  82638. dispatchSprites(spriteManager: ISpriteManager): void;
  82639. /**
  82640. * Add a particle system to the rendering manager in order to render it this frame.
  82641. * @param particleSystem Define the particle system to render
  82642. */
  82643. dispatchParticles(particleSystem: IParticleSystem): void;
  82644. /**
  82645. * Add a submesh to the manager in order to render it this frame
  82646. * @param subMesh The submesh to dispatch
  82647. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  82648. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  82649. */
  82650. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  82651. /**
  82652. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  82653. * This allowed control for front to back rendering or reversly depending of the special needs.
  82654. *
  82655. * @param renderingGroupId The rendering group id corresponding to its index
  82656. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  82657. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  82658. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  82659. */
  82660. 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;
  82661. /**
  82662. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  82663. *
  82664. * @param renderingGroupId The rendering group id corresponding to its index
  82665. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  82666. * @param depth Automatically clears depth between groups if true and autoClear is true.
  82667. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  82668. */
  82669. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  82670. /**
  82671. * Gets the current auto clear configuration for one rendering group of the rendering
  82672. * manager.
  82673. * @param index the rendering group index to get the information for
  82674. * @returns The auto clear setup for the requested rendering group
  82675. */
  82676. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  82677. }
  82678. }
  82679. declare module BABYLON {
  82680. /**
  82681. * This Helps creating a texture that will be created from a camera in your scene.
  82682. * It is basically a dynamic texture that could be used to create special effects for instance.
  82683. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  82684. */
  82685. export class RenderTargetTexture extends Texture {
  82686. isCube: boolean;
  82687. /**
  82688. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  82689. */
  82690. static readonly REFRESHRATE_RENDER_ONCE: number;
  82691. /**
  82692. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  82693. */
  82694. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  82695. /**
  82696. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  82697. * the central point of your effect and can save a lot of performances.
  82698. */
  82699. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  82700. /**
  82701. * Use this predicate to dynamically define the list of mesh you want to render.
  82702. * If set, the renderList property will be overwritten.
  82703. */
  82704. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  82705. private _renderList;
  82706. /**
  82707. * Use this list to define the list of mesh you want to render.
  82708. */
  82709. renderList: Nullable<Array<AbstractMesh>>;
  82710. private _hookArray;
  82711. /**
  82712. * Define if particles should be rendered in your texture.
  82713. */
  82714. renderParticles: boolean;
  82715. /**
  82716. * Define if sprites should be rendered in your texture.
  82717. */
  82718. renderSprites: boolean;
  82719. /**
  82720. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  82721. */
  82722. coordinatesMode: number;
  82723. /**
  82724. * Define the camera used to render the texture.
  82725. */
  82726. activeCamera: Nullable<Camera>;
  82727. /**
  82728. * Override the render function of the texture with your own one.
  82729. */
  82730. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  82731. /**
  82732. * Define if camera post processes should be use while rendering the texture.
  82733. */
  82734. useCameraPostProcesses: boolean;
  82735. /**
  82736. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  82737. */
  82738. ignoreCameraViewport: boolean;
  82739. private _postProcessManager;
  82740. private _postProcesses;
  82741. private _resizeObserver;
  82742. /**
  82743. * An event triggered when the texture is unbind.
  82744. */
  82745. onBeforeBindObservable: Observable<RenderTargetTexture>;
  82746. /**
  82747. * An event triggered when the texture is unbind.
  82748. */
  82749. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  82750. private _onAfterUnbindObserver;
  82751. /**
  82752. * Set a after unbind callback in the texture.
  82753. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  82754. */
  82755. onAfterUnbind: () => void;
  82756. /**
  82757. * An event triggered before rendering the texture
  82758. */
  82759. onBeforeRenderObservable: Observable<number>;
  82760. private _onBeforeRenderObserver;
  82761. /**
  82762. * Set a before render callback in the texture.
  82763. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  82764. */
  82765. onBeforeRender: (faceIndex: number) => void;
  82766. /**
  82767. * An event triggered after rendering the texture
  82768. */
  82769. onAfterRenderObservable: Observable<number>;
  82770. private _onAfterRenderObserver;
  82771. /**
  82772. * Set a after render callback in the texture.
  82773. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  82774. */
  82775. onAfterRender: (faceIndex: number) => void;
  82776. /**
  82777. * An event triggered after the texture clear
  82778. */
  82779. onClearObservable: Observable<Engine>;
  82780. private _onClearObserver;
  82781. /**
  82782. * Set a clear callback in the texture.
  82783. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  82784. */
  82785. onClear: (Engine: Engine) => void;
  82786. /**
  82787. * Define the clear color of the Render Target if it should be different from the scene.
  82788. */
  82789. clearColor: Color4;
  82790. protected _size: number | {
  82791. width: number;
  82792. height: number;
  82793. };
  82794. protected _initialSizeParameter: number | {
  82795. width: number;
  82796. height: number;
  82797. } | {
  82798. ratio: number;
  82799. };
  82800. protected _sizeRatio: Nullable<number>;
  82801. /** @hidden */
  82802. _generateMipMaps: boolean;
  82803. protected _renderingManager: RenderingManager;
  82804. /** @hidden */
  82805. _waitingRenderList: string[];
  82806. protected _doNotChangeAspectRatio: boolean;
  82807. protected _currentRefreshId: number;
  82808. protected _refreshRate: number;
  82809. protected _textureMatrix: Matrix;
  82810. protected _samples: number;
  82811. protected _renderTargetOptions: RenderTargetCreationOptions;
  82812. /**
  82813. * Gets render target creation options that were used.
  82814. */
  82815. readonly renderTargetOptions: RenderTargetCreationOptions;
  82816. protected _engine: Engine;
  82817. protected _onRatioRescale(): void;
  82818. /**
  82819. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  82820. * It must define where the camera used to render the texture is set
  82821. */
  82822. boundingBoxPosition: Vector3;
  82823. private _boundingBoxSize;
  82824. /**
  82825. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  82826. * When defined, the cubemap will switch to local mode
  82827. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  82828. * @example https://www.babylonjs-playground.com/#RNASML
  82829. */
  82830. boundingBoxSize: Vector3;
  82831. /**
  82832. * In case the RTT has been created with a depth texture, get the associated
  82833. * depth texture.
  82834. * Otherwise, return null.
  82835. */
  82836. depthStencilTexture: Nullable<InternalTexture>;
  82837. /**
  82838. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  82839. * or used a shadow, depth texture...
  82840. * @param name The friendly name of the texture
  82841. * @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)
  82842. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  82843. * @param generateMipMaps True if mip maps need to be generated after render.
  82844. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  82845. * @param type The type of the buffer in the RTT (int, half float, float...)
  82846. * @param isCube True if a cube texture needs to be created
  82847. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  82848. * @param generateDepthBuffer True to generate a depth buffer
  82849. * @param generateStencilBuffer True to generate a stencil buffer
  82850. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  82851. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  82852. * @param delayAllocation if the texture allocation should be delayed (default: false)
  82853. */
  82854. constructor(name: string, size: number | {
  82855. width: number;
  82856. height: number;
  82857. } | {
  82858. ratio: number;
  82859. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  82860. /**
  82861. * Creates a depth stencil texture.
  82862. * This is only available in WebGL 2 or with the depth texture extension available.
  82863. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  82864. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  82865. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  82866. */
  82867. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  82868. private _processSizeParameter;
  82869. /**
  82870. * Define the number of samples to use in case of MSAA.
  82871. * It defaults to one meaning no MSAA has been enabled.
  82872. */
  82873. samples: number;
  82874. /**
  82875. * Resets the refresh counter of the texture and start bak from scratch.
  82876. * Could be useful to regenerate the texture if it is setup to render only once.
  82877. */
  82878. resetRefreshCounter(): void;
  82879. /**
  82880. * Define the refresh rate of the texture or the rendering frequency.
  82881. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  82882. */
  82883. refreshRate: number;
  82884. /**
  82885. * Adds a post process to the render target rendering passes.
  82886. * @param postProcess define the post process to add
  82887. */
  82888. addPostProcess(postProcess: PostProcess): void;
  82889. /**
  82890. * Clear all the post processes attached to the render target
  82891. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  82892. */
  82893. clearPostProcesses(dispose?: boolean): void;
  82894. /**
  82895. * Remove one of the post process from the list of attached post processes to the texture
  82896. * @param postProcess define the post process to remove from the list
  82897. */
  82898. removePostProcess(postProcess: PostProcess): void;
  82899. /** @hidden */
  82900. _shouldRender(): boolean;
  82901. /**
  82902. * Gets the actual render size of the texture.
  82903. * @returns the width of the render size
  82904. */
  82905. getRenderSize(): number;
  82906. /**
  82907. * Gets the actual render width of the texture.
  82908. * @returns the width of the render size
  82909. */
  82910. getRenderWidth(): number;
  82911. /**
  82912. * Gets the actual render height of the texture.
  82913. * @returns the height of the render size
  82914. */
  82915. getRenderHeight(): number;
  82916. /**
  82917. * Get if the texture can be rescaled or not.
  82918. */
  82919. readonly canRescale: boolean;
  82920. /**
  82921. * Resize the texture using a ratio.
  82922. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  82923. */
  82924. scale(ratio: number): void;
  82925. /**
  82926. * Get the texture reflection matrix used to rotate/transform the reflection.
  82927. * @returns the reflection matrix
  82928. */
  82929. getReflectionTextureMatrix(): Matrix;
  82930. /**
  82931. * Resize the texture to a new desired size.
  82932. * Be carrefull as it will recreate all the data in the new texture.
  82933. * @param size Define the new size. It can be:
  82934. * - a number for squared texture,
  82935. * - an object containing { width: number, height: number }
  82936. * - or an object containing a ratio { ratio: number }
  82937. */
  82938. resize(size: number | {
  82939. width: number;
  82940. height: number;
  82941. } | {
  82942. ratio: number;
  82943. }): void;
  82944. /**
  82945. * Renders all the objects from the render list into the texture.
  82946. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  82947. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  82948. */
  82949. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  82950. private _bestReflectionRenderTargetDimension;
  82951. /**
  82952. * @hidden
  82953. * @param faceIndex face index to bind to if this is a cubetexture
  82954. */
  82955. _bindFrameBuffer(faceIndex?: number): void;
  82956. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  82957. private renderToTarget;
  82958. /**
  82959. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  82960. * This allowed control for front to back rendering or reversly depending of the special needs.
  82961. *
  82962. * @param renderingGroupId The rendering group id corresponding to its index
  82963. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  82964. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  82965. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  82966. */
  82967. 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;
  82968. /**
  82969. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  82970. *
  82971. * @param renderingGroupId The rendering group id corresponding to its index
  82972. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  82973. */
  82974. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  82975. /**
  82976. * Clones the texture.
  82977. * @returns the cloned texture
  82978. */
  82979. clone(): RenderTargetTexture;
  82980. /**
  82981. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  82982. * @returns The JSON representation of the texture
  82983. */
  82984. serialize(): any;
  82985. /**
  82986. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  82987. */
  82988. disposeFramebufferObjects(): void;
  82989. /**
  82990. * Dispose the texture and release its associated resources.
  82991. */
  82992. dispose(): void;
  82993. /** @hidden */
  82994. _rebuild(): void;
  82995. /**
  82996. * Clear the info related to rendering groups preventing retention point in material dispose.
  82997. */
  82998. freeRenderingGroups(): void;
  82999. /**
  83000. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  83001. * @returns the view count
  83002. */
  83003. getViewCount(): number;
  83004. }
  83005. }
  83006. declare module BABYLON {
  83007. /**
  83008. * Base class for the main features of a material in Babylon.js
  83009. */
  83010. export class Material implements IAnimatable {
  83011. /**
  83012. * Returns the triangle fill mode
  83013. */
  83014. static readonly TriangleFillMode: number;
  83015. /**
  83016. * Returns the wireframe mode
  83017. */
  83018. static readonly WireFrameFillMode: number;
  83019. /**
  83020. * Returns the point fill mode
  83021. */
  83022. static readonly PointFillMode: number;
  83023. /**
  83024. * Returns the point list draw mode
  83025. */
  83026. static readonly PointListDrawMode: number;
  83027. /**
  83028. * Returns the line list draw mode
  83029. */
  83030. static readonly LineListDrawMode: number;
  83031. /**
  83032. * Returns the line loop draw mode
  83033. */
  83034. static readonly LineLoopDrawMode: number;
  83035. /**
  83036. * Returns the line strip draw mode
  83037. */
  83038. static readonly LineStripDrawMode: number;
  83039. /**
  83040. * Returns the triangle strip draw mode
  83041. */
  83042. static readonly TriangleStripDrawMode: number;
  83043. /**
  83044. * Returns the triangle fan draw mode
  83045. */
  83046. static readonly TriangleFanDrawMode: number;
  83047. /**
  83048. * Stores the clock-wise side orientation
  83049. */
  83050. static readonly ClockWiseSideOrientation: number;
  83051. /**
  83052. * Stores the counter clock-wise side orientation
  83053. */
  83054. static readonly CounterClockWiseSideOrientation: number;
  83055. /**
  83056. * The dirty texture flag value
  83057. */
  83058. static readonly TextureDirtyFlag: number;
  83059. /**
  83060. * The dirty light flag value
  83061. */
  83062. static readonly LightDirtyFlag: number;
  83063. /**
  83064. * The dirty fresnel flag value
  83065. */
  83066. static readonly FresnelDirtyFlag: number;
  83067. /**
  83068. * The dirty attribute flag value
  83069. */
  83070. static readonly AttributesDirtyFlag: number;
  83071. /**
  83072. * The dirty misc flag value
  83073. */
  83074. static readonly MiscDirtyFlag: number;
  83075. /**
  83076. * The all dirty flag value
  83077. */
  83078. static readonly AllDirtyFlag: number;
  83079. /**
  83080. * The ID of the material
  83081. */
  83082. id: string;
  83083. /**
  83084. * Gets or sets the unique id of the material
  83085. */
  83086. uniqueId: number;
  83087. /**
  83088. * The name of the material
  83089. */
  83090. name: string;
  83091. /**
  83092. * Gets or sets user defined metadata
  83093. */
  83094. metadata: any;
  83095. /**
  83096. * For internal use only. Please do not use.
  83097. */
  83098. reservedDataStore: any;
  83099. /**
  83100. * Specifies if the ready state should be checked on each call
  83101. */
  83102. checkReadyOnEveryCall: boolean;
  83103. /**
  83104. * Specifies if the ready state should be checked once
  83105. */
  83106. checkReadyOnlyOnce: boolean;
  83107. /**
  83108. * The state of the material
  83109. */
  83110. state: string;
  83111. /**
  83112. * The alpha value of the material
  83113. */
  83114. protected _alpha: number;
  83115. /**
  83116. * List of inspectable custom properties (used by the Inspector)
  83117. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83118. */
  83119. inspectableCustomProperties: IInspectable[];
  83120. /**
  83121. * Sets the alpha value of the material
  83122. */
  83123. /**
  83124. * Gets the alpha value of the material
  83125. */
  83126. alpha: number;
  83127. /**
  83128. * Specifies if back face culling is enabled
  83129. */
  83130. protected _backFaceCulling: boolean;
  83131. /**
  83132. * Sets the back-face culling state
  83133. */
  83134. /**
  83135. * Gets the back-face culling state
  83136. */
  83137. backFaceCulling: boolean;
  83138. /**
  83139. * Stores the value for side orientation
  83140. */
  83141. sideOrientation: number;
  83142. /**
  83143. * Callback triggered when the material is compiled
  83144. */
  83145. onCompiled: Nullable<(effect: Effect) => void>;
  83146. /**
  83147. * Callback triggered when an error occurs
  83148. */
  83149. onError: Nullable<(effect: Effect, errors: string) => void>;
  83150. /**
  83151. * Callback triggered to get the render target textures
  83152. */
  83153. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  83154. /**
  83155. * Gets a boolean indicating that current material needs to register RTT
  83156. */
  83157. readonly hasRenderTargetTextures: boolean;
  83158. /**
  83159. * Specifies if the material should be serialized
  83160. */
  83161. doNotSerialize: boolean;
  83162. /**
  83163. * @hidden
  83164. */
  83165. _storeEffectOnSubMeshes: boolean;
  83166. /**
  83167. * Stores the animations for the material
  83168. */
  83169. animations: Nullable<Array<Animation>>;
  83170. /**
  83171. * An event triggered when the material is disposed
  83172. */
  83173. onDisposeObservable: Observable<Material>;
  83174. /**
  83175. * An observer which watches for dispose events
  83176. */
  83177. private _onDisposeObserver;
  83178. private _onUnBindObservable;
  83179. /**
  83180. * Called during a dispose event
  83181. */
  83182. onDispose: () => void;
  83183. private _onBindObservable;
  83184. /**
  83185. * An event triggered when the material is bound
  83186. */
  83187. readonly onBindObservable: Observable<AbstractMesh>;
  83188. /**
  83189. * An observer which watches for bind events
  83190. */
  83191. private _onBindObserver;
  83192. /**
  83193. * Called during a bind event
  83194. */
  83195. onBind: (Mesh: AbstractMesh) => void;
  83196. /**
  83197. * An event triggered when the material is unbound
  83198. */
  83199. readonly onUnBindObservable: Observable<Material>;
  83200. /**
  83201. * Stores the value of the alpha mode
  83202. */
  83203. private _alphaMode;
  83204. /**
  83205. * Sets the value of the alpha mode.
  83206. *
  83207. * | Value | Type | Description |
  83208. * | --- | --- | --- |
  83209. * | 0 | ALPHA_DISABLE | |
  83210. * | 1 | ALPHA_ADD | |
  83211. * | 2 | ALPHA_COMBINE | |
  83212. * | 3 | ALPHA_SUBTRACT | |
  83213. * | 4 | ALPHA_MULTIPLY | |
  83214. * | 5 | ALPHA_MAXIMIZED | |
  83215. * | 6 | ALPHA_ONEONE | |
  83216. * | 7 | ALPHA_PREMULTIPLIED | |
  83217. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  83218. * | 9 | ALPHA_INTERPOLATE | |
  83219. * | 10 | ALPHA_SCREENMODE | |
  83220. *
  83221. */
  83222. /**
  83223. * Gets the value of the alpha mode
  83224. */
  83225. alphaMode: number;
  83226. /**
  83227. * Stores the state of the need depth pre-pass value
  83228. */
  83229. private _needDepthPrePass;
  83230. /**
  83231. * Sets the need depth pre-pass value
  83232. */
  83233. /**
  83234. * Gets the depth pre-pass value
  83235. */
  83236. needDepthPrePass: boolean;
  83237. /**
  83238. * Specifies if depth writing should be disabled
  83239. */
  83240. disableDepthWrite: boolean;
  83241. /**
  83242. * Specifies if depth writing should be forced
  83243. */
  83244. forceDepthWrite: boolean;
  83245. /**
  83246. * Specifies if there should be a separate pass for culling
  83247. */
  83248. separateCullingPass: boolean;
  83249. /**
  83250. * Stores the state specifing if fog should be enabled
  83251. */
  83252. private _fogEnabled;
  83253. /**
  83254. * Sets the state for enabling fog
  83255. */
  83256. /**
  83257. * Gets the value of the fog enabled state
  83258. */
  83259. fogEnabled: boolean;
  83260. /**
  83261. * Stores the size of points
  83262. */
  83263. pointSize: number;
  83264. /**
  83265. * Stores the z offset value
  83266. */
  83267. zOffset: number;
  83268. /**
  83269. * Gets a value specifying if wireframe mode is enabled
  83270. */
  83271. /**
  83272. * Sets the state of wireframe mode
  83273. */
  83274. wireframe: boolean;
  83275. /**
  83276. * Gets the value specifying if point clouds are enabled
  83277. */
  83278. /**
  83279. * Sets the state of point cloud mode
  83280. */
  83281. pointsCloud: boolean;
  83282. /**
  83283. * Gets the material fill mode
  83284. */
  83285. /**
  83286. * Sets the material fill mode
  83287. */
  83288. fillMode: number;
  83289. /**
  83290. * @hidden
  83291. * Stores the effects for the material
  83292. */
  83293. _effect: Nullable<Effect>;
  83294. /**
  83295. * @hidden
  83296. * Specifies if the material was previously ready
  83297. */
  83298. _wasPreviouslyReady: boolean;
  83299. /**
  83300. * Specifies if uniform buffers should be used
  83301. */
  83302. private _useUBO;
  83303. /**
  83304. * Stores a reference to the scene
  83305. */
  83306. private _scene;
  83307. /**
  83308. * Stores the fill mode state
  83309. */
  83310. private _fillMode;
  83311. /**
  83312. * Specifies if the depth write state should be cached
  83313. */
  83314. private _cachedDepthWriteState;
  83315. /**
  83316. * Stores the uniform buffer
  83317. */
  83318. protected _uniformBuffer: UniformBuffer;
  83319. /** @hidden */
  83320. _indexInSceneMaterialArray: number;
  83321. /** @hidden */
  83322. meshMap: Nullable<{
  83323. [id: string]: AbstractMesh | undefined;
  83324. }>;
  83325. /**
  83326. * Creates a material instance
  83327. * @param name defines the name of the material
  83328. * @param scene defines the scene to reference
  83329. * @param doNotAdd specifies if the material should be added to the scene
  83330. */
  83331. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  83332. /**
  83333. * Returns a string representation of the current material
  83334. * @param fullDetails defines a boolean indicating which levels of logging is desired
  83335. * @returns a string with material information
  83336. */
  83337. toString(fullDetails?: boolean): string;
  83338. /**
  83339. * Gets the class name of the material
  83340. * @returns a string with the class name of the material
  83341. */
  83342. getClassName(): string;
  83343. /**
  83344. * Specifies if updates for the material been locked
  83345. */
  83346. readonly isFrozen: boolean;
  83347. /**
  83348. * Locks updates for the material
  83349. */
  83350. freeze(): void;
  83351. /**
  83352. * Unlocks updates for the material
  83353. */
  83354. unfreeze(): void;
  83355. /**
  83356. * Specifies if the material is ready to be used
  83357. * @param mesh defines the mesh to check
  83358. * @param useInstances specifies if instances should be used
  83359. * @returns a boolean indicating if the material is ready to be used
  83360. */
  83361. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  83362. /**
  83363. * Specifies that the submesh is ready to be used
  83364. * @param mesh defines the mesh to check
  83365. * @param subMesh defines which submesh to check
  83366. * @param useInstances specifies that instances should be used
  83367. * @returns a boolean indicating that the submesh is ready or not
  83368. */
  83369. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  83370. /**
  83371. * Returns the material effect
  83372. * @returns the effect associated with the material
  83373. */
  83374. getEffect(): Nullable<Effect>;
  83375. /**
  83376. * Returns the current scene
  83377. * @returns a Scene
  83378. */
  83379. getScene(): Scene;
  83380. /**
  83381. * Specifies if the material will require alpha blending
  83382. * @returns a boolean specifying if alpha blending is needed
  83383. */
  83384. needAlphaBlending(): boolean;
  83385. /**
  83386. * Specifies if the mesh will require alpha blending
  83387. * @param mesh defines the mesh to check
  83388. * @returns a boolean specifying if alpha blending is needed for the mesh
  83389. */
  83390. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  83391. /**
  83392. * Specifies if this material should be rendered in alpha test mode
  83393. * @returns a boolean specifying if an alpha test is needed.
  83394. */
  83395. needAlphaTesting(): boolean;
  83396. /**
  83397. * Gets the texture used for the alpha test
  83398. * @returns the texture to use for alpha testing
  83399. */
  83400. getAlphaTestTexture(): Nullable<BaseTexture>;
  83401. /**
  83402. * Marks the material to indicate that it needs to be re-calculated
  83403. */
  83404. markDirty(): void;
  83405. /** @hidden */
  83406. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  83407. /**
  83408. * Binds the material to the mesh
  83409. * @param world defines the world transformation matrix
  83410. * @param mesh defines the mesh to bind the material to
  83411. */
  83412. bind(world: Matrix, mesh?: Mesh): void;
  83413. /**
  83414. * Binds the submesh to the material
  83415. * @param world defines the world transformation matrix
  83416. * @param mesh defines the mesh containing the submesh
  83417. * @param subMesh defines the submesh to bind the material to
  83418. */
  83419. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  83420. /**
  83421. * Binds the world matrix to the material
  83422. * @param world defines the world transformation matrix
  83423. */
  83424. bindOnlyWorldMatrix(world: Matrix): void;
  83425. /**
  83426. * Binds the scene's uniform buffer to the effect.
  83427. * @param effect defines the effect to bind to the scene uniform buffer
  83428. * @param sceneUbo defines the uniform buffer storing scene data
  83429. */
  83430. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  83431. /**
  83432. * Binds the view matrix to the effect
  83433. * @param effect defines the effect to bind the view matrix to
  83434. */
  83435. bindView(effect: Effect): void;
  83436. /**
  83437. * Binds the view projection matrix to the effect
  83438. * @param effect defines the effect to bind the view projection matrix to
  83439. */
  83440. bindViewProjection(effect: Effect): void;
  83441. /**
  83442. * Specifies if material alpha testing should be turned on for the mesh
  83443. * @param mesh defines the mesh to check
  83444. */
  83445. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  83446. /**
  83447. * Processes to execute after binding the material to a mesh
  83448. * @param mesh defines the rendered mesh
  83449. */
  83450. protected _afterBind(mesh?: Mesh): void;
  83451. /**
  83452. * Unbinds the material from the mesh
  83453. */
  83454. unbind(): void;
  83455. /**
  83456. * Gets the active textures from the material
  83457. * @returns an array of textures
  83458. */
  83459. getActiveTextures(): BaseTexture[];
  83460. /**
  83461. * Specifies if the material uses a texture
  83462. * @param texture defines the texture to check against the material
  83463. * @returns a boolean specifying if the material uses the texture
  83464. */
  83465. hasTexture(texture: BaseTexture): boolean;
  83466. /**
  83467. * Makes a duplicate of the material, and gives it a new name
  83468. * @param name defines the new name for the duplicated material
  83469. * @returns the cloned material
  83470. */
  83471. clone(name: string): Nullable<Material>;
  83472. /**
  83473. * Gets the meshes bound to the material
  83474. * @returns an array of meshes bound to the material
  83475. */
  83476. getBindedMeshes(): AbstractMesh[];
  83477. /**
  83478. * Force shader compilation
  83479. * @param mesh defines the mesh associated with this material
  83480. * @param onCompiled defines a function to execute once the material is compiled
  83481. * @param options defines the options to configure the compilation
  83482. */
  83483. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  83484. clipPlane: boolean;
  83485. }>): void;
  83486. /**
  83487. * Force shader compilation
  83488. * @param mesh defines the mesh that will use this material
  83489. * @param options defines additional options for compiling the shaders
  83490. * @returns a promise that resolves when the compilation completes
  83491. */
  83492. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  83493. clipPlane: boolean;
  83494. }>): Promise<void>;
  83495. private static readonly _AllDirtyCallBack;
  83496. private static readonly _ImageProcessingDirtyCallBack;
  83497. private static readonly _TextureDirtyCallBack;
  83498. private static readonly _FresnelDirtyCallBack;
  83499. private static readonly _MiscDirtyCallBack;
  83500. private static readonly _LightsDirtyCallBack;
  83501. private static readonly _AttributeDirtyCallBack;
  83502. private static _FresnelAndMiscDirtyCallBack;
  83503. private static _TextureAndMiscDirtyCallBack;
  83504. private static readonly _DirtyCallbackArray;
  83505. private static readonly _RunDirtyCallBacks;
  83506. /**
  83507. * Marks a define in the material to indicate that it needs to be re-computed
  83508. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  83509. */
  83510. markAsDirty(flag: number): void;
  83511. /**
  83512. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  83513. * @param func defines a function which checks material defines against the submeshes
  83514. */
  83515. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  83516. /**
  83517. * Indicates that we need to re-calculated for all submeshes
  83518. */
  83519. protected _markAllSubMeshesAsAllDirty(): void;
  83520. /**
  83521. * Indicates that image processing needs to be re-calculated for all submeshes
  83522. */
  83523. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  83524. /**
  83525. * Indicates that textures need to be re-calculated for all submeshes
  83526. */
  83527. protected _markAllSubMeshesAsTexturesDirty(): void;
  83528. /**
  83529. * Indicates that fresnel needs to be re-calculated for all submeshes
  83530. */
  83531. protected _markAllSubMeshesAsFresnelDirty(): void;
  83532. /**
  83533. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  83534. */
  83535. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  83536. /**
  83537. * Indicates that lights need to be re-calculated for all submeshes
  83538. */
  83539. protected _markAllSubMeshesAsLightsDirty(): void;
  83540. /**
  83541. * Indicates that attributes need to be re-calculated for all submeshes
  83542. */
  83543. protected _markAllSubMeshesAsAttributesDirty(): void;
  83544. /**
  83545. * Indicates that misc needs to be re-calculated for all submeshes
  83546. */
  83547. protected _markAllSubMeshesAsMiscDirty(): void;
  83548. /**
  83549. * Indicates that textures and misc need to be re-calculated for all submeshes
  83550. */
  83551. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  83552. /**
  83553. * Disposes the material
  83554. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  83555. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  83556. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  83557. */
  83558. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  83559. /** @hidden */
  83560. private releaseVertexArrayObject;
  83561. /**
  83562. * Serializes this material
  83563. * @returns the serialized material object
  83564. */
  83565. serialize(): any;
  83566. /**
  83567. * Creates a material from parsed material data
  83568. * @param parsedMaterial defines parsed material data
  83569. * @param scene defines the hosting scene
  83570. * @param rootUrl defines the root URL to use to load textures
  83571. * @returns a new material
  83572. */
  83573. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  83574. }
  83575. }
  83576. declare module BABYLON {
  83577. /**
  83578. * A multi-material is used to apply different materials to different parts of the same object without the need of
  83579. * separate meshes. This can be use to improve performances.
  83580. * @see http://doc.babylonjs.com/how_to/multi_materials
  83581. */
  83582. export class MultiMaterial extends Material {
  83583. private _subMaterials;
  83584. /**
  83585. * Gets or Sets the list of Materials used within the multi material.
  83586. * They need to be ordered according to the submeshes order in the associated mesh
  83587. */
  83588. subMaterials: Nullable<Material>[];
  83589. /**
  83590. * Function used to align with Node.getChildren()
  83591. * @returns the list of Materials used within the multi material
  83592. */
  83593. getChildren(): Nullable<Material>[];
  83594. /**
  83595. * Instantiates a new Multi Material
  83596. * A multi-material is used to apply different materials to different parts of the same object without the need of
  83597. * separate meshes. This can be use to improve performances.
  83598. * @see http://doc.babylonjs.com/how_to/multi_materials
  83599. * @param name Define the name in the scene
  83600. * @param scene Define the scene the material belongs to
  83601. */
  83602. constructor(name: string, scene: Scene);
  83603. private _hookArray;
  83604. /**
  83605. * Get one of the submaterial by its index in the submaterials array
  83606. * @param index The index to look the sub material at
  83607. * @returns The Material if the index has been defined
  83608. */
  83609. getSubMaterial(index: number): Nullable<Material>;
  83610. /**
  83611. * Get the list of active textures for the whole sub materials list.
  83612. * @returns All the textures that will be used during the rendering
  83613. */
  83614. getActiveTextures(): BaseTexture[];
  83615. /**
  83616. * Gets the current class name of the material e.g. "MultiMaterial"
  83617. * Mainly use in serialization.
  83618. * @returns the class name
  83619. */
  83620. getClassName(): string;
  83621. /**
  83622. * Checks if the material is ready to render the requested sub mesh
  83623. * @param mesh Define the mesh the submesh belongs to
  83624. * @param subMesh Define the sub mesh to look readyness for
  83625. * @param useInstances Define whether or not the material is used with instances
  83626. * @returns true if ready, otherwise false
  83627. */
  83628. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  83629. /**
  83630. * Clones the current material and its related sub materials
  83631. * @param name Define the name of the newly cloned material
  83632. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  83633. * @returns the cloned material
  83634. */
  83635. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  83636. /**
  83637. * Serializes the materials into a JSON representation.
  83638. * @returns the JSON representation
  83639. */
  83640. serialize(): any;
  83641. /**
  83642. * Dispose the material and release its associated resources
  83643. * @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)
  83644. * @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)
  83645. * @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)
  83646. */
  83647. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  83648. /**
  83649. * Creates a MultiMaterial from parsed MultiMaterial data.
  83650. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  83651. * @param scene defines the hosting scene
  83652. * @returns a new MultiMaterial
  83653. */
  83654. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  83655. }
  83656. }
  83657. declare module BABYLON {
  83658. /**
  83659. * Base class for submeshes
  83660. */
  83661. export class BaseSubMesh {
  83662. /** @hidden */
  83663. _materialDefines: Nullable<MaterialDefines>;
  83664. /** @hidden */
  83665. _materialEffect: Nullable<Effect>;
  83666. /**
  83667. * Gets associated effect
  83668. */
  83669. readonly effect: Nullable<Effect>;
  83670. /**
  83671. * Sets associated effect (effect used to render this submesh)
  83672. * @param effect defines the effect to associate with
  83673. * @param defines defines the set of defines used to compile this effect
  83674. */
  83675. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  83676. }
  83677. /**
  83678. * Defines a subdivision inside a mesh
  83679. */
  83680. export class SubMesh extends BaseSubMesh implements ICullable {
  83681. /** the material index to use */
  83682. materialIndex: number;
  83683. /** vertex index start */
  83684. verticesStart: number;
  83685. /** vertices count */
  83686. verticesCount: number;
  83687. /** index start */
  83688. indexStart: number;
  83689. /** indices count */
  83690. indexCount: number;
  83691. /** @hidden */
  83692. _linesIndexCount: number;
  83693. private _mesh;
  83694. private _renderingMesh;
  83695. private _boundingInfo;
  83696. private _linesIndexBuffer;
  83697. /** @hidden */
  83698. _lastColliderWorldVertices: Nullable<Vector3[]>;
  83699. /** @hidden */
  83700. _trianglePlanes: Plane[];
  83701. /** @hidden */
  83702. _lastColliderTransformMatrix: Nullable<Matrix>;
  83703. /** @hidden */
  83704. _renderId: number;
  83705. /** @hidden */
  83706. _alphaIndex: number;
  83707. /** @hidden */
  83708. _distanceToCamera: number;
  83709. /** @hidden */
  83710. _id: number;
  83711. private _currentMaterial;
  83712. /**
  83713. * Add a new submesh to a mesh
  83714. * @param materialIndex defines the material index to use
  83715. * @param verticesStart defines vertex index start
  83716. * @param verticesCount defines vertices count
  83717. * @param indexStart defines index start
  83718. * @param indexCount defines indices count
  83719. * @param mesh defines the parent mesh
  83720. * @param renderingMesh defines an optional rendering mesh
  83721. * @param createBoundingBox defines if bounding box should be created for this submesh
  83722. * @returns the new submesh
  83723. */
  83724. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  83725. /**
  83726. * Creates a new submesh
  83727. * @param materialIndex defines the material index to use
  83728. * @param verticesStart defines vertex index start
  83729. * @param verticesCount defines vertices count
  83730. * @param indexStart defines index start
  83731. * @param indexCount defines indices count
  83732. * @param mesh defines the parent mesh
  83733. * @param renderingMesh defines an optional rendering mesh
  83734. * @param createBoundingBox defines if bounding box should be created for this submesh
  83735. */
  83736. constructor(
  83737. /** the material index to use */
  83738. materialIndex: number,
  83739. /** vertex index start */
  83740. verticesStart: number,
  83741. /** vertices count */
  83742. verticesCount: number,
  83743. /** index start */
  83744. indexStart: number,
  83745. /** indices count */
  83746. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  83747. /**
  83748. * Returns true if this submesh covers the entire parent mesh
  83749. * @ignorenaming
  83750. */
  83751. readonly IsGlobal: boolean;
  83752. /**
  83753. * Returns the submesh BoudingInfo object
  83754. * @returns current bounding info (or mesh's one if the submesh is global)
  83755. */
  83756. getBoundingInfo(): BoundingInfo;
  83757. /**
  83758. * Sets the submesh BoundingInfo
  83759. * @param boundingInfo defines the new bounding info to use
  83760. * @returns the SubMesh
  83761. */
  83762. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  83763. /**
  83764. * Returns the mesh of the current submesh
  83765. * @return the parent mesh
  83766. */
  83767. getMesh(): AbstractMesh;
  83768. /**
  83769. * Returns the rendering mesh of the submesh
  83770. * @returns the rendering mesh (could be different from parent mesh)
  83771. */
  83772. getRenderingMesh(): Mesh;
  83773. /**
  83774. * Returns the submesh material
  83775. * @returns null or the current material
  83776. */
  83777. getMaterial(): Nullable<Material>;
  83778. /**
  83779. * Sets a new updated BoundingInfo object to the submesh
  83780. * @param data defines an optional position array to use to determine the bounding info
  83781. * @returns the SubMesh
  83782. */
  83783. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  83784. /** @hidden */
  83785. _checkCollision(collider: Collider): boolean;
  83786. /**
  83787. * Updates the submesh BoundingInfo
  83788. * @param world defines the world matrix to use to update the bounding info
  83789. * @returns the submesh
  83790. */
  83791. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  83792. /**
  83793. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  83794. * @param frustumPlanes defines the frustum planes
  83795. * @returns true if the submesh is intersecting with the frustum
  83796. */
  83797. isInFrustum(frustumPlanes: Plane[]): boolean;
  83798. /**
  83799. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  83800. * @param frustumPlanes defines the frustum planes
  83801. * @returns true if the submesh is inside the frustum
  83802. */
  83803. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  83804. /**
  83805. * Renders the submesh
  83806. * @param enableAlphaMode defines if alpha needs to be used
  83807. * @returns the submesh
  83808. */
  83809. render(enableAlphaMode: boolean): SubMesh;
  83810. /**
  83811. * @hidden
  83812. */
  83813. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  83814. /**
  83815. * Checks if the submesh intersects with a ray
  83816. * @param ray defines the ray to test
  83817. * @returns true is the passed ray intersects the submesh bounding box
  83818. */
  83819. canIntersects(ray: Ray): boolean;
  83820. /**
  83821. * Intersects current submesh with a ray
  83822. * @param ray defines the ray to test
  83823. * @param positions defines mesh's positions array
  83824. * @param indices defines mesh's indices array
  83825. * @param fastCheck defines if only bounding info should be used
  83826. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  83827. * @returns intersection info or null if no intersection
  83828. */
  83829. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  83830. /** @hidden */
  83831. private _intersectLines;
  83832. /** @hidden */
  83833. private _intersectUnIndexedLines;
  83834. /** @hidden */
  83835. private _intersectTriangles;
  83836. /** @hidden */
  83837. private _intersectUnIndexedTriangles;
  83838. /** @hidden */
  83839. _rebuild(): void;
  83840. /**
  83841. * Creates a new submesh from the passed mesh
  83842. * @param newMesh defines the new hosting mesh
  83843. * @param newRenderingMesh defines an optional rendering mesh
  83844. * @returns the new submesh
  83845. */
  83846. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  83847. /**
  83848. * Release associated resources
  83849. */
  83850. dispose(): void;
  83851. /**
  83852. * Gets the class name
  83853. * @returns the string "SubMesh".
  83854. */
  83855. getClassName(): string;
  83856. /**
  83857. * Creates a new submesh from indices data
  83858. * @param materialIndex the index of the main mesh material
  83859. * @param startIndex the index where to start the copy in the mesh indices array
  83860. * @param indexCount the number of indices to copy then from the startIndex
  83861. * @param mesh the main mesh to create the submesh from
  83862. * @param renderingMesh the optional rendering mesh
  83863. * @returns a new submesh
  83864. */
  83865. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  83866. }
  83867. }
  83868. declare module BABYLON {
  83869. /**
  83870. * Class used to represent data loading progression
  83871. */
  83872. export class SceneLoaderFlags {
  83873. private static _ForceFullSceneLoadingForIncremental;
  83874. private static _ShowLoadingScreen;
  83875. private static _CleanBoneMatrixWeights;
  83876. private static _loggingLevel;
  83877. /**
  83878. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  83879. */
  83880. static ForceFullSceneLoadingForIncremental: boolean;
  83881. /**
  83882. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  83883. */
  83884. static ShowLoadingScreen: boolean;
  83885. /**
  83886. * Defines the current logging level (while loading the scene)
  83887. * @ignorenaming
  83888. */
  83889. static loggingLevel: number;
  83890. /**
  83891. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  83892. */
  83893. static CleanBoneMatrixWeights: boolean;
  83894. }
  83895. }
  83896. declare module BABYLON {
  83897. /**
  83898. * Class used to store geometry data (vertex buffers + index buffer)
  83899. */
  83900. export class Geometry implements IGetSetVerticesData {
  83901. /**
  83902. * Gets or sets the ID of the geometry
  83903. */
  83904. id: string;
  83905. /**
  83906. * Gets or sets the unique ID of the geometry
  83907. */
  83908. uniqueId: number;
  83909. /**
  83910. * Gets the delay loading state of the geometry (none by default which means not delayed)
  83911. */
  83912. delayLoadState: number;
  83913. /**
  83914. * Gets the file containing the data to load when running in delay load state
  83915. */
  83916. delayLoadingFile: Nullable<string>;
  83917. /**
  83918. * Callback called when the geometry is updated
  83919. */
  83920. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  83921. private _scene;
  83922. private _engine;
  83923. private _meshes;
  83924. private _totalVertices;
  83925. /** @hidden */
  83926. _indices: IndicesArray;
  83927. /** @hidden */
  83928. _vertexBuffers: {
  83929. [key: string]: VertexBuffer;
  83930. };
  83931. private _isDisposed;
  83932. private _extend;
  83933. private _boundingBias;
  83934. /** @hidden */
  83935. _delayInfo: Array<string>;
  83936. private _indexBuffer;
  83937. private _indexBufferIsUpdatable;
  83938. /** @hidden */
  83939. _boundingInfo: Nullable<BoundingInfo>;
  83940. /** @hidden */
  83941. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  83942. /** @hidden */
  83943. _softwareSkinningFrameId: number;
  83944. private _vertexArrayObjects;
  83945. private _updatable;
  83946. /** @hidden */
  83947. _positions: Nullable<Vector3[]>;
  83948. /**
  83949. * 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
  83950. */
  83951. /**
  83952. * 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
  83953. */
  83954. boundingBias: Vector2;
  83955. /**
  83956. * Static function used to attach a new empty geometry to a mesh
  83957. * @param mesh defines the mesh to attach the geometry to
  83958. * @returns the new Geometry
  83959. */
  83960. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  83961. /**
  83962. * Creates a new geometry
  83963. * @param id defines the unique ID
  83964. * @param scene defines the hosting scene
  83965. * @param vertexData defines the VertexData used to get geometry data
  83966. * @param updatable defines if geometry must be updatable (false by default)
  83967. * @param mesh defines the mesh that will be associated with the geometry
  83968. */
  83969. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  83970. /**
  83971. * Gets the current extend of the geometry
  83972. */
  83973. readonly extend: {
  83974. minimum: Vector3;
  83975. maximum: Vector3;
  83976. };
  83977. /**
  83978. * Gets the hosting scene
  83979. * @returns the hosting Scene
  83980. */
  83981. getScene(): Scene;
  83982. /**
  83983. * Gets the hosting engine
  83984. * @returns the hosting Engine
  83985. */
  83986. getEngine(): Engine;
  83987. /**
  83988. * Defines if the geometry is ready to use
  83989. * @returns true if the geometry is ready to be used
  83990. */
  83991. isReady(): boolean;
  83992. /**
  83993. * Gets a value indicating that the geometry should not be serialized
  83994. */
  83995. readonly doNotSerialize: boolean;
  83996. /** @hidden */
  83997. _rebuild(): void;
  83998. /**
  83999. * Affects all geometry data in one call
  84000. * @param vertexData defines the geometry data
  84001. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  84002. */
  84003. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  84004. /**
  84005. * Set specific vertex data
  84006. * @param kind defines the data kind (Position, normal, etc...)
  84007. * @param data defines the vertex data to use
  84008. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  84009. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  84010. */
  84011. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  84012. /**
  84013. * Removes a specific vertex data
  84014. * @param kind defines the data kind (Position, normal, etc...)
  84015. */
  84016. removeVerticesData(kind: string): void;
  84017. /**
  84018. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  84019. * @param buffer defines the vertex buffer to use
  84020. * @param totalVertices defines the total number of vertices for position kind (could be null)
  84021. */
  84022. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  84023. /**
  84024. * Update a specific vertex buffer
  84025. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  84026. * It will do nothing if the buffer is not updatable
  84027. * @param kind defines the data kind (Position, normal, etc...)
  84028. * @param data defines the data to use
  84029. * @param offset defines the offset in the target buffer where to store the data
  84030. * @param useBytes set to true if the offset is in bytes
  84031. */
  84032. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  84033. /**
  84034. * Update a specific vertex buffer
  84035. * This function will create a new buffer if the current one is not updatable
  84036. * @param kind defines the data kind (Position, normal, etc...)
  84037. * @param data defines the data to use
  84038. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  84039. */
  84040. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  84041. private _updateBoundingInfo;
  84042. /** @hidden */
  84043. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  84044. /**
  84045. * Gets total number of vertices
  84046. * @returns the total number of vertices
  84047. */
  84048. getTotalVertices(): number;
  84049. /**
  84050. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  84051. * @param kind defines the data kind (Position, normal, etc...)
  84052. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  84053. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84054. * @returns a float array containing vertex data
  84055. */
  84056. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  84057. /**
  84058. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  84059. * @param kind defines the data kind (Position, normal, etc...)
  84060. * @returns true if the vertex buffer with the specified kind is updatable
  84061. */
  84062. isVertexBufferUpdatable(kind: string): boolean;
  84063. /**
  84064. * Gets a specific vertex buffer
  84065. * @param kind defines the data kind (Position, normal, etc...)
  84066. * @returns a VertexBuffer
  84067. */
  84068. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  84069. /**
  84070. * Returns all vertex buffers
  84071. * @return an object holding all vertex buffers indexed by kind
  84072. */
  84073. getVertexBuffers(): Nullable<{
  84074. [key: string]: VertexBuffer;
  84075. }>;
  84076. /**
  84077. * Gets a boolean indicating if specific vertex buffer is present
  84078. * @param kind defines the data kind (Position, normal, etc...)
  84079. * @returns true if data is present
  84080. */
  84081. isVerticesDataPresent(kind: string): boolean;
  84082. /**
  84083. * Gets a list of all attached data kinds (Position, normal, etc...)
  84084. * @returns a list of string containing all kinds
  84085. */
  84086. getVerticesDataKinds(): string[];
  84087. /**
  84088. * Update index buffer
  84089. * @param indices defines the indices to store in the index buffer
  84090. * @param offset defines the offset in the target buffer where to store the data
  84091. * @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)
  84092. */
  84093. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  84094. /**
  84095. * Creates a new index buffer
  84096. * @param indices defines the indices to store in the index buffer
  84097. * @param totalVertices defines the total number of vertices (could be null)
  84098. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  84099. */
  84100. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  84101. /**
  84102. * Return the total number of indices
  84103. * @returns the total number of indices
  84104. */
  84105. getTotalIndices(): number;
  84106. /**
  84107. * Gets the index buffer array
  84108. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  84109. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84110. * @returns the index buffer array
  84111. */
  84112. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  84113. /**
  84114. * Gets the index buffer
  84115. * @return the index buffer
  84116. */
  84117. getIndexBuffer(): Nullable<DataBuffer>;
  84118. /** @hidden */
  84119. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  84120. /**
  84121. * Release the associated resources for a specific mesh
  84122. * @param mesh defines the source mesh
  84123. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  84124. */
  84125. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  84126. /**
  84127. * Apply current geometry to a given mesh
  84128. * @param mesh defines the mesh to apply geometry to
  84129. */
  84130. applyToMesh(mesh: Mesh): void;
  84131. private _updateExtend;
  84132. private _applyToMesh;
  84133. private notifyUpdate;
  84134. /**
  84135. * Load the geometry if it was flagged as delay loaded
  84136. * @param scene defines the hosting scene
  84137. * @param onLoaded defines a callback called when the geometry is loaded
  84138. */
  84139. load(scene: Scene, onLoaded?: () => void): void;
  84140. private _queueLoad;
  84141. /**
  84142. * Invert the geometry to move from a right handed system to a left handed one.
  84143. */
  84144. toLeftHanded(): void;
  84145. /** @hidden */
  84146. _resetPointsArrayCache(): void;
  84147. /** @hidden */
  84148. _generatePointsArray(): boolean;
  84149. /**
  84150. * Gets a value indicating if the geometry is disposed
  84151. * @returns true if the geometry was disposed
  84152. */
  84153. isDisposed(): boolean;
  84154. private _disposeVertexArrayObjects;
  84155. /**
  84156. * Free all associated resources
  84157. */
  84158. dispose(): void;
  84159. /**
  84160. * Clone the current geometry into a new geometry
  84161. * @param id defines the unique ID of the new geometry
  84162. * @returns a new geometry object
  84163. */
  84164. copy(id: string): Geometry;
  84165. /**
  84166. * Serialize the current geometry info (and not the vertices data) into a JSON object
  84167. * @return a JSON representation of the current geometry data (without the vertices data)
  84168. */
  84169. serialize(): any;
  84170. private toNumberArray;
  84171. /**
  84172. * Serialize all vertices data into a JSON oject
  84173. * @returns a JSON representation of the current geometry data
  84174. */
  84175. serializeVerticeData(): any;
  84176. /**
  84177. * Extracts a clone of a mesh geometry
  84178. * @param mesh defines the source mesh
  84179. * @param id defines the unique ID of the new geometry object
  84180. * @returns the new geometry object
  84181. */
  84182. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  84183. /**
  84184. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  84185. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  84186. * Be aware Math.random() could cause collisions, but:
  84187. * "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"
  84188. * @returns a string containing a new GUID
  84189. */
  84190. static RandomId(): string;
  84191. /** @hidden */
  84192. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  84193. private static _CleanMatricesWeights;
  84194. /**
  84195. * Create a new geometry from persisted data (Using .babylon file format)
  84196. * @param parsedVertexData defines the persisted data
  84197. * @param scene defines the hosting scene
  84198. * @param rootUrl defines the root url to use to load assets (like delayed data)
  84199. * @returns the new geometry object
  84200. */
  84201. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  84202. }
  84203. }
  84204. declare module BABYLON {
  84205. /**
  84206. * Define an interface for all classes that will get and set the data on vertices
  84207. */
  84208. export interface IGetSetVerticesData {
  84209. /**
  84210. * Gets a boolean indicating if specific vertex data is present
  84211. * @param kind defines the vertex data kind to use
  84212. * @returns true is data kind is present
  84213. */
  84214. isVerticesDataPresent(kind: string): boolean;
  84215. /**
  84216. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  84217. * @param kind defines the data kind (Position, normal, etc...)
  84218. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  84219. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84220. * @returns a float array containing vertex data
  84221. */
  84222. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  84223. /**
  84224. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  84225. * @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.
  84226. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84227. * @returns the indices array or an empty array if the mesh has no geometry
  84228. */
  84229. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  84230. /**
  84231. * Set specific vertex data
  84232. * @param kind defines the data kind (Position, normal, etc...)
  84233. * @param data defines the vertex data to use
  84234. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  84235. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  84236. */
  84237. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  84238. /**
  84239. * Update a specific associated vertex buffer
  84240. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  84241. * - VertexBuffer.PositionKind
  84242. * - VertexBuffer.UVKind
  84243. * - VertexBuffer.UV2Kind
  84244. * - VertexBuffer.UV3Kind
  84245. * - VertexBuffer.UV4Kind
  84246. * - VertexBuffer.UV5Kind
  84247. * - VertexBuffer.UV6Kind
  84248. * - VertexBuffer.ColorKind
  84249. * - VertexBuffer.MatricesIndicesKind
  84250. * - VertexBuffer.MatricesIndicesExtraKind
  84251. * - VertexBuffer.MatricesWeightsKind
  84252. * - VertexBuffer.MatricesWeightsExtraKind
  84253. * @param data defines the data source
  84254. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  84255. * @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)
  84256. */
  84257. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  84258. /**
  84259. * Creates a new index buffer
  84260. * @param indices defines the indices to store in the index buffer
  84261. * @param totalVertices defines the total number of vertices (could be null)
  84262. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  84263. */
  84264. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  84265. }
  84266. /**
  84267. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  84268. */
  84269. export class VertexData {
  84270. /**
  84271. * Mesh side orientation : usually the external or front surface
  84272. */
  84273. static readonly FRONTSIDE: number;
  84274. /**
  84275. * Mesh side orientation : usually the internal or back surface
  84276. */
  84277. static readonly BACKSIDE: number;
  84278. /**
  84279. * Mesh side orientation : both internal and external or front and back surfaces
  84280. */
  84281. static readonly DOUBLESIDE: number;
  84282. /**
  84283. * Mesh side orientation : by default, `FRONTSIDE`
  84284. */
  84285. static readonly DEFAULTSIDE: number;
  84286. /**
  84287. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  84288. */
  84289. positions: Nullable<FloatArray>;
  84290. /**
  84291. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  84292. */
  84293. normals: Nullable<FloatArray>;
  84294. /**
  84295. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  84296. */
  84297. tangents: Nullable<FloatArray>;
  84298. /**
  84299. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  84300. */
  84301. uvs: Nullable<FloatArray>;
  84302. /**
  84303. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  84304. */
  84305. uvs2: Nullable<FloatArray>;
  84306. /**
  84307. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  84308. */
  84309. uvs3: Nullable<FloatArray>;
  84310. /**
  84311. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  84312. */
  84313. uvs4: Nullable<FloatArray>;
  84314. /**
  84315. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  84316. */
  84317. uvs5: Nullable<FloatArray>;
  84318. /**
  84319. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  84320. */
  84321. uvs6: Nullable<FloatArray>;
  84322. /**
  84323. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  84324. */
  84325. colors: Nullable<FloatArray>;
  84326. /**
  84327. * 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).
  84328. */
  84329. matricesIndices: Nullable<FloatArray>;
  84330. /**
  84331. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  84332. */
  84333. matricesWeights: Nullable<FloatArray>;
  84334. /**
  84335. * An array extending the number of possible indices
  84336. */
  84337. matricesIndicesExtra: Nullable<FloatArray>;
  84338. /**
  84339. * An array extending the number of possible weights when the number of indices is extended
  84340. */
  84341. matricesWeightsExtra: Nullable<FloatArray>;
  84342. /**
  84343. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  84344. */
  84345. indices: Nullable<IndicesArray>;
  84346. /**
  84347. * Uses the passed data array to set the set the values for the specified kind of data
  84348. * @param data a linear array of floating numbers
  84349. * @param kind the type of data that is being set, eg positions, colors etc
  84350. */
  84351. set(data: FloatArray, kind: string): void;
  84352. /**
  84353. * Associates the vertexData to the passed Mesh.
  84354. * Sets it as updatable or not (default `false`)
  84355. * @param mesh the mesh the vertexData is applied to
  84356. * @param updatable when used and having the value true allows new data to update the vertexData
  84357. * @returns the VertexData
  84358. */
  84359. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  84360. /**
  84361. * Associates the vertexData to the passed Geometry.
  84362. * Sets it as updatable or not (default `false`)
  84363. * @param geometry the geometry the vertexData is applied to
  84364. * @param updatable when used and having the value true allows new data to update the vertexData
  84365. * @returns VertexData
  84366. */
  84367. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  84368. /**
  84369. * Updates the associated mesh
  84370. * @param mesh the mesh to be updated
  84371. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  84372. * @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
  84373. * @returns VertexData
  84374. */
  84375. updateMesh(mesh: Mesh): VertexData;
  84376. /**
  84377. * Updates the associated geometry
  84378. * @param geometry the geometry to be updated
  84379. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  84380. * @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
  84381. * @returns VertexData.
  84382. */
  84383. updateGeometry(geometry: Geometry): VertexData;
  84384. private _applyTo;
  84385. private _update;
  84386. /**
  84387. * Transforms each position and each normal of the vertexData according to the passed Matrix
  84388. * @param matrix the transforming matrix
  84389. * @returns the VertexData
  84390. */
  84391. transform(matrix: Matrix): VertexData;
  84392. /**
  84393. * Merges the passed VertexData into the current one
  84394. * @param other the VertexData to be merged into the current one
  84395. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  84396. * @returns the modified VertexData
  84397. */
  84398. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  84399. private _mergeElement;
  84400. private _validate;
  84401. /**
  84402. * Serializes the VertexData
  84403. * @returns a serialized object
  84404. */
  84405. serialize(): any;
  84406. /**
  84407. * Extracts the vertexData from a mesh
  84408. * @param mesh the mesh from which to extract the VertexData
  84409. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  84410. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  84411. * @returns the object VertexData associated to the passed mesh
  84412. */
  84413. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  84414. /**
  84415. * Extracts the vertexData from the geometry
  84416. * @param geometry the geometry from which to extract the VertexData
  84417. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  84418. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  84419. * @returns the object VertexData associated to the passed mesh
  84420. */
  84421. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  84422. private static _ExtractFrom;
  84423. /**
  84424. * Creates the VertexData for a Ribbon
  84425. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  84426. * * pathArray array of paths, each of which an array of successive Vector3
  84427. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  84428. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  84429. * * 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
  84430. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84431. * * 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)
  84432. * * 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)
  84433. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  84434. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  84435. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  84436. * @returns the VertexData of the ribbon
  84437. */
  84438. static CreateRibbon(options: {
  84439. pathArray: Vector3[][];
  84440. closeArray?: boolean;
  84441. closePath?: boolean;
  84442. offset?: number;
  84443. sideOrientation?: number;
  84444. frontUVs?: Vector4;
  84445. backUVs?: Vector4;
  84446. invertUV?: boolean;
  84447. uvs?: Vector2[];
  84448. colors?: Color4[];
  84449. }): VertexData;
  84450. /**
  84451. * Creates the VertexData for a box
  84452. * @param options an object used to set the following optional parameters for the box, required but can be empty
  84453. * * size sets the width, height and depth of the box to the value of size, optional default 1
  84454. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  84455. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  84456. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  84457. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  84458. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  84459. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84460. * * 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)
  84461. * * 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)
  84462. * @returns the VertexData of the box
  84463. */
  84464. static CreateBox(options: {
  84465. size?: number;
  84466. width?: number;
  84467. height?: number;
  84468. depth?: number;
  84469. faceUV?: Vector4[];
  84470. faceColors?: Color4[];
  84471. sideOrientation?: number;
  84472. frontUVs?: Vector4;
  84473. backUVs?: Vector4;
  84474. }): VertexData;
  84475. /**
  84476. * Creates the VertexData for a tiled box
  84477. * @param options an object used to set the following optional parameters for the box, required but can be empty
  84478. * * faceTiles sets the pattern, tile size and number of tiles for a face
  84479. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  84480. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  84481. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84482. * @returns the VertexData of the box
  84483. */
  84484. static CreateTiledBox(options: {
  84485. pattern?: number;
  84486. width?: number;
  84487. height?: number;
  84488. depth?: number;
  84489. tileSize?: number;
  84490. tileWidth?: number;
  84491. tileHeight?: number;
  84492. alignHorizontal?: number;
  84493. alignVertical?: number;
  84494. faceUV?: Vector4[];
  84495. faceColors?: Color4[];
  84496. sideOrientation?: number;
  84497. }): VertexData;
  84498. /**
  84499. * Creates the VertexData for a tiled plane
  84500. * @param options an object used to set the following optional parameters for the box, required but can be empty
  84501. * * pattern a limited pattern arrangement depending on the number
  84502. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  84503. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  84504. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  84505. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84506. * * 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)
  84507. * * 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)
  84508. * @returns the VertexData of the tiled plane
  84509. */
  84510. static CreateTiledPlane(options: {
  84511. pattern?: number;
  84512. tileSize?: number;
  84513. tileWidth?: number;
  84514. tileHeight?: number;
  84515. size?: number;
  84516. width?: number;
  84517. height?: number;
  84518. alignHorizontal?: number;
  84519. alignVertical?: number;
  84520. sideOrientation?: number;
  84521. frontUVs?: Vector4;
  84522. backUVs?: Vector4;
  84523. }): VertexData;
  84524. /**
  84525. * Creates the VertexData for an ellipsoid, defaults to a sphere
  84526. * @param options an object used to set the following optional parameters for the box, required but can be empty
  84527. * * segments sets the number of horizontal strips optional, default 32
  84528. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  84529. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  84530. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  84531. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  84532. * * 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
  84533. * * 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
  84534. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84535. * * 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)
  84536. * * 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)
  84537. * @returns the VertexData of the ellipsoid
  84538. */
  84539. static CreateSphere(options: {
  84540. segments?: number;
  84541. diameter?: number;
  84542. diameterX?: number;
  84543. diameterY?: number;
  84544. diameterZ?: number;
  84545. arc?: number;
  84546. slice?: number;
  84547. sideOrientation?: number;
  84548. frontUVs?: Vector4;
  84549. backUVs?: Vector4;
  84550. }): VertexData;
  84551. /**
  84552. * Creates the VertexData for a cylinder, cone or prism
  84553. * @param options an object used to set the following optional parameters for the box, required but can be empty
  84554. * * height sets the height (y direction) of the cylinder, optional, default 2
  84555. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  84556. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  84557. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  84558. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  84559. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  84560. * * 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
  84561. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  84562. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  84563. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  84564. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  84565. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84566. * * 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)
  84567. * * 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)
  84568. * @returns the VertexData of the cylinder, cone or prism
  84569. */
  84570. static CreateCylinder(options: {
  84571. height?: number;
  84572. diameterTop?: number;
  84573. diameterBottom?: number;
  84574. diameter?: number;
  84575. tessellation?: number;
  84576. subdivisions?: number;
  84577. arc?: number;
  84578. faceColors?: Color4[];
  84579. faceUV?: Vector4[];
  84580. hasRings?: boolean;
  84581. enclose?: boolean;
  84582. sideOrientation?: number;
  84583. frontUVs?: Vector4;
  84584. backUVs?: Vector4;
  84585. }): VertexData;
  84586. /**
  84587. * Creates the VertexData for a torus
  84588. * @param options an object used to set the following optional parameters for the box, required but can be empty
  84589. * * diameter the diameter of the torus, optional default 1
  84590. * * thickness the diameter of the tube forming the torus, optional default 0.5
  84591. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  84592. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84593. * * 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)
  84594. * * 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)
  84595. * @returns the VertexData of the torus
  84596. */
  84597. static CreateTorus(options: {
  84598. diameter?: number;
  84599. thickness?: number;
  84600. tessellation?: number;
  84601. sideOrientation?: number;
  84602. frontUVs?: Vector4;
  84603. backUVs?: Vector4;
  84604. }): VertexData;
  84605. /**
  84606. * Creates the VertexData of the LineSystem
  84607. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  84608. * - lines an array of lines, each line being an array of successive Vector3
  84609. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  84610. * @returns the VertexData of the LineSystem
  84611. */
  84612. static CreateLineSystem(options: {
  84613. lines: Vector3[][];
  84614. colors?: Nullable<Color4[][]>;
  84615. }): VertexData;
  84616. /**
  84617. * Create the VertexData for a DashedLines
  84618. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  84619. * - points an array successive Vector3
  84620. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  84621. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  84622. * - dashNb the intended total number of dashes, optional, default 200
  84623. * @returns the VertexData for the DashedLines
  84624. */
  84625. static CreateDashedLines(options: {
  84626. points: Vector3[];
  84627. dashSize?: number;
  84628. gapSize?: number;
  84629. dashNb?: number;
  84630. }): VertexData;
  84631. /**
  84632. * Creates the VertexData for a Ground
  84633. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  84634. * - width the width (x direction) of the ground, optional, default 1
  84635. * - height the height (z direction) of the ground, optional, default 1
  84636. * - subdivisions the number of subdivisions per side, optional, default 1
  84637. * @returns the VertexData of the Ground
  84638. */
  84639. static CreateGround(options: {
  84640. width?: number;
  84641. height?: number;
  84642. subdivisions?: number;
  84643. subdivisionsX?: number;
  84644. subdivisionsY?: number;
  84645. }): VertexData;
  84646. /**
  84647. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  84648. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  84649. * * xmin the ground minimum X coordinate, optional, default -1
  84650. * * zmin the ground minimum Z coordinate, optional, default -1
  84651. * * xmax the ground maximum X coordinate, optional, default 1
  84652. * * zmax the ground maximum Z coordinate, optional, default 1
  84653. * * 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}
  84654. * * 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}
  84655. * @returns the VertexData of the TiledGround
  84656. */
  84657. static CreateTiledGround(options: {
  84658. xmin: number;
  84659. zmin: number;
  84660. xmax: number;
  84661. zmax: number;
  84662. subdivisions?: {
  84663. w: number;
  84664. h: number;
  84665. };
  84666. precision?: {
  84667. w: number;
  84668. h: number;
  84669. };
  84670. }): VertexData;
  84671. /**
  84672. * Creates the VertexData of the Ground designed from a heightmap
  84673. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  84674. * * width the width (x direction) of the ground
  84675. * * height the height (z direction) of the ground
  84676. * * subdivisions the number of subdivisions per side
  84677. * * minHeight the minimum altitude on the ground, optional, default 0
  84678. * * maxHeight the maximum altitude on the ground, optional default 1
  84679. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  84680. * * buffer the array holding the image color data
  84681. * * bufferWidth the width of image
  84682. * * bufferHeight the height of image
  84683. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  84684. * @returns the VertexData of the Ground designed from a heightmap
  84685. */
  84686. static CreateGroundFromHeightMap(options: {
  84687. width: number;
  84688. height: number;
  84689. subdivisions: number;
  84690. minHeight: number;
  84691. maxHeight: number;
  84692. colorFilter: Color3;
  84693. buffer: Uint8Array;
  84694. bufferWidth: number;
  84695. bufferHeight: number;
  84696. alphaFilter: number;
  84697. }): VertexData;
  84698. /**
  84699. * Creates the VertexData for a Plane
  84700. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  84701. * * size sets the width and height of the plane to the value of size, optional default 1
  84702. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  84703. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  84704. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84705. * * 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)
  84706. * * 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)
  84707. * @returns the VertexData of the box
  84708. */
  84709. static CreatePlane(options: {
  84710. size?: number;
  84711. width?: number;
  84712. height?: number;
  84713. sideOrientation?: number;
  84714. frontUVs?: Vector4;
  84715. backUVs?: Vector4;
  84716. }): VertexData;
  84717. /**
  84718. * Creates the VertexData of the Disc or regular Polygon
  84719. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  84720. * * radius the radius of the disc, optional default 0.5
  84721. * * tessellation the number of polygon sides, optional, default 64
  84722. * * 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
  84723. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84724. * * 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)
  84725. * * 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)
  84726. * @returns the VertexData of the box
  84727. */
  84728. static CreateDisc(options: {
  84729. radius?: number;
  84730. tessellation?: number;
  84731. arc?: number;
  84732. sideOrientation?: number;
  84733. frontUVs?: Vector4;
  84734. backUVs?: Vector4;
  84735. }): VertexData;
  84736. /**
  84737. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  84738. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  84739. * @param polygon a mesh built from polygonTriangulation.build()
  84740. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84741. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  84742. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  84743. * @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)
  84744. * @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)
  84745. * @returns the VertexData of the Polygon
  84746. */
  84747. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  84748. /**
  84749. * Creates the VertexData of the IcoSphere
  84750. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  84751. * * radius the radius of the IcoSphere, optional default 1
  84752. * * radiusX allows stretching in the x direction, optional, default radius
  84753. * * radiusY allows stretching in the y direction, optional, default radius
  84754. * * radiusZ allows stretching in the z direction, optional, default radius
  84755. * * flat when true creates a flat shaded mesh, optional, default true
  84756. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  84757. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84758. * * 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)
  84759. * * 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)
  84760. * @returns the VertexData of the IcoSphere
  84761. */
  84762. static CreateIcoSphere(options: {
  84763. radius?: number;
  84764. radiusX?: number;
  84765. radiusY?: number;
  84766. radiusZ?: number;
  84767. flat?: boolean;
  84768. subdivisions?: number;
  84769. sideOrientation?: number;
  84770. frontUVs?: Vector4;
  84771. backUVs?: Vector4;
  84772. }): VertexData;
  84773. /**
  84774. * Creates the VertexData for a Polyhedron
  84775. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  84776. * * type provided types are:
  84777. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  84778. * * 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)
  84779. * * size the size of the IcoSphere, optional default 1
  84780. * * sizeX allows stretching in the x direction, optional, default size
  84781. * * sizeY allows stretching in the y direction, optional, default size
  84782. * * sizeZ allows stretching in the z direction, optional, default size
  84783. * * 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
  84784. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  84785. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  84786. * * flat when true creates a flat shaded mesh, optional, default true
  84787. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  84788. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84789. * * 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)
  84790. * * 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)
  84791. * @returns the VertexData of the Polyhedron
  84792. */
  84793. static CreatePolyhedron(options: {
  84794. type?: number;
  84795. size?: number;
  84796. sizeX?: number;
  84797. sizeY?: number;
  84798. sizeZ?: number;
  84799. custom?: any;
  84800. faceUV?: Vector4[];
  84801. faceColors?: Color4[];
  84802. flat?: boolean;
  84803. sideOrientation?: number;
  84804. frontUVs?: Vector4;
  84805. backUVs?: Vector4;
  84806. }): VertexData;
  84807. /**
  84808. * Creates the VertexData for a TorusKnot
  84809. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  84810. * * radius the radius of the torus knot, optional, default 2
  84811. * * tube the thickness of the tube, optional, default 0.5
  84812. * * radialSegments the number of sides on each tube segments, optional, default 32
  84813. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  84814. * * p the number of windings around the z axis, optional, default 2
  84815. * * q the number of windings around the x axis, optional, default 3
  84816. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84817. * * 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)
  84818. * * 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)
  84819. * @returns the VertexData of the Torus Knot
  84820. */
  84821. static CreateTorusKnot(options: {
  84822. radius?: number;
  84823. tube?: number;
  84824. radialSegments?: number;
  84825. tubularSegments?: number;
  84826. p?: number;
  84827. q?: number;
  84828. sideOrientation?: number;
  84829. frontUVs?: Vector4;
  84830. backUVs?: Vector4;
  84831. }): VertexData;
  84832. /**
  84833. * Compute normals for given positions and indices
  84834. * @param positions an array of vertex positions, [...., x, y, z, ......]
  84835. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  84836. * @param normals an array of vertex normals, [...., x, y, z, ......]
  84837. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  84838. * * facetNormals : optional array of facet normals (vector3)
  84839. * * facetPositions : optional array of facet positions (vector3)
  84840. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  84841. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  84842. * * bInfo : optional bounding info, required for facetPartitioning computation
  84843. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  84844. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  84845. * * useRightHandedSystem: optional boolean to for right handed system computation
  84846. * * depthSort : optional boolean to enable the facet depth sort computation
  84847. * * distanceTo : optional Vector3 to compute the facet depth from this location
  84848. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  84849. */
  84850. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  84851. facetNormals?: any;
  84852. facetPositions?: any;
  84853. facetPartitioning?: any;
  84854. ratio?: number;
  84855. bInfo?: any;
  84856. bbSize?: Vector3;
  84857. subDiv?: any;
  84858. useRightHandedSystem?: boolean;
  84859. depthSort?: boolean;
  84860. distanceTo?: Vector3;
  84861. depthSortedFacets?: any;
  84862. }): void;
  84863. /** @hidden */
  84864. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  84865. /**
  84866. * Applies VertexData created from the imported parameters to the geometry
  84867. * @param parsedVertexData the parsed data from an imported file
  84868. * @param geometry the geometry to apply the VertexData to
  84869. */
  84870. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  84871. }
  84872. }
  84873. declare module BABYLON {
  84874. /**
  84875. * Defines a target to use with MorphTargetManager
  84876. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  84877. */
  84878. export class MorphTarget implements IAnimatable {
  84879. /** defines the name of the target */
  84880. name: string;
  84881. /**
  84882. * Gets or sets the list of animations
  84883. */
  84884. animations: Animation[];
  84885. private _scene;
  84886. private _positions;
  84887. private _normals;
  84888. private _tangents;
  84889. private _uvs;
  84890. private _influence;
  84891. /**
  84892. * Observable raised when the influence changes
  84893. */
  84894. onInfluenceChanged: Observable<boolean>;
  84895. /** @hidden */
  84896. _onDataLayoutChanged: Observable<void>;
  84897. /**
  84898. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  84899. */
  84900. influence: number;
  84901. /**
  84902. * Gets or sets the id of the morph Target
  84903. */
  84904. id: string;
  84905. private _animationPropertiesOverride;
  84906. /**
  84907. * Gets or sets the animation properties override
  84908. */
  84909. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  84910. /**
  84911. * Creates a new MorphTarget
  84912. * @param name defines the name of the target
  84913. * @param influence defines the influence to use
  84914. * @param scene defines the scene the morphtarget belongs to
  84915. */
  84916. constructor(
  84917. /** defines the name of the target */
  84918. name: string, influence?: number, scene?: Nullable<Scene>);
  84919. /**
  84920. * Gets a boolean defining if the target contains position data
  84921. */
  84922. readonly hasPositions: boolean;
  84923. /**
  84924. * Gets a boolean defining if the target contains normal data
  84925. */
  84926. readonly hasNormals: boolean;
  84927. /**
  84928. * Gets a boolean defining if the target contains tangent data
  84929. */
  84930. readonly hasTangents: boolean;
  84931. /**
  84932. * Gets a boolean defining if the target contains texture coordinates data
  84933. */
  84934. readonly hasUVs: boolean;
  84935. /**
  84936. * Affects position data to this target
  84937. * @param data defines the position data to use
  84938. */
  84939. setPositions(data: Nullable<FloatArray>): void;
  84940. /**
  84941. * Gets the position data stored in this target
  84942. * @returns a FloatArray containing the position data (or null if not present)
  84943. */
  84944. getPositions(): Nullable<FloatArray>;
  84945. /**
  84946. * Affects normal data to this target
  84947. * @param data defines the normal data to use
  84948. */
  84949. setNormals(data: Nullable<FloatArray>): void;
  84950. /**
  84951. * Gets the normal data stored in this target
  84952. * @returns a FloatArray containing the normal data (or null if not present)
  84953. */
  84954. getNormals(): Nullable<FloatArray>;
  84955. /**
  84956. * Affects tangent data to this target
  84957. * @param data defines the tangent data to use
  84958. */
  84959. setTangents(data: Nullable<FloatArray>): void;
  84960. /**
  84961. * Gets the tangent data stored in this target
  84962. * @returns a FloatArray containing the tangent data (or null if not present)
  84963. */
  84964. getTangents(): Nullable<FloatArray>;
  84965. /**
  84966. * Affects texture coordinates data to this target
  84967. * @param data defines the texture coordinates data to use
  84968. */
  84969. setUVs(data: Nullable<FloatArray>): void;
  84970. /**
  84971. * Gets the texture coordinates data stored in this target
  84972. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  84973. */
  84974. getUVs(): Nullable<FloatArray>;
  84975. /**
  84976. * Serializes the current target into a Serialization object
  84977. * @returns the serialized object
  84978. */
  84979. serialize(): any;
  84980. /**
  84981. * Returns the string "MorphTarget"
  84982. * @returns "MorphTarget"
  84983. */
  84984. getClassName(): string;
  84985. /**
  84986. * Creates a new target from serialized data
  84987. * @param serializationObject defines the serialized data to use
  84988. * @returns a new MorphTarget
  84989. */
  84990. static Parse(serializationObject: any): MorphTarget;
  84991. /**
  84992. * Creates a MorphTarget from mesh data
  84993. * @param mesh defines the source mesh
  84994. * @param name defines the name to use for the new target
  84995. * @param influence defines the influence to attach to the target
  84996. * @returns a new MorphTarget
  84997. */
  84998. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  84999. }
  85000. }
  85001. declare module BABYLON {
  85002. /**
  85003. * This class is used to deform meshes using morphing between different targets
  85004. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  85005. */
  85006. export class MorphTargetManager {
  85007. private _targets;
  85008. private _targetInfluenceChangedObservers;
  85009. private _targetDataLayoutChangedObservers;
  85010. private _activeTargets;
  85011. private _scene;
  85012. private _influences;
  85013. private _supportsNormals;
  85014. private _supportsTangents;
  85015. private _supportsUVs;
  85016. private _vertexCount;
  85017. private _uniqueId;
  85018. private _tempInfluences;
  85019. /**
  85020. * Gets or sets a boolean indicating if normals must be morphed
  85021. */
  85022. enableNormalMorphing: boolean;
  85023. /**
  85024. * Gets or sets a boolean indicating if tangents must be morphed
  85025. */
  85026. enableTangentMorphing: boolean;
  85027. /**
  85028. * Gets or sets a boolean indicating if UV must be morphed
  85029. */
  85030. enableUVMorphing: boolean;
  85031. /**
  85032. * Creates a new MorphTargetManager
  85033. * @param scene defines the current scene
  85034. */
  85035. constructor(scene?: Nullable<Scene>);
  85036. /**
  85037. * Gets the unique ID of this manager
  85038. */
  85039. readonly uniqueId: number;
  85040. /**
  85041. * Gets the number of vertices handled by this manager
  85042. */
  85043. readonly vertexCount: number;
  85044. /**
  85045. * Gets a boolean indicating if this manager supports morphing of normals
  85046. */
  85047. readonly supportsNormals: boolean;
  85048. /**
  85049. * Gets a boolean indicating if this manager supports morphing of tangents
  85050. */
  85051. readonly supportsTangents: boolean;
  85052. /**
  85053. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  85054. */
  85055. readonly supportsUVs: boolean;
  85056. /**
  85057. * Gets the number of targets stored in this manager
  85058. */
  85059. readonly numTargets: number;
  85060. /**
  85061. * Gets the number of influencers (ie. the number of targets with influences > 0)
  85062. */
  85063. readonly numInfluencers: number;
  85064. /**
  85065. * Gets the list of influences (one per target)
  85066. */
  85067. readonly influences: Float32Array;
  85068. /**
  85069. * Gets the active target at specified index. An active target is a target with an influence > 0
  85070. * @param index defines the index to check
  85071. * @returns the requested target
  85072. */
  85073. getActiveTarget(index: number): MorphTarget;
  85074. /**
  85075. * Gets the target at specified index
  85076. * @param index defines the index to check
  85077. * @returns the requested target
  85078. */
  85079. getTarget(index: number): MorphTarget;
  85080. /**
  85081. * Add a new target to this manager
  85082. * @param target defines the target to add
  85083. */
  85084. addTarget(target: MorphTarget): void;
  85085. /**
  85086. * Removes a target from the manager
  85087. * @param target defines the target to remove
  85088. */
  85089. removeTarget(target: MorphTarget): void;
  85090. /**
  85091. * Serializes the current manager into a Serialization object
  85092. * @returns the serialized object
  85093. */
  85094. serialize(): any;
  85095. private _syncActiveTargets;
  85096. /**
  85097. * Syncrhonize the targets with all the meshes using this morph target manager
  85098. */
  85099. synchronize(): void;
  85100. /**
  85101. * Creates a new MorphTargetManager from serialized data
  85102. * @param serializationObject defines the serialized data
  85103. * @param scene defines the hosting scene
  85104. * @returns the new MorphTargetManager
  85105. */
  85106. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  85107. }
  85108. }
  85109. declare module BABYLON {
  85110. /**
  85111. * Class used to represent a specific level of detail of a mesh
  85112. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  85113. */
  85114. export class MeshLODLevel {
  85115. /** Defines the distance where this level should star being displayed */
  85116. distance: number;
  85117. /** Defines the mesh to use to render this level */
  85118. mesh: Nullable<Mesh>;
  85119. /**
  85120. * Creates a new LOD level
  85121. * @param distance defines the distance where this level should star being displayed
  85122. * @param mesh defines the mesh to use to render this level
  85123. */
  85124. constructor(
  85125. /** Defines the distance where this level should star being displayed */
  85126. distance: number,
  85127. /** Defines the mesh to use to render this level */
  85128. mesh: Nullable<Mesh>);
  85129. }
  85130. }
  85131. declare module BABYLON {
  85132. /**
  85133. * Mesh representing the gorund
  85134. */
  85135. export class GroundMesh extends Mesh {
  85136. /** If octree should be generated */
  85137. generateOctree: boolean;
  85138. private _heightQuads;
  85139. /** @hidden */
  85140. _subdivisionsX: number;
  85141. /** @hidden */
  85142. _subdivisionsY: number;
  85143. /** @hidden */
  85144. _width: number;
  85145. /** @hidden */
  85146. _height: number;
  85147. /** @hidden */
  85148. _minX: number;
  85149. /** @hidden */
  85150. _maxX: number;
  85151. /** @hidden */
  85152. _minZ: number;
  85153. /** @hidden */
  85154. _maxZ: number;
  85155. constructor(name: string, scene: Scene);
  85156. /**
  85157. * "GroundMesh"
  85158. * @returns "GroundMesh"
  85159. */
  85160. getClassName(): string;
  85161. /**
  85162. * The minimum of x and y subdivisions
  85163. */
  85164. readonly subdivisions: number;
  85165. /**
  85166. * X subdivisions
  85167. */
  85168. readonly subdivisionsX: number;
  85169. /**
  85170. * Y subdivisions
  85171. */
  85172. readonly subdivisionsY: number;
  85173. /**
  85174. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  85175. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  85176. * @param chunksCount the number of subdivisions for x and y
  85177. * @param octreeBlocksSize (Default: 32)
  85178. */
  85179. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  85180. /**
  85181. * Returns a height (y) value in the Worl system :
  85182. * the ground altitude at the coordinates (x, z) expressed in the World system.
  85183. * @param x x coordinate
  85184. * @param z z coordinate
  85185. * @returns the ground y position if (x, z) are outside the ground surface.
  85186. */
  85187. getHeightAtCoordinates(x: number, z: number): number;
  85188. /**
  85189. * Returns a normalized vector (Vector3) orthogonal to the ground
  85190. * at the ground coordinates (x, z) expressed in the World system.
  85191. * @param x x coordinate
  85192. * @param z z coordinate
  85193. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  85194. */
  85195. getNormalAtCoordinates(x: number, z: number): Vector3;
  85196. /**
  85197. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  85198. * at the ground coordinates (x, z) expressed in the World system.
  85199. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  85200. * @param x x coordinate
  85201. * @param z z coordinate
  85202. * @param ref vector to store the result
  85203. * @returns the GroundMesh.
  85204. */
  85205. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  85206. /**
  85207. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  85208. * if the ground has been updated.
  85209. * This can be used in the render loop.
  85210. * @returns the GroundMesh.
  85211. */
  85212. updateCoordinateHeights(): GroundMesh;
  85213. private _getFacetAt;
  85214. private _initHeightQuads;
  85215. private _computeHeightQuads;
  85216. /**
  85217. * Serializes this ground mesh
  85218. * @param serializationObject object to write serialization to
  85219. */
  85220. serialize(serializationObject: any): void;
  85221. /**
  85222. * Parses a serialized ground mesh
  85223. * @param parsedMesh the serialized mesh
  85224. * @param scene the scene to create the ground mesh in
  85225. * @returns the created ground mesh
  85226. */
  85227. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  85228. }
  85229. }
  85230. declare module BABYLON {
  85231. /**
  85232. * Interface for Physics-Joint data
  85233. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  85234. */
  85235. export interface PhysicsJointData {
  85236. /**
  85237. * The main pivot of the joint
  85238. */
  85239. mainPivot?: Vector3;
  85240. /**
  85241. * The connected pivot of the joint
  85242. */
  85243. connectedPivot?: Vector3;
  85244. /**
  85245. * The main axis of the joint
  85246. */
  85247. mainAxis?: Vector3;
  85248. /**
  85249. * The connected axis of the joint
  85250. */
  85251. connectedAxis?: Vector3;
  85252. /**
  85253. * The collision of the joint
  85254. */
  85255. collision?: boolean;
  85256. /**
  85257. * Native Oimo/Cannon/Energy data
  85258. */
  85259. nativeParams?: any;
  85260. }
  85261. /**
  85262. * This is a holder class for the physics joint created by the physics plugin
  85263. * It holds a set of functions to control the underlying joint
  85264. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  85265. */
  85266. export class PhysicsJoint {
  85267. /**
  85268. * The type of the physics joint
  85269. */
  85270. type: number;
  85271. /**
  85272. * The data for the physics joint
  85273. */
  85274. jointData: PhysicsJointData;
  85275. private _physicsJoint;
  85276. protected _physicsPlugin: IPhysicsEnginePlugin;
  85277. /**
  85278. * Initializes the physics joint
  85279. * @param type The type of the physics joint
  85280. * @param jointData The data for the physics joint
  85281. */
  85282. constructor(
  85283. /**
  85284. * The type of the physics joint
  85285. */
  85286. type: number,
  85287. /**
  85288. * The data for the physics joint
  85289. */
  85290. jointData: PhysicsJointData);
  85291. /**
  85292. * Gets the physics joint
  85293. */
  85294. /**
  85295. * Sets the physics joint
  85296. */
  85297. physicsJoint: any;
  85298. /**
  85299. * Sets the physics plugin
  85300. */
  85301. physicsPlugin: IPhysicsEnginePlugin;
  85302. /**
  85303. * Execute a function that is physics-plugin specific.
  85304. * @param {Function} func the function that will be executed.
  85305. * It accepts two parameters: the physics world and the physics joint
  85306. */
  85307. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  85308. /**
  85309. * Distance-Joint type
  85310. */
  85311. static DistanceJoint: number;
  85312. /**
  85313. * Hinge-Joint type
  85314. */
  85315. static HingeJoint: number;
  85316. /**
  85317. * Ball-and-Socket joint type
  85318. */
  85319. static BallAndSocketJoint: number;
  85320. /**
  85321. * Wheel-Joint type
  85322. */
  85323. static WheelJoint: number;
  85324. /**
  85325. * Slider-Joint type
  85326. */
  85327. static SliderJoint: number;
  85328. /**
  85329. * Prismatic-Joint type
  85330. */
  85331. static PrismaticJoint: number;
  85332. /**
  85333. * Universal-Joint type
  85334. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  85335. */
  85336. static UniversalJoint: number;
  85337. /**
  85338. * Hinge-Joint 2 type
  85339. */
  85340. static Hinge2Joint: number;
  85341. /**
  85342. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  85343. */
  85344. static PointToPointJoint: number;
  85345. /**
  85346. * Spring-Joint type
  85347. */
  85348. static SpringJoint: number;
  85349. /**
  85350. * Lock-Joint type
  85351. */
  85352. static LockJoint: number;
  85353. }
  85354. /**
  85355. * A class representing a physics distance joint
  85356. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  85357. */
  85358. export class DistanceJoint extends PhysicsJoint {
  85359. /**
  85360. *
  85361. * @param jointData The data for the Distance-Joint
  85362. */
  85363. constructor(jointData: DistanceJointData);
  85364. /**
  85365. * Update the predefined distance.
  85366. * @param maxDistance The maximum preferred distance
  85367. * @param minDistance The minimum preferred distance
  85368. */
  85369. updateDistance(maxDistance: number, minDistance?: number): void;
  85370. }
  85371. /**
  85372. * Represents a Motor-Enabled Joint
  85373. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  85374. */
  85375. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  85376. /**
  85377. * Initializes the Motor-Enabled Joint
  85378. * @param type The type of the joint
  85379. * @param jointData The physica joint data for the joint
  85380. */
  85381. constructor(type: number, jointData: PhysicsJointData);
  85382. /**
  85383. * Set the motor values.
  85384. * Attention, this function is plugin specific. Engines won't react 100% the same.
  85385. * @param force the force to apply
  85386. * @param maxForce max force for this motor.
  85387. */
  85388. setMotor(force?: number, maxForce?: number): void;
  85389. /**
  85390. * Set the motor's limits.
  85391. * Attention, this function is plugin specific. Engines won't react 100% the same.
  85392. * @param upperLimit The upper limit of the motor
  85393. * @param lowerLimit The lower limit of the motor
  85394. */
  85395. setLimit(upperLimit: number, lowerLimit?: number): void;
  85396. }
  85397. /**
  85398. * This class represents a single physics Hinge-Joint
  85399. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  85400. */
  85401. export class HingeJoint extends MotorEnabledJoint {
  85402. /**
  85403. * Initializes the Hinge-Joint
  85404. * @param jointData The joint data for the Hinge-Joint
  85405. */
  85406. constructor(jointData: PhysicsJointData);
  85407. /**
  85408. * Set the motor values.
  85409. * Attention, this function is plugin specific. Engines won't react 100% the same.
  85410. * @param {number} force the force to apply
  85411. * @param {number} maxForce max force for this motor.
  85412. */
  85413. setMotor(force?: number, maxForce?: number): void;
  85414. /**
  85415. * Set the motor's limits.
  85416. * Attention, this function is plugin specific. Engines won't react 100% the same.
  85417. * @param upperLimit The upper limit of the motor
  85418. * @param lowerLimit The lower limit of the motor
  85419. */
  85420. setLimit(upperLimit: number, lowerLimit?: number): void;
  85421. }
  85422. /**
  85423. * This class represents a dual hinge physics joint (same as wheel joint)
  85424. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  85425. */
  85426. export class Hinge2Joint extends MotorEnabledJoint {
  85427. /**
  85428. * Initializes the Hinge2-Joint
  85429. * @param jointData The joint data for the Hinge2-Joint
  85430. */
  85431. constructor(jointData: PhysicsJointData);
  85432. /**
  85433. * Set the motor values.
  85434. * Attention, this function is plugin specific. Engines won't react 100% the same.
  85435. * @param {number} targetSpeed the speed the motor is to reach
  85436. * @param {number} maxForce max force for this motor.
  85437. * @param {motorIndex} the motor's index, 0 or 1.
  85438. */
  85439. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  85440. /**
  85441. * Set the motor limits.
  85442. * Attention, this function is plugin specific. Engines won't react 100% the same.
  85443. * @param {number} upperLimit the upper limit
  85444. * @param {number} lowerLimit lower limit
  85445. * @param {motorIndex} the motor's index, 0 or 1.
  85446. */
  85447. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  85448. }
  85449. /**
  85450. * Interface for a motor enabled joint
  85451. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  85452. */
  85453. export interface IMotorEnabledJoint {
  85454. /**
  85455. * Physics joint
  85456. */
  85457. physicsJoint: any;
  85458. /**
  85459. * Sets the motor of the motor-enabled joint
  85460. * @param force The force of the motor
  85461. * @param maxForce The maximum force of the motor
  85462. * @param motorIndex The index of the motor
  85463. */
  85464. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  85465. /**
  85466. * Sets the limit of the motor
  85467. * @param upperLimit The upper limit of the motor
  85468. * @param lowerLimit The lower limit of the motor
  85469. * @param motorIndex The index of the motor
  85470. */
  85471. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  85472. }
  85473. /**
  85474. * Joint data for a Distance-Joint
  85475. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  85476. */
  85477. export interface DistanceJointData extends PhysicsJointData {
  85478. /**
  85479. * Max distance the 2 joint objects can be apart
  85480. */
  85481. maxDistance: number;
  85482. }
  85483. /**
  85484. * Joint data from a spring joint
  85485. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  85486. */
  85487. export interface SpringJointData extends PhysicsJointData {
  85488. /**
  85489. * Length of the spring
  85490. */
  85491. length: number;
  85492. /**
  85493. * Stiffness of the spring
  85494. */
  85495. stiffness: number;
  85496. /**
  85497. * Damping of the spring
  85498. */
  85499. damping: number;
  85500. /** this callback will be called when applying the force to the impostors. */
  85501. forceApplicationCallback: () => void;
  85502. }
  85503. }
  85504. declare module BABYLON {
  85505. /**
  85506. * Holds the data for the raycast result
  85507. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  85508. */
  85509. export class PhysicsRaycastResult {
  85510. private _hasHit;
  85511. private _hitDistance;
  85512. private _hitNormalWorld;
  85513. private _hitPointWorld;
  85514. private _rayFromWorld;
  85515. private _rayToWorld;
  85516. /**
  85517. * Gets if there was a hit
  85518. */
  85519. readonly hasHit: boolean;
  85520. /**
  85521. * Gets the distance from the hit
  85522. */
  85523. readonly hitDistance: number;
  85524. /**
  85525. * Gets the hit normal/direction in the world
  85526. */
  85527. readonly hitNormalWorld: Vector3;
  85528. /**
  85529. * Gets the hit point in the world
  85530. */
  85531. readonly hitPointWorld: Vector3;
  85532. /**
  85533. * Gets the ray "start point" of the ray in the world
  85534. */
  85535. readonly rayFromWorld: Vector3;
  85536. /**
  85537. * Gets the ray "end point" of the ray in the world
  85538. */
  85539. readonly rayToWorld: Vector3;
  85540. /**
  85541. * Sets the hit data (normal & point in world space)
  85542. * @param hitNormalWorld defines the normal in world space
  85543. * @param hitPointWorld defines the point in world space
  85544. */
  85545. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  85546. /**
  85547. * Sets the distance from the start point to the hit point
  85548. * @param distance
  85549. */
  85550. setHitDistance(distance: number): void;
  85551. /**
  85552. * Calculates the distance manually
  85553. */
  85554. calculateHitDistance(): void;
  85555. /**
  85556. * Resets all the values to default
  85557. * @param from The from point on world space
  85558. * @param to The to point on world space
  85559. */
  85560. reset(from?: Vector3, to?: Vector3): void;
  85561. }
  85562. /**
  85563. * Interface for the size containing width and height
  85564. */
  85565. interface IXYZ {
  85566. /**
  85567. * X
  85568. */
  85569. x: number;
  85570. /**
  85571. * Y
  85572. */
  85573. y: number;
  85574. /**
  85575. * Z
  85576. */
  85577. z: number;
  85578. }
  85579. }
  85580. declare module BABYLON {
  85581. /**
  85582. * Interface used to describe a physics joint
  85583. */
  85584. export interface PhysicsImpostorJoint {
  85585. /** Defines the main impostor to which the joint is linked */
  85586. mainImpostor: PhysicsImpostor;
  85587. /** Defines the impostor that is connected to the main impostor using this joint */
  85588. connectedImpostor: PhysicsImpostor;
  85589. /** Defines the joint itself */
  85590. joint: PhysicsJoint;
  85591. }
  85592. /** @hidden */
  85593. export interface IPhysicsEnginePlugin {
  85594. world: any;
  85595. name: string;
  85596. setGravity(gravity: Vector3): void;
  85597. setTimeStep(timeStep: number): void;
  85598. getTimeStep(): number;
  85599. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  85600. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  85601. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  85602. generatePhysicsBody(impostor: PhysicsImpostor): void;
  85603. removePhysicsBody(impostor: PhysicsImpostor): void;
  85604. generateJoint(joint: PhysicsImpostorJoint): void;
  85605. removeJoint(joint: PhysicsImpostorJoint): void;
  85606. isSupported(): boolean;
  85607. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  85608. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  85609. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  85610. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  85611. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  85612. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  85613. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  85614. getBodyMass(impostor: PhysicsImpostor): number;
  85615. getBodyFriction(impostor: PhysicsImpostor): number;
  85616. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  85617. getBodyRestitution(impostor: PhysicsImpostor): number;
  85618. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  85619. getBodyPressure?(impostor: PhysicsImpostor): number;
  85620. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  85621. getBodyStiffness?(impostor: PhysicsImpostor): number;
  85622. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  85623. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  85624. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  85625. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  85626. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  85627. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  85628. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  85629. sleepBody(impostor: PhysicsImpostor): void;
  85630. wakeUpBody(impostor: PhysicsImpostor): void;
  85631. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  85632. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  85633. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  85634. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  85635. getRadius(impostor: PhysicsImpostor): number;
  85636. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  85637. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  85638. dispose(): void;
  85639. }
  85640. /**
  85641. * Interface used to define a physics engine
  85642. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  85643. */
  85644. export interface IPhysicsEngine {
  85645. /**
  85646. * Gets the gravity vector used by the simulation
  85647. */
  85648. gravity: Vector3;
  85649. /**
  85650. * Sets the gravity vector used by the simulation
  85651. * @param gravity defines the gravity vector to use
  85652. */
  85653. setGravity(gravity: Vector3): void;
  85654. /**
  85655. * Set the time step of the physics engine.
  85656. * Default is 1/60.
  85657. * To slow it down, enter 1/600 for example.
  85658. * To speed it up, 1/30
  85659. * @param newTimeStep the new timestep to apply to this world.
  85660. */
  85661. setTimeStep(newTimeStep: number): void;
  85662. /**
  85663. * Get the time step of the physics engine.
  85664. * @returns the current time step
  85665. */
  85666. getTimeStep(): number;
  85667. /**
  85668. * Release all resources
  85669. */
  85670. dispose(): void;
  85671. /**
  85672. * Gets the name of the current physics plugin
  85673. * @returns the name of the plugin
  85674. */
  85675. getPhysicsPluginName(): string;
  85676. /**
  85677. * Adding a new impostor for the impostor tracking.
  85678. * This will be done by the impostor itself.
  85679. * @param impostor the impostor to add
  85680. */
  85681. addImpostor(impostor: PhysicsImpostor): void;
  85682. /**
  85683. * Remove an impostor from the engine.
  85684. * This impostor and its mesh will not longer be updated by the physics engine.
  85685. * @param impostor the impostor to remove
  85686. */
  85687. removeImpostor(impostor: PhysicsImpostor): void;
  85688. /**
  85689. * Add a joint to the physics engine
  85690. * @param mainImpostor defines the main impostor to which the joint is added.
  85691. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  85692. * @param joint defines the joint that will connect both impostors.
  85693. */
  85694. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  85695. /**
  85696. * Removes a joint from the simulation
  85697. * @param mainImpostor defines the impostor used with the joint
  85698. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  85699. * @param joint defines the joint to remove
  85700. */
  85701. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  85702. /**
  85703. * Gets the current plugin used to run the simulation
  85704. * @returns current plugin
  85705. */
  85706. getPhysicsPlugin(): IPhysicsEnginePlugin;
  85707. /**
  85708. * Gets the list of physic impostors
  85709. * @returns an array of PhysicsImpostor
  85710. */
  85711. getImpostors(): Array<PhysicsImpostor>;
  85712. /**
  85713. * Gets the impostor for a physics enabled object
  85714. * @param object defines the object impersonated by the impostor
  85715. * @returns the PhysicsImpostor or null if not found
  85716. */
  85717. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  85718. /**
  85719. * Gets the impostor for a physics body object
  85720. * @param body defines physics body used by the impostor
  85721. * @returns the PhysicsImpostor or null if not found
  85722. */
  85723. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  85724. /**
  85725. * Does a raycast in the physics world
  85726. * @param from when should the ray start?
  85727. * @param to when should the ray end?
  85728. * @returns PhysicsRaycastResult
  85729. */
  85730. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  85731. /**
  85732. * Called by the scene. No need to call it.
  85733. * @param delta defines the timespam between frames
  85734. */
  85735. _step(delta: number): void;
  85736. }
  85737. }
  85738. declare module BABYLON {
  85739. /**
  85740. * The interface for the physics imposter parameters
  85741. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  85742. */
  85743. export interface PhysicsImpostorParameters {
  85744. /**
  85745. * The mass of the physics imposter
  85746. */
  85747. mass: number;
  85748. /**
  85749. * The friction of the physics imposter
  85750. */
  85751. friction?: number;
  85752. /**
  85753. * The coefficient of restitution of the physics imposter
  85754. */
  85755. restitution?: number;
  85756. /**
  85757. * The native options of the physics imposter
  85758. */
  85759. nativeOptions?: any;
  85760. /**
  85761. * Specifies if the parent should be ignored
  85762. */
  85763. ignoreParent?: boolean;
  85764. /**
  85765. * Specifies if bi-directional transformations should be disabled
  85766. */
  85767. disableBidirectionalTransformation?: boolean;
  85768. /**
  85769. * The pressure inside the physics imposter, soft object only
  85770. */
  85771. pressure?: number;
  85772. /**
  85773. * The stiffness the physics imposter, soft object only
  85774. */
  85775. stiffness?: number;
  85776. /**
  85777. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  85778. */
  85779. velocityIterations?: number;
  85780. /**
  85781. * The number of iterations used in maintaining consistent vertex positions, soft object only
  85782. */
  85783. positionIterations?: number;
  85784. /**
  85785. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  85786. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  85787. * Add to fix multiple points
  85788. */
  85789. fixedPoints?: number;
  85790. /**
  85791. * The collision margin around a soft object
  85792. */
  85793. margin?: number;
  85794. /**
  85795. * The collision margin around a soft object
  85796. */
  85797. damping?: number;
  85798. /**
  85799. * The path for a rope based on an extrusion
  85800. */
  85801. path?: any;
  85802. /**
  85803. * The shape of an extrusion used for a rope based on an extrusion
  85804. */
  85805. shape?: any;
  85806. }
  85807. /**
  85808. * Interface for a physics-enabled object
  85809. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  85810. */
  85811. export interface IPhysicsEnabledObject {
  85812. /**
  85813. * The position of the physics-enabled object
  85814. */
  85815. position: Vector3;
  85816. /**
  85817. * The rotation of the physics-enabled object
  85818. */
  85819. rotationQuaternion: Nullable<Quaternion>;
  85820. /**
  85821. * The scale of the physics-enabled object
  85822. */
  85823. scaling: Vector3;
  85824. /**
  85825. * The rotation of the physics-enabled object
  85826. */
  85827. rotation?: Vector3;
  85828. /**
  85829. * The parent of the physics-enabled object
  85830. */
  85831. parent?: any;
  85832. /**
  85833. * The bounding info of the physics-enabled object
  85834. * @returns The bounding info of the physics-enabled object
  85835. */
  85836. getBoundingInfo(): BoundingInfo;
  85837. /**
  85838. * Computes the world matrix
  85839. * @param force Specifies if the world matrix should be computed by force
  85840. * @returns A world matrix
  85841. */
  85842. computeWorldMatrix(force: boolean): Matrix;
  85843. /**
  85844. * Gets the world matrix
  85845. * @returns A world matrix
  85846. */
  85847. getWorldMatrix?(): Matrix;
  85848. /**
  85849. * Gets the child meshes
  85850. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  85851. * @returns An array of abstract meshes
  85852. */
  85853. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  85854. /**
  85855. * Gets the vertex data
  85856. * @param kind The type of vertex data
  85857. * @returns A nullable array of numbers, or a float32 array
  85858. */
  85859. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  85860. /**
  85861. * Gets the indices from the mesh
  85862. * @returns A nullable array of index arrays
  85863. */
  85864. getIndices?(): Nullable<IndicesArray>;
  85865. /**
  85866. * Gets the scene from the mesh
  85867. * @returns the indices array or null
  85868. */
  85869. getScene?(): Scene;
  85870. /**
  85871. * Gets the absolute position from the mesh
  85872. * @returns the absolute position
  85873. */
  85874. getAbsolutePosition(): Vector3;
  85875. /**
  85876. * Gets the absolute pivot point from the mesh
  85877. * @returns the absolute pivot point
  85878. */
  85879. getAbsolutePivotPoint(): Vector3;
  85880. /**
  85881. * Rotates the mesh
  85882. * @param axis The axis of rotation
  85883. * @param amount The amount of rotation
  85884. * @param space The space of the rotation
  85885. * @returns The rotation transform node
  85886. */
  85887. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  85888. /**
  85889. * Translates the mesh
  85890. * @param axis The axis of translation
  85891. * @param distance The distance of translation
  85892. * @param space The space of the translation
  85893. * @returns The transform node
  85894. */
  85895. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  85896. /**
  85897. * Sets the absolute position of the mesh
  85898. * @param absolutePosition The absolute position of the mesh
  85899. * @returns The transform node
  85900. */
  85901. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  85902. /**
  85903. * Gets the class name of the mesh
  85904. * @returns The class name
  85905. */
  85906. getClassName(): string;
  85907. }
  85908. /**
  85909. * Represents a physics imposter
  85910. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  85911. */
  85912. export class PhysicsImpostor {
  85913. /**
  85914. * The physics-enabled object used as the physics imposter
  85915. */
  85916. object: IPhysicsEnabledObject;
  85917. /**
  85918. * The type of the physics imposter
  85919. */
  85920. type: number;
  85921. private _options;
  85922. private _scene?;
  85923. /**
  85924. * The default object size of the imposter
  85925. */
  85926. static DEFAULT_OBJECT_SIZE: Vector3;
  85927. /**
  85928. * The identity quaternion of the imposter
  85929. */
  85930. static IDENTITY_QUATERNION: Quaternion;
  85931. /** @hidden */
  85932. _pluginData: any;
  85933. private _physicsEngine;
  85934. private _physicsBody;
  85935. private _bodyUpdateRequired;
  85936. private _onBeforePhysicsStepCallbacks;
  85937. private _onAfterPhysicsStepCallbacks;
  85938. /** @hidden */
  85939. _onPhysicsCollideCallbacks: Array<{
  85940. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  85941. otherImpostors: Array<PhysicsImpostor>;
  85942. }>;
  85943. private _deltaPosition;
  85944. private _deltaRotation;
  85945. private _deltaRotationConjugated;
  85946. /** @hidden */
  85947. _isFromLine: boolean;
  85948. private _parent;
  85949. private _isDisposed;
  85950. private static _tmpVecs;
  85951. private static _tmpQuat;
  85952. /**
  85953. * Specifies if the physics imposter is disposed
  85954. */
  85955. readonly isDisposed: boolean;
  85956. /**
  85957. * Gets the mass of the physics imposter
  85958. */
  85959. mass: number;
  85960. /**
  85961. * Gets the coefficient of friction
  85962. */
  85963. /**
  85964. * Sets the coefficient of friction
  85965. */
  85966. friction: number;
  85967. /**
  85968. * Gets the coefficient of restitution
  85969. */
  85970. /**
  85971. * Sets the coefficient of restitution
  85972. */
  85973. restitution: number;
  85974. /**
  85975. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  85976. */
  85977. /**
  85978. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  85979. */
  85980. pressure: number;
  85981. /**
  85982. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  85983. */
  85984. /**
  85985. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  85986. */
  85987. stiffness: number;
  85988. /**
  85989. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  85990. */
  85991. /**
  85992. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  85993. */
  85994. velocityIterations: number;
  85995. /**
  85996. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  85997. */
  85998. /**
  85999. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  86000. */
  86001. positionIterations: number;
  86002. /**
  86003. * The unique id of the physics imposter
  86004. * set by the physics engine when adding this impostor to the array
  86005. */
  86006. uniqueId: number;
  86007. /**
  86008. * @hidden
  86009. */
  86010. soft: boolean;
  86011. /**
  86012. * @hidden
  86013. */
  86014. segments: number;
  86015. private _joints;
  86016. /**
  86017. * Initializes the physics imposter
  86018. * @param object The physics-enabled object used as the physics imposter
  86019. * @param type The type of the physics imposter
  86020. * @param _options The options for the physics imposter
  86021. * @param _scene The Babylon scene
  86022. */
  86023. constructor(
  86024. /**
  86025. * The physics-enabled object used as the physics imposter
  86026. */
  86027. object: IPhysicsEnabledObject,
  86028. /**
  86029. * The type of the physics imposter
  86030. */
  86031. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  86032. /**
  86033. * This function will completly initialize this impostor.
  86034. * It will create a new body - but only if this mesh has no parent.
  86035. * If it has, this impostor will not be used other than to define the impostor
  86036. * of the child mesh.
  86037. * @hidden
  86038. */
  86039. _init(): void;
  86040. private _getPhysicsParent;
  86041. /**
  86042. * Should a new body be generated.
  86043. * @returns boolean specifying if body initialization is required
  86044. */
  86045. isBodyInitRequired(): boolean;
  86046. /**
  86047. * Sets the updated scaling
  86048. * @param updated Specifies if the scaling is updated
  86049. */
  86050. setScalingUpdated(): void;
  86051. /**
  86052. * Force a regeneration of this or the parent's impostor's body.
  86053. * Use under cautious - This will remove all joints already implemented.
  86054. */
  86055. forceUpdate(): void;
  86056. /**
  86057. * Gets the body that holds this impostor. Either its own, or its parent.
  86058. */
  86059. /**
  86060. * Set the physics body. Used mainly by the physics engine/plugin
  86061. */
  86062. physicsBody: any;
  86063. /**
  86064. * Get the parent of the physics imposter
  86065. * @returns Physics imposter or null
  86066. */
  86067. /**
  86068. * Sets the parent of the physics imposter
  86069. */
  86070. parent: Nullable<PhysicsImpostor>;
  86071. /**
  86072. * Resets the update flags
  86073. */
  86074. resetUpdateFlags(): void;
  86075. /**
  86076. * Gets the object extend size
  86077. * @returns the object extend size
  86078. */
  86079. getObjectExtendSize(): Vector3;
  86080. /**
  86081. * Gets the object center
  86082. * @returns The object center
  86083. */
  86084. getObjectCenter(): Vector3;
  86085. /**
  86086. * Get a specific parametes from the options parameter
  86087. * @param paramName The object parameter name
  86088. * @returns The object parameter
  86089. */
  86090. getParam(paramName: string): any;
  86091. /**
  86092. * Sets a specific parameter in the options given to the physics plugin
  86093. * @param paramName The parameter name
  86094. * @param value The value of the parameter
  86095. */
  86096. setParam(paramName: string, value: number): void;
  86097. /**
  86098. * Specifically change the body's mass option. Won't recreate the physics body object
  86099. * @param mass The mass of the physics imposter
  86100. */
  86101. setMass(mass: number): void;
  86102. /**
  86103. * Gets the linear velocity
  86104. * @returns linear velocity or null
  86105. */
  86106. getLinearVelocity(): Nullable<Vector3>;
  86107. /**
  86108. * Sets the linear velocity
  86109. * @param velocity linear velocity or null
  86110. */
  86111. setLinearVelocity(velocity: Nullable<Vector3>): void;
  86112. /**
  86113. * Gets the angular velocity
  86114. * @returns angular velocity or null
  86115. */
  86116. getAngularVelocity(): Nullable<Vector3>;
  86117. /**
  86118. * Sets the angular velocity
  86119. * @param velocity The velocity or null
  86120. */
  86121. setAngularVelocity(velocity: Nullable<Vector3>): void;
  86122. /**
  86123. * Execute a function with the physics plugin native code
  86124. * Provide a function the will have two variables - the world object and the physics body object
  86125. * @param func The function to execute with the physics plugin native code
  86126. */
  86127. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  86128. /**
  86129. * Register a function that will be executed before the physics world is stepping forward
  86130. * @param func The function to execute before the physics world is stepped forward
  86131. */
  86132. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  86133. /**
  86134. * Unregister a function that will be executed before the physics world is stepping forward
  86135. * @param func The function to execute before the physics world is stepped forward
  86136. */
  86137. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  86138. /**
  86139. * Register a function that will be executed after the physics step
  86140. * @param func The function to execute after physics step
  86141. */
  86142. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  86143. /**
  86144. * Unregisters a function that will be executed after the physics step
  86145. * @param func The function to execute after physics step
  86146. */
  86147. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  86148. /**
  86149. * register a function that will be executed when this impostor collides against a different body
  86150. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  86151. * @param func Callback that is executed on collision
  86152. */
  86153. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  86154. /**
  86155. * Unregisters the physics imposter on contact
  86156. * @param collideAgainst The physics object to collide against
  86157. * @param func Callback to execute on collision
  86158. */
  86159. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  86160. private _tmpQuat;
  86161. private _tmpQuat2;
  86162. /**
  86163. * Get the parent rotation
  86164. * @returns The parent rotation
  86165. */
  86166. getParentsRotation(): Quaternion;
  86167. /**
  86168. * this function is executed by the physics engine.
  86169. */
  86170. beforeStep: () => void;
  86171. /**
  86172. * this function is executed by the physics engine
  86173. */
  86174. afterStep: () => void;
  86175. /**
  86176. * Legacy collision detection event support
  86177. */
  86178. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  86179. /**
  86180. * event and body object due to cannon's event-based architecture.
  86181. */
  86182. onCollide: (e: {
  86183. body: any;
  86184. }) => void;
  86185. /**
  86186. * Apply a force
  86187. * @param force The force to apply
  86188. * @param contactPoint The contact point for the force
  86189. * @returns The physics imposter
  86190. */
  86191. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  86192. /**
  86193. * Apply an impulse
  86194. * @param force The impulse force
  86195. * @param contactPoint The contact point for the impulse force
  86196. * @returns The physics imposter
  86197. */
  86198. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  86199. /**
  86200. * A help function to create a joint
  86201. * @param otherImpostor A physics imposter used to create a joint
  86202. * @param jointType The type of joint
  86203. * @param jointData The data for the joint
  86204. * @returns The physics imposter
  86205. */
  86206. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  86207. /**
  86208. * Add a joint to this impostor with a different impostor
  86209. * @param otherImpostor A physics imposter used to add a joint
  86210. * @param joint The joint to add
  86211. * @returns The physics imposter
  86212. */
  86213. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  86214. /**
  86215. * Add an anchor to a cloth impostor
  86216. * @param otherImpostor rigid impostor to anchor to
  86217. * @param width ratio across width from 0 to 1
  86218. * @param height ratio up height from 0 to 1
  86219. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  86220. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  86221. * @returns impostor the soft imposter
  86222. */
  86223. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  86224. /**
  86225. * Add a hook to a rope impostor
  86226. * @param otherImpostor rigid impostor to anchor to
  86227. * @param length ratio across rope from 0 to 1
  86228. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  86229. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  86230. * @returns impostor the rope imposter
  86231. */
  86232. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  86233. /**
  86234. * Will keep this body still, in a sleep mode.
  86235. * @returns the physics imposter
  86236. */
  86237. sleep(): PhysicsImpostor;
  86238. /**
  86239. * Wake the body up.
  86240. * @returns The physics imposter
  86241. */
  86242. wakeUp(): PhysicsImpostor;
  86243. /**
  86244. * Clones the physics imposter
  86245. * @param newObject The physics imposter clones to this physics-enabled object
  86246. * @returns A nullable physics imposter
  86247. */
  86248. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  86249. /**
  86250. * Disposes the physics imposter
  86251. */
  86252. dispose(): void;
  86253. /**
  86254. * Sets the delta position
  86255. * @param position The delta position amount
  86256. */
  86257. setDeltaPosition(position: Vector3): void;
  86258. /**
  86259. * Sets the delta rotation
  86260. * @param rotation The delta rotation amount
  86261. */
  86262. setDeltaRotation(rotation: Quaternion): void;
  86263. /**
  86264. * Gets the box size of the physics imposter and stores the result in the input parameter
  86265. * @param result Stores the box size
  86266. * @returns The physics imposter
  86267. */
  86268. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  86269. /**
  86270. * Gets the radius of the physics imposter
  86271. * @returns Radius of the physics imposter
  86272. */
  86273. getRadius(): number;
  86274. /**
  86275. * Sync a bone with this impostor
  86276. * @param bone The bone to sync to the impostor.
  86277. * @param boneMesh The mesh that the bone is influencing.
  86278. * @param jointPivot The pivot of the joint / bone in local space.
  86279. * @param distToJoint Optional distance from the impostor to the joint.
  86280. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  86281. */
  86282. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  86283. /**
  86284. * Sync impostor to a bone
  86285. * @param bone The bone that the impostor will be synced to.
  86286. * @param boneMesh The mesh that the bone is influencing.
  86287. * @param jointPivot The pivot of the joint / bone in local space.
  86288. * @param distToJoint Optional distance from the impostor to the joint.
  86289. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  86290. * @param boneAxis Optional vector3 axis the bone is aligned with
  86291. */
  86292. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  86293. /**
  86294. * No-Imposter type
  86295. */
  86296. static NoImpostor: number;
  86297. /**
  86298. * Sphere-Imposter type
  86299. */
  86300. static SphereImpostor: number;
  86301. /**
  86302. * Box-Imposter type
  86303. */
  86304. static BoxImpostor: number;
  86305. /**
  86306. * Plane-Imposter type
  86307. */
  86308. static PlaneImpostor: number;
  86309. /**
  86310. * Mesh-imposter type
  86311. */
  86312. static MeshImpostor: number;
  86313. /**
  86314. * Capsule-Impostor type (Ammo.js plugin only)
  86315. */
  86316. static CapsuleImpostor: number;
  86317. /**
  86318. * Cylinder-Imposter type
  86319. */
  86320. static CylinderImpostor: number;
  86321. /**
  86322. * Particle-Imposter type
  86323. */
  86324. static ParticleImpostor: number;
  86325. /**
  86326. * Heightmap-Imposter type
  86327. */
  86328. static HeightmapImpostor: number;
  86329. /**
  86330. * ConvexHull-Impostor type (Ammo.js plugin only)
  86331. */
  86332. static ConvexHullImpostor: number;
  86333. /**
  86334. * Rope-Imposter type
  86335. */
  86336. static RopeImpostor: number;
  86337. /**
  86338. * Cloth-Imposter type
  86339. */
  86340. static ClothImpostor: number;
  86341. /**
  86342. * Softbody-Imposter type
  86343. */
  86344. static SoftbodyImpostor: number;
  86345. }
  86346. }
  86347. declare module BABYLON {
  86348. /**
  86349. * @hidden
  86350. **/
  86351. export class _CreationDataStorage {
  86352. closePath?: boolean;
  86353. closeArray?: boolean;
  86354. idx: number[];
  86355. dashSize: number;
  86356. gapSize: number;
  86357. path3D: Path3D;
  86358. pathArray: Vector3[][];
  86359. arc: number;
  86360. radius: number;
  86361. cap: number;
  86362. tessellation: number;
  86363. }
  86364. /**
  86365. * @hidden
  86366. **/
  86367. class _InstanceDataStorage {
  86368. visibleInstances: any;
  86369. batchCache: _InstancesBatch;
  86370. instancesBufferSize: number;
  86371. instancesBuffer: Nullable<Buffer>;
  86372. instancesData: Float32Array;
  86373. overridenInstanceCount: number;
  86374. isFrozen: boolean;
  86375. previousBatch: Nullable<_InstancesBatch>;
  86376. hardwareInstancedRendering: boolean;
  86377. sideOrientation: number;
  86378. }
  86379. /**
  86380. * @hidden
  86381. **/
  86382. export class _InstancesBatch {
  86383. mustReturn: boolean;
  86384. visibleInstances: Nullable<InstancedMesh[]>[];
  86385. renderSelf: boolean[];
  86386. hardwareInstancedRendering: boolean[];
  86387. }
  86388. /**
  86389. * Class used to represent renderable models
  86390. */
  86391. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  86392. /**
  86393. * Mesh side orientation : usually the external or front surface
  86394. */
  86395. static readonly FRONTSIDE: number;
  86396. /**
  86397. * Mesh side orientation : usually the internal or back surface
  86398. */
  86399. static readonly BACKSIDE: number;
  86400. /**
  86401. * Mesh side orientation : both internal and external or front and back surfaces
  86402. */
  86403. static readonly DOUBLESIDE: number;
  86404. /**
  86405. * Mesh side orientation : by default, `FRONTSIDE`
  86406. */
  86407. static readonly DEFAULTSIDE: number;
  86408. /**
  86409. * Mesh cap setting : no cap
  86410. */
  86411. static readonly NO_CAP: number;
  86412. /**
  86413. * Mesh cap setting : one cap at the beginning of the mesh
  86414. */
  86415. static readonly CAP_START: number;
  86416. /**
  86417. * Mesh cap setting : one cap at the end of the mesh
  86418. */
  86419. static readonly CAP_END: number;
  86420. /**
  86421. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  86422. */
  86423. static readonly CAP_ALL: number;
  86424. /**
  86425. * Mesh pattern setting : no flip or rotate
  86426. */
  86427. static readonly NO_FLIP: number;
  86428. /**
  86429. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  86430. */
  86431. static readonly FLIP_TILE: number;
  86432. /**
  86433. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  86434. */
  86435. static readonly ROTATE_TILE: number;
  86436. /**
  86437. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  86438. */
  86439. static readonly FLIP_ROW: number;
  86440. /**
  86441. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  86442. */
  86443. static readonly ROTATE_ROW: number;
  86444. /**
  86445. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  86446. */
  86447. static readonly FLIP_N_ROTATE_TILE: number;
  86448. /**
  86449. * Mesh pattern setting : rotate pattern and rotate
  86450. */
  86451. static readonly FLIP_N_ROTATE_ROW: number;
  86452. /**
  86453. * Mesh tile positioning : part tiles same on left/right or top/bottom
  86454. */
  86455. static readonly CENTER: number;
  86456. /**
  86457. * Mesh tile positioning : part tiles on left
  86458. */
  86459. static readonly LEFT: number;
  86460. /**
  86461. * Mesh tile positioning : part tiles on right
  86462. */
  86463. static readonly RIGHT: number;
  86464. /**
  86465. * Mesh tile positioning : part tiles on top
  86466. */
  86467. static readonly TOP: number;
  86468. /**
  86469. * Mesh tile positioning : part tiles on bottom
  86470. */
  86471. static readonly BOTTOM: number;
  86472. /**
  86473. * Gets the default side orientation.
  86474. * @param orientation the orientation to value to attempt to get
  86475. * @returns the default orientation
  86476. * @hidden
  86477. */
  86478. static _GetDefaultSideOrientation(orientation?: number): number;
  86479. private _internalMeshDataInfo;
  86480. /**
  86481. * An event triggered before rendering the mesh
  86482. */
  86483. readonly onBeforeRenderObservable: Observable<Mesh>;
  86484. /**
  86485. * An event triggered before binding the mesh
  86486. */
  86487. readonly onBeforeBindObservable: Observable<Mesh>;
  86488. /**
  86489. * An event triggered after rendering the mesh
  86490. */
  86491. readonly onAfterRenderObservable: Observable<Mesh>;
  86492. /**
  86493. * An event triggered before drawing the mesh
  86494. */
  86495. readonly onBeforeDrawObservable: Observable<Mesh>;
  86496. private _onBeforeDrawObserver;
  86497. /**
  86498. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  86499. */
  86500. onBeforeDraw: () => void;
  86501. /**
  86502. * Gets the delay loading state of the mesh (when delay loading is turned on)
  86503. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  86504. */
  86505. delayLoadState: number;
  86506. /**
  86507. * Gets the list of instances created from this mesh
  86508. * it is not supposed to be modified manually.
  86509. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  86510. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  86511. */
  86512. instances: InstancedMesh[];
  86513. /**
  86514. * Gets the file containing delay loading data for this mesh
  86515. */
  86516. delayLoadingFile: string;
  86517. /** @hidden */
  86518. _binaryInfo: any;
  86519. /**
  86520. * User defined function used to change how LOD level selection is done
  86521. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  86522. */
  86523. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  86524. /**
  86525. * Gets or sets the morph target manager
  86526. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  86527. */
  86528. morphTargetManager: Nullable<MorphTargetManager>;
  86529. /** @hidden */
  86530. _creationDataStorage: Nullable<_CreationDataStorage>;
  86531. /** @hidden */
  86532. _geometry: Nullable<Geometry>;
  86533. /** @hidden */
  86534. _delayInfo: Array<string>;
  86535. /** @hidden */
  86536. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  86537. /** @hidden */
  86538. _instanceDataStorage: _InstanceDataStorage;
  86539. private _effectiveMaterial;
  86540. /** @hidden */
  86541. _shouldGenerateFlatShading: boolean;
  86542. /** @hidden */
  86543. _originalBuilderSideOrientation: number;
  86544. /**
  86545. * Use this property to change the original side orientation defined at construction time
  86546. */
  86547. overrideMaterialSideOrientation: Nullable<number>;
  86548. /**
  86549. * Gets the source mesh (the one used to clone this one from)
  86550. */
  86551. readonly source: Nullable<Mesh>;
  86552. /**
  86553. * Gets or sets a boolean indicating that this mesh does not use index buffer
  86554. */
  86555. isUnIndexed: boolean;
  86556. /**
  86557. * @constructor
  86558. * @param name The value used by scene.getMeshByName() to do a lookup.
  86559. * @param scene The scene to add this mesh to.
  86560. * @param parent The parent of this mesh, if it has one
  86561. * @param source An optional Mesh from which geometry is shared, cloned.
  86562. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  86563. * When false, achieved by calling a clone(), also passing False.
  86564. * This will make creation of children, recursive.
  86565. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  86566. */
  86567. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  86568. /**
  86569. * Gets the class name
  86570. * @returns the string "Mesh".
  86571. */
  86572. getClassName(): string;
  86573. /** @hidden */
  86574. readonly _isMesh: boolean;
  86575. /**
  86576. * Returns a description of this mesh
  86577. * @param fullDetails define if full details about this mesh must be used
  86578. * @returns a descriptive string representing this mesh
  86579. */
  86580. toString(fullDetails?: boolean): string;
  86581. /** @hidden */
  86582. _unBindEffect(): void;
  86583. /**
  86584. * Gets a boolean indicating if this mesh has LOD
  86585. */
  86586. readonly hasLODLevels: boolean;
  86587. /**
  86588. * Gets the list of MeshLODLevel associated with the current mesh
  86589. * @returns an array of MeshLODLevel
  86590. */
  86591. getLODLevels(): MeshLODLevel[];
  86592. private _sortLODLevels;
  86593. /**
  86594. * Add a mesh as LOD level triggered at the given distance.
  86595. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  86596. * @param distance The distance from the center of the object to show this level
  86597. * @param mesh The mesh to be added as LOD level (can be null)
  86598. * @return This mesh (for chaining)
  86599. */
  86600. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  86601. /**
  86602. * Returns the LOD level mesh at the passed distance or null if not found.
  86603. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  86604. * @param distance The distance from the center of the object to show this level
  86605. * @returns a Mesh or `null`
  86606. */
  86607. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  86608. /**
  86609. * Remove a mesh from the LOD array
  86610. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  86611. * @param mesh defines the mesh to be removed
  86612. * @return This mesh (for chaining)
  86613. */
  86614. removeLODLevel(mesh: Mesh): Mesh;
  86615. /**
  86616. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  86617. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  86618. * @param camera defines the camera to use to compute distance
  86619. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  86620. * @return This mesh (for chaining)
  86621. */
  86622. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  86623. /**
  86624. * Gets the mesh internal Geometry object
  86625. */
  86626. readonly geometry: Nullable<Geometry>;
  86627. /**
  86628. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  86629. * @returns the total number of vertices
  86630. */
  86631. getTotalVertices(): number;
  86632. /**
  86633. * Returns the content of an associated vertex buffer
  86634. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  86635. * - VertexBuffer.PositionKind
  86636. * - VertexBuffer.UVKind
  86637. * - VertexBuffer.UV2Kind
  86638. * - VertexBuffer.UV3Kind
  86639. * - VertexBuffer.UV4Kind
  86640. * - VertexBuffer.UV5Kind
  86641. * - VertexBuffer.UV6Kind
  86642. * - VertexBuffer.ColorKind
  86643. * - VertexBuffer.MatricesIndicesKind
  86644. * - VertexBuffer.MatricesIndicesExtraKind
  86645. * - VertexBuffer.MatricesWeightsKind
  86646. * - VertexBuffer.MatricesWeightsExtraKind
  86647. * @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
  86648. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  86649. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  86650. */
  86651. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  86652. /**
  86653. * Returns the mesh VertexBuffer object from the requested `kind`
  86654. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  86655. * - VertexBuffer.PositionKind
  86656. * - VertexBuffer.NormalKind
  86657. * - VertexBuffer.UVKind
  86658. * - VertexBuffer.UV2Kind
  86659. * - VertexBuffer.UV3Kind
  86660. * - VertexBuffer.UV4Kind
  86661. * - VertexBuffer.UV5Kind
  86662. * - VertexBuffer.UV6Kind
  86663. * - VertexBuffer.ColorKind
  86664. * - VertexBuffer.MatricesIndicesKind
  86665. * - VertexBuffer.MatricesIndicesExtraKind
  86666. * - VertexBuffer.MatricesWeightsKind
  86667. * - VertexBuffer.MatricesWeightsExtraKind
  86668. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  86669. */
  86670. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  86671. /**
  86672. * Tests if a specific vertex buffer is associated with this mesh
  86673. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  86674. * - VertexBuffer.PositionKind
  86675. * - VertexBuffer.NormalKind
  86676. * - VertexBuffer.UVKind
  86677. * - VertexBuffer.UV2Kind
  86678. * - VertexBuffer.UV3Kind
  86679. * - VertexBuffer.UV4Kind
  86680. * - VertexBuffer.UV5Kind
  86681. * - VertexBuffer.UV6Kind
  86682. * - VertexBuffer.ColorKind
  86683. * - VertexBuffer.MatricesIndicesKind
  86684. * - VertexBuffer.MatricesIndicesExtraKind
  86685. * - VertexBuffer.MatricesWeightsKind
  86686. * - VertexBuffer.MatricesWeightsExtraKind
  86687. * @returns a boolean
  86688. */
  86689. isVerticesDataPresent(kind: string): boolean;
  86690. /**
  86691. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  86692. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  86693. * - VertexBuffer.PositionKind
  86694. * - VertexBuffer.UVKind
  86695. * - VertexBuffer.UV2Kind
  86696. * - VertexBuffer.UV3Kind
  86697. * - VertexBuffer.UV4Kind
  86698. * - VertexBuffer.UV5Kind
  86699. * - VertexBuffer.UV6Kind
  86700. * - VertexBuffer.ColorKind
  86701. * - VertexBuffer.MatricesIndicesKind
  86702. * - VertexBuffer.MatricesIndicesExtraKind
  86703. * - VertexBuffer.MatricesWeightsKind
  86704. * - VertexBuffer.MatricesWeightsExtraKind
  86705. * @returns a boolean
  86706. */
  86707. isVertexBufferUpdatable(kind: string): boolean;
  86708. /**
  86709. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  86710. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  86711. * - VertexBuffer.PositionKind
  86712. * - VertexBuffer.NormalKind
  86713. * - VertexBuffer.UVKind
  86714. * - VertexBuffer.UV2Kind
  86715. * - VertexBuffer.UV3Kind
  86716. * - VertexBuffer.UV4Kind
  86717. * - VertexBuffer.UV5Kind
  86718. * - VertexBuffer.UV6Kind
  86719. * - VertexBuffer.ColorKind
  86720. * - VertexBuffer.MatricesIndicesKind
  86721. * - VertexBuffer.MatricesIndicesExtraKind
  86722. * - VertexBuffer.MatricesWeightsKind
  86723. * - VertexBuffer.MatricesWeightsExtraKind
  86724. * @returns an array of strings
  86725. */
  86726. getVerticesDataKinds(): string[];
  86727. /**
  86728. * Returns a positive integer : the total number of indices in this mesh geometry.
  86729. * @returns the numner of indices or zero if the mesh has no geometry.
  86730. */
  86731. getTotalIndices(): number;
  86732. /**
  86733. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  86734. * @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.
  86735. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86736. * @returns the indices array or an empty array if the mesh has no geometry
  86737. */
  86738. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  86739. readonly isBlocked: boolean;
  86740. /**
  86741. * Determine if the current mesh is ready to be rendered
  86742. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  86743. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  86744. * @returns true if all associated assets are ready (material, textures, shaders)
  86745. */
  86746. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  86747. /**
  86748. * 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.
  86749. */
  86750. readonly areNormalsFrozen: boolean;
  86751. /**
  86752. * 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.
  86753. * @returns the current mesh
  86754. */
  86755. freezeNormals(): Mesh;
  86756. /**
  86757. * 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
  86758. * @returns the current mesh
  86759. */
  86760. unfreezeNormals(): Mesh;
  86761. /**
  86762. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  86763. */
  86764. overridenInstanceCount: number;
  86765. /** @hidden */
  86766. _preActivate(): Mesh;
  86767. /** @hidden */
  86768. _preActivateForIntermediateRendering(renderId: number): Mesh;
  86769. /** @hidden */
  86770. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  86771. /**
  86772. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  86773. * This means the mesh underlying bounding box and sphere are recomputed.
  86774. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  86775. * @returns the current mesh
  86776. */
  86777. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  86778. /** @hidden */
  86779. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  86780. /**
  86781. * This function will subdivide the mesh into multiple submeshes
  86782. * @param count defines the expected number of submeshes
  86783. */
  86784. subdivide(count: number): void;
  86785. /**
  86786. * Copy a FloatArray into a specific associated vertex buffer
  86787. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  86788. * - VertexBuffer.PositionKind
  86789. * - VertexBuffer.UVKind
  86790. * - VertexBuffer.UV2Kind
  86791. * - VertexBuffer.UV3Kind
  86792. * - VertexBuffer.UV4Kind
  86793. * - VertexBuffer.UV5Kind
  86794. * - VertexBuffer.UV6Kind
  86795. * - VertexBuffer.ColorKind
  86796. * - VertexBuffer.MatricesIndicesKind
  86797. * - VertexBuffer.MatricesIndicesExtraKind
  86798. * - VertexBuffer.MatricesWeightsKind
  86799. * - VertexBuffer.MatricesWeightsExtraKind
  86800. * @param data defines the data source
  86801. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  86802. * @param stride defines the data stride size (can be null)
  86803. * @returns the current mesh
  86804. */
  86805. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  86806. /**
  86807. * Flags an associated vertex buffer as updatable
  86808. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  86809. * - VertexBuffer.PositionKind
  86810. * - VertexBuffer.UVKind
  86811. * - VertexBuffer.UV2Kind
  86812. * - VertexBuffer.UV3Kind
  86813. * - VertexBuffer.UV4Kind
  86814. * - VertexBuffer.UV5Kind
  86815. * - VertexBuffer.UV6Kind
  86816. * - VertexBuffer.ColorKind
  86817. * - VertexBuffer.MatricesIndicesKind
  86818. * - VertexBuffer.MatricesIndicesExtraKind
  86819. * - VertexBuffer.MatricesWeightsKind
  86820. * - VertexBuffer.MatricesWeightsExtraKind
  86821. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  86822. */
  86823. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  86824. /**
  86825. * Sets the mesh global Vertex Buffer
  86826. * @param buffer defines the buffer to use
  86827. * @returns the current mesh
  86828. */
  86829. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  86830. /**
  86831. * Update a specific associated vertex buffer
  86832. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  86833. * - VertexBuffer.PositionKind
  86834. * - VertexBuffer.UVKind
  86835. * - VertexBuffer.UV2Kind
  86836. * - VertexBuffer.UV3Kind
  86837. * - VertexBuffer.UV4Kind
  86838. * - VertexBuffer.UV5Kind
  86839. * - VertexBuffer.UV6Kind
  86840. * - VertexBuffer.ColorKind
  86841. * - VertexBuffer.MatricesIndicesKind
  86842. * - VertexBuffer.MatricesIndicesExtraKind
  86843. * - VertexBuffer.MatricesWeightsKind
  86844. * - VertexBuffer.MatricesWeightsExtraKind
  86845. * @param data defines the data source
  86846. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  86847. * @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)
  86848. * @returns the current mesh
  86849. */
  86850. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  86851. /**
  86852. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  86853. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  86854. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  86855. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  86856. * @returns the current mesh
  86857. */
  86858. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  86859. /**
  86860. * Creates a un-shared specific occurence of the geometry for the mesh.
  86861. * @returns the current mesh
  86862. */
  86863. makeGeometryUnique(): Mesh;
  86864. /**
  86865. * Set the index buffer of this mesh
  86866. * @param indices defines the source data
  86867. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  86868. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  86869. * @returns the current mesh
  86870. */
  86871. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  86872. /**
  86873. * Update the current index buffer
  86874. * @param indices defines the source data
  86875. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  86876. * @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)
  86877. * @returns the current mesh
  86878. */
  86879. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  86880. /**
  86881. * Invert the geometry to move from a right handed system to a left handed one.
  86882. * @returns the current mesh
  86883. */
  86884. toLeftHanded(): Mesh;
  86885. /** @hidden */
  86886. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  86887. /** @hidden */
  86888. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  86889. /**
  86890. * Registers for this mesh a javascript function called just before the rendering process
  86891. * @param func defines the function to call before rendering this mesh
  86892. * @returns the current mesh
  86893. */
  86894. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  86895. /**
  86896. * Disposes a previously registered javascript function called before the rendering
  86897. * @param func defines the function to remove
  86898. * @returns the current mesh
  86899. */
  86900. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  86901. /**
  86902. * Registers for this mesh a javascript function called just after the rendering is complete
  86903. * @param func defines the function to call after rendering this mesh
  86904. * @returns the current mesh
  86905. */
  86906. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  86907. /**
  86908. * Disposes a previously registered javascript function called after the rendering.
  86909. * @param func defines the function to remove
  86910. * @returns the current mesh
  86911. */
  86912. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  86913. /** @hidden */
  86914. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  86915. /** @hidden */
  86916. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  86917. /** @hidden */
  86918. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  86919. /** @hidden */
  86920. _rebuild(): void;
  86921. /** @hidden */
  86922. _freeze(): void;
  86923. /** @hidden */
  86924. _unFreeze(): void;
  86925. /**
  86926. * 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
  86927. * @param subMesh defines the subMesh to render
  86928. * @param enableAlphaMode defines if alpha mode can be changed
  86929. * @returns the current mesh
  86930. */
  86931. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  86932. private _onBeforeDraw;
  86933. /**
  86934. * Renormalize the mesh and patch it up if there are no weights
  86935. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  86936. * However in the case of zero weights then we set just a single influence to 1.
  86937. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  86938. */
  86939. cleanMatrixWeights(): void;
  86940. private normalizeSkinFourWeights;
  86941. private normalizeSkinWeightsAndExtra;
  86942. /**
  86943. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  86944. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  86945. * the user know there was an issue with importing the mesh
  86946. * @returns a validation object with skinned, valid and report string
  86947. */
  86948. validateSkinning(): {
  86949. skinned: boolean;
  86950. valid: boolean;
  86951. report: string;
  86952. };
  86953. /** @hidden */
  86954. _checkDelayState(): Mesh;
  86955. private _queueLoad;
  86956. /**
  86957. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  86958. * A mesh is in the frustum if its bounding box intersects the frustum
  86959. * @param frustumPlanes defines the frustum to test
  86960. * @returns true if the mesh is in the frustum planes
  86961. */
  86962. isInFrustum(frustumPlanes: Plane[]): boolean;
  86963. /**
  86964. * Sets the mesh material by the material or multiMaterial `id` property
  86965. * @param id is a string identifying the material or the multiMaterial
  86966. * @returns the current mesh
  86967. */
  86968. setMaterialByID(id: string): Mesh;
  86969. /**
  86970. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  86971. * @returns an array of IAnimatable
  86972. */
  86973. getAnimatables(): IAnimatable[];
  86974. /**
  86975. * Modifies the mesh geometry according to the passed transformation matrix.
  86976. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  86977. * The mesh normals are modified using the same transformation.
  86978. * Note that, under the hood, this method sets a new VertexBuffer each call.
  86979. * @param transform defines the transform matrix to use
  86980. * @see http://doc.babylonjs.com/resources/baking_transformations
  86981. * @returns the current mesh
  86982. */
  86983. bakeTransformIntoVertices(transform: Matrix): Mesh;
  86984. /**
  86985. * Modifies the mesh geometry according to its own current World Matrix.
  86986. * The mesh World Matrix is then reset.
  86987. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  86988. * Note that, under the hood, this method sets a new VertexBuffer each call.
  86989. * @see http://doc.babylonjs.com/resources/baking_transformations
  86990. * @returns the current mesh
  86991. */
  86992. bakeCurrentTransformIntoVertices(): Mesh;
  86993. /** @hidden */
  86994. readonly _positions: Nullable<Vector3[]>;
  86995. /** @hidden */
  86996. _resetPointsArrayCache(): Mesh;
  86997. /** @hidden */
  86998. _generatePointsArray(): boolean;
  86999. /**
  87000. * Returns a new Mesh object generated from the current mesh properties.
  87001. * This method must not get confused with createInstance()
  87002. * @param name is a string, the name given to the new mesh
  87003. * @param newParent can be any Node object (default `null`)
  87004. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  87005. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  87006. * @returns a new mesh
  87007. */
  87008. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  87009. /**
  87010. * Releases resources associated with this mesh.
  87011. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87012. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87013. */
  87014. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87015. /**
  87016. * Modifies the mesh geometry according to a displacement map.
  87017. * 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.
  87018. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  87019. * @param url is a string, the URL from the image file is to be downloaded.
  87020. * @param minHeight is the lower limit of the displacement.
  87021. * @param maxHeight is the upper limit of the displacement.
  87022. * @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.
  87023. * @param uvOffset is an optional vector2 used to offset UV.
  87024. * @param uvScale is an optional vector2 used to scale UV.
  87025. * @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.
  87026. * @returns the Mesh.
  87027. */
  87028. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  87029. /**
  87030. * Modifies the mesh geometry according to a displacementMap buffer.
  87031. * 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.
  87032. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  87033. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  87034. * @param heightMapWidth is the width of the buffer image.
  87035. * @param heightMapHeight is the height of the buffer image.
  87036. * @param minHeight is the lower limit of the displacement.
  87037. * @param maxHeight is the upper limit of the displacement.
  87038. * @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.
  87039. * @param uvOffset is an optional vector2 used to offset UV.
  87040. * @param uvScale is an optional vector2 used to scale UV.
  87041. * @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.
  87042. * @returns the Mesh.
  87043. */
  87044. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  87045. /**
  87046. * Modify the mesh to get a flat shading rendering.
  87047. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  87048. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  87049. * @returns current mesh
  87050. */
  87051. convertToFlatShadedMesh(): Mesh;
  87052. /**
  87053. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  87054. * In other words, more vertices, no more indices and a single bigger VBO.
  87055. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  87056. * @returns current mesh
  87057. */
  87058. convertToUnIndexedMesh(): Mesh;
  87059. /**
  87060. * Inverses facet orientations.
  87061. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  87062. * @param flipNormals will also inverts the normals
  87063. * @returns current mesh
  87064. */
  87065. flipFaces(flipNormals?: boolean): Mesh;
  87066. /**
  87067. * Increase the number of facets and hence vertices in a mesh
  87068. * Vertex normals are interpolated from existing vertex normals
  87069. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  87070. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  87071. */
  87072. increaseVertices(numberPerEdge: number): void;
  87073. /**
  87074. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  87075. * This will undo any application of covertToFlatShadedMesh
  87076. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  87077. */
  87078. forceSharedVertices(): void;
  87079. /** @hidden */
  87080. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  87081. /** @hidden */
  87082. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  87083. /**
  87084. * Creates a new InstancedMesh object from the mesh model.
  87085. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  87086. * @param name defines the name of the new instance
  87087. * @returns a new InstancedMesh
  87088. */
  87089. createInstance(name: string): InstancedMesh;
  87090. /**
  87091. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  87092. * After this call, all the mesh instances have the same submeshes than the current mesh.
  87093. * @returns the current mesh
  87094. */
  87095. synchronizeInstances(): Mesh;
  87096. /**
  87097. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  87098. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  87099. * This should be used together with the simplification to avoid disappearing triangles.
  87100. * @param successCallback an optional success callback to be called after the optimization finished.
  87101. * @returns the current mesh
  87102. */
  87103. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  87104. /**
  87105. * Serialize current mesh
  87106. * @param serializationObject defines the object which will receive the serialization data
  87107. */
  87108. serialize(serializationObject: any): void;
  87109. /** @hidden */
  87110. _syncGeometryWithMorphTargetManager(): void;
  87111. /** @hidden */
  87112. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  87113. /**
  87114. * Returns a new Mesh object parsed from the source provided.
  87115. * @param parsedMesh is the source
  87116. * @param scene defines the hosting scene
  87117. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  87118. * @returns a new Mesh
  87119. */
  87120. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  87121. /**
  87122. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  87123. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  87124. * @param name defines the name of the mesh to create
  87125. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  87126. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  87127. * @param closePath creates a seam between the first and the last points of each path of the path array
  87128. * @param offset is taken in account only if the `pathArray` is containing a single path
  87129. * @param scene defines the hosting scene
  87130. * @param updatable defines if the mesh must be flagged as updatable
  87131. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87132. * @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)
  87133. * @returns a new Mesh
  87134. */
  87135. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  87136. /**
  87137. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  87138. * @param name defines the name of the mesh to create
  87139. * @param radius sets the radius size (float) of the polygon (default 0.5)
  87140. * @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
  87141. * @param scene defines the hosting scene
  87142. * @param updatable defines if the mesh must be flagged as updatable
  87143. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87144. * @returns a new Mesh
  87145. */
  87146. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  87147. /**
  87148. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  87149. * @param name defines the name of the mesh to create
  87150. * @param size sets the size (float) of each box side (default 1)
  87151. * @param scene defines the hosting scene
  87152. * @param updatable defines if the mesh must be flagged as updatable
  87153. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87154. * @returns a new Mesh
  87155. */
  87156. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  87157. /**
  87158. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  87159. * @param name defines the name of the mesh to create
  87160. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  87161. * @param diameter sets the diameter size (float) of the sphere (default 1)
  87162. * @param scene defines the hosting scene
  87163. * @param updatable defines if the mesh must be flagged as updatable
  87164. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87165. * @returns a new Mesh
  87166. */
  87167. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  87168. /**
  87169. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  87170. * @param name defines the name of the mesh to create
  87171. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  87172. * @param diameter sets the diameter size (float) of the sphere (default 1)
  87173. * @param scene defines the hosting scene
  87174. * @returns a new Mesh
  87175. */
  87176. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  87177. /**
  87178. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  87179. * @param name defines the name of the mesh to create
  87180. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  87181. * @param diameterTop set the top cap diameter (floats, default 1)
  87182. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  87183. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  87184. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  87185. * @param scene defines the hosting scene
  87186. * @param updatable defines if the mesh must be flagged as updatable
  87187. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87188. * @returns a new Mesh
  87189. */
  87190. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  87191. /**
  87192. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  87193. * @param name defines the name of the mesh to create
  87194. * @param diameter sets the diameter size (float) of the torus (default 1)
  87195. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  87196. * @param tessellation sets the number of torus sides (postive integer, default 16)
  87197. * @param scene defines the hosting scene
  87198. * @param updatable defines if the mesh must be flagged as updatable
  87199. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87200. * @returns a new Mesh
  87201. */
  87202. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  87203. /**
  87204. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  87205. * @param name defines the name of the mesh to create
  87206. * @param radius sets the global radius size (float) of the torus knot (default 2)
  87207. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  87208. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  87209. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  87210. * @param p the number of windings on X axis (positive integers, default 2)
  87211. * @param q the number of windings on Y axis (positive integers, default 3)
  87212. * @param scene defines the hosting scene
  87213. * @param updatable defines if the mesh must be flagged as updatable
  87214. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87215. * @returns a new Mesh
  87216. */
  87217. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  87218. /**
  87219. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  87220. * @param name defines the name of the mesh to create
  87221. * @param points is an array successive Vector3
  87222. * @param scene defines the hosting scene
  87223. * @param updatable defines if the mesh must be flagged as updatable
  87224. * @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).
  87225. * @returns a new Mesh
  87226. */
  87227. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  87228. /**
  87229. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  87230. * @param name defines the name of the mesh to create
  87231. * @param points is an array successive Vector3
  87232. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  87233. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  87234. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  87235. * @param scene defines the hosting scene
  87236. * @param updatable defines if the mesh must be flagged as updatable
  87237. * @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)
  87238. * @returns a new Mesh
  87239. */
  87240. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  87241. /**
  87242. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  87243. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  87244. * 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.
  87245. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87246. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  87247. * Remember you can only change the shape positions, not their number when updating a polygon.
  87248. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  87249. * @param name defines the name of the mesh to create
  87250. * @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
  87251. * @param scene defines the hosting scene
  87252. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  87253. * @param updatable defines if the mesh must be flagged as updatable
  87254. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87255. * @param earcutInjection can be used to inject your own earcut reference
  87256. * @returns a new Mesh
  87257. */
  87258. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  87259. /**
  87260. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  87261. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  87262. * @param name defines the name of the mesh to create
  87263. * @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
  87264. * @param depth defines the height of extrusion
  87265. * @param scene defines the hosting scene
  87266. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  87267. * @param updatable defines if the mesh must be flagged as updatable
  87268. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87269. * @param earcutInjection can be used to inject your own earcut reference
  87270. * @returns a new Mesh
  87271. */
  87272. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  87273. /**
  87274. * Creates an extruded shape mesh.
  87275. * 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
  87276. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  87277. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  87278. * @param name defines the name of the mesh to create
  87279. * @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
  87280. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  87281. * @param scale is the value to scale the shape
  87282. * @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
  87283. * @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
  87284. * @param scene defines the hosting scene
  87285. * @param updatable defines if the mesh must be flagged as updatable
  87286. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87287. * @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)
  87288. * @returns a new Mesh
  87289. */
  87290. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  87291. /**
  87292. * Creates an custom extruded shape mesh.
  87293. * The custom extrusion is a parametric shape.
  87294. * It has no predefined shape. Its final shape will depend on the input parameters.
  87295. * Please consider using the same method from the MeshBuilder class instead
  87296. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  87297. * @param name defines the name of the mesh to create
  87298. * @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
  87299. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  87300. * @param scaleFunction is a custom Javascript function called on each path point
  87301. * @param rotationFunction is a custom Javascript function called on each path point
  87302. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  87303. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  87304. * @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
  87305. * @param scene defines the hosting scene
  87306. * @param updatable defines if the mesh must be flagged as updatable
  87307. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87308. * @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)
  87309. * @returns a new Mesh
  87310. */
  87311. 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;
  87312. /**
  87313. * Creates lathe mesh.
  87314. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  87315. * Please consider using the same method from the MeshBuilder class instead
  87316. * @param name defines the name of the mesh to create
  87317. * @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
  87318. * @param radius is the radius value of the lathe
  87319. * @param tessellation is the side number of the lathe.
  87320. * @param scene defines the hosting scene
  87321. * @param updatable defines if the mesh must be flagged as updatable
  87322. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87323. * @returns a new Mesh
  87324. */
  87325. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  87326. /**
  87327. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  87328. * @param name defines the name of the mesh to create
  87329. * @param size sets the size (float) of both sides of the plane at once (default 1)
  87330. * @param scene defines the hosting scene
  87331. * @param updatable defines if the mesh must be flagged as updatable
  87332. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87333. * @returns a new Mesh
  87334. */
  87335. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  87336. /**
  87337. * Creates a ground mesh.
  87338. * Please consider using the same method from the MeshBuilder class instead
  87339. * @param name defines the name of the mesh to create
  87340. * @param width set the width of the ground
  87341. * @param height set the height of the ground
  87342. * @param subdivisions sets the number of subdivisions per side
  87343. * @param scene defines the hosting scene
  87344. * @param updatable defines if the mesh must be flagged as updatable
  87345. * @returns a new Mesh
  87346. */
  87347. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  87348. /**
  87349. * Creates a tiled ground mesh.
  87350. * Please consider using the same method from the MeshBuilder class instead
  87351. * @param name defines the name of the mesh to create
  87352. * @param xmin set the ground minimum X coordinate
  87353. * @param zmin set the ground minimum Y coordinate
  87354. * @param xmax set the ground maximum X coordinate
  87355. * @param zmax set the ground maximum Z coordinate
  87356. * @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
  87357. * @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
  87358. * @param scene defines the hosting scene
  87359. * @param updatable defines if the mesh must be flagged as updatable
  87360. * @returns a new Mesh
  87361. */
  87362. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  87363. w: number;
  87364. h: number;
  87365. }, precision: {
  87366. w: number;
  87367. h: number;
  87368. }, scene: Scene, updatable?: boolean): Mesh;
  87369. /**
  87370. * Creates a ground mesh from a height map.
  87371. * Please consider using the same method from the MeshBuilder class instead
  87372. * @see http://doc.babylonjs.com/babylon101/height_map
  87373. * @param name defines the name of the mesh to create
  87374. * @param url sets the URL of the height map image resource
  87375. * @param width set the ground width size
  87376. * @param height set the ground height size
  87377. * @param subdivisions sets the number of subdivision per side
  87378. * @param minHeight is the minimum altitude on the ground
  87379. * @param maxHeight is the maximum altitude on the ground
  87380. * @param scene defines the hosting scene
  87381. * @param updatable defines if the mesh must be flagged as updatable
  87382. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  87383. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  87384. * @returns a new Mesh
  87385. */
  87386. 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;
  87387. /**
  87388. * Creates a tube mesh.
  87389. * The tube is a parametric shape.
  87390. * It has no predefined shape. Its final shape will depend on the input parameters.
  87391. * Please consider using the same method from the MeshBuilder class instead
  87392. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  87393. * @param name defines the name of the mesh to create
  87394. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  87395. * @param radius sets the tube radius size
  87396. * @param tessellation is the number of sides on the tubular surface
  87397. * @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
  87398. * @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
  87399. * @param scene defines the hosting scene
  87400. * @param updatable defines if the mesh must be flagged as updatable
  87401. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87402. * @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)
  87403. * @returns a new Mesh
  87404. */
  87405. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  87406. (i: number, distance: number): number;
  87407. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  87408. /**
  87409. * Creates a polyhedron mesh.
  87410. * Please consider using the same method from the MeshBuilder class instead.
  87411. * * 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
  87412. * * The parameter `size` (positive float, default 1) sets the polygon size
  87413. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  87414. * * 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`
  87415. * * 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
  87416. * * 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)`)
  87417. * * 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
  87418. * * 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
  87419. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87420. * * If you create a double-sided mesh, you can choose what parts of 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
  87421. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  87422. * @param name defines the name of the mesh to create
  87423. * @param options defines the options used to create the mesh
  87424. * @param scene defines the hosting scene
  87425. * @returns a new Mesh
  87426. */
  87427. static CreatePolyhedron(name: string, options: {
  87428. type?: number;
  87429. size?: number;
  87430. sizeX?: number;
  87431. sizeY?: number;
  87432. sizeZ?: number;
  87433. custom?: any;
  87434. faceUV?: Vector4[];
  87435. faceColors?: Color4[];
  87436. updatable?: boolean;
  87437. sideOrientation?: number;
  87438. }, scene: Scene): Mesh;
  87439. /**
  87440. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  87441. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  87442. * * 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`)
  87443. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  87444. * * 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
  87445. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87446. * * If you create a double-sided mesh, you can choose what parts of 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
  87447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  87448. * @param name defines the name of the mesh
  87449. * @param options defines the options used to create the mesh
  87450. * @param scene defines the hosting scene
  87451. * @returns a new Mesh
  87452. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  87453. */
  87454. static CreateIcoSphere(name: string, options: {
  87455. radius?: number;
  87456. flat?: boolean;
  87457. subdivisions?: number;
  87458. sideOrientation?: number;
  87459. updatable?: boolean;
  87460. }, scene: Scene): Mesh;
  87461. /**
  87462. * Creates a decal mesh.
  87463. * Please consider using the same method from the MeshBuilder class instead.
  87464. * A decal is a mesh usually applied as a model onto the surface of another mesh
  87465. * @param name defines the name of the mesh
  87466. * @param sourceMesh defines the mesh receiving the decal
  87467. * @param position sets the position of the decal in world coordinates
  87468. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  87469. * @param size sets the decal scaling
  87470. * @param angle sets the angle to rotate the decal
  87471. * @returns a new Mesh
  87472. */
  87473. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  87474. /**
  87475. * Prepare internal position array for software CPU skinning
  87476. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  87477. */
  87478. setPositionsForCPUSkinning(): Float32Array;
  87479. /**
  87480. * Prepare internal normal array for software CPU skinning
  87481. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  87482. */
  87483. setNormalsForCPUSkinning(): Float32Array;
  87484. /**
  87485. * Updates the vertex buffer by applying transformation from the bones
  87486. * @param skeleton defines the skeleton to apply to current mesh
  87487. * @returns the current mesh
  87488. */
  87489. applySkeleton(skeleton: Skeleton): Mesh;
  87490. /**
  87491. * 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
  87492. * @param meshes defines the list of meshes to scan
  87493. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  87494. */
  87495. static MinMax(meshes: AbstractMesh[]): {
  87496. min: Vector3;
  87497. max: Vector3;
  87498. };
  87499. /**
  87500. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  87501. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  87502. * @returns a vector3
  87503. */
  87504. static Center(meshesOrMinMaxVector: {
  87505. min: Vector3;
  87506. max: Vector3;
  87507. } | AbstractMesh[]): Vector3;
  87508. /**
  87509. * Merge the array of meshes into a single mesh for performance reasons.
  87510. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  87511. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  87512. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  87513. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  87514. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  87515. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  87516. * @returns a new mesh
  87517. */
  87518. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  87519. /** @hidden */
  87520. addInstance(instance: InstancedMesh): void;
  87521. /** @hidden */
  87522. removeInstance(instance: InstancedMesh): void;
  87523. }
  87524. }
  87525. declare module BABYLON {
  87526. /**
  87527. * This is the base class of all the camera used in the application.
  87528. * @see http://doc.babylonjs.com/features/cameras
  87529. */
  87530. export class Camera extends Node {
  87531. /** @hidden */
  87532. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  87533. /**
  87534. * This is the default projection mode used by the cameras.
  87535. * It helps recreating a feeling of perspective and better appreciate depth.
  87536. * This is the best way to simulate real life cameras.
  87537. */
  87538. static readonly PERSPECTIVE_CAMERA: number;
  87539. /**
  87540. * This helps creating camera with an orthographic mode.
  87541. * 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.
  87542. */
  87543. static readonly ORTHOGRAPHIC_CAMERA: number;
  87544. /**
  87545. * This is the default FOV mode for perspective cameras.
  87546. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  87547. */
  87548. static readonly FOVMODE_VERTICAL_FIXED: number;
  87549. /**
  87550. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  87551. */
  87552. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  87553. /**
  87554. * This specifies ther is no need for a camera rig.
  87555. * Basically only one eye is rendered corresponding to the camera.
  87556. */
  87557. static readonly RIG_MODE_NONE: number;
  87558. /**
  87559. * Simulates a camera Rig with one blue eye and one red eye.
  87560. * This can be use with 3d blue and red glasses.
  87561. */
  87562. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  87563. /**
  87564. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  87565. */
  87566. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  87567. /**
  87568. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  87569. */
  87570. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  87571. /**
  87572. * Defines that both eyes of the camera will be rendered over under each other.
  87573. */
  87574. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  87575. /**
  87576. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  87577. */
  87578. static readonly RIG_MODE_VR: number;
  87579. /**
  87580. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  87581. */
  87582. static readonly RIG_MODE_WEBVR: number;
  87583. /**
  87584. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  87585. */
  87586. static readonly RIG_MODE_CUSTOM: number;
  87587. /**
  87588. * Defines if by default attaching controls should prevent the default javascript event to continue.
  87589. */
  87590. static ForceAttachControlToAlwaysPreventDefault: boolean;
  87591. /**
  87592. * Define the input manager associated with the camera.
  87593. */
  87594. inputs: CameraInputsManager<Camera>;
  87595. /** @hidden */
  87596. _position: Vector3;
  87597. /**
  87598. * Define the current local position of the camera in the scene
  87599. */
  87600. position: Vector3;
  87601. /**
  87602. * The vector the camera should consider as up.
  87603. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  87604. */
  87605. upVector: Vector3;
  87606. /**
  87607. * Define the current limit on the left side for an orthographic camera
  87608. * In scene unit
  87609. */
  87610. orthoLeft: Nullable<number>;
  87611. /**
  87612. * Define the current limit on the right side for an orthographic camera
  87613. * In scene unit
  87614. */
  87615. orthoRight: Nullable<number>;
  87616. /**
  87617. * Define the current limit on the bottom side for an orthographic camera
  87618. * In scene unit
  87619. */
  87620. orthoBottom: Nullable<number>;
  87621. /**
  87622. * Define the current limit on the top side for an orthographic camera
  87623. * In scene unit
  87624. */
  87625. orthoTop: Nullable<number>;
  87626. /**
  87627. * Field Of View is set in Radians. (default is 0.8)
  87628. */
  87629. fov: number;
  87630. /**
  87631. * Define the minimum distance the camera can see from.
  87632. * This is important to note that the depth buffer are not infinite and the closer it starts
  87633. * the more your scene might encounter depth fighting issue.
  87634. */
  87635. minZ: number;
  87636. /**
  87637. * Define the maximum distance the camera can see to.
  87638. * This is important to note that the depth buffer are not infinite and the further it end
  87639. * the more your scene might encounter depth fighting issue.
  87640. */
  87641. maxZ: number;
  87642. /**
  87643. * Define the default inertia of the camera.
  87644. * This helps giving a smooth feeling to the camera movement.
  87645. */
  87646. inertia: number;
  87647. /**
  87648. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  87649. */
  87650. mode: number;
  87651. /**
  87652. * Define wether the camera is intermediate.
  87653. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  87654. */
  87655. isIntermediate: boolean;
  87656. /**
  87657. * Define the viewport of the camera.
  87658. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  87659. */
  87660. viewport: Viewport;
  87661. /**
  87662. * Restricts the camera to viewing objects with the same layerMask.
  87663. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  87664. */
  87665. layerMask: number;
  87666. /**
  87667. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  87668. */
  87669. fovMode: number;
  87670. /**
  87671. * Rig mode of the camera.
  87672. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  87673. * This is normally controlled byt the camera themselves as internal use.
  87674. */
  87675. cameraRigMode: number;
  87676. /**
  87677. * Defines the distance between both "eyes" in case of a RIG
  87678. */
  87679. interaxialDistance: number;
  87680. /**
  87681. * Defines if stereoscopic rendering is done side by side or over under.
  87682. */
  87683. isStereoscopicSideBySide: boolean;
  87684. /**
  87685. * 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
  87686. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  87687. * else in the scene. (Eg. security camera)
  87688. *
  87689. * 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)
  87690. */
  87691. customRenderTargets: RenderTargetTexture[];
  87692. /**
  87693. * When set, the camera will render to this render target instead of the default canvas
  87694. *
  87695. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  87696. */
  87697. outputRenderTarget: Nullable<RenderTargetTexture>;
  87698. /**
  87699. * Observable triggered when the camera view matrix has changed.
  87700. */
  87701. onViewMatrixChangedObservable: Observable<Camera>;
  87702. /**
  87703. * Observable triggered when the camera Projection matrix has changed.
  87704. */
  87705. onProjectionMatrixChangedObservable: Observable<Camera>;
  87706. /**
  87707. * Observable triggered when the inputs have been processed.
  87708. */
  87709. onAfterCheckInputsObservable: Observable<Camera>;
  87710. /**
  87711. * Observable triggered when reset has been called and applied to the camera.
  87712. */
  87713. onRestoreStateObservable: Observable<Camera>;
  87714. /** @hidden */
  87715. _cameraRigParams: any;
  87716. /** @hidden */
  87717. _rigCameras: Camera[];
  87718. /** @hidden */
  87719. _rigPostProcess: Nullable<PostProcess>;
  87720. protected _webvrViewMatrix: Matrix;
  87721. /** @hidden */
  87722. _skipRendering: boolean;
  87723. /** @hidden */
  87724. _projectionMatrix: Matrix;
  87725. /** @hidden */
  87726. _postProcesses: Nullable<PostProcess>[];
  87727. /** @hidden */
  87728. _activeMeshes: SmartArray<AbstractMesh>;
  87729. protected _globalPosition: Vector3;
  87730. /** @hidden */
  87731. _computedViewMatrix: Matrix;
  87732. private _doNotComputeProjectionMatrix;
  87733. private _transformMatrix;
  87734. private _frustumPlanes;
  87735. private _refreshFrustumPlanes;
  87736. private _storedFov;
  87737. private _stateStored;
  87738. /**
  87739. * Instantiates a new camera object.
  87740. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  87741. * @see http://doc.babylonjs.com/features/cameras
  87742. * @param name Defines the name of the camera in the scene
  87743. * @param position Defines the position of the camera
  87744. * @param scene Defines the scene the camera belongs too
  87745. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  87746. */
  87747. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  87748. /**
  87749. * Store current camera state (fov, position, etc..)
  87750. * @returns the camera
  87751. */
  87752. storeState(): Camera;
  87753. /**
  87754. * Restores the camera state values if it has been stored. You must call storeState() first
  87755. */
  87756. protected _restoreStateValues(): boolean;
  87757. /**
  87758. * Restored camera state. You must call storeState() first.
  87759. * @returns true if restored and false otherwise
  87760. */
  87761. restoreState(): boolean;
  87762. /**
  87763. * Gets the class name of the camera.
  87764. * @returns the class name
  87765. */
  87766. getClassName(): string;
  87767. /** @hidden */
  87768. readonly _isCamera: boolean;
  87769. /**
  87770. * Gets a string representation of the camera useful for debug purpose.
  87771. * @param fullDetails Defines that a more verboe level of logging is required
  87772. * @returns the string representation
  87773. */
  87774. toString(fullDetails?: boolean): string;
  87775. /**
  87776. * Gets the current world space position of the camera.
  87777. */
  87778. readonly globalPosition: Vector3;
  87779. /**
  87780. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  87781. * @returns the active meshe list
  87782. */
  87783. getActiveMeshes(): SmartArray<AbstractMesh>;
  87784. /**
  87785. * Check wether a mesh is part of the current active mesh list of the camera
  87786. * @param mesh Defines the mesh to check
  87787. * @returns true if active, false otherwise
  87788. */
  87789. isActiveMesh(mesh: Mesh): boolean;
  87790. /**
  87791. * Is this camera ready to be used/rendered
  87792. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  87793. * @return true if the camera is ready
  87794. */
  87795. isReady(completeCheck?: boolean): boolean;
  87796. /** @hidden */
  87797. _initCache(): void;
  87798. /** @hidden */
  87799. _updateCache(ignoreParentClass?: boolean): void;
  87800. /** @hidden */
  87801. _isSynchronized(): boolean;
  87802. /** @hidden */
  87803. _isSynchronizedViewMatrix(): boolean;
  87804. /** @hidden */
  87805. _isSynchronizedProjectionMatrix(): boolean;
  87806. /**
  87807. * Attach the input controls to a specific dom element to get the input from.
  87808. * @param element Defines the element the controls should be listened from
  87809. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87810. */
  87811. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  87812. /**
  87813. * Detach the current controls from the specified dom element.
  87814. * @param element Defines the element to stop listening the inputs from
  87815. */
  87816. detachControl(element: HTMLElement): void;
  87817. /**
  87818. * Update the camera state according to the different inputs gathered during the frame.
  87819. */
  87820. update(): void;
  87821. /** @hidden */
  87822. _checkInputs(): void;
  87823. /** @hidden */
  87824. readonly rigCameras: Camera[];
  87825. /**
  87826. * Gets the post process used by the rig cameras
  87827. */
  87828. readonly rigPostProcess: Nullable<PostProcess>;
  87829. /**
  87830. * Internal, gets the first post proces.
  87831. * @returns the first post process to be run on this camera.
  87832. */
  87833. _getFirstPostProcess(): Nullable<PostProcess>;
  87834. private _cascadePostProcessesToRigCams;
  87835. /**
  87836. * Attach a post process to the camera.
  87837. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  87838. * @param postProcess The post process to attach to the camera
  87839. * @param insertAt The position of the post process in case several of them are in use in the scene
  87840. * @returns the position the post process has been inserted at
  87841. */
  87842. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  87843. /**
  87844. * Detach a post process to the camera.
  87845. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  87846. * @param postProcess The post process to detach from the camera
  87847. */
  87848. detachPostProcess(postProcess: PostProcess): void;
  87849. /**
  87850. * Gets the current world matrix of the camera
  87851. */
  87852. getWorldMatrix(): Matrix;
  87853. /** @hidden */
  87854. _getViewMatrix(): Matrix;
  87855. /**
  87856. * Gets the current view matrix of the camera.
  87857. * @param force forces the camera to recompute the matrix without looking at the cached state
  87858. * @returns the view matrix
  87859. */
  87860. getViewMatrix(force?: boolean): Matrix;
  87861. /**
  87862. * Freeze the projection matrix.
  87863. * It will prevent the cache check of the camera projection compute and can speed up perf
  87864. * if no parameter of the camera are meant to change
  87865. * @param projection Defines manually a projection if necessary
  87866. */
  87867. freezeProjectionMatrix(projection?: Matrix): void;
  87868. /**
  87869. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  87870. */
  87871. unfreezeProjectionMatrix(): void;
  87872. /**
  87873. * Gets the current projection matrix of the camera.
  87874. * @param force forces the camera to recompute the matrix without looking at the cached state
  87875. * @returns the projection matrix
  87876. */
  87877. getProjectionMatrix(force?: boolean): Matrix;
  87878. /**
  87879. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  87880. * @returns a Matrix
  87881. */
  87882. getTransformationMatrix(): Matrix;
  87883. private _updateFrustumPlanes;
  87884. /**
  87885. * Checks if a cullable object (mesh...) is in the camera frustum
  87886. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  87887. * @param target The object to check
  87888. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  87889. * @returns true if the object is in frustum otherwise false
  87890. */
  87891. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  87892. /**
  87893. * Checks if a cullable object (mesh...) is in the camera frustum
  87894. * Unlike isInFrustum this cheks the full bounding box
  87895. * @param target The object to check
  87896. * @returns true if the object is in frustum otherwise false
  87897. */
  87898. isCompletelyInFrustum(target: ICullable): boolean;
  87899. /**
  87900. * Gets a ray in the forward direction from the camera.
  87901. * @param length Defines the length of the ray to create
  87902. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  87903. * @param origin Defines the start point of the ray which defaults to the camera position
  87904. * @returns the forward ray
  87905. */
  87906. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  87907. /**
  87908. * Releases resources associated with this node.
  87909. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87910. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87911. */
  87912. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87913. /** @hidden */
  87914. _isLeftCamera: boolean;
  87915. /**
  87916. * Gets the left camera of a rig setup in case of Rigged Camera
  87917. */
  87918. readonly isLeftCamera: boolean;
  87919. /** @hidden */
  87920. _isRightCamera: boolean;
  87921. /**
  87922. * Gets the right camera of a rig setup in case of Rigged Camera
  87923. */
  87924. readonly isRightCamera: boolean;
  87925. /**
  87926. * Gets the left camera of a rig setup in case of Rigged Camera
  87927. */
  87928. readonly leftCamera: Nullable<FreeCamera>;
  87929. /**
  87930. * Gets the right camera of a rig setup in case of Rigged Camera
  87931. */
  87932. readonly rightCamera: Nullable<FreeCamera>;
  87933. /**
  87934. * Gets the left camera target of a rig setup in case of Rigged Camera
  87935. * @returns the target position
  87936. */
  87937. getLeftTarget(): Nullable<Vector3>;
  87938. /**
  87939. * Gets the right camera target of a rig setup in case of Rigged Camera
  87940. * @returns the target position
  87941. */
  87942. getRightTarget(): Nullable<Vector3>;
  87943. /**
  87944. * @hidden
  87945. */
  87946. setCameraRigMode(mode: number, rigParams: any): void;
  87947. /** @hidden */
  87948. static _setStereoscopicRigMode(camera: Camera): void;
  87949. /** @hidden */
  87950. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  87951. /** @hidden */
  87952. static _setVRRigMode(camera: Camera, rigParams: any): void;
  87953. /** @hidden */
  87954. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  87955. /** @hidden */
  87956. _getVRProjectionMatrix(): Matrix;
  87957. protected _updateCameraRotationMatrix(): void;
  87958. protected _updateWebVRCameraRotationMatrix(): void;
  87959. /**
  87960. * This function MUST be overwritten by the different WebVR cameras available.
  87961. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  87962. * @hidden
  87963. */
  87964. _getWebVRProjectionMatrix(): Matrix;
  87965. /**
  87966. * This function MUST be overwritten by the different WebVR cameras available.
  87967. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  87968. * @hidden
  87969. */
  87970. _getWebVRViewMatrix(): Matrix;
  87971. /** @hidden */
  87972. setCameraRigParameter(name: string, value: any): void;
  87973. /**
  87974. * needs to be overridden by children so sub has required properties to be copied
  87975. * @hidden
  87976. */
  87977. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  87978. /**
  87979. * May need to be overridden by children
  87980. * @hidden
  87981. */
  87982. _updateRigCameras(): void;
  87983. /** @hidden */
  87984. _setupInputs(): void;
  87985. /**
  87986. * Serialiaze the camera setup to a json represention
  87987. * @returns the JSON representation
  87988. */
  87989. serialize(): any;
  87990. /**
  87991. * Clones the current camera.
  87992. * @param name The cloned camera name
  87993. * @returns the cloned camera
  87994. */
  87995. clone(name: string): Camera;
  87996. /**
  87997. * Gets the direction of the camera relative to a given local axis.
  87998. * @param localAxis Defines the reference axis to provide a relative direction.
  87999. * @return the direction
  88000. */
  88001. getDirection(localAxis: Vector3): Vector3;
  88002. /**
  88003. * Gets the direction of the camera relative to a given local axis into a passed vector.
  88004. * @param localAxis Defines the reference axis to provide a relative direction.
  88005. * @param result Defines the vector to store the result in
  88006. */
  88007. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  88008. /**
  88009. * Gets a camera constructor for a given camera type
  88010. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  88011. * @param name The name of the camera the result will be able to instantiate
  88012. * @param scene The scene the result will construct the camera in
  88013. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  88014. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  88015. * @returns a factory method to construc the camera
  88016. */
  88017. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  88018. /**
  88019. * Compute the world matrix of the camera.
  88020. * @returns the camera workd matrix
  88021. */
  88022. computeWorldMatrix(): Matrix;
  88023. /**
  88024. * Parse a JSON and creates the camera from the parsed information
  88025. * @param parsedCamera The JSON to parse
  88026. * @param scene The scene to instantiate the camera in
  88027. * @returns the newly constructed camera
  88028. */
  88029. static Parse(parsedCamera: any, scene: Scene): Camera;
  88030. }
  88031. }
  88032. declare module BABYLON {
  88033. /**
  88034. * Class containing static functions to help procedurally build meshes
  88035. */
  88036. export class DiscBuilder {
  88037. /**
  88038. * Creates a plane polygonal mesh. By default, this is a disc
  88039. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  88040. * * 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
  88041. * * 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
  88042. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88043. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  88044. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88045. * @param name defines the name of the mesh
  88046. * @param options defines the options used to create the mesh
  88047. * @param scene defines the hosting scene
  88048. * @returns the plane polygonal mesh
  88049. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  88050. */
  88051. static CreateDisc(name: string, options: {
  88052. radius?: number;
  88053. tessellation?: number;
  88054. arc?: number;
  88055. updatable?: boolean;
  88056. sideOrientation?: number;
  88057. frontUVs?: Vector4;
  88058. backUVs?: Vector4;
  88059. }, scene?: Nullable<Scene>): Mesh;
  88060. }
  88061. }
  88062. declare module BABYLON {
  88063. /**
  88064. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  88065. *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.
  88066. * The SPS is also a particle system. It provides some methods to manage the particles.
  88067. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  88068. *
  88069. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  88070. */
  88071. export class SolidParticleSystem implements IDisposable {
  88072. /**
  88073. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  88074. * Example : var p = SPS.particles[i];
  88075. */
  88076. particles: SolidParticle[];
  88077. /**
  88078. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  88079. */
  88080. nbParticles: number;
  88081. /**
  88082. * If the particles must ever face the camera (default false). Useful for planar particles.
  88083. */
  88084. billboard: boolean;
  88085. /**
  88086. * Recompute normals when adding a shape
  88087. */
  88088. recomputeNormals: boolean;
  88089. /**
  88090. * This a counter ofr your own usage. It's not set by any SPS functions.
  88091. */
  88092. counter: number;
  88093. /**
  88094. * The SPS name. This name is also given to the underlying mesh.
  88095. */
  88096. name: string;
  88097. /**
  88098. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  88099. */
  88100. mesh: Mesh;
  88101. /**
  88102. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  88103. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  88104. */
  88105. vars: any;
  88106. /**
  88107. * This array is populated when the SPS is set as 'pickable'.
  88108. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  88109. * Each element of this array is an object `{idx: int, faceId: int}`.
  88110. * `idx` is the picked particle index in the `SPS.particles` array
  88111. * `faceId` is the picked face index counted within this particle.
  88112. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  88113. */
  88114. pickedParticles: {
  88115. idx: number;
  88116. faceId: number;
  88117. }[];
  88118. /**
  88119. * This array is populated when `enableDepthSort` is set to true.
  88120. * Each element of this array is an instance of the class DepthSortedParticle.
  88121. */
  88122. depthSortedParticles: DepthSortedParticle[];
  88123. /**
  88124. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  88125. * @hidden
  88126. */
  88127. _bSphereOnly: boolean;
  88128. /**
  88129. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  88130. * @hidden
  88131. */
  88132. _bSphereRadiusFactor: number;
  88133. private _scene;
  88134. private _positions;
  88135. private _indices;
  88136. private _normals;
  88137. private _colors;
  88138. private _uvs;
  88139. private _indices32;
  88140. private _positions32;
  88141. private _normals32;
  88142. private _fixedNormal32;
  88143. private _colors32;
  88144. private _uvs32;
  88145. private _index;
  88146. private _updatable;
  88147. private _pickable;
  88148. private _isVisibilityBoxLocked;
  88149. private _alwaysVisible;
  88150. private _depthSort;
  88151. private _shapeCounter;
  88152. private _copy;
  88153. private _color;
  88154. private _computeParticleColor;
  88155. private _computeParticleTexture;
  88156. private _computeParticleRotation;
  88157. private _computeParticleVertex;
  88158. private _computeBoundingBox;
  88159. private _depthSortParticles;
  88160. private _camera;
  88161. private _mustUnrotateFixedNormals;
  88162. private _particlesIntersect;
  88163. private _needs32Bits;
  88164. /**
  88165. * Creates a SPS (Solid Particle System) object.
  88166. * @param name (String) is the SPS name, this will be the underlying mesh name.
  88167. * @param scene (Scene) is the scene in which the SPS is added.
  88168. * @param options defines the options of the sps e.g.
  88169. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  88170. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  88171. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  88172. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  88173. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  88174. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  88175. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  88176. */
  88177. constructor(name: string, scene: Scene, options?: {
  88178. updatable?: boolean;
  88179. isPickable?: boolean;
  88180. enableDepthSort?: boolean;
  88181. particleIntersection?: boolean;
  88182. boundingSphereOnly?: boolean;
  88183. bSphereRadiusFactor?: number;
  88184. });
  88185. /**
  88186. * Builds the SPS underlying mesh. Returns a standard Mesh.
  88187. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  88188. * @returns the created mesh
  88189. */
  88190. buildMesh(): Mesh;
  88191. /**
  88192. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  88193. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  88194. * Thus the particles generated from `digest()` have their property `position` set yet.
  88195. * @param mesh ( Mesh ) is the mesh to be digested
  88196. * @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
  88197. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  88198. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  88199. * @returns the current SPS
  88200. */
  88201. digest(mesh: Mesh, options?: {
  88202. facetNb?: number;
  88203. number?: number;
  88204. delta?: number;
  88205. }): SolidParticleSystem;
  88206. private _unrotateFixedNormals;
  88207. private _resetCopy;
  88208. private _meshBuilder;
  88209. private _posToShape;
  88210. private _uvsToShapeUV;
  88211. private _addParticle;
  88212. /**
  88213. * Adds some particles to the SPS from the model shape. Returns the shape id.
  88214. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  88215. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  88216. * @param nb (positive integer) the number of particles to be created from this model
  88217. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  88218. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  88219. * @returns the number of shapes in the system
  88220. */
  88221. addShape(mesh: Mesh, nb: number, options?: {
  88222. positionFunction?: any;
  88223. vertexFunction?: any;
  88224. }): number;
  88225. private _rebuildParticle;
  88226. /**
  88227. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  88228. * @returns the SPS.
  88229. */
  88230. rebuildMesh(): SolidParticleSystem;
  88231. /**
  88232. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  88233. * This method calls `updateParticle()` for each particle of the SPS.
  88234. * For an animated SPS, it is usually called within the render loop.
  88235. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  88236. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  88237. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  88238. * @returns the SPS.
  88239. */
  88240. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  88241. /**
  88242. * Disposes the SPS.
  88243. */
  88244. dispose(): void;
  88245. /**
  88246. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  88247. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  88248. * @returns the SPS.
  88249. */
  88250. refreshVisibleSize(): SolidParticleSystem;
  88251. /**
  88252. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  88253. * @param size the size (float) of the visibility box
  88254. * note : this doesn't lock the SPS mesh bounding box.
  88255. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  88256. */
  88257. setVisibilityBox(size: number): void;
  88258. /**
  88259. * Gets whether the SPS as always visible or not
  88260. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  88261. */
  88262. /**
  88263. * Sets the SPS as always visible or not
  88264. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  88265. */
  88266. isAlwaysVisible: boolean;
  88267. /**
  88268. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  88269. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  88270. */
  88271. /**
  88272. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  88273. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  88274. */
  88275. isVisibilityBoxLocked: boolean;
  88276. /**
  88277. * Tells to `setParticles()` to compute the particle rotations or not.
  88278. * Default value : true. The SPS is faster when it's set to false.
  88279. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  88280. */
  88281. /**
  88282. * Gets if `setParticles()` computes the particle rotations or not.
  88283. * Default value : true. The SPS is faster when it's set to false.
  88284. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  88285. */
  88286. computeParticleRotation: boolean;
  88287. /**
  88288. * Tells to `setParticles()` to compute the particle colors or not.
  88289. * Default value : true. The SPS is faster when it's set to false.
  88290. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  88291. */
  88292. /**
  88293. * Gets if `setParticles()` computes the particle colors or not.
  88294. * Default value : true. The SPS is faster when it's set to false.
  88295. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  88296. */
  88297. computeParticleColor: boolean;
  88298. /**
  88299. * Gets if `setParticles()` computes the particle textures or not.
  88300. * Default value : true. The SPS is faster when it's set to false.
  88301. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  88302. */
  88303. computeParticleTexture: boolean;
  88304. /**
  88305. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  88306. * Default value : false. The SPS is faster when it's set to false.
  88307. * Note : the particle custom vertex positions aren't stored values.
  88308. */
  88309. /**
  88310. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  88311. * Default value : false. The SPS is faster when it's set to false.
  88312. * Note : the particle custom vertex positions aren't stored values.
  88313. */
  88314. computeParticleVertex: boolean;
  88315. /**
  88316. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  88317. */
  88318. /**
  88319. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  88320. */
  88321. computeBoundingBox: boolean;
  88322. /**
  88323. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  88324. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  88325. * Default : `true`
  88326. */
  88327. /**
  88328. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  88329. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  88330. * Default : `true`
  88331. */
  88332. depthSortParticles: boolean;
  88333. /**
  88334. * This function does nothing. It may be overwritten to set all the particle first values.
  88335. * The SPS doesn't call this function, you may have to call it by your own.
  88336. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  88337. */
  88338. initParticles(): void;
  88339. /**
  88340. * This function does nothing. It may be overwritten to recycle a particle.
  88341. * The SPS doesn't call this function, you may have to call it by your own.
  88342. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  88343. * @param particle The particle to recycle
  88344. * @returns the recycled particle
  88345. */
  88346. recycleParticle(particle: SolidParticle): SolidParticle;
  88347. /**
  88348. * Updates a particle : this function should be overwritten by the user.
  88349. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  88350. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  88351. * @example : just set a particle position or velocity and recycle conditions
  88352. * @param particle The particle to update
  88353. * @returns the updated particle
  88354. */
  88355. updateParticle(particle: SolidParticle): SolidParticle;
  88356. /**
  88357. * Updates a vertex of a particle : it can be overwritten by the user.
  88358. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  88359. * @param particle the current particle
  88360. * @param vertex the current index of the current particle
  88361. * @param pt the index of the current vertex in the particle shape
  88362. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  88363. * @example : just set a vertex particle position
  88364. * @returns the updated vertex
  88365. */
  88366. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  88367. /**
  88368. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  88369. * This does nothing and may be overwritten by the user.
  88370. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  88371. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  88372. * @param update the boolean update value actually passed to setParticles()
  88373. */
  88374. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  88375. /**
  88376. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  88377. * This will be passed three parameters.
  88378. * This does nothing and may be overwritten by the user.
  88379. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  88380. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  88381. * @param update the boolean update value actually passed to setParticles()
  88382. */
  88383. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  88384. }
  88385. }
  88386. declare module BABYLON {
  88387. /**
  88388. * Represents one particle of a solid particle system.
  88389. */
  88390. export class SolidParticle {
  88391. /**
  88392. * particle global index
  88393. */
  88394. idx: number;
  88395. /**
  88396. * The color of the particle
  88397. */
  88398. color: Nullable<Color4>;
  88399. /**
  88400. * The world space position of the particle.
  88401. */
  88402. position: Vector3;
  88403. /**
  88404. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  88405. */
  88406. rotation: Vector3;
  88407. /**
  88408. * The world space rotation quaternion of the particle.
  88409. */
  88410. rotationQuaternion: Nullable<Quaternion>;
  88411. /**
  88412. * The scaling of the particle.
  88413. */
  88414. scaling: Vector3;
  88415. /**
  88416. * The uvs of the particle.
  88417. */
  88418. uvs: Vector4;
  88419. /**
  88420. * The current speed of the particle.
  88421. */
  88422. velocity: Vector3;
  88423. /**
  88424. * The pivot point in the particle local space.
  88425. */
  88426. pivot: Vector3;
  88427. /**
  88428. * Must the particle be translated from its pivot point in its local space ?
  88429. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  88430. * Default : false
  88431. */
  88432. translateFromPivot: boolean;
  88433. /**
  88434. * Is the particle active or not ?
  88435. */
  88436. alive: boolean;
  88437. /**
  88438. * Is the particle visible or not ?
  88439. */
  88440. isVisible: boolean;
  88441. /**
  88442. * Index of this particle in the global "positions" array (Internal use)
  88443. * @hidden
  88444. */
  88445. _pos: number;
  88446. /**
  88447. * @hidden Index of this particle in the global "indices" array (Internal use)
  88448. */
  88449. _ind: number;
  88450. /**
  88451. * @hidden ModelShape of this particle (Internal use)
  88452. */
  88453. _model: ModelShape;
  88454. /**
  88455. * ModelShape id of this particle
  88456. */
  88457. shapeId: number;
  88458. /**
  88459. * Index of the particle in its shape id (Internal use)
  88460. */
  88461. idxInShape: number;
  88462. /**
  88463. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  88464. */
  88465. _modelBoundingInfo: BoundingInfo;
  88466. /**
  88467. * @hidden Particle BoundingInfo object (Internal use)
  88468. */
  88469. _boundingInfo: BoundingInfo;
  88470. /**
  88471. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  88472. */
  88473. _sps: SolidParticleSystem;
  88474. /**
  88475. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  88476. */
  88477. _stillInvisible: boolean;
  88478. /**
  88479. * @hidden Last computed particle rotation matrix
  88480. */
  88481. _rotationMatrix: number[];
  88482. /**
  88483. * Parent particle Id, if any.
  88484. * Default null.
  88485. */
  88486. parentId: Nullable<number>;
  88487. /**
  88488. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  88489. * The possible values are :
  88490. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  88491. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  88492. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  88493. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  88494. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  88495. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  88496. * */
  88497. cullingStrategy: number;
  88498. /**
  88499. * @hidden Internal global position in the SPS.
  88500. */
  88501. _globalPosition: Vector3;
  88502. /**
  88503. * Creates a Solid Particle object.
  88504. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  88505. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  88506. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  88507. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  88508. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  88509. * @param shapeId (integer) is the model shape identifier in the SPS.
  88510. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  88511. * @param sps defines the sps it is associated to
  88512. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  88513. */
  88514. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  88515. /**
  88516. * Legacy support, changed scale to scaling
  88517. */
  88518. /**
  88519. * Legacy support, changed scale to scaling
  88520. */
  88521. scale: Vector3;
  88522. /**
  88523. * Legacy support, changed quaternion to rotationQuaternion
  88524. */
  88525. /**
  88526. * Legacy support, changed quaternion to rotationQuaternion
  88527. */
  88528. quaternion: Nullable<Quaternion>;
  88529. /**
  88530. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  88531. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  88532. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  88533. * @returns true if it intersects
  88534. */
  88535. intersectsMesh(target: Mesh | SolidParticle): boolean;
  88536. /**
  88537. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  88538. * A particle is in the frustum if its bounding box intersects the frustum
  88539. * @param frustumPlanes defines the frustum to test
  88540. * @returns true if the particle is in the frustum planes
  88541. */
  88542. isInFrustum(frustumPlanes: Plane[]): boolean;
  88543. /**
  88544. * get the rotation matrix of the particle
  88545. * @hidden
  88546. */
  88547. getRotationMatrix(m: Matrix): void;
  88548. }
  88549. /**
  88550. * Represents the shape of the model used by one particle of a solid particle system.
  88551. * SPS internal tool, don't use it manually.
  88552. */
  88553. export class ModelShape {
  88554. /**
  88555. * The shape id
  88556. * @hidden
  88557. */
  88558. shapeID: number;
  88559. /**
  88560. * flat array of model positions (internal use)
  88561. * @hidden
  88562. */
  88563. _shape: Vector3[];
  88564. /**
  88565. * flat array of model UVs (internal use)
  88566. * @hidden
  88567. */
  88568. _shapeUV: number[];
  88569. /**
  88570. * length of the shape in the model indices array (internal use)
  88571. * @hidden
  88572. */
  88573. _indicesLength: number;
  88574. /**
  88575. * Custom position function (internal use)
  88576. * @hidden
  88577. */
  88578. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  88579. /**
  88580. * Custom vertex function (internal use)
  88581. * @hidden
  88582. */
  88583. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  88584. /**
  88585. * 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.
  88586. * SPS internal tool, don't use it manually.
  88587. * @hidden
  88588. */
  88589. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  88590. }
  88591. /**
  88592. * Represents a Depth Sorted Particle in the solid particle system.
  88593. */
  88594. export class DepthSortedParticle {
  88595. /**
  88596. * Index of the particle in the "indices" array
  88597. */
  88598. ind: number;
  88599. /**
  88600. * Length of the particle shape in the "indices" array
  88601. */
  88602. indicesLength: number;
  88603. /**
  88604. * Squared distance from the particle to the camera
  88605. */
  88606. sqDistance: number;
  88607. }
  88608. }
  88609. declare module BABYLON {
  88610. /**
  88611. * @hidden
  88612. */
  88613. export class _MeshCollisionData {
  88614. _checkCollisions: boolean;
  88615. _collisionMask: number;
  88616. _collisionGroup: number;
  88617. _collider: Nullable<Collider>;
  88618. _oldPositionForCollisions: Vector3;
  88619. _diffPositionForCollisions: Vector3;
  88620. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  88621. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  88622. }
  88623. }
  88624. declare module BABYLON {
  88625. /** @hidden */
  88626. class _FacetDataStorage {
  88627. facetPositions: Vector3[];
  88628. facetNormals: Vector3[];
  88629. facetPartitioning: number[][];
  88630. facetNb: number;
  88631. partitioningSubdivisions: number;
  88632. partitioningBBoxRatio: number;
  88633. facetDataEnabled: boolean;
  88634. facetParameters: any;
  88635. bbSize: Vector3;
  88636. subDiv: {
  88637. max: number;
  88638. X: number;
  88639. Y: number;
  88640. Z: number;
  88641. };
  88642. facetDepthSort: boolean;
  88643. facetDepthSortEnabled: boolean;
  88644. depthSortedIndices: IndicesArray;
  88645. depthSortedFacets: {
  88646. ind: number;
  88647. sqDistance: number;
  88648. }[];
  88649. facetDepthSortFunction: (f1: {
  88650. ind: number;
  88651. sqDistance: number;
  88652. }, f2: {
  88653. ind: number;
  88654. sqDistance: number;
  88655. }) => number;
  88656. facetDepthSortFrom: Vector3;
  88657. facetDepthSortOrigin: Vector3;
  88658. invertedMatrix: Matrix;
  88659. }
  88660. /**
  88661. * @hidden
  88662. **/
  88663. class _InternalAbstractMeshDataInfo {
  88664. _hasVertexAlpha: boolean;
  88665. _useVertexColors: boolean;
  88666. _numBoneInfluencers: number;
  88667. _applyFog: boolean;
  88668. _receiveShadows: boolean;
  88669. _facetData: _FacetDataStorage;
  88670. _visibility: number;
  88671. _skeleton: Nullable<Skeleton>;
  88672. _layerMask: number;
  88673. _computeBonesUsingShaders: boolean;
  88674. _isActive: boolean;
  88675. _onlyForInstances: boolean;
  88676. _isActiveIntermediate: boolean;
  88677. _onlyForInstancesIntermediate: boolean;
  88678. }
  88679. /**
  88680. * Class used to store all common mesh properties
  88681. */
  88682. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  88683. /** No occlusion */
  88684. static OCCLUSION_TYPE_NONE: number;
  88685. /** Occlusion set to optimisitic */
  88686. static OCCLUSION_TYPE_OPTIMISTIC: number;
  88687. /** Occlusion set to strict */
  88688. static OCCLUSION_TYPE_STRICT: number;
  88689. /** Use an accurante occlusion algorithm */
  88690. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  88691. /** Use a conservative occlusion algorithm */
  88692. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  88693. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  88694. * Test order :
  88695. * Is the bounding sphere outside the frustum ?
  88696. * If not, are the bounding box vertices outside the frustum ?
  88697. * It not, then the cullable object is in the frustum.
  88698. */
  88699. static readonly CULLINGSTRATEGY_STANDARD: number;
  88700. /** Culling strategy : Bounding Sphere Only.
  88701. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  88702. * It's also less accurate than the standard because some not visible objects can still be selected.
  88703. * Test : is the bounding sphere outside the frustum ?
  88704. * If not, then the cullable object is in the frustum.
  88705. */
  88706. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  88707. /** Culling strategy : Optimistic Inclusion.
  88708. * This in an inclusion test first, then the standard exclusion test.
  88709. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  88710. * 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.
  88711. * Anyway, it's as accurate as the standard strategy.
  88712. * Test :
  88713. * Is the cullable object bounding sphere center in the frustum ?
  88714. * If not, apply the default culling strategy.
  88715. */
  88716. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  88717. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  88718. * This in an inclusion test first, then the bounding sphere only exclusion test.
  88719. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  88720. * 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.
  88721. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  88722. * Test :
  88723. * Is the cullable object bounding sphere center in the frustum ?
  88724. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  88725. */
  88726. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  88727. /**
  88728. * No billboard
  88729. */
  88730. static readonly BILLBOARDMODE_NONE: number;
  88731. /** Billboard on X axis */
  88732. static readonly BILLBOARDMODE_X: number;
  88733. /** Billboard on Y axis */
  88734. static readonly BILLBOARDMODE_Y: number;
  88735. /** Billboard on Z axis */
  88736. static readonly BILLBOARDMODE_Z: number;
  88737. /** Billboard on all axes */
  88738. static readonly BILLBOARDMODE_ALL: number;
  88739. /** @hidden */
  88740. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  88741. /**
  88742. * The culling strategy to use to check whether the mesh must be rendered or not.
  88743. * This value can be changed at any time and will be used on the next render mesh selection.
  88744. * The possible values are :
  88745. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  88746. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  88747. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  88748. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  88749. * Please read each static variable documentation to get details about the culling process.
  88750. * */
  88751. cullingStrategy: number;
  88752. /**
  88753. * Gets the number of facets in the mesh
  88754. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  88755. */
  88756. readonly facetNb: number;
  88757. /**
  88758. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  88759. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  88760. */
  88761. partitioningSubdivisions: number;
  88762. /**
  88763. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  88764. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  88765. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  88766. */
  88767. partitioningBBoxRatio: number;
  88768. /**
  88769. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  88770. * Works only for updatable meshes.
  88771. * Doesn't work with multi-materials
  88772. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  88773. */
  88774. mustDepthSortFacets: boolean;
  88775. /**
  88776. * The location (Vector3) where the facet depth sort must be computed from.
  88777. * By default, the active camera position.
  88778. * Used only when facet depth sort is enabled
  88779. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  88780. */
  88781. facetDepthSortFrom: Vector3;
  88782. /**
  88783. * gets a boolean indicating if facetData is enabled
  88784. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  88785. */
  88786. readonly isFacetDataEnabled: boolean;
  88787. /** @hidden */
  88788. _updateNonUniformScalingState(value: boolean): boolean;
  88789. /**
  88790. * An event triggered when this mesh collides with another one
  88791. */
  88792. onCollideObservable: Observable<AbstractMesh>;
  88793. /** Set a function to call when this mesh collides with another one */
  88794. onCollide: () => void;
  88795. /**
  88796. * An event triggered when the collision's position changes
  88797. */
  88798. onCollisionPositionChangeObservable: Observable<Vector3>;
  88799. /** Set a function to call when the collision's position changes */
  88800. onCollisionPositionChange: () => void;
  88801. /**
  88802. * An event triggered when material is changed
  88803. */
  88804. onMaterialChangedObservable: Observable<AbstractMesh>;
  88805. /**
  88806. * Gets or sets the orientation for POV movement & rotation
  88807. */
  88808. definedFacingForward: boolean;
  88809. /** @hidden */
  88810. _occlusionQuery: Nullable<WebGLQuery>;
  88811. /** @hidden */
  88812. _renderingGroup: Nullable<RenderingGroup>;
  88813. /**
  88814. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  88815. */
  88816. /**
  88817. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  88818. */
  88819. visibility: number;
  88820. /** Gets or sets the alpha index used to sort transparent meshes
  88821. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  88822. */
  88823. alphaIndex: number;
  88824. /**
  88825. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  88826. */
  88827. isVisible: boolean;
  88828. /**
  88829. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  88830. */
  88831. isPickable: boolean;
  88832. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  88833. showSubMeshesBoundingBox: boolean;
  88834. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  88835. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  88836. */
  88837. isBlocker: boolean;
  88838. /**
  88839. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  88840. */
  88841. enablePointerMoveEvents: boolean;
  88842. /**
  88843. * Specifies the rendering group id for this mesh (0 by default)
  88844. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  88845. */
  88846. renderingGroupId: number;
  88847. private _material;
  88848. /** Gets or sets current material */
  88849. material: Nullable<Material>;
  88850. /**
  88851. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  88852. * @see http://doc.babylonjs.com/babylon101/shadows
  88853. */
  88854. receiveShadows: boolean;
  88855. /** Defines color to use when rendering outline */
  88856. outlineColor: Color3;
  88857. /** Define width to use when rendering outline */
  88858. outlineWidth: number;
  88859. /** Defines color to use when rendering overlay */
  88860. overlayColor: Color3;
  88861. /** Defines alpha to use when rendering overlay */
  88862. overlayAlpha: number;
  88863. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  88864. hasVertexAlpha: boolean;
  88865. /** 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) */
  88866. useVertexColors: boolean;
  88867. /**
  88868. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  88869. */
  88870. computeBonesUsingShaders: boolean;
  88871. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  88872. numBoneInfluencers: number;
  88873. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  88874. applyFog: boolean;
  88875. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  88876. useOctreeForRenderingSelection: boolean;
  88877. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  88878. useOctreeForPicking: boolean;
  88879. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  88880. useOctreeForCollisions: boolean;
  88881. /**
  88882. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  88883. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  88884. */
  88885. layerMask: number;
  88886. /**
  88887. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  88888. */
  88889. alwaysSelectAsActiveMesh: boolean;
  88890. /**
  88891. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  88892. */
  88893. doNotSyncBoundingInfo: boolean;
  88894. /**
  88895. * Gets or sets the current action manager
  88896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  88897. */
  88898. actionManager: Nullable<AbstractActionManager>;
  88899. private _meshCollisionData;
  88900. /**
  88901. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  88902. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  88903. */
  88904. ellipsoid: Vector3;
  88905. /**
  88906. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  88907. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  88908. */
  88909. ellipsoidOffset: Vector3;
  88910. /**
  88911. * Gets or sets a collision mask used to mask collisions (default is -1).
  88912. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  88913. */
  88914. collisionMask: number;
  88915. /**
  88916. * Gets or sets the current collision group mask (-1 by default).
  88917. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  88918. */
  88919. collisionGroup: number;
  88920. /**
  88921. * Defines edge width used when edgesRenderer is enabled
  88922. * @see https://www.babylonjs-playground.com/#10OJSG#13
  88923. */
  88924. edgesWidth: number;
  88925. /**
  88926. * Defines edge color used when edgesRenderer is enabled
  88927. * @see https://www.babylonjs-playground.com/#10OJSG#13
  88928. */
  88929. edgesColor: Color4;
  88930. /** @hidden */
  88931. _edgesRenderer: Nullable<IEdgesRenderer>;
  88932. /** @hidden */
  88933. _masterMesh: Nullable<AbstractMesh>;
  88934. /** @hidden */
  88935. _boundingInfo: Nullable<BoundingInfo>;
  88936. /** @hidden */
  88937. _renderId: number;
  88938. /**
  88939. * Gets or sets the list of subMeshes
  88940. * @see http://doc.babylonjs.com/how_to/multi_materials
  88941. */
  88942. subMeshes: SubMesh[];
  88943. /** @hidden */
  88944. _intersectionsInProgress: AbstractMesh[];
  88945. /** @hidden */
  88946. _unIndexed: boolean;
  88947. /** @hidden */
  88948. _lightSources: Light[];
  88949. /** Gets the list of lights affecting that mesh */
  88950. readonly lightSources: Light[];
  88951. /** @hidden */
  88952. readonly _positions: Nullable<Vector3[]>;
  88953. /** @hidden */
  88954. _waitingData: {
  88955. lods: Nullable<any>;
  88956. actions: Nullable<any>;
  88957. freezeWorldMatrix: Nullable<boolean>;
  88958. };
  88959. /** @hidden */
  88960. _bonesTransformMatrices: Nullable<Float32Array>;
  88961. /** @hidden */
  88962. _transformMatrixTexture: Nullable<RawTexture>;
  88963. /**
  88964. * Gets or sets a skeleton to apply skining transformations
  88965. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  88966. */
  88967. skeleton: Nullable<Skeleton>;
  88968. /**
  88969. * An event triggered when the mesh is rebuilt.
  88970. */
  88971. onRebuildObservable: Observable<AbstractMesh>;
  88972. /**
  88973. * Creates a new AbstractMesh
  88974. * @param name defines the name of the mesh
  88975. * @param scene defines the hosting scene
  88976. */
  88977. constructor(name: string, scene?: Nullable<Scene>);
  88978. /**
  88979. * Returns the string "AbstractMesh"
  88980. * @returns "AbstractMesh"
  88981. */
  88982. getClassName(): string;
  88983. /**
  88984. * Gets a string representation of the current mesh
  88985. * @param fullDetails defines a boolean indicating if full details must be included
  88986. * @returns a string representation of the current mesh
  88987. */
  88988. toString(fullDetails?: boolean): string;
  88989. /**
  88990. * @hidden
  88991. */
  88992. protected _getEffectiveParent(): Nullable<Node>;
  88993. /** @hidden */
  88994. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  88995. /** @hidden */
  88996. _rebuild(): void;
  88997. /** @hidden */
  88998. _resyncLightSources(): void;
  88999. /** @hidden */
  89000. _resyncLighSource(light: Light): void;
  89001. /** @hidden */
  89002. _unBindEffect(): void;
  89003. /** @hidden */
  89004. _removeLightSource(light: Light): void;
  89005. private _markSubMeshesAsDirty;
  89006. /** @hidden */
  89007. _markSubMeshesAsLightDirty(): void;
  89008. /** @hidden */
  89009. _markSubMeshesAsAttributesDirty(): void;
  89010. /** @hidden */
  89011. _markSubMeshesAsMiscDirty(): void;
  89012. /**
  89013. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  89014. */
  89015. scaling: Vector3;
  89016. /**
  89017. * Returns true if the mesh is blocked. Implemented by child classes
  89018. */
  89019. readonly isBlocked: boolean;
  89020. /**
  89021. * Returns the mesh itself by default. Implemented by child classes
  89022. * @param camera defines the camera to use to pick the right LOD level
  89023. * @returns the currentAbstractMesh
  89024. */
  89025. getLOD(camera: Camera): Nullable<AbstractMesh>;
  89026. /**
  89027. * Returns 0 by default. Implemented by child classes
  89028. * @returns an integer
  89029. */
  89030. getTotalVertices(): number;
  89031. /**
  89032. * Returns a positive integer : the total number of indices in this mesh geometry.
  89033. * @returns the numner of indices or zero if the mesh has no geometry.
  89034. */
  89035. getTotalIndices(): number;
  89036. /**
  89037. * Returns null by default. Implemented by child classes
  89038. * @returns null
  89039. */
  89040. getIndices(): Nullable<IndicesArray>;
  89041. /**
  89042. * Returns the array of the requested vertex data kind. Implemented by child classes
  89043. * @param kind defines the vertex data kind to use
  89044. * @returns null
  89045. */
  89046. getVerticesData(kind: string): Nullable<FloatArray>;
  89047. /**
  89048. * Sets the vertex data of the mesh geometry for the requested `kind`.
  89049. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  89050. * Note that a new underlying VertexBuffer object is created each call.
  89051. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  89052. * @param kind defines vertex data kind:
  89053. * * VertexBuffer.PositionKind
  89054. * * VertexBuffer.UVKind
  89055. * * VertexBuffer.UV2Kind
  89056. * * VertexBuffer.UV3Kind
  89057. * * VertexBuffer.UV4Kind
  89058. * * VertexBuffer.UV5Kind
  89059. * * VertexBuffer.UV6Kind
  89060. * * VertexBuffer.ColorKind
  89061. * * VertexBuffer.MatricesIndicesKind
  89062. * * VertexBuffer.MatricesIndicesExtraKind
  89063. * * VertexBuffer.MatricesWeightsKind
  89064. * * VertexBuffer.MatricesWeightsExtraKind
  89065. * @param data defines the data source
  89066. * @param updatable defines if the data must be flagged as updatable (or static)
  89067. * @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
  89068. * @returns the current mesh
  89069. */
  89070. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  89071. /**
  89072. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  89073. * If the mesh has no geometry, it is simply returned as it is.
  89074. * @param kind defines vertex data kind:
  89075. * * VertexBuffer.PositionKind
  89076. * * VertexBuffer.UVKind
  89077. * * VertexBuffer.UV2Kind
  89078. * * VertexBuffer.UV3Kind
  89079. * * VertexBuffer.UV4Kind
  89080. * * VertexBuffer.UV5Kind
  89081. * * VertexBuffer.UV6Kind
  89082. * * VertexBuffer.ColorKind
  89083. * * VertexBuffer.MatricesIndicesKind
  89084. * * VertexBuffer.MatricesIndicesExtraKind
  89085. * * VertexBuffer.MatricesWeightsKind
  89086. * * VertexBuffer.MatricesWeightsExtraKind
  89087. * @param data defines the data source
  89088. * @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
  89089. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  89090. * @returns the current mesh
  89091. */
  89092. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  89093. /**
  89094. * Sets the mesh indices,
  89095. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  89096. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  89097. * @param totalVertices Defines the total number of vertices
  89098. * @returns the current mesh
  89099. */
  89100. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  89101. /**
  89102. * Gets a boolean indicating if specific vertex data is present
  89103. * @param kind defines the vertex data kind to use
  89104. * @returns true is data kind is present
  89105. */
  89106. isVerticesDataPresent(kind: string): boolean;
  89107. /**
  89108. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  89109. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  89110. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  89111. * @returns a BoundingInfo
  89112. */
  89113. getBoundingInfo(): BoundingInfo;
  89114. /**
  89115. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  89116. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  89117. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  89118. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  89119. * @returns the current mesh
  89120. */
  89121. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  89122. /**
  89123. * Overwrite the current bounding info
  89124. * @param boundingInfo defines the new bounding info
  89125. * @returns the current mesh
  89126. */
  89127. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  89128. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  89129. readonly useBones: boolean;
  89130. /** @hidden */
  89131. _preActivate(): void;
  89132. /** @hidden */
  89133. _preActivateForIntermediateRendering(renderId: number): void;
  89134. /** @hidden */
  89135. _activate(renderId: number, intermediateRendering: boolean): boolean;
  89136. /** @hidden */
  89137. _postActivate(): void;
  89138. /** @hidden */
  89139. _freeze(): void;
  89140. /** @hidden */
  89141. _unFreeze(): void;
  89142. /**
  89143. * Gets the current world matrix
  89144. * @returns a Matrix
  89145. */
  89146. getWorldMatrix(): Matrix;
  89147. /** @hidden */
  89148. _getWorldMatrixDeterminant(): number;
  89149. /**
  89150. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  89151. */
  89152. readonly isAnInstance: boolean;
  89153. /**
  89154. * Perform relative position change from the point of view of behind the front of the mesh.
  89155. * This is performed taking into account the meshes current rotation, so you do not have to care.
  89156. * Supports definition of mesh facing forward or backward
  89157. * @param amountRight defines the distance on the right axis
  89158. * @param amountUp defines the distance on the up axis
  89159. * @param amountForward defines the distance on the forward axis
  89160. * @returns the current mesh
  89161. */
  89162. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  89163. /**
  89164. * Calculate relative position change from the point of view of behind the front of the mesh.
  89165. * This is performed taking into account the meshes current rotation, so you do not have to care.
  89166. * Supports definition of mesh facing forward or backward
  89167. * @param amountRight defines the distance on the right axis
  89168. * @param amountUp defines the distance on the up axis
  89169. * @param amountForward defines the distance on the forward axis
  89170. * @returns the new displacement vector
  89171. */
  89172. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  89173. /**
  89174. * Perform relative rotation change from the point of view of behind the front of the mesh.
  89175. * Supports definition of mesh facing forward or backward
  89176. * @param flipBack defines the flip
  89177. * @param twirlClockwise defines the twirl
  89178. * @param tiltRight defines the tilt
  89179. * @returns the current mesh
  89180. */
  89181. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  89182. /**
  89183. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  89184. * Supports definition of mesh facing forward or backward.
  89185. * @param flipBack defines the flip
  89186. * @param twirlClockwise defines the twirl
  89187. * @param tiltRight defines the tilt
  89188. * @returns the new rotation vector
  89189. */
  89190. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  89191. /**
  89192. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  89193. * This means the mesh underlying bounding box and sphere are recomputed.
  89194. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  89195. * @returns the current mesh
  89196. */
  89197. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  89198. /** @hidden */
  89199. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  89200. /** @hidden */
  89201. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  89202. /** @hidden */
  89203. _updateBoundingInfo(): AbstractMesh;
  89204. /** @hidden */
  89205. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  89206. /** @hidden */
  89207. protected _afterComputeWorldMatrix(): void;
  89208. /** @hidden */
  89209. readonly _effectiveMesh: AbstractMesh;
  89210. /**
  89211. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  89212. * A mesh is in the frustum if its bounding box intersects the frustum
  89213. * @param frustumPlanes defines the frustum to test
  89214. * @returns true if the mesh is in the frustum planes
  89215. */
  89216. isInFrustum(frustumPlanes: Plane[]): boolean;
  89217. /**
  89218. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  89219. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  89220. * @param frustumPlanes defines the frustum to test
  89221. * @returns true if the mesh is completely in the frustum planes
  89222. */
  89223. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  89224. /**
  89225. * True if the mesh intersects another mesh or a SolidParticle object
  89226. * @param mesh defines a target mesh or SolidParticle to test
  89227. * @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)
  89228. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  89229. * @returns true if there is an intersection
  89230. */
  89231. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  89232. /**
  89233. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  89234. * @param point defines the point to test
  89235. * @returns true if there is an intersection
  89236. */
  89237. intersectsPoint(point: Vector3): boolean;
  89238. /**
  89239. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  89240. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89241. */
  89242. checkCollisions: boolean;
  89243. /**
  89244. * Gets Collider object used to compute collisions (not physics)
  89245. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89246. */
  89247. readonly collider: Nullable<Collider>;
  89248. /**
  89249. * Move the mesh using collision engine
  89250. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89251. * @param displacement defines the requested displacement vector
  89252. * @returns the current mesh
  89253. */
  89254. moveWithCollisions(displacement: Vector3): AbstractMesh;
  89255. private _onCollisionPositionChange;
  89256. /** @hidden */
  89257. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  89258. /** @hidden */
  89259. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  89260. /** @hidden */
  89261. _checkCollision(collider: Collider): AbstractMesh;
  89262. /** @hidden */
  89263. _generatePointsArray(): boolean;
  89264. /**
  89265. * Checks if the passed Ray intersects with the mesh
  89266. * @param ray defines the ray to use
  89267. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  89268. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  89269. * @returns the picking info
  89270. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  89271. */
  89272. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  89273. /**
  89274. * Clones the current mesh
  89275. * @param name defines the mesh name
  89276. * @param newParent defines the new mesh parent
  89277. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  89278. * @returns the new mesh
  89279. */
  89280. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  89281. /**
  89282. * Disposes all the submeshes of the current meshnp
  89283. * @returns the current mesh
  89284. */
  89285. releaseSubMeshes(): AbstractMesh;
  89286. /**
  89287. * Releases resources associated with this abstract mesh.
  89288. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89289. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89290. */
  89291. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89292. /**
  89293. * Adds the passed mesh as a child to the current mesh
  89294. * @param mesh defines the child mesh
  89295. * @returns the current mesh
  89296. */
  89297. addChild(mesh: AbstractMesh): AbstractMesh;
  89298. /**
  89299. * Removes the passed mesh from the current mesh children list
  89300. * @param mesh defines the child mesh
  89301. * @returns the current mesh
  89302. */
  89303. removeChild(mesh: AbstractMesh): AbstractMesh;
  89304. /** @hidden */
  89305. private _initFacetData;
  89306. /**
  89307. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  89308. * This method can be called within the render loop.
  89309. * 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
  89310. * @returns the current mesh
  89311. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89312. */
  89313. updateFacetData(): AbstractMesh;
  89314. /**
  89315. * Returns the facetLocalNormals array.
  89316. * The normals are expressed in the mesh local spac
  89317. * @returns an array of Vector3
  89318. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89319. */
  89320. getFacetLocalNormals(): Vector3[];
  89321. /**
  89322. * Returns the facetLocalPositions array.
  89323. * The facet positions are expressed in the mesh local space
  89324. * @returns an array of Vector3
  89325. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89326. */
  89327. getFacetLocalPositions(): Vector3[];
  89328. /**
  89329. * Returns the facetLocalPartioning array
  89330. * @returns an array of array of numbers
  89331. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89332. */
  89333. getFacetLocalPartitioning(): number[][];
  89334. /**
  89335. * Returns the i-th facet position in the world system.
  89336. * This method allocates a new Vector3 per call
  89337. * @param i defines the facet index
  89338. * @returns a new Vector3
  89339. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89340. */
  89341. getFacetPosition(i: number): Vector3;
  89342. /**
  89343. * Sets the reference Vector3 with the i-th facet position in the world system
  89344. * @param i defines the facet index
  89345. * @param ref defines the target vector
  89346. * @returns the current mesh
  89347. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89348. */
  89349. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  89350. /**
  89351. * Returns the i-th facet normal in the world system.
  89352. * This method allocates a new Vector3 per call
  89353. * @param i defines the facet index
  89354. * @returns a new Vector3
  89355. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89356. */
  89357. getFacetNormal(i: number): Vector3;
  89358. /**
  89359. * Sets the reference Vector3 with the i-th facet normal in the world system
  89360. * @param i defines the facet index
  89361. * @param ref defines the target vector
  89362. * @returns the current mesh
  89363. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89364. */
  89365. getFacetNormalToRef(i: number, ref: Vector3): this;
  89366. /**
  89367. * 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)
  89368. * @param x defines x coordinate
  89369. * @param y defines y coordinate
  89370. * @param z defines z coordinate
  89371. * @returns the array of facet indexes
  89372. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89373. */
  89374. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  89375. /**
  89376. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  89377. * @param projected sets as the (x,y,z) world projection on the facet
  89378. * @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
  89379. * @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
  89380. * @param x defines x coordinate
  89381. * @param y defines y coordinate
  89382. * @param z defines z coordinate
  89383. * @returns the face index if found (or null instead)
  89384. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89385. */
  89386. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  89387. /**
  89388. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  89389. * @param projected sets as the (x,y,z) local projection on the facet
  89390. * @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
  89391. * @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
  89392. * @param x defines x coordinate
  89393. * @param y defines y coordinate
  89394. * @param z defines z coordinate
  89395. * @returns the face index if found (or null instead)
  89396. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89397. */
  89398. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  89399. /**
  89400. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  89401. * @returns the parameters
  89402. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89403. */
  89404. getFacetDataParameters(): any;
  89405. /**
  89406. * Disables the feature FacetData and frees the related memory
  89407. * @returns the current mesh
  89408. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89409. */
  89410. disableFacetData(): AbstractMesh;
  89411. /**
  89412. * Updates the AbstractMesh indices array
  89413. * @param indices defines the data source
  89414. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  89415. * @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)
  89416. * @returns the current mesh
  89417. */
  89418. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  89419. /**
  89420. * Creates new normals data for the mesh
  89421. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  89422. * @returns the current mesh
  89423. */
  89424. createNormals(updatable: boolean): AbstractMesh;
  89425. /**
  89426. * Align the mesh with a normal
  89427. * @param normal defines the normal to use
  89428. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  89429. * @returns the current mesh
  89430. */
  89431. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  89432. /** @hidden */
  89433. _checkOcclusionQuery(): boolean;
  89434. /**
  89435. * Disables the mesh edge rendering mode
  89436. * @returns the currentAbstractMesh
  89437. */
  89438. disableEdgesRendering(): AbstractMesh;
  89439. /**
  89440. * Enables the edge rendering mode on the mesh.
  89441. * This mode makes the mesh edges visible
  89442. * @param epsilon defines the maximal distance between two angles to detect a face
  89443. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  89444. * @returns the currentAbstractMesh
  89445. * @see https://www.babylonjs-playground.com/#19O9TU#0
  89446. */
  89447. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  89448. }
  89449. }
  89450. declare module BABYLON {
  89451. /**
  89452. * Interface used to define ActionEvent
  89453. */
  89454. export interface IActionEvent {
  89455. /** The mesh or sprite that triggered the action */
  89456. source: any;
  89457. /** The X mouse cursor position at the time of the event */
  89458. pointerX: number;
  89459. /** The Y mouse cursor position at the time of the event */
  89460. pointerY: number;
  89461. /** The mesh that is currently pointed at (can be null) */
  89462. meshUnderPointer: Nullable<AbstractMesh>;
  89463. /** the original (browser) event that triggered the ActionEvent */
  89464. sourceEvent?: any;
  89465. /** additional data for the event */
  89466. additionalData?: any;
  89467. }
  89468. /**
  89469. * ActionEvent is the event being sent when an action is triggered.
  89470. */
  89471. export class ActionEvent implements IActionEvent {
  89472. /** The mesh or sprite that triggered the action */
  89473. source: any;
  89474. /** The X mouse cursor position at the time of the event */
  89475. pointerX: number;
  89476. /** The Y mouse cursor position at the time of the event */
  89477. pointerY: number;
  89478. /** The mesh that is currently pointed at (can be null) */
  89479. meshUnderPointer: Nullable<AbstractMesh>;
  89480. /** the original (browser) event that triggered the ActionEvent */
  89481. sourceEvent?: any;
  89482. /** additional data for the event */
  89483. additionalData?: any;
  89484. /**
  89485. * Creates a new ActionEvent
  89486. * @param source The mesh or sprite that triggered the action
  89487. * @param pointerX The X mouse cursor position at the time of the event
  89488. * @param pointerY The Y mouse cursor position at the time of the event
  89489. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  89490. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  89491. * @param additionalData additional data for the event
  89492. */
  89493. constructor(
  89494. /** The mesh or sprite that triggered the action */
  89495. source: any,
  89496. /** The X mouse cursor position at the time of the event */
  89497. pointerX: number,
  89498. /** The Y mouse cursor position at the time of the event */
  89499. pointerY: number,
  89500. /** The mesh that is currently pointed at (can be null) */
  89501. meshUnderPointer: Nullable<AbstractMesh>,
  89502. /** the original (browser) event that triggered the ActionEvent */
  89503. sourceEvent?: any,
  89504. /** additional data for the event */
  89505. additionalData?: any);
  89506. /**
  89507. * Helper function to auto-create an ActionEvent from a source mesh.
  89508. * @param source The source mesh that triggered the event
  89509. * @param evt The original (browser) event
  89510. * @param additionalData additional data for the event
  89511. * @returns the new ActionEvent
  89512. */
  89513. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  89514. /**
  89515. * Helper function to auto-create an ActionEvent from a source sprite
  89516. * @param source The source sprite that triggered the event
  89517. * @param scene Scene associated with the sprite
  89518. * @param evt The original (browser) event
  89519. * @param additionalData additional data for the event
  89520. * @returns the new ActionEvent
  89521. */
  89522. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  89523. /**
  89524. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  89525. * @param scene the scene where the event occurred
  89526. * @param evt The original (browser) event
  89527. * @returns the new ActionEvent
  89528. */
  89529. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  89530. /**
  89531. * Helper function to auto-create an ActionEvent from a primitive
  89532. * @param prim defines the target primitive
  89533. * @param pointerPos defines the pointer position
  89534. * @param evt The original (browser) event
  89535. * @param additionalData additional data for the event
  89536. * @returns the new ActionEvent
  89537. */
  89538. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  89539. }
  89540. }
  89541. declare module BABYLON {
  89542. /**
  89543. * Abstract class used to decouple action Manager from scene and meshes.
  89544. * Do not instantiate.
  89545. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  89546. */
  89547. export abstract class AbstractActionManager implements IDisposable {
  89548. /** Gets the list of active triggers */
  89549. static Triggers: {
  89550. [key: string]: number;
  89551. };
  89552. /** Gets the cursor to use when hovering items */
  89553. hoverCursor: string;
  89554. /** Gets the list of actions */
  89555. actions: IAction[];
  89556. /**
  89557. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  89558. */
  89559. isRecursive: boolean;
  89560. /**
  89561. * Releases all associated resources
  89562. */
  89563. abstract dispose(): void;
  89564. /**
  89565. * Does this action manager has pointer triggers
  89566. */
  89567. abstract readonly hasPointerTriggers: boolean;
  89568. /**
  89569. * Does this action manager has pick triggers
  89570. */
  89571. abstract readonly hasPickTriggers: boolean;
  89572. /**
  89573. * Process a specific trigger
  89574. * @param trigger defines the trigger to process
  89575. * @param evt defines the event details to be processed
  89576. */
  89577. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  89578. /**
  89579. * Does this action manager handles actions of any of the given triggers
  89580. * @param triggers defines the triggers to be tested
  89581. * @return a boolean indicating whether one (or more) of the triggers is handled
  89582. */
  89583. abstract hasSpecificTriggers(triggers: number[]): boolean;
  89584. /**
  89585. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  89586. * speed.
  89587. * @param triggerA defines the trigger to be tested
  89588. * @param triggerB defines the trigger to be tested
  89589. * @return a boolean indicating whether one (or more) of the triggers is handled
  89590. */
  89591. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  89592. /**
  89593. * Does this action manager handles actions of a given trigger
  89594. * @param trigger defines the trigger to be tested
  89595. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  89596. * @return whether the trigger is handled
  89597. */
  89598. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  89599. /**
  89600. * Serialize this manager to a JSON object
  89601. * @param name defines the property name to store this manager
  89602. * @returns a JSON representation of this manager
  89603. */
  89604. abstract serialize(name: string): any;
  89605. /**
  89606. * Registers an action to this action manager
  89607. * @param action defines the action to be registered
  89608. * @return the action amended (prepared) after registration
  89609. */
  89610. abstract registerAction(action: IAction): Nullable<IAction>;
  89611. /**
  89612. * Unregisters an action to this action manager
  89613. * @param action defines the action to be unregistered
  89614. * @return a boolean indicating whether the action has been unregistered
  89615. */
  89616. abstract unregisterAction(action: IAction): Boolean;
  89617. /**
  89618. * Does exist one action manager with at least one trigger
  89619. **/
  89620. static readonly HasTriggers: boolean;
  89621. /**
  89622. * Does exist one action manager with at least one pick trigger
  89623. **/
  89624. static readonly HasPickTriggers: boolean;
  89625. /**
  89626. * Does exist one action manager that handles actions of a given trigger
  89627. * @param trigger defines the trigger to be tested
  89628. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  89629. **/
  89630. static HasSpecificTrigger(trigger: number): boolean;
  89631. }
  89632. }
  89633. declare module BABYLON {
  89634. /**
  89635. * Defines how a node can be built from a string name.
  89636. */
  89637. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  89638. /**
  89639. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  89640. */
  89641. export class Node implements IBehaviorAware<Node> {
  89642. /** @hidden */
  89643. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  89644. private static _NodeConstructors;
  89645. /**
  89646. * Add a new node constructor
  89647. * @param type defines the type name of the node to construct
  89648. * @param constructorFunc defines the constructor function
  89649. */
  89650. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  89651. /**
  89652. * Returns a node constructor based on type name
  89653. * @param type defines the type name
  89654. * @param name defines the new node name
  89655. * @param scene defines the hosting scene
  89656. * @param options defines optional options to transmit to constructors
  89657. * @returns the new constructor or null
  89658. */
  89659. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  89660. /**
  89661. * Gets or sets the name of the node
  89662. */
  89663. name: string;
  89664. /**
  89665. * Gets or sets the id of the node
  89666. */
  89667. id: string;
  89668. /**
  89669. * Gets or sets the unique id of the node
  89670. */
  89671. uniqueId: number;
  89672. /**
  89673. * Gets or sets a string used to store user defined state for the node
  89674. */
  89675. state: string;
  89676. /**
  89677. * Gets or sets an object used to store user defined information for the node
  89678. */
  89679. metadata: any;
  89680. /**
  89681. * For internal use only. Please do not use.
  89682. */
  89683. reservedDataStore: any;
  89684. /**
  89685. * List of inspectable custom properties (used by the Inspector)
  89686. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  89687. */
  89688. inspectableCustomProperties: IInspectable[];
  89689. /**
  89690. * Gets or sets a boolean used to define if the node must be serialized
  89691. */
  89692. doNotSerialize: boolean;
  89693. /** @hidden */
  89694. _isDisposed: boolean;
  89695. /**
  89696. * Gets a list of Animations associated with the node
  89697. */
  89698. animations: Animation[];
  89699. protected _ranges: {
  89700. [name: string]: Nullable<AnimationRange>;
  89701. };
  89702. /**
  89703. * Callback raised when the node is ready to be used
  89704. */
  89705. onReady: Nullable<(node: Node) => void>;
  89706. private _isEnabled;
  89707. private _isParentEnabled;
  89708. private _isReady;
  89709. /** @hidden */
  89710. _currentRenderId: number;
  89711. private _parentUpdateId;
  89712. /** @hidden */
  89713. _childUpdateId: number;
  89714. /** @hidden */
  89715. _waitingParentId: Nullable<string>;
  89716. /** @hidden */
  89717. _scene: Scene;
  89718. /** @hidden */
  89719. _cache: any;
  89720. private _parentNode;
  89721. private _children;
  89722. /** @hidden */
  89723. _worldMatrix: Matrix;
  89724. /** @hidden */
  89725. _worldMatrixDeterminant: number;
  89726. /** @hidden */
  89727. _worldMatrixDeterminantIsDirty: boolean;
  89728. /** @hidden */
  89729. private _sceneRootNodesIndex;
  89730. /**
  89731. * Gets a boolean indicating if the node has been disposed
  89732. * @returns true if the node was disposed
  89733. */
  89734. isDisposed(): boolean;
  89735. /**
  89736. * Gets or sets the parent of the node (without keeping the current position in the scene)
  89737. * @see https://doc.babylonjs.com/how_to/parenting
  89738. */
  89739. parent: Nullable<Node>;
  89740. private addToSceneRootNodes;
  89741. private removeFromSceneRootNodes;
  89742. private _animationPropertiesOverride;
  89743. /**
  89744. * Gets or sets the animation properties override
  89745. */
  89746. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  89747. /**
  89748. * Gets a string idenfifying the name of the class
  89749. * @returns "Node" string
  89750. */
  89751. getClassName(): string;
  89752. /** @hidden */
  89753. readonly _isNode: boolean;
  89754. /**
  89755. * An event triggered when the mesh is disposed
  89756. */
  89757. onDisposeObservable: Observable<Node>;
  89758. private _onDisposeObserver;
  89759. /**
  89760. * Sets a callback that will be raised when the node will be disposed
  89761. */
  89762. onDispose: () => void;
  89763. /**
  89764. * Creates a new Node
  89765. * @param name the name and id to be given to this node
  89766. * @param scene the scene this node will be added to
  89767. * @param addToRootNodes the node will be added to scene.rootNodes
  89768. */
  89769. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  89770. /**
  89771. * Gets the scene of the node
  89772. * @returns a scene
  89773. */
  89774. getScene(): Scene;
  89775. /**
  89776. * Gets the engine of the node
  89777. * @returns a Engine
  89778. */
  89779. getEngine(): Engine;
  89780. private _behaviors;
  89781. /**
  89782. * Attach a behavior to the node
  89783. * @see http://doc.babylonjs.com/features/behaviour
  89784. * @param behavior defines the behavior to attach
  89785. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  89786. * @returns the current Node
  89787. */
  89788. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  89789. /**
  89790. * Remove an attached behavior
  89791. * @see http://doc.babylonjs.com/features/behaviour
  89792. * @param behavior defines the behavior to attach
  89793. * @returns the current Node
  89794. */
  89795. removeBehavior(behavior: Behavior<Node>): Node;
  89796. /**
  89797. * Gets the list of attached behaviors
  89798. * @see http://doc.babylonjs.com/features/behaviour
  89799. */
  89800. readonly behaviors: Behavior<Node>[];
  89801. /**
  89802. * Gets an attached behavior by name
  89803. * @param name defines the name of the behavior to look for
  89804. * @see http://doc.babylonjs.com/features/behaviour
  89805. * @returns null if behavior was not found else the requested behavior
  89806. */
  89807. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  89808. /**
  89809. * Returns the latest update of the World matrix
  89810. * @returns a Matrix
  89811. */
  89812. getWorldMatrix(): Matrix;
  89813. /** @hidden */
  89814. _getWorldMatrixDeterminant(): number;
  89815. /**
  89816. * Returns directly the latest state of the mesh World matrix.
  89817. * A Matrix is returned.
  89818. */
  89819. readonly worldMatrixFromCache: Matrix;
  89820. /** @hidden */
  89821. _initCache(): void;
  89822. /** @hidden */
  89823. updateCache(force?: boolean): void;
  89824. /** @hidden */
  89825. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  89826. /** @hidden */
  89827. _updateCache(ignoreParentClass?: boolean): void;
  89828. /** @hidden */
  89829. _isSynchronized(): boolean;
  89830. /** @hidden */
  89831. _markSyncedWithParent(): void;
  89832. /** @hidden */
  89833. isSynchronizedWithParent(): boolean;
  89834. /** @hidden */
  89835. isSynchronized(): boolean;
  89836. /**
  89837. * Is this node ready to be used/rendered
  89838. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  89839. * @return true if the node is ready
  89840. */
  89841. isReady(completeCheck?: boolean): boolean;
  89842. /**
  89843. * Is this node enabled?
  89844. * 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
  89845. * @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
  89846. * @return whether this node (and its parent) is enabled
  89847. */
  89848. isEnabled(checkAncestors?: boolean): boolean;
  89849. /** @hidden */
  89850. protected _syncParentEnabledState(): void;
  89851. /**
  89852. * Set the enabled state of this node
  89853. * @param value defines the new enabled state
  89854. */
  89855. setEnabled(value: boolean): void;
  89856. /**
  89857. * Is this node a descendant of the given node?
  89858. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  89859. * @param ancestor defines the parent node to inspect
  89860. * @returns a boolean indicating if this node is a descendant of the given node
  89861. */
  89862. isDescendantOf(ancestor: Node): boolean;
  89863. /** @hidden */
  89864. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  89865. /**
  89866. * Will return all nodes that have this node as ascendant
  89867. * @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
  89868. * @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
  89869. * @return all children nodes of all types
  89870. */
  89871. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  89872. /**
  89873. * Get all child-meshes of this node
  89874. * @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)
  89875. * @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
  89876. * @returns an array of AbstractMesh
  89877. */
  89878. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  89879. /**
  89880. * Get all direct children of this node
  89881. * @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
  89882. * @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)
  89883. * @returns an array of Node
  89884. */
  89885. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  89886. /** @hidden */
  89887. _setReady(state: boolean): void;
  89888. /**
  89889. * Get an animation by name
  89890. * @param name defines the name of the animation to look for
  89891. * @returns null if not found else the requested animation
  89892. */
  89893. getAnimationByName(name: string): Nullable<Animation>;
  89894. /**
  89895. * Creates an animation range for this node
  89896. * @param name defines the name of the range
  89897. * @param from defines the starting key
  89898. * @param to defines the end key
  89899. */
  89900. createAnimationRange(name: string, from: number, to: number): void;
  89901. /**
  89902. * Delete a specific animation range
  89903. * @param name defines the name of the range to delete
  89904. * @param deleteFrames defines if animation frames from the range must be deleted as well
  89905. */
  89906. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  89907. /**
  89908. * Get an animation range by name
  89909. * @param name defines the name of the animation range to look for
  89910. * @returns null if not found else the requested animation range
  89911. */
  89912. getAnimationRange(name: string): Nullable<AnimationRange>;
  89913. /**
  89914. * Gets the list of all animation ranges defined on this node
  89915. * @returns an array
  89916. */
  89917. getAnimationRanges(): Nullable<AnimationRange>[];
  89918. /**
  89919. * Will start the animation sequence
  89920. * @param name defines the range frames for animation sequence
  89921. * @param loop defines if the animation should loop (false by default)
  89922. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  89923. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  89924. * @returns the object created for this animation. If range does not exist, it will return null
  89925. */
  89926. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  89927. /**
  89928. * Serialize animation ranges into a JSON compatible object
  89929. * @returns serialization object
  89930. */
  89931. serializeAnimationRanges(): any;
  89932. /**
  89933. * Computes the world matrix of the node
  89934. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  89935. * @returns the world matrix
  89936. */
  89937. computeWorldMatrix(force?: boolean): Matrix;
  89938. /**
  89939. * Releases resources associated with this node.
  89940. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89941. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89942. */
  89943. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89944. /**
  89945. * Parse animation range data from a serialization object and store them into a given node
  89946. * @param node defines where to store the animation ranges
  89947. * @param parsedNode defines the serialization object to read data from
  89948. * @param scene defines the hosting scene
  89949. */
  89950. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  89951. /**
  89952. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  89953. * @param includeDescendants Include bounding info from descendants as well (true by default)
  89954. * @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
  89955. * @returns the new bounding vectors
  89956. */
  89957. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  89958. min: Vector3;
  89959. max: Vector3;
  89960. };
  89961. }
  89962. }
  89963. declare module BABYLON {
  89964. /**
  89965. * @hidden
  89966. */
  89967. export class _IAnimationState {
  89968. key: number;
  89969. repeatCount: number;
  89970. workValue?: any;
  89971. loopMode?: number;
  89972. offsetValue?: any;
  89973. highLimitValue?: any;
  89974. }
  89975. /**
  89976. * Class used to store any kind of animation
  89977. */
  89978. export class Animation {
  89979. /**Name of the animation */
  89980. name: string;
  89981. /**Property to animate */
  89982. targetProperty: string;
  89983. /**The frames per second of the animation */
  89984. framePerSecond: number;
  89985. /**The data type of the animation */
  89986. dataType: number;
  89987. /**The loop mode of the animation */
  89988. loopMode?: number | undefined;
  89989. /**Specifies if blending should be enabled */
  89990. enableBlending?: boolean | undefined;
  89991. /**
  89992. * Use matrix interpolation instead of using direct key value when animating matrices
  89993. */
  89994. static AllowMatricesInterpolation: boolean;
  89995. /**
  89996. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  89997. */
  89998. static AllowMatrixDecomposeForInterpolation: boolean;
  89999. /**
  90000. * Stores the key frames of the animation
  90001. */
  90002. private _keys;
  90003. /**
  90004. * Stores the easing function of the animation
  90005. */
  90006. private _easingFunction;
  90007. /**
  90008. * @hidden Internal use only
  90009. */
  90010. _runtimeAnimations: RuntimeAnimation[];
  90011. /**
  90012. * The set of event that will be linked to this animation
  90013. */
  90014. private _events;
  90015. /**
  90016. * Stores an array of target property paths
  90017. */
  90018. targetPropertyPath: string[];
  90019. /**
  90020. * Stores the blending speed of the animation
  90021. */
  90022. blendingSpeed: number;
  90023. /**
  90024. * Stores the animation ranges for the animation
  90025. */
  90026. private _ranges;
  90027. /**
  90028. * @hidden Internal use
  90029. */
  90030. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  90031. /**
  90032. * Sets up an animation
  90033. * @param property The property to animate
  90034. * @param animationType The animation type to apply
  90035. * @param framePerSecond The frames per second of the animation
  90036. * @param easingFunction The easing function used in the animation
  90037. * @returns The created animation
  90038. */
  90039. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  90040. /**
  90041. * Create and start an animation on a node
  90042. * @param name defines the name of the global animation that will be run on all nodes
  90043. * @param node defines the root node where the animation will take place
  90044. * @param targetProperty defines property to animate
  90045. * @param framePerSecond defines the number of frame per second yo use
  90046. * @param totalFrame defines the number of frames in total
  90047. * @param from defines the initial value
  90048. * @param to defines the final value
  90049. * @param loopMode defines which loop mode you want to use (off by default)
  90050. * @param easingFunction defines the easing function to use (linear by default)
  90051. * @param onAnimationEnd defines the callback to call when animation end
  90052. * @returns the animatable created for this animation
  90053. */
  90054. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  90055. /**
  90056. * Create and start an animation on a node and its descendants
  90057. * @param name defines the name of the global animation that will be run on all nodes
  90058. * @param node defines the root node where the animation will take place
  90059. * @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
  90060. * @param targetProperty defines property to animate
  90061. * @param framePerSecond defines the number of frame per second to use
  90062. * @param totalFrame defines the number of frames in total
  90063. * @param from defines the initial value
  90064. * @param to defines the final value
  90065. * @param loopMode defines which loop mode you want to use (off by default)
  90066. * @param easingFunction defines the easing function to use (linear by default)
  90067. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  90068. * @returns the list of animatables created for all nodes
  90069. * @example https://www.babylonjs-playground.com/#MH0VLI
  90070. */
  90071. 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[]>;
  90072. /**
  90073. * Creates a new animation, merges it with the existing animations and starts it
  90074. * @param name Name of the animation
  90075. * @param node Node which contains the scene that begins the animations
  90076. * @param targetProperty Specifies which property to animate
  90077. * @param framePerSecond The frames per second of the animation
  90078. * @param totalFrame The total number of frames
  90079. * @param from The frame at the beginning of the animation
  90080. * @param to The frame at the end of the animation
  90081. * @param loopMode Specifies the loop mode of the animation
  90082. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  90083. * @param onAnimationEnd Callback to run once the animation is complete
  90084. * @returns Nullable animation
  90085. */
  90086. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  90087. /**
  90088. * Transition property of an host to the target Value
  90089. * @param property The property to transition
  90090. * @param targetValue The target Value of the property
  90091. * @param host The object where the property to animate belongs
  90092. * @param scene Scene used to run the animation
  90093. * @param frameRate Framerate (in frame/s) to use
  90094. * @param transition The transition type we want to use
  90095. * @param duration The duration of the animation, in milliseconds
  90096. * @param onAnimationEnd Callback trigger at the end of the animation
  90097. * @returns Nullable animation
  90098. */
  90099. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  90100. /**
  90101. * Return the array of runtime animations currently using this animation
  90102. */
  90103. readonly runtimeAnimations: RuntimeAnimation[];
  90104. /**
  90105. * Specifies if any of the runtime animations are currently running
  90106. */
  90107. readonly hasRunningRuntimeAnimations: boolean;
  90108. /**
  90109. * Initializes the animation
  90110. * @param name Name of the animation
  90111. * @param targetProperty Property to animate
  90112. * @param framePerSecond The frames per second of the animation
  90113. * @param dataType The data type of the animation
  90114. * @param loopMode The loop mode of the animation
  90115. * @param enableBlending Specifies if blending should be enabled
  90116. */
  90117. constructor(
  90118. /**Name of the animation */
  90119. name: string,
  90120. /**Property to animate */
  90121. targetProperty: string,
  90122. /**The frames per second of the animation */
  90123. framePerSecond: number,
  90124. /**The data type of the animation */
  90125. dataType: number,
  90126. /**The loop mode of the animation */
  90127. loopMode?: number | undefined,
  90128. /**Specifies if blending should be enabled */
  90129. enableBlending?: boolean | undefined);
  90130. /**
  90131. * Converts the animation to a string
  90132. * @param fullDetails support for multiple levels of logging within scene loading
  90133. * @returns String form of the animation
  90134. */
  90135. toString(fullDetails?: boolean): string;
  90136. /**
  90137. * Add an event to this animation
  90138. * @param event Event to add
  90139. */
  90140. addEvent(event: AnimationEvent): void;
  90141. /**
  90142. * Remove all events found at the given frame
  90143. * @param frame The frame to remove events from
  90144. */
  90145. removeEvents(frame: number): void;
  90146. /**
  90147. * Retrieves all the events from the animation
  90148. * @returns Events from the animation
  90149. */
  90150. getEvents(): AnimationEvent[];
  90151. /**
  90152. * Creates an animation range
  90153. * @param name Name of the animation range
  90154. * @param from Starting frame of the animation range
  90155. * @param to Ending frame of the animation
  90156. */
  90157. createRange(name: string, from: number, to: number): void;
  90158. /**
  90159. * Deletes an animation range by name
  90160. * @param name Name of the animation range to delete
  90161. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  90162. */
  90163. deleteRange(name: string, deleteFrames?: boolean): void;
  90164. /**
  90165. * Gets the animation range by name, or null if not defined
  90166. * @param name Name of the animation range
  90167. * @returns Nullable animation range
  90168. */
  90169. getRange(name: string): Nullable<AnimationRange>;
  90170. /**
  90171. * Gets the key frames from the animation
  90172. * @returns The key frames of the animation
  90173. */
  90174. getKeys(): Array<IAnimationKey>;
  90175. /**
  90176. * Gets the highest frame rate of the animation
  90177. * @returns Highest frame rate of the animation
  90178. */
  90179. getHighestFrame(): number;
  90180. /**
  90181. * Gets the easing function of the animation
  90182. * @returns Easing function of the animation
  90183. */
  90184. getEasingFunction(): IEasingFunction;
  90185. /**
  90186. * Sets the easing function of the animation
  90187. * @param easingFunction A custom mathematical formula for animation
  90188. */
  90189. setEasingFunction(easingFunction: EasingFunction): void;
  90190. /**
  90191. * Interpolates a scalar linearly
  90192. * @param startValue Start value of the animation curve
  90193. * @param endValue End value of the animation curve
  90194. * @param gradient Scalar amount to interpolate
  90195. * @returns Interpolated scalar value
  90196. */
  90197. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  90198. /**
  90199. * Interpolates a scalar cubically
  90200. * @param startValue Start value of the animation curve
  90201. * @param outTangent End tangent of the animation
  90202. * @param endValue End value of the animation curve
  90203. * @param inTangent Start tangent of the animation curve
  90204. * @param gradient Scalar amount to interpolate
  90205. * @returns Interpolated scalar value
  90206. */
  90207. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  90208. /**
  90209. * Interpolates a quaternion using a spherical linear interpolation
  90210. * @param startValue Start value of the animation curve
  90211. * @param endValue End value of the animation curve
  90212. * @param gradient Scalar amount to interpolate
  90213. * @returns Interpolated quaternion value
  90214. */
  90215. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  90216. /**
  90217. * Interpolates a quaternion cubically
  90218. * @param startValue Start value of the animation curve
  90219. * @param outTangent End tangent of the animation curve
  90220. * @param endValue End value of the animation curve
  90221. * @param inTangent Start tangent of the animation curve
  90222. * @param gradient Scalar amount to interpolate
  90223. * @returns Interpolated quaternion value
  90224. */
  90225. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  90226. /**
  90227. * Interpolates a Vector3 linearl
  90228. * @param startValue Start value of the animation curve
  90229. * @param endValue End value of the animation curve
  90230. * @param gradient Scalar amount to interpolate
  90231. * @returns Interpolated scalar value
  90232. */
  90233. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  90234. /**
  90235. * Interpolates a Vector3 cubically
  90236. * @param startValue Start value of the animation curve
  90237. * @param outTangent End tangent of the animation
  90238. * @param endValue End value of the animation curve
  90239. * @param inTangent Start tangent of the animation curve
  90240. * @param gradient Scalar amount to interpolate
  90241. * @returns InterpolatedVector3 value
  90242. */
  90243. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  90244. /**
  90245. * Interpolates a Vector2 linearly
  90246. * @param startValue Start value of the animation curve
  90247. * @param endValue End value of the animation curve
  90248. * @param gradient Scalar amount to interpolate
  90249. * @returns Interpolated Vector2 value
  90250. */
  90251. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  90252. /**
  90253. * Interpolates a Vector2 cubically
  90254. * @param startValue Start value of the animation curve
  90255. * @param outTangent End tangent of the animation
  90256. * @param endValue End value of the animation curve
  90257. * @param inTangent Start tangent of the animation curve
  90258. * @param gradient Scalar amount to interpolate
  90259. * @returns Interpolated Vector2 value
  90260. */
  90261. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  90262. /**
  90263. * Interpolates a size linearly
  90264. * @param startValue Start value of the animation curve
  90265. * @param endValue End value of the animation curve
  90266. * @param gradient Scalar amount to interpolate
  90267. * @returns Interpolated Size value
  90268. */
  90269. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  90270. /**
  90271. * Interpolates a Color3 linearly
  90272. * @param startValue Start value of the animation curve
  90273. * @param endValue End value of the animation curve
  90274. * @param gradient Scalar amount to interpolate
  90275. * @returns Interpolated Color3 value
  90276. */
  90277. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  90278. /**
  90279. * @hidden Internal use only
  90280. */
  90281. _getKeyValue(value: any): any;
  90282. /**
  90283. * @hidden Internal use only
  90284. */
  90285. _interpolate(currentFrame: number, state: _IAnimationState): any;
  90286. /**
  90287. * Defines the function to use to interpolate matrices
  90288. * @param startValue defines the start matrix
  90289. * @param endValue defines the end matrix
  90290. * @param gradient defines the gradient between both matrices
  90291. * @param result defines an optional target matrix where to store the interpolation
  90292. * @returns the interpolated matrix
  90293. */
  90294. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  90295. /**
  90296. * Makes a copy of the animation
  90297. * @returns Cloned animation
  90298. */
  90299. clone(): Animation;
  90300. /**
  90301. * Sets the key frames of the animation
  90302. * @param values The animation key frames to set
  90303. */
  90304. setKeys(values: Array<IAnimationKey>): void;
  90305. /**
  90306. * Serializes the animation to an object
  90307. * @returns Serialized object
  90308. */
  90309. serialize(): any;
  90310. /**
  90311. * Float animation type
  90312. */
  90313. private static _ANIMATIONTYPE_FLOAT;
  90314. /**
  90315. * Vector3 animation type
  90316. */
  90317. private static _ANIMATIONTYPE_VECTOR3;
  90318. /**
  90319. * Quaternion animation type
  90320. */
  90321. private static _ANIMATIONTYPE_QUATERNION;
  90322. /**
  90323. * Matrix animation type
  90324. */
  90325. private static _ANIMATIONTYPE_MATRIX;
  90326. /**
  90327. * Color3 animation type
  90328. */
  90329. private static _ANIMATIONTYPE_COLOR3;
  90330. /**
  90331. * Vector2 animation type
  90332. */
  90333. private static _ANIMATIONTYPE_VECTOR2;
  90334. /**
  90335. * Size animation type
  90336. */
  90337. private static _ANIMATIONTYPE_SIZE;
  90338. /**
  90339. * Relative Loop Mode
  90340. */
  90341. private static _ANIMATIONLOOPMODE_RELATIVE;
  90342. /**
  90343. * Cycle Loop Mode
  90344. */
  90345. private static _ANIMATIONLOOPMODE_CYCLE;
  90346. /**
  90347. * Constant Loop Mode
  90348. */
  90349. private static _ANIMATIONLOOPMODE_CONSTANT;
  90350. /**
  90351. * Get the float animation type
  90352. */
  90353. static readonly ANIMATIONTYPE_FLOAT: number;
  90354. /**
  90355. * Get the Vector3 animation type
  90356. */
  90357. static readonly ANIMATIONTYPE_VECTOR3: number;
  90358. /**
  90359. * Get the Vector2 animation type
  90360. */
  90361. static readonly ANIMATIONTYPE_VECTOR2: number;
  90362. /**
  90363. * Get the Size animation type
  90364. */
  90365. static readonly ANIMATIONTYPE_SIZE: number;
  90366. /**
  90367. * Get the Quaternion animation type
  90368. */
  90369. static readonly ANIMATIONTYPE_QUATERNION: number;
  90370. /**
  90371. * Get the Matrix animation type
  90372. */
  90373. static readonly ANIMATIONTYPE_MATRIX: number;
  90374. /**
  90375. * Get the Color3 animation type
  90376. */
  90377. static readonly ANIMATIONTYPE_COLOR3: number;
  90378. /**
  90379. * Get the Relative Loop Mode
  90380. */
  90381. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  90382. /**
  90383. * Get the Cycle Loop Mode
  90384. */
  90385. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  90386. /**
  90387. * Get the Constant Loop Mode
  90388. */
  90389. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  90390. /** @hidden */
  90391. static _UniversalLerp(left: any, right: any, amount: number): any;
  90392. /**
  90393. * Parses an animation object and creates an animation
  90394. * @param parsedAnimation Parsed animation object
  90395. * @returns Animation object
  90396. */
  90397. static Parse(parsedAnimation: any): Animation;
  90398. /**
  90399. * Appends the serialized animations from the source animations
  90400. * @param source Source containing the animations
  90401. * @param destination Target to store the animations
  90402. */
  90403. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  90404. }
  90405. }
  90406. declare module BABYLON {
  90407. /**
  90408. * Interface containing an array of animations
  90409. */
  90410. export interface IAnimatable {
  90411. /**
  90412. * Array of animations
  90413. */
  90414. animations: Nullable<Array<Animation>>;
  90415. }
  90416. }
  90417. declare module BABYLON {
  90418. /**
  90419. * This represents all the required information to add a fresnel effect on a material:
  90420. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  90421. */
  90422. export class FresnelParameters {
  90423. private _isEnabled;
  90424. /**
  90425. * Define if the fresnel effect is enable or not.
  90426. */
  90427. isEnabled: boolean;
  90428. /**
  90429. * Define the color used on edges (grazing angle)
  90430. */
  90431. leftColor: Color3;
  90432. /**
  90433. * Define the color used on center
  90434. */
  90435. rightColor: Color3;
  90436. /**
  90437. * Define bias applied to computed fresnel term
  90438. */
  90439. bias: number;
  90440. /**
  90441. * Defined the power exponent applied to fresnel term
  90442. */
  90443. power: number;
  90444. /**
  90445. * Clones the current fresnel and its valuues
  90446. * @returns a clone fresnel configuration
  90447. */
  90448. clone(): FresnelParameters;
  90449. /**
  90450. * Serializes the current fresnel parameters to a JSON representation.
  90451. * @return the JSON serialization
  90452. */
  90453. serialize(): any;
  90454. /**
  90455. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  90456. * @param parsedFresnelParameters Define the JSON representation
  90457. * @returns the parsed parameters
  90458. */
  90459. static Parse(parsedFresnelParameters: any): FresnelParameters;
  90460. }
  90461. }
  90462. declare module BABYLON {
  90463. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  90464. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90465. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90466. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90467. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90468. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90469. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90470. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90471. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90472. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90473. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90474. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90475. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90476. /**
  90477. * Decorator used to define property that can be serialized as reference to a camera
  90478. * @param sourceName defines the name of the property to decorate
  90479. */
  90480. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  90481. /**
  90482. * Class used to help serialization objects
  90483. */
  90484. export class SerializationHelper {
  90485. /** @hidden */
  90486. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  90487. /** @hidden */
  90488. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  90489. /** @hidden */
  90490. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  90491. /** @hidden */
  90492. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  90493. /**
  90494. * Appends the serialized animations from the source animations
  90495. * @param source Source containing the animations
  90496. * @param destination Target to store the animations
  90497. */
  90498. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  90499. /**
  90500. * Static function used to serialized a specific entity
  90501. * @param entity defines the entity to serialize
  90502. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  90503. * @returns a JSON compatible object representing the serialization of the entity
  90504. */
  90505. static Serialize<T>(entity: T, serializationObject?: any): any;
  90506. /**
  90507. * Creates a new entity from a serialization data object
  90508. * @param creationFunction defines a function used to instanciated the new entity
  90509. * @param source defines the source serialization data
  90510. * @param scene defines the hosting scene
  90511. * @param rootUrl defines the root url for resources
  90512. * @returns a new entity
  90513. */
  90514. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  90515. /**
  90516. * Clones an object
  90517. * @param creationFunction defines the function used to instanciate the new object
  90518. * @param source defines the source object
  90519. * @returns the cloned object
  90520. */
  90521. static Clone<T>(creationFunction: () => T, source: T): T;
  90522. /**
  90523. * Instanciates a new object based on a source one (some data will be shared between both object)
  90524. * @param creationFunction defines the function used to instanciate the new object
  90525. * @param source defines the source object
  90526. * @returns the new object
  90527. */
  90528. static Instanciate<T>(creationFunction: () => T, source: T): T;
  90529. }
  90530. }
  90531. declare module BABYLON {
  90532. /**
  90533. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  90534. */
  90535. export interface CubeMapInfo {
  90536. /**
  90537. * The pixel array for the front face.
  90538. * This is stored in format, left to right, up to down format.
  90539. */
  90540. front: Nullable<ArrayBufferView>;
  90541. /**
  90542. * The pixel array for the back face.
  90543. * This is stored in format, left to right, up to down format.
  90544. */
  90545. back: Nullable<ArrayBufferView>;
  90546. /**
  90547. * The pixel array for the left face.
  90548. * This is stored in format, left to right, up to down format.
  90549. */
  90550. left: Nullable<ArrayBufferView>;
  90551. /**
  90552. * The pixel array for the right face.
  90553. * This is stored in format, left to right, up to down format.
  90554. */
  90555. right: Nullable<ArrayBufferView>;
  90556. /**
  90557. * The pixel array for the up face.
  90558. * This is stored in format, left to right, up to down format.
  90559. */
  90560. up: Nullable<ArrayBufferView>;
  90561. /**
  90562. * The pixel array for the down face.
  90563. * This is stored in format, left to right, up to down format.
  90564. */
  90565. down: Nullable<ArrayBufferView>;
  90566. /**
  90567. * The size of the cubemap stored.
  90568. *
  90569. * Each faces will be size * size pixels.
  90570. */
  90571. size: number;
  90572. /**
  90573. * The format of the texture.
  90574. *
  90575. * RGBA, RGB.
  90576. */
  90577. format: number;
  90578. /**
  90579. * The type of the texture data.
  90580. *
  90581. * UNSIGNED_INT, FLOAT.
  90582. */
  90583. type: number;
  90584. /**
  90585. * Specifies whether the texture is in gamma space.
  90586. */
  90587. gammaSpace: boolean;
  90588. }
  90589. /**
  90590. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  90591. */
  90592. export class PanoramaToCubeMapTools {
  90593. private static FACE_FRONT;
  90594. private static FACE_BACK;
  90595. private static FACE_RIGHT;
  90596. private static FACE_LEFT;
  90597. private static FACE_DOWN;
  90598. private static FACE_UP;
  90599. /**
  90600. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  90601. *
  90602. * @param float32Array The source data.
  90603. * @param inputWidth The width of the input panorama.
  90604. * @param inputHeight The height of the input panorama.
  90605. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  90606. * @return The cubemap data
  90607. */
  90608. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  90609. private static CreateCubemapTexture;
  90610. private static CalcProjectionSpherical;
  90611. }
  90612. }
  90613. declare module BABYLON {
  90614. /**
  90615. * Helper class dealing with the extraction of spherical polynomial dataArray
  90616. * from a cube map.
  90617. */
  90618. export class CubeMapToSphericalPolynomialTools {
  90619. private static FileFaces;
  90620. /**
  90621. * Converts a texture to the according Spherical Polynomial data.
  90622. * This extracts the first 3 orders only as they are the only one used in the lighting.
  90623. *
  90624. * @param texture The texture to extract the information from.
  90625. * @return The Spherical Polynomial data.
  90626. */
  90627. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  90628. /**
  90629. * Converts a cubemap to the according Spherical Polynomial data.
  90630. * This extracts the first 3 orders only as they are the only one used in the lighting.
  90631. *
  90632. * @param cubeInfo The Cube map to extract the information from.
  90633. * @return The Spherical Polynomial data.
  90634. */
  90635. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  90636. }
  90637. }
  90638. declare module BABYLON {
  90639. /**
  90640. * Class used to manipulate GUIDs
  90641. */
  90642. export class GUID {
  90643. /**
  90644. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  90645. * Be aware Math.random() could cause collisions, but:
  90646. * "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"
  90647. * @returns a pseudo random id
  90648. */
  90649. static RandomId(): string;
  90650. }
  90651. }
  90652. declare module BABYLON {
  90653. /**
  90654. * Base class of all the textures in babylon.
  90655. * It groups all the common properties the materials, post process, lights... might need
  90656. * in order to make a correct use of the texture.
  90657. */
  90658. export class BaseTexture implements IAnimatable {
  90659. /**
  90660. * Default anisotropic filtering level for the application.
  90661. * It is set to 4 as a good tradeoff between perf and quality.
  90662. */
  90663. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  90664. /**
  90665. * Gets or sets the unique id of the texture
  90666. */
  90667. uniqueId: number;
  90668. /**
  90669. * Define the name of the texture.
  90670. */
  90671. name: string;
  90672. /**
  90673. * Gets or sets an object used to store user defined information.
  90674. */
  90675. metadata: any;
  90676. /**
  90677. * For internal use only. Please do not use.
  90678. */
  90679. reservedDataStore: any;
  90680. private _hasAlpha;
  90681. /**
  90682. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  90683. */
  90684. hasAlpha: boolean;
  90685. /**
  90686. * Defines if the alpha value should be determined via the rgb values.
  90687. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  90688. */
  90689. getAlphaFromRGB: boolean;
  90690. /**
  90691. * Intensity or strength of the texture.
  90692. * It is commonly used by materials to fine tune the intensity of the texture
  90693. */
  90694. level: number;
  90695. /**
  90696. * Define the UV chanel to use starting from 0 and defaulting to 0.
  90697. * This is part of the texture as textures usually maps to one uv set.
  90698. */
  90699. coordinatesIndex: number;
  90700. private _coordinatesMode;
  90701. /**
  90702. * How a texture is mapped.
  90703. *
  90704. * | Value | Type | Description |
  90705. * | ----- | ----------------------------------- | ----------- |
  90706. * | 0 | EXPLICIT_MODE | |
  90707. * | 1 | SPHERICAL_MODE | |
  90708. * | 2 | PLANAR_MODE | |
  90709. * | 3 | CUBIC_MODE | |
  90710. * | 4 | PROJECTION_MODE | |
  90711. * | 5 | SKYBOX_MODE | |
  90712. * | 6 | INVCUBIC_MODE | |
  90713. * | 7 | EQUIRECTANGULAR_MODE | |
  90714. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  90715. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  90716. */
  90717. coordinatesMode: number;
  90718. /**
  90719. * | Value | Type | Description |
  90720. * | ----- | ------------------ | ----------- |
  90721. * | 0 | CLAMP_ADDRESSMODE | |
  90722. * | 1 | WRAP_ADDRESSMODE | |
  90723. * | 2 | MIRROR_ADDRESSMODE | |
  90724. */
  90725. wrapU: number;
  90726. /**
  90727. * | Value | Type | Description |
  90728. * | ----- | ------------------ | ----------- |
  90729. * | 0 | CLAMP_ADDRESSMODE | |
  90730. * | 1 | WRAP_ADDRESSMODE | |
  90731. * | 2 | MIRROR_ADDRESSMODE | |
  90732. */
  90733. wrapV: number;
  90734. /**
  90735. * | Value | Type | Description |
  90736. * | ----- | ------------------ | ----------- |
  90737. * | 0 | CLAMP_ADDRESSMODE | |
  90738. * | 1 | WRAP_ADDRESSMODE | |
  90739. * | 2 | MIRROR_ADDRESSMODE | |
  90740. */
  90741. wrapR: number;
  90742. /**
  90743. * With compliant hardware and browser (supporting anisotropic filtering)
  90744. * this defines the level of anisotropic filtering in the texture.
  90745. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  90746. */
  90747. anisotropicFilteringLevel: number;
  90748. /**
  90749. * Define if the texture is a cube texture or if false a 2d texture.
  90750. */
  90751. isCube: boolean;
  90752. /**
  90753. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  90754. */
  90755. is3D: boolean;
  90756. /**
  90757. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  90758. * HDR texture are usually stored in linear space.
  90759. * This only impacts the PBR and Background materials
  90760. */
  90761. gammaSpace: boolean;
  90762. /**
  90763. * Gets whether or not the texture contains RGBD data.
  90764. */
  90765. readonly isRGBD: boolean;
  90766. /**
  90767. * Is Z inverted in the texture (useful in a cube texture).
  90768. */
  90769. invertZ: boolean;
  90770. /**
  90771. * Are mip maps generated for this texture or not.
  90772. */
  90773. readonly noMipmap: boolean;
  90774. /**
  90775. * @hidden
  90776. */
  90777. lodLevelInAlpha: boolean;
  90778. /**
  90779. * With prefiltered texture, defined the offset used during the prefiltering steps.
  90780. */
  90781. lodGenerationOffset: number;
  90782. /**
  90783. * With prefiltered texture, defined the scale used during the prefiltering steps.
  90784. */
  90785. lodGenerationScale: number;
  90786. /**
  90787. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  90788. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  90789. * average roughness values.
  90790. */
  90791. linearSpecularLOD: boolean;
  90792. /**
  90793. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  90794. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  90795. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  90796. */
  90797. irradianceTexture: Nullable<BaseTexture>;
  90798. /**
  90799. * Define if the texture is a render target.
  90800. */
  90801. isRenderTarget: boolean;
  90802. /**
  90803. * Define the unique id of the texture in the scene.
  90804. */
  90805. readonly uid: string;
  90806. /**
  90807. * Return a string representation of the texture.
  90808. * @returns the texture as a string
  90809. */
  90810. toString(): string;
  90811. /**
  90812. * Get the class name of the texture.
  90813. * @returns "BaseTexture"
  90814. */
  90815. getClassName(): string;
  90816. /**
  90817. * Define the list of animation attached to the texture.
  90818. */
  90819. animations: Animation[];
  90820. /**
  90821. * An event triggered when the texture is disposed.
  90822. */
  90823. onDisposeObservable: Observable<BaseTexture>;
  90824. private _onDisposeObserver;
  90825. /**
  90826. * Callback triggered when the texture has been disposed.
  90827. * Kept for back compatibility, you can use the onDisposeObservable instead.
  90828. */
  90829. onDispose: () => void;
  90830. /**
  90831. * Define the current state of the loading sequence when in delayed load mode.
  90832. */
  90833. delayLoadState: number;
  90834. private _scene;
  90835. /** @hidden */
  90836. _texture: Nullable<InternalTexture>;
  90837. private _uid;
  90838. /**
  90839. * Define if the texture is preventinga material to render or not.
  90840. * If not and the texture is not ready, the engine will use a default black texture instead.
  90841. */
  90842. readonly isBlocking: boolean;
  90843. /**
  90844. * Instantiates a new BaseTexture.
  90845. * Base class of all the textures in babylon.
  90846. * It groups all the common properties the materials, post process, lights... might need
  90847. * in order to make a correct use of the texture.
  90848. * @param scene Define the scene the texture blongs to
  90849. */
  90850. constructor(scene: Nullable<Scene>);
  90851. /**
  90852. * Get the scene the texture belongs to.
  90853. * @returns the scene or null if undefined
  90854. */
  90855. getScene(): Nullable<Scene>;
  90856. /**
  90857. * Get the texture transform matrix used to offset tile the texture for istance.
  90858. * @returns the transformation matrix
  90859. */
  90860. getTextureMatrix(): Matrix;
  90861. /**
  90862. * Get the texture reflection matrix used to rotate/transform the reflection.
  90863. * @returns the reflection matrix
  90864. */
  90865. getReflectionTextureMatrix(): Matrix;
  90866. /**
  90867. * Get the underlying lower level texture from Babylon.
  90868. * @returns the insternal texture
  90869. */
  90870. getInternalTexture(): Nullable<InternalTexture>;
  90871. /**
  90872. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  90873. * @returns true if ready or not blocking
  90874. */
  90875. isReadyOrNotBlocking(): boolean;
  90876. /**
  90877. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  90878. * @returns true if fully ready
  90879. */
  90880. isReady(): boolean;
  90881. private _cachedSize;
  90882. /**
  90883. * Get the size of the texture.
  90884. * @returns the texture size.
  90885. */
  90886. getSize(): ISize;
  90887. /**
  90888. * Get the base size of the texture.
  90889. * It can be different from the size if the texture has been resized for POT for instance
  90890. * @returns the base size
  90891. */
  90892. getBaseSize(): ISize;
  90893. /**
  90894. * Update the sampling mode of the texture.
  90895. * Default is Trilinear mode.
  90896. *
  90897. * | Value | Type | Description |
  90898. * | ----- | ------------------ | ----------- |
  90899. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  90900. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  90901. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  90902. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  90903. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  90904. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  90905. * | 7 | NEAREST_LINEAR | |
  90906. * | 8 | NEAREST_NEAREST | |
  90907. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  90908. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  90909. * | 11 | LINEAR_LINEAR | |
  90910. * | 12 | LINEAR_NEAREST | |
  90911. *
  90912. * > _mag_: magnification filter (close to the viewer)
  90913. * > _min_: minification filter (far from the viewer)
  90914. * > _mip_: filter used between mip map levels
  90915. *@param samplingMode Define the new sampling mode of the texture
  90916. */
  90917. updateSamplingMode(samplingMode: number): void;
  90918. /**
  90919. * Scales the texture if is `canRescale()`
  90920. * @param ratio the resize factor we want to use to rescale
  90921. */
  90922. scale(ratio: number): void;
  90923. /**
  90924. * Get if the texture can rescale.
  90925. */
  90926. readonly canRescale: boolean;
  90927. /** @hidden */
  90928. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  90929. /** @hidden */
  90930. _rebuild(): void;
  90931. /**
  90932. * Triggers the load sequence in delayed load mode.
  90933. */
  90934. delayLoad(): void;
  90935. /**
  90936. * Clones the texture.
  90937. * @returns the cloned texture
  90938. */
  90939. clone(): Nullable<BaseTexture>;
  90940. /**
  90941. * Get the texture underlying type (INT, FLOAT...)
  90942. */
  90943. readonly textureType: number;
  90944. /**
  90945. * Get the texture underlying format (RGB, RGBA...)
  90946. */
  90947. readonly textureFormat: number;
  90948. /**
  90949. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  90950. * This will returns an RGBA array buffer containing either in values (0-255) or
  90951. * float values (0-1) depending of the underlying buffer type.
  90952. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  90953. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  90954. * @param buffer defines a user defined buffer to fill with data (can be null)
  90955. * @returns The Array buffer containing the pixels data.
  90956. */
  90957. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  90958. /**
  90959. * Release and destroy the underlying lower level texture aka internalTexture.
  90960. */
  90961. releaseInternalTexture(): void;
  90962. /**
  90963. * Get the polynomial representation of the texture data.
  90964. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  90965. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  90966. */
  90967. sphericalPolynomial: Nullable<SphericalPolynomial>;
  90968. /** @hidden */
  90969. readonly _lodTextureHigh: Nullable<BaseTexture>;
  90970. /** @hidden */
  90971. readonly _lodTextureMid: Nullable<BaseTexture>;
  90972. /** @hidden */
  90973. readonly _lodTextureLow: Nullable<BaseTexture>;
  90974. /**
  90975. * Dispose the texture and release its associated resources.
  90976. */
  90977. dispose(): void;
  90978. /**
  90979. * Serialize the texture into a JSON representation that can be parsed later on.
  90980. * @returns the JSON representation of the texture
  90981. */
  90982. serialize(): any;
  90983. /**
  90984. * Helper function to be called back once a list of texture contains only ready textures.
  90985. * @param textures Define the list of textures to wait for
  90986. * @param callback Define the callback triggered once the entire list will be ready
  90987. */
  90988. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  90989. }
  90990. }
  90991. declare module BABYLON {
  90992. /**
  90993. * Class used to store data associated with WebGL texture data for the engine
  90994. * This class should not be used directly
  90995. */
  90996. export class InternalTexture {
  90997. /** @hidden */
  90998. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  90999. /**
  91000. * The source of the texture data is unknown
  91001. */
  91002. static DATASOURCE_UNKNOWN: number;
  91003. /**
  91004. * Texture data comes from an URL
  91005. */
  91006. static DATASOURCE_URL: number;
  91007. /**
  91008. * Texture data is only used for temporary storage
  91009. */
  91010. static DATASOURCE_TEMP: number;
  91011. /**
  91012. * Texture data comes from raw data (ArrayBuffer)
  91013. */
  91014. static DATASOURCE_RAW: number;
  91015. /**
  91016. * Texture content is dynamic (video or dynamic texture)
  91017. */
  91018. static DATASOURCE_DYNAMIC: number;
  91019. /**
  91020. * Texture content is generated by rendering to it
  91021. */
  91022. static DATASOURCE_RENDERTARGET: number;
  91023. /**
  91024. * Texture content is part of a multi render target process
  91025. */
  91026. static DATASOURCE_MULTIRENDERTARGET: number;
  91027. /**
  91028. * Texture data comes from a cube data file
  91029. */
  91030. static DATASOURCE_CUBE: number;
  91031. /**
  91032. * Texture data comes from a raw cube data
  91033. */
  91034. static DATASOURCE_CUBERAW: number;
  91035. /**
  91036. * Texture data come from a prefiltered cube data file
  91037. */
  91038. static DATASOURCE_CUBEPREFILTERED: number;
  91039. /**
  91040. * Texture content is raw 3D data
  91041. */
  91042. static DATASOURCE_RAW3D: number;
  91043. /**
  91044. * Texture content is a depth texture
  91045. */
  91046. static DATASOURCE_DEPTHTEXTURE: number;
  91047. /**
  91048. * Texture data comes from a raw cube data encoded with RGBD
  91049. */
  91050. static DATASOURCE_CUBERAW_RGBD: number;
  91051. /**
  91052. * Defines if the texture is ready
  91053. */
  91054. isReady: boolean;
  91055. /**
  91056. * Defines if the texture is a cube texture
  91057. */
  91058. isCube: boolean;
  91059. /**
  91060. * Defines if the texture contains 3D data
  91061. */
  91062. is3D: boolean;
  91063. /**
  91064. * Defines if the texture contains multiview data
  91065. */
  91066. isMultiview: boolean;
  91067. /**
  91068. * Gets the URL used to load this texture
  91069. */
  91070. url: string;
  91071. /**
  91072. * Gets the sampling mode of the texture
  91073. */
  91074. samplingMode: number;
  91075. /**
  91076. * Gets a boolean indicating if the texture needs mipmaps generation
  91077. */
  91078. generateMipMaps: boolean;
  91079. /**
  91080. * Gets the number of samples used by the texture (WebGL2+ only)
  91081. */
  91082. samples: number;
  91083. /**
  91084. * Gets the type of the texture (int, float...)
  91085. */
  91086. type: number;
  91087. /**
  91088. * Gets the format of the texture (RGB, RGBA...)
  91089. */
  91090. format: number;
  91091. /**
  91092. * Observable called when the texture is loaded
  91093. */
  91094. onLoadedObservable: Observable<InternalTexture>;
  91095. /**
  91096. * Gets the width of the texture
  91097. */
  91098. width: number;
  91099. /**
  91100. * Gets the height of the texture
  91101. */
  91102. height: number;
  91103. /**
  91104. * Gets the depth of the texture
  91105. */
  91106. depth: number;
  91107. /**
  91108. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  91109. */
  91110. baseWidth: number;
  91111. /**
  91112. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  91113. */
  91114. baseHeight: number;
  91115. /**
  91116. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  91117. */
  91118. baseDepth: number;
  91119. /**
  91120. * Gets a boolean indicating if the texture is inverted on Y axis
  91121. */
  91122. invertY: boolean;
  91123. /** @hidden */
  91124. _invertVScale: boolean;
  91125. /** @hidden */
  91126. _associatedChannel: number;
  91127. /** @hidden */
  91128. _dataSource: number;
  91129. /** @hidden */
  91130. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  91131. /** @hidden */
  91132. _bufferView: Nullable<ArrayBufferView>;
  91133. /** @hidden */
  91134. _bufferViewArray: Nullable<ArrayBufferView[]>;
  91135. /** @hidden */
  91136. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  91137. /** @hidden */
  91138. _size: number;
  91139. /** @hidden */
  91140. _extension: string;
  91141. /** @hidden */
  91142. _files: Nullable<string[]>;
  91143. /** @hidden */
  91144. _workingCanvas: Nullable<HTMLCanvasElement>;
  91145. /** @hidden */
  91146. _workingContext: Nullable<CanvasRenderingContext2D>;
  91147. /** @hidden */
  91148. _framebuffer: Nullable<WebGLFramebuffer>;
  91149. /** @hidden */
  91150. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  91151. /** @hidden */
  91152. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  91153. /** @hidden */
  91154. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  91155. /** @hidden */
  91156. _attachments: Nullable<number[]>;
  91157. /** @hidden */
  91158. _cachedCoordinatesMode: Nullable<number>;
  91159. /** @hidden */
  91160. _cachedWrapU: Nullable<number>;
  91161. /** @hidden */
  91162. _cachedWrapV: Nullable<number>;
  91163. /** @hidden */
  91164. _cachedWrapR: Nullable<number>;
  91165. /** @hidden */
  91166. _cachedAnisotropicFilteringLevel: Nullable<number>;
  91167. /** @hidden */
  91168. _isDisabled: boolean;
  91169. /** @hidden */
  91170. _compression: Nullable<string>;
  91171. /** @hidden */
  91172. _generateStencilBuffer: boolean;
  91173. /** @hidden */
  91174. _generateDepthBuffer: boolean;
  91175. /** @hidden */
  91176. _comparisonFunction: number;
  91177. /** @hidden */
  91178. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  91179. /** @hidden */
  91180. _lodGenerationScale: number;
  91181. /** @hidden */
  91182. _lodGenerationOffset: number;
  91183. /** @hidden */
  91184. _colorTextureArray: Nullable<WebGLTexture>;
  91185. /** @hidden */
  91186. _depthStencilTextureArray: Nullable<WebGLTexture>;
  91187. /** @hidden */
  91188. _lodTextureHigh: Nullable<BaseTexture>;
  91189. /** @hidden */
  91190. _lodTextureMid: Nullable<BaseTexture>;
  91191. /** @hidden */
  91192. _lodTextureLow: Nullable<BaseTexture>;
  91193. /** @hidden */
  91194. _isRGBD: boolean;
  91195. /** @hidden */
  91196. _linearSpecularLOD: boolean;
  91197. /** @hidden */
  91198. _irradianceTexture: Nullable<BaseTexture>;
  91199. /** @hidden */
  91200. _webGLTexture: Nullable<WebGLTexture>;
  91201. /** @hidden */
  91202. _references: number;
  91203. private _engine;
  91204. /**
  91205. * Gets the Engine the texture belongs to.
  91206. * @returns The babylon engine
  91207. */
  91208. getEngine(): Engine;
  91209. /**
  91210. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  91211. */
  91212. readonly dataSource: number;
  91213. /**
  91214. * Creates a new InternalTexture
  91215. * @param engine defines the engine to use
  91216. * @param dataSource defines the type of data that will be used
  91217. * @param delayAllocation if the texture allocation should be delayed (default: false)
  91218. */
  91219. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  91220. /**
  91221. * Increments the number of references (ie. the number of Texture that point to it)
  91222. */
  91223. incrementReferences(): void;
  91224. /**
  91225. * Change the size of the texture (not the size of the content)
  91226. * @param width defines the new width
  91227. * @param height defines the new height
  91228. * @param depth defines the new depth (1 by default)
  91229. */
  91230. updateSize(width: int, height: int, depth?: int): void;
  91231. /** @hidden */
  91232. _rebuild(): void;
  91233. /** @hidden */
  91234. _swapAndDie(target: InternalTexture): void;
  91235. /**
  91236. * Dispose the current allocated resources
  91237. */
  91238. dispose(): void;
  91239. }
  91240. }
  91241. declare module BABYLON {
  91242. /**
  91243. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  91244. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  91245. */
  91246. export class EffectFallbacks {
  91247. private _defines;
  91248. private _currentRank;
  91249. private _maxRank;
  91250. private _mesh;
  91251. /**
  91252. * Removes the fallback from the bound mesh.
  91253. */
  91254. unBindMesh(): void;
  91255. /**
  91256. * Adds a fallback on the specified property.
  91257. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  91258. * @param define The name of the define in the shader
  91259. */
  91260. addFallback(rank: number, define: string): void;
  91261. /**
  91262. * Sets the mesh to use CPU skinning when needing to fallback.
  91263. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  91264. * @param mesh The mesh to use the fallbacks.
  91265. */
  91266. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  91267. /**
  91268. * Checks to see if more fallbacks are still availible.
  91269. */
  91270. readonly isMoreFallbacks: boolean;
  91271. /**
  91272. * Removes the defines that should be removed when falling back.
  91273. * @param currentDefines defines the current define statements for the shader.
  91274. * @param effect defines the current effect we try to compile
  91275. * @returns The resulting defines with defines of the current rank removed.
  91276. */
  91277. reduce(currentDefines: string, effect: Effect): string;
  91278. }
  91279. /**
  91280. * Options to be used when creating an effect.
  91281. */
  91282. export class EffectCreationOptions {
  91283. /**
  91284. * Atrributes that will be used in the shader.
  91285. */
  91286. attributes: string[];
  91287. /**
  91288. * Uniform varible names that will be set in the shader.
  91289. */
  91290. uniformsNames: string[];
  91291. /**
  91292. * Uniform buffer varible names that will be set in the shader.
  91293. */
  91294. uniformBuffersNames: string[];
  91295. /**
  91296. * Sampler texture variable names that will be set in the shader.
  91297. */
  91298. samplers: string[];
  91299. /**
  91300. * Define statements that will be set in the shader.
  91301. */
  91302. defines: any;
  91303. /**
  91304. * Possible fallbacks for this effect to improve performance when needed.
  91305. */
  91306. fallbacks: Nullable<EffectFallbacks>;
  91307. /**
  91308. * Callback that will be called when the shader is compiled.
  91309. */
  91310. onCompiled: Nullable<(effect: Effect) => void>;
  91311. /**
  91312. * Callback that will be called if an error occurs during shader compilation.
  91313. */
  91314. onError: Nullable<(effect: Effect, errors: string) => void>;
  91315. /**
  91316. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  91317. */
  91318. indexParameters: any;
  91319. /**
  91320. * Max number of lights that can be used in the shader.
  91321. */
  91322. maxSimultaneousLights: number;
  91323. /**
  91324. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  91325. */
  91326. transformFeedbackVaryings: Nullable<string[]>;
  91327. }
  91328. /**
  91329. * Effect containing vertex and fragment shader that can be executed on an object.
  91330. */
  91331. export class Effect implements IDisposable {
  91332. /**
  91333. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  91334. */
  91335. static ShadersRepository: string;
  91336. /**
  91337. * Name of the effect.
  91338. */
  91339. name: any;
  91340. /**
  91341. * String container all the define statements that should be set on the shader.
  91342. */
  91343. defines: string;
  91344. /**
  91345. * Callback that will be called when the shader is compiled.
  91346. */
  91347. onCompiled: Nullable<(effect: Effect) => void>;
  91348. /**
  91349. * Callback that will be called if an error occurs during shader compilation.
  91350. */
  91351. onError: Nullable<(effect: Effect, errors: string) => void>;
  91352. /**
  91353. * Callback that will be called when effect is bound.
  91354. */
  91355. onBind: Nullable<(effect: Effect) => void>;
  91356. /**
  91357. * Unique ID of the effect.
  91358. */
  91359. uniqueId: number;
  91360. /**
  91361. * Observable that will be called when the shader is compiled.
  91362. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  91363. */
  91364. onCompileObservable: Observable<Effect>;
  91365. /**
  91366. * Observable that will be called if an error occurs during shader compilation.
  91367. */
  91368. onErrorObservable: Observable<Effect>;
  91369. /** @hidden */
  91370. _onBindObservable: Nullable<Observable<Effect>>;
  91371. /**
  91372. * Observable that will be called when effect is bound.
  91373. */
  91374. readonly onBindObservable: Observable<Effect>;
  91375. /** @hidden */
  91376. _bonesComputationForcedToCPU: boolean;
  91377. private static _uniqueIdSeed;
  91378. private _engine;
  91379. private _uniformBuffersNames;
  91380. private _uniformsNames;
  91381. private _samplerList;
  91382. private _samplers;
  91383. private _isReady;
  91384. private _compilationError;
  91385. private _attributesNames;
  91386. private _attributes;
  91387. private _uniforms;
  91388. /**
  91389. * Key for the effect.
  91390. * @hidden
  91391. */
  91392. _key: string;
  91393. private _indexParameters;
  91394. private _fallbacks;
  91395. private _vertexSourceCode;
  91396. private _fragmentSourceCode;
  91397. private _vertexSourceCodeOverride;
  91398. private _fragmentSourceCodeOverride;
  91399. private _transformFeedbackVaryings;
  91400. /**
  91401. * Compiled shader to webGL program.
  91402. * @hidden
  91403. */
  91404. _pipelineContext: Nullable<IPipelineContext>;
  91405. private _valueCache;
  91406. private static _baseCache;
  91407. /**
  91408. * Instantiates an effect.
  91409. * An effect can be used to create/manage/execute vertex and fragment shaders.
  91410. * @param baseName Name of the effect.
  91411. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  91412. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  91413. * @param samplers List of sampler variables that will be passed to the shader.
  91414. * @param engine Engine to be used to render the effect
  91415. * @param defines Define statements to be added to the shader.
  91416. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  91417. * @param onCompiled Callback that will be called when the shader is compiled.
  91418. * @param onError Callback that will be called if an error occurs during shader compilation.
  91419. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  91420. */
  91421. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  91422. private _useFinalCode;
  91423. /**
  91424. * Unique key for this effect
  91425. */
  91426. readonly key: string;
  91427. /**
  91428. * If the effect has been compiled and prepared.
  91429. * @returns if the effect is compiled and prepared.
  91430. */
  91431. isReady(): boolean;
  91432. /**
  91433. * The engine the effect was initialized with.
  91434. * @returns the engine.
  91435. */
  91436. getEngine(): Engine;
  91437. /**
  91438. * The pipeline context for this effect
  91439. * @returns the associated pipeline context
  91440. */
  91441. getPipelineContext(): Nullable<IPipelineContext>;
  91442. /**
  91443. * The set of names of attribute variables for the shader.
  91444. * @returns An array of attribute names.
  91445. */
  91446. getAttributesNames(): string[];
  91447. /**
  91448. * Returns the attribute at the given index.
  91449. * @param index The index of the attribute.
  91450. * @returns The location of the attribute.
  91451. */
  91452. getAttributeLocation(index: number): number;
  91453. /**
  91454. * Returns the attribute based on the name of the variable.
  91455. * @param name of the attribute to look up.
  91456. * @returns the attribute location.
  91457. */
  91458. getAttributeLocationByName(name: string): number;
  91459. /**
  91460. * The number of attributes.
  91461. * @returns the numnber of attributes.
  91462. */
  91463. getAttributesCount(): number;
  91464. /**
  91465. * Gets the index of a uniform variable.
  91466. * @param uniformName of the uniform to look up.
  91467. * @returns the index.
  91468. */
  91469. getUniformIndex(uniformName: string): number;
  91470. /**
  91471. * Returns the attribute based on the name of the variable.
  91472. * @param uniformName of the uniform to look up.
  91473. * @returns the location of the uniform.
  91474. */
  91475. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  91476. /**
  91477. * Returns an array of sampler variable names
  91478. * @returns The array of sampler variable neames.
  91479. */
  91480. getSamplers(): string[];
  91481. /**
  91482. * The error from the last compilation.
  91483. * @returns the error string.
  91484. */
  91485. getCompilationError(): string;
  91486. /**
  91487. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  91488. * @param func The callback to be used.
  91489. */
  91490. executeWhenCompiled(func: (effect: Effect) => void): void;
  91491. private _checkIsReady;
  91492. /** @hidden */
  91493. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  91494. /** @hidden */
  91495. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  91496. /** @hidden */
  91497. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  91498. /**
  91499. * Recompiles the webGL program
  91500. * @param vertexSourceCode The source code for the vertex shader.
  91501. * @param fragmentSourceCode The source code for the fragment shader.
  91502. * @param onCompiled Callback called when completed.
  91503. * @param onError Callback called on error.
  91504. * @hidden
  91505. */
  91506. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  91507. /**
  91508. * Prepares the effect
  91509. * @hidden
  91510. */
  91511. _prepareEffect(): void;
  91512. /**
  91513. * Checks if the effect is supported. (Must be called after compilation)
  91514. */
  91515. readonly isSupported: boolean;
  91516. /**
  91517. * Binds a texture to the engine to be used as output of the shader.
  91518. * @param channel Name of the output variable.
  91519. * @param texture Texture to bind.
  91520. * @hidden
  91521. */
  91522. _bindTexture(channel: string, texture: InternalTexture): void;
  91523. /**
  91524. * Sets a texture on the engine to be used in the shader.
  91525. * @param channel Name of the sampler variable.
  91526. * @param texture Texture to set.
  91527. */
  91528. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  91529. /**
  91530. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  91531. * @param channel Name of the sampler variable.
  91532. * @param texture Texture to set.
  91533. */
  91534. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  91535. /**
  91536. * Sets an array of textures on the engine to be used in the shader.
  91537. * @param channel Name of the variable.
  91538. * @param textures Textures to set.
  91539. */
  91540. setTextureArray(channel: string, textures: BaseTexture[]): void;
  91541. /**
  91542. * 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)
  91543. * @param channel Name of the sampler variable.
  91544. * @param postProcess Post process to get the input texture from.
  91545. */
  91546. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  91547. /**
  91548. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  91549. * 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)
  91550. * @param channel Name of the sampler variable.
  91551. * @param postProcess Post process to get the output texture from.
  91552. */
  91553. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  91554. /** @hidden */
  91555. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  91556. /** @hidden */
  91557. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  91558. /** @hidden */
  91559. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  91560. /** @hidden */
  91561. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  91562. /**
  91563. * Binds a buffer to a uniform.
  91564. * @param buffer Buffer to bind.
  91565. * @param name Name of the uniform variable to bind to.
  91566. */
  91567. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  91568. /**
  91569. * Binds block to a uniform.
  91570. * @param blockName Name of the block to bind.
  91571. * @param index Index to bind.
  91572. */
  91573. bindUniformBlock(blockName: string, index: number): void;
  91574. /**
  91575. * Sets an interger value on a uniform variable.
  91576. * @param uniformName Name of the variable.
  91577. * @param value Value to be set.
  91578. * @returns this effect.
  91579. */
  91580. setInt(uniformName: string, value: number): Effect;
  91581. /**
  91582. * Sets an int array on a uniform variable.
  91583. * @param uniformName Name of the variable.
  91584. * @param array array to be set.
  91585. * @returns this effect.
  91586. */
  91587. setIntArray(uniformName: string, array: Int32Array): Effect;
  91588. /**
  91589. * 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)
  91590. * @param uniformName Name of the variable.
  91591. * @param array array to be set.
  91592. * @returns this effect.
  91593. */
  91594. setIntArray2(uniformName: string, array: Int32Array): Effect;
  91595. /**
  91596. * 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)
  91597. * @param uniformName Name of the variable.
  91598. * @param array array to be set.
  91599. * @returns this effect.
  91600. */
  91601. setIntArray3(uniformName: string, array: Int32Array): Effect;
  91602. /**
  91603. * 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)
  91604. * @param uniformName Name of the variable.
  91605. * @param array array to be set.
  91606. * @returns this effect.
  91607. */
  91608. setIntArray4(uniformName: string, array: Int32Array): Effect;
  91609. /**
  91610. * Sets an float array on a uniform variable.
  91611. * @param uniformName Name of the variable.
  91612. * @param array array to be set.
  91613. * @returns this effect.
  91614. */
  91615. setFloatArray(uniformName: string, array: Float32Array): Effect;
  91616. /**
  91617. * 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)
  91618. * @param uniformName Name of the variable.
  91619. * @param array array to be set.
  91620. * @returns this effect.
  91621. */
  91622. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  91623. /**
  91624. * 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)
  91625. * @param uniformName Name of the variable.
  91626. * @param array array to be set.
  91627. * @returns this effect.
  91628. */
  91629. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  91630. /**
  91631. * 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)
  91632. * @param uniformName Name of the variable.
  91633. * @param array array to be set.
  91634. * @returns this effect.
  91635. */
  91636. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  91637. /**
  91638. * Sets an array on a uniform variable.
  91639. * @param uniformName Name of the variable.
  91640. * @param array array to be set.
  91641. * @returns this effect.
  91642. */
  91643. setArray(uniformName: string, array: number[]): Effect;
  91644. /**
  91645. * 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)
  91646. * @param uniformName Name of the variable.
  91647. * @param array array to be set.
  91648. * @returns this effect.
  91649. */
  91650. setArray2(uniformName: string, array: number[]): Effect;
  91651. /**
  91652. * 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)
  91653. * @param uniformName Name of the variable.
  91654. * @param array array to be set.
  91655. * @returns this effect.
  91656. */
  91657. setArray3(uniformName: string, array: number[]): Effect;
  91658. /**
  91659. * 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)
  91660. * @param uniformName Name of the variable.
  91661. * @param array array to be set.
  91662. * @returns this effect.
  91663. */
  91664. setArray4(uniformName: string, array: number[]): Effect;
  91665. /**
  91666. * Sets matrices on a uniform variable.
  91667. * @param uniformName Name of the variable.
  91668. * @param matrices matrices to be set.
  91669. * @returns this effect.
  91670. */
  91671. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  91672. /**
  91673. * Sets matrix on a uniform variable.
  91674. * @param uniformName Name of the variable.
  91675. * @param matrix matrix to be set.
  91676. * @returns this effect.
  91677. */
  91678. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  91679. /**
  91680. * 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)
  91681. * @param uniformName Name of the variable.
  91682. * @param matrix matrix to be set.
  91683. * @returns this effect.
  91684. */
  91685. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  91686. /**
  91687. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  91688. * @param uniformName Name of the variable.
  91689. * @param matrix matrix to be set.
  91690. * @returns this effect.
  91691. */
  91692. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  91693. /**
  91694. * Sets a float on a uniform variable.
  91695. * @param uniformName Name of the variable.
  91696. * @param value value to be set.
  91697. * @returns this effect.
  91698. */
  91699. setFloat(uniformName: string, value: number): Effect;
  91700. /**
  91701. * Sets a boolean on a uniform variable.
  91702. * @param uniformName Name of the variable.
  91703. * @param bool value to be set.
  91704. * @returns this effect.
  91705. */
  91706. setBool(uniformName: string, bool: boolean): Effect;
  91707. /**
  91708. * Sets a Vector2 on a uniform variable.
  91709. * @param uniformName Name of the variable.
  91710. * @param vector2 vector2 to be set.
  91711. * @returns this effect.
  91712. */
  91713. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  91714. /**
  91715. * Sets a float2 on a uniform variable.
  91716. * @param uniformName Name of the variable.
  91717. * @param x First float in float2.
  91718. * @param y Second float in float2.
  91719. * @returns this effect.
  91720. */
  91721. setFloat2(uniformName: string, x: number, y: number): Effect;
  91722. /**
  91723. * Sets a Vector3 on a uniform variable.
  91724. * @param uniformName Name of the variable.
  91725. * @param vector3 Value to be set.
  91726. * @returns this effect.
  91727. */
  91728. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  91729. /**
  91730. * Sets a float3 on a uniform variable.
  91731. * @param uniformName Name of the variable.
  91732. * @param x First float in float3.
  91733. * @param y Second float in float3.
  91734. * @param z Third float in float3.
  91735. * @returns this effect.
  91736. */
  91737. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  91738. /**
  91739. * Sets a Vector4 on a uniform variable.
  91740. * @param uniformName Name of the variable.
  91741. * @param vector4 Value to be set.
  91742. * @returns this effect.
  91743. */
  91744. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  91745. /**
  91746. * Sets a float4 on a uniform variable.
  91747. * @param uniformName Name of the variable.
  91748. * @param x First float in float4.
  91749. * @param y Second float in float4.
  91750. * @param z Third float in float4.
  91751. * @param w Fourth float in float4.
  91752. * @returns this effect.
  91753. */
  91754. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  91755. /**
  91756. * Sets a Color3 on a uniform variable.
  91757. * @param uniformName Name of the variable.
  91758. * @param color3 Value to be set.
  91759. * @returns this effect.
  91760. */
  91761. setColor3(uniformName: string, color3: IColor3Like): Effect;
  91762. /**
  91763. * Sets a Color4 on a uniform variable.
  91764. * @param uniformName Name of the variable.
  91765. * @param color3 Value to be set.
  91766. * @param alpha Alpha value to be set.
  91767. * @returns this effect.
  91768. */
  91769. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  91770. /**
  91771. * Sets a Color4 on a uniform variable
  91772. * @param uniformName defines the name of the variable
  91773. * @param color4 defines the value to be set
  91774. * @returns this effect.
  91775. */
  91776. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  91777. /** Release all associated resources */
  91778. dispose(): void;
  91779. /**
  91780. * This function will add a new shader to the shader store
  91781. * @param name the name of the shader
  91782. * @param pixelShader optional pixel shader content
  91783. * @param vertexShader optional vertex shader content
  91784. */
  91785. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  91786. /**
  91787. * Store of each shader (The can be looked up using effect.key)
  91788. */
  91789. static ShadersStore: {
  91790. [key: string]: string;
  91791. };
  91792. /**
  91793. * Store of each included file for a shader (The can be looked up using effect.key)
  91794. */
  91795. static IncludesShadersStore: {
  91796. [key: string]: string;
  91797. };
  91798. /**
  91799. * Resets the cache of effects.
  91800. */
  91801. static ResetCache(): void;
  91802. }
  91803. }
  91804. declare module BABYLON {
  91805. /**
  91806. * Uniform buffer objects.
  91807. *
  91808. * Handles blocks of uniform on the GPU.
  91809. *
  91810. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  91811. *
  91812. * For more information, please refer to :
  91813. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  91814. */
  91815. export class UniformBuffer {
  91816. private _engine;
  91817. private _buffer;
  91818. private _data;
  91819. private _bufferData;
  91820. private _dynamic?;
  91821. private _uniformLocations;
  91822. private _uniformSizes;
  91823. private _uniformLocationPointer;
  91824. private _needSync;
  91825. private _noUBO;
  91826. private _currentEffect;
  91827. private static _MAX_UNIFORM_SIZE;
  91828. private static _tempBuffer;
  91829. /**
  91830. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  91831. * This is dynamic to allow compat with webgl 1 and 2.
  91832. * You will need to pass the name of the uniform as well as the value.
  91833. */
  91834. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  91835. /**
  91836. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  91837. * This is dynamic to allow compat with webgl 1 and 2.
  91838. * You will need to pass the name of the uniform as well as the value.
  91839. */
  91840. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  91841. /**
  91842. * Lambda to Update a single float in a uniform buffer.
  91843. * This is dynamic to allow compat with webgl 1 and 2.
  91844. * You will need to pass the name of the uniform as well as the value.
  91845. */
  91846. updateFloat: (name: string, x: number) => void;
  91847. /**
  91848. * Lambda to Update a vec2 of float in a uniform buffer.
  91849. * This is dynamic to allow compat with webgl 1 and 2.
  91850. * You will need to pass the name of the uniform as well as the value.
  91851. */
  91852. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  91853. /**
  91854. * Lambda to Update a vec3 of float in a uniform buffer.
  91855. * This is dynamic to allow compat with webgl 1 and 2.
  91856. * You will need to pass the name of the uniform as well as the value.
  91857. */
  91858. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  91859. /**
  91860. * Lambda to Update a vec4 of float in a uniform buffer.
  91861. * This is dynamic to allow compat with webgl 1 and 2.
  91862. * You will need to pass the name of the uniform as well as the value.
  91863. */
  91864. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  91865. /**
  91866. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  91867. * This is dynamic to allow compat with webgl 1 and 2.
  91868. * You will need to pass the name of the uniform as well as the value.
  91869. */
  91870. updateMatrix: (name: string, mat: Matrix) => void;
  91871. /**
  91872. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  91873. * This is dynamic to allow compat with webgl 1 and 2.
  91874. * You will need to pass the name of the uniform as well as the value.
  91875. */
  91876. updateVector3: (name: string, vector: Vector3) => void;
  91877. /**
  91878. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  91879. * This is dynamic to allow compat with webgl 1 and 2.
  91880. * You will need to pass the name of the uniform as well as the value.
  91881. */
  91882. updateVector4: (name: string, vector: Vector4) => void;
  91883. /**
  91884. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  91885. * This is dynamic to allow compat with webgl 1 and 2.
  91886. * You will need to pass the name of the uniform as well as the value.
  91887. */
  91888. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  91889. /**
  91890. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  91891. * This is dynamic to allow compat with webgl 1 and 2.
  91892. * You will need to pass the name of the uniform as well as the value.
  91893. */
  91894. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  91895. /**
  91896. * Instantiates a new Uniform buffer objects.
  91897. *
  91898. * Handles blocks of uniform on the GPU.
  91899. *
  91900. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  91901. *
  91902. * For more information, please refer to :
  91903. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  91904. * @param engine Define the engine the buffer is associated with
  91905. * @param data Define the data contained in the buffer
  91906. * @param dynamic Define if the buffer is updatable
  91907. */
  91908. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  91909. /**
  91910. * Indicates if the buffer is using the WebGL2 UBO implementation,
  91911. * or just falling back on setUniformXXX calls.
  91912. */
  91913. readonly useUbo: boolean;
  91914. /**
  91915. * Indicates if the WebGL underlying uniform buffer is in sync
  91916. * with the javascript cache data.
  91917. */
  91918. readonly isSync: boolean;
  91919. /**
  91920. * Indicates if the WebGL underlying uniform buffer is dynamic.
  91921. * Also, a dynamic UniformBuffer will disable cache verification and always
  91922. * update the underlying WebGL uniform buffer to the GPU.
  91923. * @returns if Dynamic, otherwise false
  91924. */
  91925. isDynamic(): boolean;
  91926. /**
  91927. * The data cache on JS side.
  91928. * @returns the underlying data as a float array
  91929. */
  91930. getData(): Float32Array;
  91931. /**
  91932. * The underlying WebGL Uniform buffer.
  91933. * @returns the webgl buffer
  91934. */
  91935. getBuffer(): Nullable<DataBuffer>;
  91936. /**
  91937. * std140 layout specifies how to align data within an UBO structure.
  91938. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  91939. * for specs.
  91940. */
  91941. private _fillAlignment;
  91942. /**
  91943. * Adds an uniform in the buffer.
  91944. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  91945. * for the layout to be correct !
  91946. * @param name Name of the uniform, as used in the uniform block in the shader.
  91947. * @param size Data size, or data directly.
  91948. */
  91949. addUniform(name: string, size: number | number[]): void;
  91950. /**
  91951. * Adds a Matrix 4x4 to the uniform buffer.
  91952. * @param name Name of the uniform, as used in the uniform block in the shader.
  91953. * @param mat A 4x4 matrix.
  91954. */
  91955. addMatrix(name: string, mat: Matrix): void;
  91956. /**
  91957. * Adds a vec2 to the uniform buffer.
  91958. * @param name Name of the uniform, as used in the uniform block in the shader.
  91959. * @param x Define the x component value of the vec2
  91960. * @param y Define the y component value of the vec2
  91961. */
  91962. addFloat2(name: string, x: number, y: number): void;
  91963. /**
  91964. * Adds a vec3 to the uniform buffer.
  91965. * @param name Name of the uniform, as used in the uniform block in the shader.
  91966. * @param x Define the x component value of the vec3
  91967. * @param y Define the y component value of the vec3
  91968. * @param z Define the z component value of the vec3
  91969. */
  91970. addFloat3(name: string, x: number, y: number, z: number): void;
  91971. /**
  91972. * Adds a vec3 to the uniform buffer.
  91973. * @param name Name of the uniform, as used in the uniform block in the shader.
  91974. * @param color Define the vec3 from a Color
  91975. */
  91976. addColor3(name: string, color: Color3): void;
  91977. /**
  91978. * Adds a vec4 to the uniform buffer.
  91979. * @param name Name of the uniform, as used in the uniform block in the shader.
  91980. * @param color Define the rgb components from a Color
  91981. * @param alpha Define the a component of the vec4
  91982. */
  91983. addColor4(name: string, color: Color3, alpha: number): void;
  91984. /**
  91985. * Adds a vec3 to the uniform buffer.
  91986. * @param name Name of the uniform, as used in the uniform block in the shader.
  91987. * @param vector Define the vec3 components from a Vector
  91988. */
  91989. addVector3(name: string, vector: Vector3): void;
  91990. /**
  91991. * Adds a Matrix 3x3 to the uniform buffer.
  91992. * @param name Name of the uniform, as used in the uniform block in the shader.
  91993. */
  91994. addMatrix3x3(name: string): void;
  91995. /**
  91996. * Adds a Matrix 2x2 to the uniform buffer.
  91997. * @param name Name of the uniform, as used in the uniform block in the shader.
  91998. */
  91999. addMatrix2x2(name: string): void;
  92000. /**
  92001. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  92002. */
  92003. create(): void;
  92004. /** @hidden */
  92005. _rebuild(): void;
  92006. /**
  92007. * Updates the WebGL Uniform Buffer on the GPU.
  92008. * If the `dynamic` flag is set to true, no cache comparison is done.
  92009. * Otherwise, the buffer will be updated only if the cache differs.
  92010. */
  92011. update(): void;
  92012. /**
  92013. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  92014. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  92015. * @param data Define the flattened data
  92016. * @param size Define the size of the data.
  92017. */
  92018. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  92019. private _updateMatrix3x3ForUniform;
  92020. private _updateMatrix3x3ForEffect;
  92021. private _updateMatrix2x2ForEffect;
  92022. private _updateMatrix2x2ForUniform;
  92023. private _updateFloatForEffect;
  92024. private _updateFloatForUniform;
  92025. private _updateFloat2ForEffect;
  92026. private _updateFloat2ForUniform;
  92027. private _updateFloat3ForEffect;
  92028. private _updateFloat3ForUniform;
  92029. private _updateFloat4ForEffect;
  92030. private _updateFloat4ForUniform;
  92031. private _updateMatrixForEffect;
  92032. private _updateMatrixForUniform;
  92033. private _updateVector3ForEffect;
  92034. private _updateVector3ForUniform;
  92035. private _updateVector4ForEffect;
  92036. private _updateVector4ForUniform;
  92037. private _updateColor3ForEffect;
  92038. private _updateColor3ForUniform;
  92039. private _updateColor4ForEffect;
  92040. private _updateColor4ForUniform;
  92041. /**
  92042. * Sets a sampler uniform on the effect.
  92043. * @param name Define the name of the sampler.
  92044. * @param texture Define the texture to set in the sampler
  92045. */
  92046. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  92047. /**
  92048. * Directly updates the value of the uniform in the cache AND on the GPU.
  92049. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  92050. * @param data Define the flattened data
  92051. */
  92052. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  92053. /**
  92054. * Binds this uniform buffer to an effect.
  92055. * @param effect Define the effect to bind the buffer to
  92056. * @param name Name of the uniform block in the shader.
  92057. */
  92058. bindToEffect(effect: Effect, name: string): void;
  92059. /**
  92060. * Disposes the uniform buffer.
  92061. */
  92062. dispose(): void;
  92063. }
  92064. }
  92065. declare module BABYLON {
  92066. /**
  92067. * Class used to work with sound analyzer using fast fourier transform (FFT)
  92068. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92069. */
  92070. export class Analyser {
  92071. /**
  92072. * Gets or sets the smoothing
  92073. * @ignorenaming
  92074. */
  92075. SMOOTHING: number;
  92076. /**
  92077. * Gets or sets the FFT table size
  92078. * @ignorenaming
  92079. */
  92080. FFT_SIZE: number;
  92081. /**
  92082. * Gets or sets the bar graph amplitude
  92083. * @ignorenaming
  92084. */
  92085. BARGRAPHAMPLITUDE: number;
  92086. /**
  92087. * Gets or sets the position of the debug canvas
  92088. * @ignorenaming
  92089. */
  92090. DEBUGCANVASPOS: {
  92091. x: number;
  92092. y: number;
  92093. };
  92094. /**
  92095. * Gets or sets the debug canvas size
  92096. * @ignorenaming
  92097. */
  92098. DEBUGCANVASSIZE: {
  92099. width: number;
  92100. height: number;
  92101. };
  92102. private _byteFreqs;
  92103. private _byteTime;
  92104. private _floatFreqs;
  92105. private _webAudioAnalyser;
  92106. private _debugCanvas;
  92107. private _debugCanvasContext;
  92108. private _scene;
  92109. private _registerFunc;
  92110. private _audioEngine;
  92111. /**
  92112. * Creates a new analyser
  92113. * @param scene defines hosting scene
  92114. */
  92115. constructor(scene: Scene);
  92116. /**
  92117. * Get the number of data values you will have to play with for the visualization
  92118. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  92119. * @returns a number
  92120. */
  92121. getFrequencyBinCount(): number;
  92122. /**
  92123. * Gets the current frequency data as a byte array
  92124. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  92125. * @returns a Uint8Array
  92126. */
  92127. getByteFrequencyData(): Uint8Array;
  92128. /**
  92129. * Gets the current waveform as a byte array
  92130. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  92131. * @returns a Uint8Array
  92132. */
  92133. getByteTimeDomainData(): Uint8Array;
  92134. /**
  92135. * Gets the current frequency data as a float array
  92136. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  92137. * @returns a Float32Array
  92138. */
  92139. getFloatFrequencyData(): Float32Array;
  92140. /**
  92141. * Renders the debug canvas
  92142. */
  92143. drawDebugCanvas(): void;
  92144. /**
  92145. * Stops rendering the debug canvas and removes it
  92146. */
  92147. stopDebugCanvas(): void;
  92148. /**
  92149. * Connects two audio nodes
  92150. * @param inputAudioNode defines first node to connect
  92151. * @param outputAudioNode defines second node to connect
  92152. */
  92153. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  92154. /**
  92155. * Releases all associated resources
  92156. */
  92157. dispose(): void;
  92158. }
  92159. }
  92160. declare module BABYLON {
  92161. /**
  92162. * This represents an audio engine and it is responsible
  92163. * to play, synchronize and analyse sounds throughout the application.
  92164. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92165. */
  92166. export interface IAudioEngine extends IDisposable {
  92167. /**
  92168. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  92169. */
  92170. readonly canUseWebAudio: boolean;
  92171. /**
  92172. * Gets the current AudioContext if available.
  92173. */
  92174. readonly audioContext: Nullable<AudioContext>;
  92175. /**
  92176. * The master gain node defines the global audio volume of your audio engine.
  92177. */
  92178. readonly masterGain: GainNode;
  92179. /**
  92180. * Gets whether or not mp3 are supported by your browser.
  92181. */
  92182. readonly isMP3supported: boolean;
  92183. /**
  92184. * Gets whether or not ogg are supported by your browser.
  92185. */
  92186. readonly isOGGsupported: boolean;
  92187. /**
  92188. * Defines if Babylon should emit a warning if WebAudio is not supported.
  92189. * @ignoreNaming
  92190. */
  92191. WarnedWebAudioUnsupported: boolean;
  92192. /**
  92193. * Defines if the audio engine relies on a custom unlocked button.
  92194. * In this case, the embedded button will not be displayed.
  92195. */
  92196. useCustomUnlockedButton: boolean;
  92197. /**
  92198. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  92199. */
  92200. readonly unlocked: boolean;
  92201. /**
  92202. * Event raised when audio has been unlocked on the browser.
  92203. */
  92204. onAudioUnlockedObservable: Observable<AudioEngine>;
  92205. /**
  92206. * Event raised when audio has been locked on the browser.
  92207. */
  92208. onAudioLockedObservable: Observable<AudioEngine>;
  92209. /**
  92210. * Flags the audio engine in Locked state.
  92211. * This happens due to new browser policies preventing audio to autoplay.
  92212. */
  92213. lock(): void;
  92214. /**
  92215. * Unlocks the audio engine once a user action has been done on the dom.
  92216. * This is helpful to resume play once browser policies have been satisfied.
  92217. */
  92218. unlock(): void;
  92219. }
  92220. /**
  92221. * This represents the default audio engine used in babylon.
  92222. * It is responsible to play, synchronize and analyse sounds throughout the application.
  92223. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92224. */
  92225. export class AudioEngine implements IAudioEngine {
  92226. private _audioContext;
  92227. private _audioContextInitialized;
  92228. private _muteButton;
  92229. private _hostElement;
  92230. /**
  92231. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  92232. */
  92233. canUseWebAudio: boolean;
  92234. /**
  92235. * The master gain node defines the global audio volume of your audio engine.
  92236. */
  92237. masterGain: GainNode;
  92238. /**
  92239. * Defines if Babylon should emit a warning if WebAudio is not supported.
  92240. * @ignoreNaming
  92241. */
  92242. WarnedWebAudioUnsupported: boolean;
  92243. /**
  92244. * Gets whether or not mp3 are supported by your browser.
  92245. */
  92246. isMP3supported: boolean;
  92247. /**
  92248. * Gets whether or not ogg are supported by your browser.
  92249. */
  92250. isOGGsupported: boolean;
  92251. /**
  92252. * Gets whether audio has been unlocked on the device.
  92253. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  92254. * a user interaction has happened.
  92255. */
  92256. unlocked: boolean;
  92257. /**
  92258. * Defines if the audio engine relies on a custom unlocked button.
  92259. * In this case, the embedded button will not be displayed.
  92260. */
  92261. useCustomUnlockedButton: boolean;
  92262. /**
  92263. * Event raised when audio has been unlocked on the browser.
  92264. */
  92265. onAudioUnlockedObservable: Observable<AudioEngine>;
  92266. /**
  92267. * Event raised when audio has been locked on the browser.
  92268. */
  92269. onAudioLockedObservable: Observable<AudioEngine>;
  92270. /**
  92271. * Gets the current AudioContext if available.
  92272. */
  92273. readonly audioContext: Nullable<AudioContext>;
  92274. private _connectedAnalyser;
  92275. /**
  92276. * Instantiates a new audio engine.
  92277. *
  92278. * There should be only one per page as some browsers restrict the number
  92279. * of audio contexts you can create.
  92280. * @param hostElement defines the host element where to display the mute icon if necessary
  92281. */
  92282. constructor(hostElement?: Nullable<HTMLElement>);
  92283. /**
  92284. * Flags the audio engine in Locked state.
  92285. * This happens due to new browser policies preventing audio to autoplay.
  92286. */
  92287. lock(): void;
  92288. /**
  92289. * Unlocks the audio engine once a user action has been done on the dom.
  92290. * This is helpful to resume play once browser policies have been satisfied.
  92291. */
  92292. unlock(): void;
  92293. private _resumeAudioContext;
  92294. private _initializeAudioContext;
  92295. private _tryToRun;
  92296. private _triggerRunningState;
  92297. private _triggerSuspendedState;
  92298. private _displayMuteButton;
  92299. private _moveButtonToTopLeft;
  92300. private _onResize;
  92301. private _hideMuteButton;
  92302. /**
  92303. * Destroy and release the resources associated with the audio ccontext.
  92304. */
  92305. dispose(): void;
  92306. /**
  92307. * Gets the global volume sets on the master gain.
  92308. * @returns the global volume if set or -1 otherwise
  92309. */
  92310. getGlobalVolume(): number;
  92311. /**
  92312. * Sets the global volume of your experience (sets on the master gain).
  92313. * @param newVolume Defines the new global volume of the application
  92314. */
  92315. setGlobalVolume(newVolume: number): void;
  92316. /**
  92317. * Connect the audio engine to an audio analyser allowing some amazing
  92318. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  92319. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  92320. * @param analyser The analyser to connect to the engine
  92321. */
  92322. connectToAnalyser(analyser: Analyser): void;
  92323. }
  92324. }
  92325. declare module BABYLON {
  92326. /**
  92327. * Interface used to present a loading screen while loading a scene
  92328. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92329. */
  92330. export interface ILoadingScreen {
  92331. /**
  92332. * Function called to display the loading screen
  92333. */
  92334. displayLoadingUI: () => void;
  92335. /**
  92336. * Function called to hide the loading screen
  92337. */
  92338. hideLoadingUI: () => void;
  92339. /**
  92340. * Gets or sets the color to use for the background
  92341. */
  92342. loadingUIBackgroundColor: string;
  92343. /**
  92344. * Gets or sets the text to display while loading
  92345. */
  92346. loadingUIText: string;
  92347. }
  92348. /**
  92349. * Class used for the default loading screen
  92350. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92351. */
  92352. export class DefaultLoadingScreen implements ILoadingScreen {
  92353. private _renderingCanvas;
  92354. private _loadingText;
  92355. private _loadingDivBackgroundColor;
  92356. private _loadingDiv;
  92357. private _loadingTextDiv;
  92358. /** Gets or sets the logo url to use for the default loading screen */
  92359. static DefaultLogoUrl: string;
  92360. /** Gets or sets the spinner url to use for the default loading screen */
  92361. static DefaultSpinnerUrl: string;
  92362. /**
  92363. * Creates a new default loading screen
  92364. * @param _renderingCanvas defines the canvas used to render the scene
  92365. * @param _loadingText defines the default text to display
  92366. * @param _loadingDivBackgroundColor defines the default background color
  92367. */
  92368. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  92369. /**
  92370. * Function called to display the loading screen
  92371. */
  92372. displayLoadingUI(): void;
  92373. /**
  92374. * Function called to hide the loading screen
  92375. */
  92376. hideLoadingUI(): void;
  92377. /**
  92378. * Gets or sets the text to display while loading
  92379. */
  92380. loadingUIText: string;
  92381. /**
  92382. * Gets or sets the color to use for the background
  92383. */
  92384. loadingUIBackgroundColor: string;
  92385. private _resizeLoadingUI;
  92386. }
  92387. }
  92388. declare module BABYLON {
  92389. /** @hidden */
  92390. export class WebGLPipelineContext implements IPipelineContext {
  92391. engine: Engine;
  92392. program: Nullable<WebGLProgram>;
  92393. context?: WebGLRenderingContext;
  92394. vertexShader?: WebGLShader;
  92395. fragmentShader?: WebGLShader;
  92396. isParallelCompiled: boolean;
  92397. onCompiled?: () => void;
  92398. transformFeedback?: WebGLTransformFeedback | null;
  92399. readonly isAsync: boolean;
  92400. readonly isReady: boolean;
  92401. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  92402. }
  92403. }
  92404. declare module BABYLON {
  92405. /** @hidden */
  92406. export class WebGLDataBuffer extends DataBuffer {
  92407. private _buffer;
  92408. constructor(resource: WebGLBuffer);
  92409. readonly underlyingResource: any;
  92410. }
  92411. }
  92412. declare module BABYLON {
  92413. /** @hidden */
  92414. export class WebGL2ShaderProcessor implements IShaderProcessor {
  92415. attributeProcessor(attribute: string): string;
  92416. varyingProcessor(varying: string, isFragment: boolean): string;
  92417. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  92418. }
  92419. }
  92420. declare module BABYLON {
  92421. /**
  92422. * This class is used to track a performance counter which is number based.
  92423. * The user has access to many properties which give statistics of different nature.
  92424. *
  92425. * The implementer can track two kinds of Performance Counter: time and count.
  92426. * 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.
  92427. * 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.
  92428. */
  92429. export class PerfCounter {
  92430. /**
  92431. * Gets or sets a global boolean to turn on and off all the counters
  92432. */
  92433. static Enabled: boolean;
  92434. /**
  92435. * Returns the smallest value ever
  92436. */
  92437. readonly min: number;
  92438. /**
  92439. * Returns the biggest value ever
  92440. */
  92441. readonly max: number;
  92442. /**
  92443. * Returns the average value since the performance counter is running
  92444. */
  92445. readonly average: number;
  92446. /**
  92447. * Returns the average value of the last second the counter was monitored
  92448. */
  92449. readonly lastSecAverage: number;
  92450. /**
  92451. * Returns the current value
  92452. */
  92453. readonly current: number;
  92454. /**
  92455. * Gets the accumulated total
  92456. */
  92457. readonly total: number;
  92458. /**
  92459. * Gets the total value count
  92460. */
  92461. readonly count: number;
  92462. /**
  92463. * Creates a new counter
  92464. */
  92465. constructor();
  92466. /**
  92467. * Call this method to start monitoring a new frame.
  92468. * 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.
  92469. */
  92470. fetchNewFrame(): void;
  92471. /**
  92472. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  92473. * @param newCount the count value to add to the monitored count
  92474. * @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.
  92475. */
  92476. addCount(newCount: number, fetchResult: boolean): void;
  92477. /**
  92478. * Start monitoring this performance counter
  92479. */
  92480. beginMonitoring(): void;
  92481. /**
  92482. * Compute the time lapsed since the previous beginMonitoring() call.
  92483. * @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
  92484. */
  92485. endMonitoring(newFrame?: boolean): void;
  92486. private _fetchResult;
  92487. private _startMonitoringTime;
  92488. private _min;
  92489. private _max;
  92490. private _average;
  92491. private _current;
  92492. private _totalValueCount;
  92493. private _totalAccumulated;
  92494. private _lastSecAverage;
  92495. private _lastSecAccumulated;
  92496. private _lastSecTime;
  92497. private _lastSecValueCount;
  92498. }
  92499. }
  92500. declare module BABYLON {
  92501. /**
  92502. * Interface for any object that can request an animation frame
  92503. */
  92504. export interface ICustomAnimationFrameRequester {
  92505. /**
  92506. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  92507. */
  92508. renderFunction?: Function;
  92509. /**
  92510. * Called to request the next frame to render to
  92511. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  92512. */
  92513. requestAnimationFrame: Function;
  92514. /**
  92515. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  92516. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  92517. */
  92518. requestID?: number;
  92519. }
  92520. }
  92521. declare module BABYLON {
  92522. /**
  92523. * Settings for finer control over video usage
  92524. */
  92525. export interface VideoTextureSettings {
  92526. /**
  92527. * Applies `autoplay` to video, if specified
  92528. */
  92529. autoPlay?: boolean;
  92530. /**
  92531. * Applies `loop` to video, if specified
  92532. */
  92533. loop?: boolean;
  92534. /**
  92535. * Automatically updates internal texture from video at every frame in the render loop
  92536. */
  92537. autoUpdateTexture: boolean;
  92538. /**
  92539. * Image src displayed during the video loading or until the user interacts with the video.
  92540. */
  92541. poster?: string;
  92542. }
  92543. /**
  92544. * If you want to display a video in your scene, this is the special texture for that.
  92545. * This special texture works similar to other textures, with the exception of a few parameters.
  92546. * @see https://doc.babylonjs.com/how_to/video_texture
  92547. */
  92548. export class VideoTexture extends Texture {
  92549. /**
  92550. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  92551. */
  92552. readonly autoUpdateTexture: boolean;
  92553. /**
  92554. * The video instance used by the texture internally
  92555. */
  92556. readonly video: HTMLVideoElement;
  92557. private _onUserActionRequestedObservable;
  92558. /**
  92559. * Event triggerd when a dom action is required by the user to play the video.
  92560. * This happens due to recent changes in browser policies preventing video to auto start.
  92561. */
  92562. readonly onUserActionRequestedObservable: Observable<Texture>;
  92563. private _generateMipMaps;
  92564. private _engine;
  92565. private _stillImageCaptured;
  92566. private _displayingPosterTexture;
  92567. private _settings;
  92568. private _createInternalTextureOnEvent;
  92569. /**
  92570. * Creates a video texture.
  92571. * If you want to display a video in your scene, this is the special texture for that.
  92572. * This special texture works similar to other textures, with the exception of a few parameters.
  92573. * @see https://doc.babylonjs.com/how_to/video_texture
  92574. * @param name optional name, will detect from video source, if not defined
  92575. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  92576. * @param scene is obviously the current scene.
  92577. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  92578. * @param invertY is false by default but can be used to invert video on Y axis
  92579. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  92580. * @param settings allows finer control over video usage
  92581. */
  92582. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  92583. private _getName;
  92584. private _getVideo;
  92585. private _createInternalTexture;
  92586. private reset;
  92587. /**
  92588. * @hidden Internal method to initiate `update`.
  92589. */
  92590. _rebuild(): void;
  92591. /**
  92592. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  92593. */
  92594. update(): void;
  92595. /**
  92596. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  92597. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  92598. */
  92599. updateTexture(isVisible: boolean): void;
  92600. protected _updateInternalTexture: () => void;
  92601. /**
  92602. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  92603. * @param url New url.
  92604. */
  92605. updateURL(url: string): void;
  92606. /**
  92607. * Dispose the texture and release its associated resources.
  92608. */
  92609. dispose(): void;
  92610. /**
  92611. * Creates a video texture straight from a stream.
  92612. * @param scene Define the scene the texture should be created in
  92613. * @param stream Define the stream the texture should be created from
  92614. * @returns The created video texture as a promise
  92615. */
  92616. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  92617. /**
  92618. * Creates a video texture straight from your WebCam video feed.
  92619. * @param scene Define the scene the texture should be created in
  92620. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  92621. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  92622. * @returns The created video texture as a promise
  92623. */
  92624. static CreateFromWebCamAsync(scene: Scene, constraints: {
  92625. minWidth: number;
  92626. maxWidth: number;
  92627. minHeight: number;
  92628. maxHeight: number;
  92629. deviceId: string;
  92630. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  92631. /**
  92632. * Creates a video texture straight from your WebCam video feed.
  92633. * @param scene Define the scene the texture should be created in
  92634. * @param onReady Define a callback to triggered once the texture will be ready
  92635. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  92636. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  92637. */
  92638. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  92639. minWidth: number;
  92640. maxWidth: number;
  92641. minHeight: number;
  92642. maxHeight: number;
  92643. deviceId: string;
  92644. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  92645. }
  92646. }
  92647. declare module BABYLON {
  92648. /**
  92649. * Defines the interface used by objects containing a viewport (like a camera)
  92650. */
  92651. interface IViewportOwnerLike {
  92652. /**
  92653. * Gets or sets the viewport
  92654. */
  92655. viewport: IViewportLike;
  92656. }
  92657. /**
  92658. * Interface for attribute information associated with buffer instanciation
  92659. */
  92660. export class InstancingAttributeInfo {
  92661. /**
  92662. * Index/offset of the attribute in the vertex shader
  92663. */
  92664. index: number;
  92665. /**
  92666. * size of the attribute, 1, 2, 3 or 4
  92667. */
  92668. attributeSize: number;
  92669. /**
  92670. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  92671. * default is FLOAT
  92672. */
  92673. attribyteType: number;
  92674. /**
  92675. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  92676. */
  92677. normalized: boolean;
  92678. /**
  92679. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  92680. */
  92681. offset: number;
  92682. /**
  92683. * Name of the GLSL attribute, for debugging purpose only
  92684. */
  92685. attributeName: string;
  92686. }
  92687. /**
  92688. * Define options used to create a depth texture
  92689. */
  92690. export class DepthTextureCreationOptions {
  92691. /** Specifies whether or not a stencil should be allocated in the texture */
  92692. generateStencil?: boolean;
  92693. /** Specifies whether or not bilinear filtering is enable on the texture */
  92694. bilinearFiltering?: boolean;
  92695. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  92696. comparisonFunction?: number;
  92697. /** Specifies if the created texture is a cube texture */
  92698. isCube?: boolean;
  92699. }
  92700. /**
  92701. * Class used to describe the capabilities of the engine relatively to the current browser
  92702. */
  92703. export class EngineCapabilities {
  92704. /** Maximum textures units per fragment shader */
  92705. maxTexturesImageUnits: number;
  92706. /** Maximum texture units per vertex shader */
  92707. maxVertexTextureImageUnits: number;
  92708. /** Maximum textures units in the entire pipeline */
  92709. maxCombinedTexturesImageUnits: number;
  92710. /** Maximum texture size */
  92711. maxTextureSize: number;
  92712. /** Maximum cube texture size */
  92713. maxCubemapTextureSize: number;
  92714. /** Maximum render texture size */
  92715. maxRenderTextureSize: number;
  92716. /** Maximum number of vertex attributes */
  92717. maxVertexAttribs: number;
  92718. /** Maximum number of varyings */
  92719. maxVaryingVectors: number;
  92720. /** Maximum number of uniforms per vertex shader */
  92721. maxVertexUniformVectors: number;
  92722. /** Maximum number of uniforms per fragment shader */
  92723. maxFragmentUniformVectors: number;
  92724. /** Defines if standard derivates (dx/dy) are supported */
  92725. standardDerivatives: boolean;
  92726. /** Defines if s3tc texture compression is supported */
  92727. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  92728. /** Defines if pvrtc texture compression is supported */
  92729. pvrtc: any;
  92730. /** Defines if etc1 texture compression is supported */
  92731. etc1: any;
  92732. /** Defines if etc2 texture compression is supported */
  92733. etc2: any;
  92734. /** Defines if astc texture compression is supported */
  92735. astc: any;
  92736. /** Defines if float textures are supported */
  92737. textureFloat: boolean;
  92738. /** Defines if vertex array objects are supported */
  92739. vertexArrayObject: boolean;
  92740. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  92741. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  92742. /** Gets the maximum level of anisotropy supported */
  92743. maxAnisotropy: number;
  92744. /** Defines if instancing is supported */
  92745. instancedArrays: boolean;
  92746. /** Defines if 32 bits indices are supported */
  92747. uintIndices: boolean;
  92748. /** Defines if high precision shaders are supported */
  92749. highPrecisionShaderSupported: boolean;
  92750. /** Defines if depth reading in the fragment shader is supported */
  92751. fragmentDepthSupported: boolean;
  92752. /** Defines if float texture linear filtering is supported*/
  92753. textureFloatLinearFiltering: boolean;
  92754. /** Defines if rendering to float textures is supported */
  92755. textureFloatRender: boolean;
  92756. /** Defines if half float textures are supported*/
  92757. textureHalfFloat: boolean;
  92758. /** Defines if half float texture linear filtering is supported*/
  92759. textureHalfFloatLinearFiltering: boolean;
  92760. /** Defines if rendering to half float textures is supported */
  92761. textureHalfFloatRender: boolean;
  92762. /** Defines if textureLOD shader command is supported */
  92763. textureLOD: boolean;
  92764. /** Defines if draw buffers extension is supported */
  92765. drawBuffersExtension: boolean;
  92766. /** Defines if depth textures are supported */
  92767. depthTextureExtension: boolean;
  92768. /** Defines if float color buffer are supported */
  92769. colorBufferFloat: boolean;
  92770. /** Gets disjoint timer query extension (null if not supported) */
  92771. timerQuery: EXT_disjoint_timer_query;
  92772. /** Defines if timestamp can be used with timer query */
  92773. canUseTimestampForTimerQuery: boolean;
  92774. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  92775. multiview: any;
  92776. /** Function used to let the system compiles shaders in background */
  92777. parallelShaderCompile: {
  92778. COMPLETION_STATUS_KHR: number;
  92779. };
  92780. }
  92781. /** Interface defining initialization parameters for Engine class */
  92782. export interface EngineOptions extends WebGLContextAttributes {
  92783. /**
  92784. * Defines if the engine should no exceed a specified device ratio
  92785. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  92786. */
  92787. limitDeviceRatio?: number;
  92788. /**
  92789. * Defines if webvr should be enabled automatically
  92790. * @see http://doc.babylonjs.com/how_to/webvr_camera
  92791. */
  92792. autoEnableWebVR?: boolean;
  92793. /**
  92794. * Defines if webgl2 should be turned off even if supported
  92795. * @see http://doc.babylonjs.com/features/webgl2
  92796. */
  92797. disableWebGL2Support?: boolean;
  92798. /**
  92799. * Defines if webaudio should be initialized as well
  92800. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92801. */
  92802. audioEngine?: boolean;
  92803. /**
  92804. * Defines if animations should run using a deterministic lock step
  92805. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  92806. */
  92807. deterministicLockstep?: boolean;
  92808. /** Defines the maximum steps to use with deterministic lock step mode */
  92809. lockstepMaxSteps?: number;
  92810. /**
  92811. * Defines that engine should ignore context lost events
  92812. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  92813. */
  92814. doNotHandleContextLost?: boolean;
  92815. /**
  92816. * Defines that engine should ignore modifying touch action attribute and style
  92817. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  92818. */
  92819. doNotHandleTouchAction?: boolean;
  92820. /**
  92821. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  92822. */
  92823. useHighPrecisionFloats?: boolean;
  92824. }
  92825. /**
  92826. * Defines the interface used by display changed events
  92827. */
  92828. export interface IDisplayChangedEventArgs {
  92829. /** Gets the vrDisplay object (if any) */
  92830. vrDisplay: Nullable<any>;
  92831. /** Gets a boolean indicating if webVR is supported */
  92832. vrSupported: boolean;
  92833. }
  92834. /**
  92835. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  92836. */
  92837. export class Engine {
  92838. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  92839. static ExceptionList: ({
  92840. key: string;
  92841. capture: string;
  92842. captureConstraint: number;
  92843. targets: string[];
  92844. } | {
  92845. key: string;
  92846. capture: null;
  92847. captureConstraint: null;
  92848. targets: string[];
  92849. })[];
  92850. /** Gets the list of created engines */
  92851. static readonly Instances: Engine[];
  92852. /**
  92853. * Gets the latest created engine
  92854. */
  92855. static readonly LastCreatedEngine: Nullable<Engine>;
  92856. /**
  92857. * Gets the latest created scene
  92858. */
  92859. static readonly LastCreatedScene: Nullable<Scene>;
  92860. /**
  92861. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  92862. * @param flag defines which part of the materials must be marked as dirty
  92863. * @param predicate defines a predicate used to filter which materials should be affected
  92864. */
  92865. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  92866. /** @hidden */
  92867. static _TextureLoaders: IInternalTextureLoader[];
  92868. /** Defines that alpha blending is disabled */
  92869. static readonly ALPHA_DISABLE: number;
  92870. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  92871. static readonly ALPHA_ADD: number;
  92872. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  92873. static readonly ALPHA_COMBINE: number;
  92874. /** Defines that alpha blending to DEST - SRC * DEST */
  92875. static readonly ALPHA_SUBTRACT: number;
  92876. /** Defines that alpha blending to SRC * DEST */
  92877. static readonly ALPHA_MULTIPLY: number;
  92878. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  92879. static readonly ALPHA_MAXIMIZED: number;
  92880. /** Defines that alpha blending to SRC + DEST */
  92881. static readonly ALPHA_ONEONE: number;
  92882. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  92883. static readonly ALPHA_PREMULTIPLIED: number;
  92884. /**
  92885. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  92886. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  92887. */
  92888. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  92889. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  92890. static readonly ALPHA_INTERPOLATE: number;
  92891. /**
  92892. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  92893. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  92894. */
  92895. static readonly ALPHA_SCREENMODE: number;
  92896. /** Defines that the ressource is not delayed*/
  92897. static readonly DELAYLOADSTATE_NONE: number;
  92898. /** Defines that the ressource was successfully delay loaded */
  92899. static readonly DELAYLOADSTATE_LOADED: number;
  92900. /** Defines that the ressource is currently delay loading */
  92901. static readonly DELAYLOADSTATE_LOADING: number;
  92902. /** Defines that the ressource is delayed and has not started loading */
  92903. static readonly DELAYLOADSTATE_NOTLOADED: number;
  92904. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  92905. static readonly NEVER: number;
  92906. /** 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 */
  92907. static readonly ALWAYS: number;
  92908. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  92909. static readonly LESS: number;
  92910. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  92911. static readonly EQUAL: number;
  92912. /** 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 */
  92913. static readonly LEQUAL: number;
  92914. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  92915. static readonly GREATER: number;
  92916. /** 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 */
  92917. static readonly GEQUAL: number;
  92918. /** 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 */
  92919. static readonly NOTEQUAL: number;
  92920. /** Passed to stencilOperation to specify that stencil value must be kept */
  92921. static readonly KEEP: number;
  92922. /** Passed to stencilOperation to specify that stencil value must be replaced */
  92923. static readonly REPLACE: number;
  92924. /** Passed to stencilOperation to specify that stencil value must be incremented */
  92925. static readonly INCR: number;
  92926. /** Passed to stencilOperation to specify that stencil value must be decremented */
  92927. static readonly DECR: number;
  92928. /** Passed to stencilOperation to specify that stencil value must be inverted */
  92929. static readonly INVERT: number;
  92930. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  92931. static readonly INCR_WRAP: number;
  92932. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  92933. static readonly DECR_WRAP: number;
  92934. /** Texture is not repeating outside of 0..1 UVs */
  92935. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  92936. /** Texture is repeating outside of 0..1 UVs */
  92937. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  92938. /** Texture is repeating and mirrored */
  92939. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  92940. /** ALPHA */
  92941. static readonly TEXTUREFORMAT_ALPHA: number;
  92942. /** LUMINANCE */
  92943. static readonly TEXTUREFORMAT_LUMINANCE: number;
  92944. /** LUMINANCE_ALPHA */
  92945. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  92946. /** RGB */
  92947. static readonly TEXTUREFORMAT_RGB: number;
  92948. /** RGBA */
  92949. static readonly TEXTUREFORMAT_RGBA: number;
  92950. /** RED */
  92951. static readonly TEXTUREFORMAT_RED: number;
  92952. /** RED (2nd reference) */
  92953. static readonly TEXTUREFORMAT_R: number;
  92954. /** RG */
  92955. static readonly TEXTUREFORMAT_RG: number;
  92956. /** RED_INTEGER */
  92957. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  92958. /** RED_INTEGER (2nd reference) */
  92959. static readonly TEXTUREFORMAT_R_INTEGER: number;
  92960. /** RG_INTEGER */
  92961. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  92962. /** RGB_INTEGER */
  92963. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  92964. /** RGBA_INTEGER */
  92965. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  92966. /** UNSIGNED_BYTE */
  92967. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  92968. /** UNSIGNED_BYTE (2nd reference) */
  92969. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  92970. /** FLOAT */
  92971. static readonly TEXTURETYPE_FLOAT: number;
  92972. /** HALF_FLOAT */
  92973. static readonly TEXTURETYPE_HALF_FLOAT: number;
  92974. /** BYTE */
  92975. static readonly TEXTURETYPE_BYTE: number;
  92976. /** SHORT */
  92977. static readonly TEXTURETYPE_SHORT: number;
  92978. /** UNSIGNED_SHORT */
  92979. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  92980. /** INT */
  92981. static readonly TEXTURETYPE_INT: number;
  92982. /** UNSIGNED_INT */
  92983. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  92984. /** UNSIGNED_SHORT_4_4_4_4 */
  92985. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  92986. /** UNSIGNED_SHORT_5_5_5_1 */
  92987. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  92988. /** UNSIGNED_SHORT_5_6_5 */
  92989. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  92990. /** UNSIGNED_INT_2_10_10_10_REV */
  92991. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  92992. /** UNSIGNED_INT_24_8 */
  92993. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  92994. /** UNSIGNED_INT_10F_11F_11F_REV */
  92995. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  92996. /** UNSIGNED_INT_5_9_9_9_REV */
  92997. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  92998. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  92999. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  93000. /** nearest is mag = nearest and min = nearest and mip = linear */
  93001. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  93002. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93003. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  93004. /** Trilinear is mag = linear and min = linear and mip = linear */
  93005. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  93006. /** nearest is mag = nearest and min = nearest and mip = linear */
  93007. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  93008. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93009. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  93010. /** Trilinear is mag = linear and min = linear and mip = linear */
  93011. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  93012. /** mag = nearest and min = nearest and mip = nearest */
  93013. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  93014. /** mag = nearest and min = linear and mip = nearest */
  93015. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  93016. /** mag = nearest and min = linear and mip = linear */
  93017. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  93018. /** mag = nearest and min = linear and mip = none */
  93019. static readonly TEXTURE_NEAREST_LINEAR: number;
  93020. /** mag = nearest and min = nearest and mip = none */
  93021. static readonly TEXTURE_NEAREST_NEAREST: number;
  93022. /** mag = linear and min = nearest and mip = nearest */
  93023. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  93024. /** mag = linear and min = nearest and mip = linear */
  93025. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  93026. /** mag = linear and min = linear and mip = none */
  93027. static readonly TEXTURE_LINEAR_LINEAR: number;
  93028. /** mag = linear and min = nearest and mip = none */
  93029. static readonly TEXTURE_LINEAR_NEAREST: number;
  93030. /** Explicit coordinates mode */
  93031. static readonly TEXTURE_EXPLICIT_MODE: number;
  93032. /** Spherical coordinates mode */
  93033. static readonly TEXTURE_SPHERICAL_MODE: number;
  93034. /** Planar coordinates mode */
  93035. static readonly TEXTURE_PLANAR_MODE: number;
  93036. /** Cubic coordinates mode */
  93037. static readonly TEXTURE_CUBIC_MODE: number;
  93038. /** Projection coordinates mode */
  93039. static readonly TEXTURE_PROJECTION_MODE: number;
  93040. /** Skybox coordinates mode */
  93041. static readonly TEXTURE_SKYBOX_MODE: number;
  93042. /** Inverse Cubic coordinates mode */
  93043. static readonly TEXTURE_INVCUBIC_MODE: number;
  93044. /** Equirectangular coordinates mode */
  93045. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  93046. /** Equirectangular Fixed coordinates mode */
  93047. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  93048. /** Equirectangular Fixed Mirrored coordinates mode */
  93049. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  93050. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  93051. static readonly SCALEMODE_FLOOR: number;
  93052. /** Defines that texture rescaling will look for the nearest power of 2 size */
  93053. static readonly SCALEMODE_NEAREST: number;
  93054. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  93055. static readonly SCALEMODE_CEILING: number;
  93056. /**
  93057. * Returns the current npm package of the sdk
  93058. */
  93059. static readonly NpmPackage: string;
  93060. /**
  93061. * Returns the current version of the framework
  93062. */
  93063. static readonly Version: string;
  93064. /**
  93065. * Returns a string describing the current engine
  93066. */
  93067. readonly description: string;
  93068. /**
  93069. * Gets or sets the epsilon value used by collision engine
  93070. */
  93071. static CollisionsEpsilon: number;
  93072. /**
  93073. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  93074. */
  93075. static ShadersRepository: string;
  93076. /**
  93077. * Method called to create the default loading screen.
  93078. * This can be overriden in your own app.
  93079. * @param canvas The rendering canvas element
  93080. * @returns The loading screen
  93081. */
  93082. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  93083. /**
  93084. * Method called to create the default rescale post process on each engine.
  93085. */
  93086. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  93087. /** @hidden */
  93088. _shaderProcessor: IShaderProcessor;
  93089. /**
  93090. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  93091. */
  93092. forcePOTTextures: boolean;
  93093. /**
  93094. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  93095. */
  93096. isFullscreen: boolean;
  93097. /**
  93098. * Gets a boolean indicating if the pointer is currently locked
  93099. */
  93100. isPointerLock: boolean;
  93101. /**
  93102. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  93103. */
  93104. cullBackFaces: boolean;
  93105. /**
  93106. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  93107. */
  93108. renderEvenInBackground: boolean;
  93109. /**
  93110. * Gets or sets a boolean indicating that cache can be kept between frames
  93111. */
  93112. preventCacheWipeBetweenFrames: boolean;
  93113. /**
  93114. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  93115. **/
  93116. enableOfflineSupport: boolean;
  93117. /**
  93118. * 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)
  93119. **/
  93120. disableManifestCheck: boolean;
  93121. /**
  93122. * Gets the list of created scenes
  93123. */
  93124. scenes: Scene[];
  93125. /**
  93126. * Event raised when a new scene is created
  93127. */
  93128. onNewSceneAddedObservable: Observable<Scene>;
  93129. /**
  93130. * Gets the list of created postprocesses
  93131. */
  93132. postProcesses: PostProcess[];
  93133. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  93134. validateShaderPrograms: boolean;
  93135. /**
  93136. * Observable event triggered each time the rendering canvas is resized
  93137. */
  93138. onResizeObservable: Observable<Engine>;
  93139. /**
  93140. * Observable event triggered each time the canvas loses focus
  93141. */
  93142. onCanvasBlurObservable: Observable<Engine>;
  93143. /**
  93144. * Observable event triggered each time the canvas gains focus
  93145. */
  93146. onCanvasFocusObservable: Observable<Engine>;
  93147. /**
  93148. * Observable event triggered each time the canvas receives pointerout event
  93149. */
  93150. onCanvasPointerOutObservable: Observable<PointerEvent>;
  93151. /**
  93152. * Observable event triggered before each texture is initialized
  93153. */
  93154. onBeforeTextureInitObservable: Observable<Texture>;
  93155. /**
  93156. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  93157. */
  93158. disableUniformBuffers: boolean;
  93159. /** @hidden */
  93160. _uniformBuffers: UniformBuffer[];
  93161. /**
  93162. * Gets a boolean indicating that the engine supports uniform buffers
  93163. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  93164. */
  93165. readonly supportsUniformBuffers: boolean;
  93166. /**
  93167. * Observable raised when the engine begins a new frame
  93168. */
  93169. onBeginFrameObservable: Observable<Engine>;
  93170. /**
  93171. * If set, will be used to request the next animation frame for the render loop
  93172. */
  93173. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  93174. /**
  93175. * Observable raised when the engine ends the current frame
  93176. */
  93177. onEndFrameObservable: Observable<Engine>;
  93178. /**
  93179. * Observable raised when the engine is about to compile a shader
  93180. */
  93181. onBeforeShaderCompilationObservable: Observable<Engine>;
  93182. /**
  93183. * Observable raised when the engine has jsut compiled a shader
  93184. */
  93185. onAfterShaderCompilationObservable: Observable<Engine>;
  93186. /** @hidden */
  93187. _gl: WebGLRenderingContext;
  93188. private _renderingCanvas;
  93189. private _windowIsBackground;
  93190. private _webGLVersion;
  93191. protected _highPrecisionShadersAllowed: boolean;
  93192. /** @hidden */
  93193. readonly _shouldUseHighPrecisionShader: boolean;
  93194. /**
  93195. * Gets a boolean indicating that only power of 2 textures are supported
  93196. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  93197. */
  93198. readonly needPOTTextures: boolean;
  93199. /** @hidden */
  93200. _badOS: boolean;
  93201. /** @hidden */
  93202. _badDesktopOS: boolean;
  93203. /**
  93204. * Gets the audio engine
  93205. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93206. * @ignorenaming
  93207. */
  93208. static audioEngine: IAudioEngine;
  93209. /**
  93210. * Default AudioEngine factory responsible of creating the Audio Engine.
  93211. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  93212. */
  93213. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  93214. /**
  93215. * Default offline support factory responsible of creating a tool used to store data locally.
  93216. * By default, this will create a Database object if the workload has been embedded.
  93217. */
  93218. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  93219. private _onFocus;
  93220. private _onBlur;
  93221. private _onCanvasPointerOut;
  93222. private _onCanvasBlur;
  93223. private _onCanvasFocus;
  93224. private _onFullscreenChange;
  93225. private _onPointerLockChange;
  93226. private _hardwareScalingLevel;
  93227. /** @hidden */
  93228. _caps: EngineCapabilities;
  93229. private _pointerLockRequested;
  93230. private _isStencilEnable;
  93231. private _colorWrite;
  93232. private _loadingScreen;
  93233. /** @hidden */
  93234. _drawCalls: PerfCounter;
  93235. private _glVersion;
  93236. private _glRenderer;
  93237. private _glVendor;
  93238. private _videoTextureSupported;
  93239. private _renderingQueueLaunched;
  93240. private _activeRenderLoops;
  93241. private _deterministicLockstep;
  93242. private _lockstepMaxSteps;
  93243. /**
  93244. * Observable signaled when a context lost event is raised
  93245. */
  93246. onContextLostObservable: Observable<Engine>;
  93247. /**
  93248. * Observable signaled when a context restored event is raised
  93249. */
  93250. onContextRestoredObservable: Observable<Engine>;
  93251. private _onContextLost;
  93252. private _onContextRestored;
  93253. private _contextWasLost;
  93254. /** @hidden */
  93255. _doNotHandleContextLost: boolean;
  93256. /**
  93257. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  93258. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  93259. */
  93260. doNotHandleContextLost: boolean;
  93261. private _performanceMonitor;
  93262. private _fps;
  93263. private _deltaTime;
  93264. /**
  93265. * Turn this value on if you want to pause FPS computation when in background
  93266. */
  93267. disablePerformanceMonitorInBackground: boolean;
  93268. /**
  93269. * Gets the performance monitor attached to this engine
  93270. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  93271. */
  93272. readonly performanceMonitor: PerformanceMonitor;
  93273. /**
  93274. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  93275. */
  93276. disableVertexArrayObjects: boolean;
  93277. /** @hidden */
  93278. protected _depthCullingState: _DepthCullingState;
  93279. /** @hidden */
  93280. protected _stencilState: _StencilState;
  93281. /** @hidden */
  93282. protected _alphaState: _AlphaState;
  93283. /** @hidden */
  93284. protected _alphaMode: number;
  93285. /** @hidden */
  93286. _internalTexturesCache: InternalTexture[];
  93287. /** @hidden */
  93288. protected _activeChannel: number;
  93289. private _currentTextureChannel;
  93290. /** @hidden */
  93291. protected _boundTexturesCache: {
  93292. [key: string]: Nullable<InternalTexture>;
  93293. };
  93294. /** @hidden */
  93295. protected _currentEffect: Nullable<Effect>;
  93296. /** @hidden */
  93297. protected _currentProgram: Nullable<WebGLProgram>;
  93298. private _compiledEffects;
  93299. private _vertexAttribArraysEnabled;
  93300. /** @hidden */
  93301. protected _cachedViewport: Nullable<IViewportLike>;
  93302. private _cachedVertexArrayObject;
  93303. /** @hidden */
  93304. protected _cachedVertexBuffers: any;
  93305. /** @hidden */
  93306. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  93307. /** @hidden */
  93308. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  93309. /** @hidden */
  93310. _currentRenderTarget: Nullable<InternalTexture>;
  93311. private _uintIndicesCurrentlySet;
  93312. private _currentBoundBuffer;
  93313. /** @hidden */
  93314. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  93315. private _currentBufferPointers;
  93316. private _currentInstanceLocations;
  93317. private _currentInstanceBuffers;
  93318. private _textureUnits;
  93319. /** @hidden */
  93320. _workingCanvas: Nullable<HTMLCanvasElement>;
  93321. /** @hidden */
  93322. _workingContext: Nullable<CanvasRenderingContext2D>;
  93323. private _rescalePostProcess;
  93324. private _dummyFramebuffer;
  93325. private _externalData;
  93326. /** @hidden */
  93327. _bindedRenderFunction: any;
  93328. private _vaoRecordInProgress;
  93329. private _mustWipeVertexAttributes;
  93330. private _emptyTexture;
  93331. private _emptyCubeTexture;
  93332. private _emptyTexture3D;
  93333. /** @hidden */
  93334. _frameHandler: number;
  93335. private _nextFreeTextureSlots;
  93336. private _maxSimultaneousTextures;
  93337. private _activeRequests;
  93338. private _texturesSupported;
  93339. /** @hidden */
  93340. _textureFormatInUse: Nullable<string>;
  93341. /**
  93342. * Gets the list of texture formats supported
  93343. */
  93344. readonly texturesSupported: Array<string>;
  93345. /**
  93346. * Gets the list of texture formats in use
  93347. */
  93348. readonly textureFormatInUse: Nullable<string>;
  93349. /**
  93350. * Gets the current viewport
  93351. */
  93352. readonly currentViewport: Nullable<IViewportLike>;
  93353. /**
  93354. * Gets the default empty texture
  93355. */
  93356. readonly emptyTexture: InternalTexture;
  93357. /**
  93358. * Gets the default empty 3D texture
  93359. */
  93360. readonly emptyTexture3D: InternalTexture;
  93361. /**
  93362. * Gets the default empty cube texture
  93363. */
  93364. readonly emptyCubeTexture: InternalTexture;
  93365. /**
  93366. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  93367. */
  93368. readonly premultipliedAlpha: boolean;
  93369. /**
  93370. * Creates a new engine
  93371. * @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
  93372. * @param antialias defines enable antialiasing (default: false)
  93373. * @param options defines further options to be sent to the getContext() function
  93374. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  93375. */
  93376. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  93377. /**
  93378. * Initializes a webVR display and starts listening to display change events
  93379. * The onVRDisplayChangedObservable will be notified upon these changes
  93380. * @returns The onVRDisplayChangedObservable
  93381. */
  93382. initWebVR(): Observable<IDisplayChangedEventArgs>;
  93383. /** @hidden */
  93384. _prepareVRComponent(): void;
  93385. /** @hidden */
  93386. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  93387. /** @hidden */
  93388. _submitVRFrame(): void;
  93389. /**
  93390. * Call this function to leave webVR mode
  93391. * Will do nothing if webVR is not supported or if there is no webVR device
  93392. * @see http://doc.babylonjs.com/how_to/webvr_camera
  93393. */
  93394. disableVR(): void;
  93395. /**
  93396. * Gets a boolean indicating that the system is in VR mode and is presenting
  93397. * @returns true if VR mode is engaged
  93398. */
  93399. isVRPresenting(): boolean;
  93400. /** @hidden */
  93401. _requestVRFrame(): void;
  93402. private _disableTouchAction;
  93403. private _rebuildInternalTextures;
  93404. private _rebuildEffects;
  93405. /**
  93406. * Gets a boolean indicating if all created effects are ready
  93407. * @returns true if all effects are ready
  93408. */
  93409. areAllEffectsReady(): boolean;
  93410. private _rebuildBuffers;
  93411. private _initGLContext;
  93412. /**
  93413. * Gets version of the current webGL context
  93414. */
  93415. readonly webGLVersion: number;
  93416. /**
  93417. * Gets a string idenfifying the name of the class
  93418. * @returns "Engine" string
  93419. */
  93420. getClassName(): string;
  93421. /**
  93422. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  93423. */
  93424. readonly isStencilEnable: boolean;
  93425. /** @hidden */
  93426. _prepareWorkingCanvas(): void;
  93427. /**
  93428. * Reset the texture cache to empty state
  93429. */
  93430. resetTextureCache(): void;
  93431. /**
  93432. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  93433. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  93434. * @returns true if engine is in deterministic lock step mode
  93435. */
  93436. isDeterministicLockStep(): boolean;
  93437. /**
  93438. * Gets the max steps when engine is running in deterministic lock step
  93439. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  93440. * @returns the max steps
  93441. */
  93442. getLockstepMaxSteps(): number;
  93443. /**
  93444. * Gets an object containing information about the current webGL context
  93445. * @returns an object containing the vender, the renderer and the version of the current webGL context
  93446. */
  93447. getGlInfo(): {
  93448. vendor: string;
  93449. renderer: string;
  93450. version: string;
  93451. };
  93452. /**
  93453. * Gets current aspect ratio
  93454. * @param viewportOwner defines the camera to use to get the aspect ratio
  93455. * @param useScreen defines if screen size must be used (or the current render target if any)
  93456. * @returns a number defining the aspect ratio
  93457. */
  93458. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  93459. /**
  93460. * Gets current screen aspect ratio
  93461. * @returns a number defining the aspect ratio
  93462. */
  93463. getScreenAspectRatio(): number;
  93464. /**
  93465. * Gets the current render width
  93466. * @param useScreen defines if screen size must be used (or the current render target if any)
  93467. * @returns a number defining the current render width
  93468. */
  93469. getRenderWidth(useScreen?: boolean): number;
  93470. /**
  93471. * Gets the current render height
  93472. * @param useScreen defines if screen size must be used (or the current render target if any)
  93473. * @returns a number defining the current render height
  93474. */
  93475. getRenderHeight(useScreen?: boolean): number;
  93476. /**
  93477. * Gets the HTML canvas attached with the current webGL context
  93478. * @returns a HTML canvas
  93479. */
  93480. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  93481. /**
  93482. * Gets the client rect of the HTML canvas attached with the current webGL context
  93483. * @returns a client rectanglee
  93484. */
  93485. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  93486. /**
  93487. * Defines the hardware scaling level.
  93488. * By default the hardware scaling level is computed from the window device ratio.
  93489. * 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.
  93490. * @param level defines the level to use
  93491. */
  93492. setHardwareScalingLevel(level: number): void;
  93493. /**
  93494. * Gets the current hardware scaling level.
  93495. * By default the hardware scaling level is computed from the window device ratio.
  93496. * 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.
  93497. * @returns a number indicating the current hardware scaling level
  93498. */
  93499. getHardwareScalingLevel(): number;
  93500. /**
  93501. * Gets the list of loaded textures
  93502. * @returns an array containing all loaded textures
  93503. */
  93504. getLoadedTexturesCache(): InternalTexture[];
  93505. /**
  93506. * Gets the object containing all engine capabilities
  93507. * @returns the EngineCapabilities object
  93508. */
  93509. getCaps(): EngineCapabilities;
  93510. /**
  93511. * Gets the current depth function
  93512. * @returns a number defining the depth function
  93513. */
  93514. getDepthFunction(): Nullable<number>;
  93515. /**
  93516. * Sets the current depth function
  93517. * @param depthFunc defines the function to use
  93518. */
  93519. setDepthFunction(depthFunc: number): void;
  93520. /**
  93521. * Sets the current depth function to GREATER
  93522. */
  93523. setDepthFunctionToGreater(): void;
  93524. /**
  93525. * Sets the current depth function to GEQUAL
  93526. */
  93527. setDepthFunctionToGreaterOrEqual(): void;
  93528. /**
  93529. * Sets the current depth function to LESS
  93530. */
  93531. setDepthFunctionToLess(): void;
  93532. private _cachedStencilBuffer;
  93533. private _cachedStencilFunction;
  93534. private _cachedStencilMask;
  93535. private _cachedStencilOperationPass;
  93536. private _cachedStencilOperationFail;
  93537. private _cachedStencilOperationDepthFail;
  93538. private _cachedStencilReference;
  93539. /**
  93540. * Caches the the state of the stencil buffer
  93541. */
  93542. cacheStencilState(): void;
  93543. /**
  93544. * Restores the state of the stencil buffer
  93545. */
  93546. restoreStencilState(): void;
  93547. /**
  93548. * Sets the current depth function to LEQUAL
  93549. */
  93550. setDepthFunctionToLessOrEqual(): void;
  93551. /**
  93552. * Gets a boolean indicating if stencil buffer is enabled
  93553. * @returns the current stencil buffer state
  93554. */
  93555. getStencilBuffer(): boolean;
  93556. /**
  93557. * Enable or disable the stencil buffer
  93558. * @param enable defines if the stencil buffer must be enabled or disabled
  93559. */
  93560. setStencilBuffer(enable: boolean): void;
  93561. /**
  93562. * Gets the current stencil mask
  93563. * @returns a number defining the new stencil mask to use
  93564. */
  93565. getStencilMask(): number;
  93566. /**
  93567. * Sets the current stencil mask
  93568. * @param mask defines the new stencil mask to use
  93569. */
  93570. setStencilMask(mask: number): void;
  93571. /**
  93572. * Gets the current stencil function
  93573. * @returns a number defining the stencil function to use
  93574. */
  93575. getStencilFunction(): number;
  93576. /**
  93577. * Gets the current stencil reference value
  93578. * @returns a number defining the stencil reference value to use
  93579. */
  93580. getStencilFunctionReference(): number;
  93581. /**
  93582. * Gets the current stencil mask
  93583. * @returns a number defining the stencil mask to use
  93584. */
  93585. getStencilFunctionMask(): number;
  93586. /**
  93587. * Sets the current stencil function
  93588. * @param stencilFunc defines the new stencil function to use
  93589. */
  93590. setStencilFunction(stencilFunc: number): void;
  93591. /**
  93592. * Sets the current stencil reference
  93593. * @param reference defines the new stencil reference to use
  93594. */
  93595. setStencilFunctionReference(reference: number): void;
  93596. /**
  93597. * Sets the current stencil mask
  93598. * @param mask defines the new stencil mask to use
  93599. */
  93600. setStencilFunctionMask(mask: number): void;
  93601. /**
  93602. * Gets the current stencil operation when stencil fails
  93603. * @returns a number defining stencil operation to use when stencil fails
  93604. */
  93605. getStencilOperationFail(): number;
  93606. /**
  93607. * Gets the current stencil operation when depth fails
  93608. * @returns a number defining stencil operation to use when depth fails
  93609. */
  93610. getStencilOperationDepthFail(): number;
  93611. /**
  93612. * Gets the current stencil operation when stencil passes
  93613. * @returns a number defining stencil operation to use when stencil passes
  93614. */
  93615. getStencilOperationPass(): number;
  93616. /**
  93617. * Sets the stencil operation to use when stencil fails
  93618. * @param operation defines the stencil operation to use when stencil fails
  93619. */
  93620. setStencilOperationFail(operation: number): void;
  93621. /**
  93622. * Sets the stencil operation to use when depth fails
  93623. * @param operation defines the stencil operation to use when depth fails
  93624. */
  93625. setStencilOperationDepthFail(operation: number): void;
  93626. /**
  93627. * Sets the stencil operation to use when stencil passes
  93628. * @param operation defines the stencil operation to use when stencil passes
  93629. */
  93630. setStencilOperationPass(operation: number): void;
  93631. /**
  93632. * Sets a boolean indicating if the dithering state is enabled or disabled
  93633. * @param value defines the dithering state
  93634. */
  93635. setDitheringState(value: boolean): void;
  93636. /**
  93637. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  93638. * @param value defines the rasterizer state
  93639. */
  93640. setRasterizerState(value: boolean): void;
  93641. /**
  93642. * stop executing a render loop function and remove it from the execution array
  93643. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  93644. */
  93645. stopRenderLoop(renderFunction?: () => void): void;
  93646. /** @hidden */
  93647. _renderLoop(): void;
  93648. /**
  93649. * Register and execute a render loop. The engine can have more than one render function
  93650. * @param renderFunction defines the function to continuously execute
  93651. */
  93652. runRenderLoop(renderFunction: () => void): void;
  93653. /**
  93654. * Toggle full screen mode
  93655. * @param requestPointerLock defines if a pointer lock should be requested from the user
  93656. */
  93657. switchFullscreen(requestPointerLock: boolean): void;
  93658. /**
  93659. * Enters full screen mode
  93660. * @param requestPointerLock defines if a pointer lock should be requested from the user
  93661. */
  93662. enterFullscreen(requestPointerLock: boolean): void;
  93663. /**
  93664. * Exits full screen mode
  93665. */
  93666. exitFullscreen(): void;
  93667. /**
  93668. * Enters Pointerlock mode
  93669. */
  93670. enterPointerlock(): void;
  93671. /**
  93672. * Exits Pointerlock mode
  93673. */
  93674. exitPointerlock(): void;
  93675. /**
  93676. * Clear the current render buffer or the current render target (if any is set up)
  93677. * @param color defines the color to use
  93678. * @param backBuffer defines if the back buffer must be cleared
  93679. * @param depth defines if the depth buffer must be cleared
  93680. * @param stencil defines if the stencil buffer must be cleared
  93681. */
  93682. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  93683. /**
  93684. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  93685. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  93686. * @param y defines the y-coordinate of the corner of the clear rectangle
  93687. * @param width defines the width of the clear rectangle
  93688. * @param height defines the height of the clear rectangle
  93689. * @param clearColor defines the clear color
  93690. */
  93691. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  93692. /**
  93693. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  93694. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  93695. * @param y defines the y-coordinate of the corner of the clear rectangle
  93696. * @param width defines the width of the clear rectangle
  93697. * @param height defines the height of the clear rectangle
  93698. */
  93699. enableScissor(x: number, y: number, width: number, height: number): void;
  93700. /**
  93701. * Disable previously set scissor test rectangle
  93702. */
  93703. disableScissor(): void;
  93704. private _viewportCached;
  93705. /** @hidden */
  93706. _viewport(x: number, y: number, width: number, height: number): void;
  93707. /**
  93708. * Set the WebGL's viewport
  93709. * @param viewport defines the viewport element to be used
  93710. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  93711. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  93712. */
  93713. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  93714. /**
  93715. * Directly set the WebGL Viewport
  93716. * @param x defines the x coordinate of the viewport (in screen space)
  93717. * @param y defines the y coordinate of the viewport (in screen space)
  93718. * @param width defines the width of the viewport (in screen space)
  93719. * @param height defines the height of the viewport (in screen space)
  93720. * @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
  93721. */
  93722. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  93723. /**
  93724. * Begin a new frame
  93725. */
  93726. beginFrame(): void;
  93727. /**
  93728. * Enf the current frame
  93729. */
  93730. endFrame(): void;
  93731. /**
  93732. * Resize the view according to the canvas' size
  93733. */
  93734. resize(): void;
  93735. /**
  93736. * Force a specific size of the canvas
  93737. * @param width defines the new canvas' width
  93738. * @param height defines the new canvas' height
  93739. */
  93740. setSize(width: number, height: number): void;
  93741. /**
  93742. * Binds the frame buffer to the specified texture.
  93743. * @param texture The texture to render to or null for the default canvas
  93744. * @param faceIndex The face of the texture to render to in case of cube texture
  93745. * @param requiredWidth The width of the target to render to
  93746. * @param requiredHeight The height of the target to render to
  93747. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  93748. * @param depthStencilTexture The depth stencil texture to use to render
  93749. * @param lodLevel defines le lod level to bind to the frame buffer
  93750. */
  93751. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  93752. /** @hidden */
  93753. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  93754. /**
  93755. * Unbind the current render target texture from the webGL context
  93756. * @param texture defines the render target texture to unbind
  93757. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  93758. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  93759. */
  93760. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  93761. /**
  93762. * Force the mipmap generation for the given render target texture
  93763. * @param texture defines the render target texture to use
  93764. */
  93765. generateMipMapsForCubemap(texture: InternalTexture): void;
  93766. /**
  93767. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  93768. */
  93769. flushFramebuffer(): void;
  93770. /**
  93771. * Unbind the current render target and bind the default framebuffer
  93772. */
  93773. restoreDefaultFramebuffer(): void;
  93774. /**
  93775. * Create an uniform buffer
  93776. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  93777. * @param elements defines the content of the uniform buffer
  93778. * @returns the webGL uniform buffer
  93779. */
  93780. createUniformBuffer(elements: FloatArray): DataBuffer;
  93781. /**
  93782. * Create a dynamic uniform buffer
  93783. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  93784. * @param elements defines the content of the uniform buffer
  93785. * @returns the webGL uniform buffer
  93786. */
  93787. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  93788. /**
  93789. * Update an existing uniform buffer
  93790. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  93791. * @param uniformBuffer defines the target uniform buffer
  93792. * @param elements defines the content to update
  93793. * @param offset defines the offset in the uniform buffer where update should start
  93794. * @param count defines the size of the data to update
  93795. */
  93796. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  93797. private _resetVertexBufferBinding;
  93798. /**
  93799. * Creates a vertex buffer
  93800. * @param data the data for the vertex buffer
  93801. * @returns the new WebGL static buffer
  93802. */
  93803. createVertexBuffer(data: DataArray): DataBuffer;
  93804. /**
  93805. * Creates a dynamic vertex buffer
  93806. * @param data the data for the dynamic vertex buffer
  93807. * @returns the new WebGL dynamic buffer
  93808. */
  93809. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  93810. /**
  93811. * Update a dynamic index buffer
  93812. * @param indexBuffer defines the target index buffer
  93813. * @param indices defines the data to update
  93814. * @param offset defines the offset in the target index buffer where update should start
  93815. */
  93816. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  93817. /**
  93818. * Updates a dynamic vertex buffer.
  93819. * @param vertexBuffer the vertex buffer to update
  93820. * @param data the data used to update the vertex buffer
  93821. * @param byteOffset the byte offset of the data
  93822. * @param byteLength the byte length of the data
  93823. */
  93824. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  93825. private _resetIndexBufferBinding;
  93826. /**
  93827. * Creates a new index buffer
  93828. * @param indices defines the content of the index buffer
  93829. * @param updatable defines if the index buffer must be updatable
  93830. * @returns a new webGL buffer
  93831. */
  93832. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  93833. /**
  93834. * Bind a webGL buffer to the webGL context
  93835. * @param buffer defines the buffer to bind
  93836. */
  93837. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  93838. /**
  93839. * Bind an uniform buffer to the current webGL context
  93840. * @param buffer defines the buffer to bind
  93841. */
  93842. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  93843. /**
  93844. * Bind a buffer to the current webGL context at a given location
  93845. * @param buffer defines the buffer to bind
  93846. * @param location defines the index where to bind the buffer
  93847. */
  93848. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  93849. /**
  93850. * Bind a specific block at a given index in a specific shader program
  93851. * @param pipelineContext defines the pipeline context to use
  93852. * @param blockName defines the block name
  93853. * @param index defines the index where to bind the block
  93854. */
  93855. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  93856. private bindIndexBuffer;
  93857. private bindBuffer;
  93858. /**
  93859. * update the bound buffer with the given data
  93860. * @param data defines the data to update
  93861. */
  93862. updateArrayBuffer(data: Float32Array): void;
  93863. private _vertexAttribPointer;
  93864. private _bindIndexBufferWithCache;
  93865. private _bindVertexBuffersAttributes;
  93866. /**
  93867. * Records a vertex array object
  93868. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  93869. * @param vertexBuffers defines the list of vertex buffers to store
  93870. * @param indexBuffer defines the index buffer to store
  93871. * @param effect defines the effect to store
  93872. * @returns the new vertex array object
  93873. */
  93874. recordVertexArrayObject(vertexBuffers: {
  93875. [key: string]: VertexBuffer;
  93876. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  93877. /**
  93878. * Bind a specific vertex array object
  93879. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  93880. * @param vertexArrayObject defines the vertex array object to bind
  93881. * @param indexBuffer defines the index buffer to bind
  93882. */
  93883. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  93884. /**
  93885. * Bind webGl buffers directly to the webGL context
  93886. * @param vertexBuffer defines the vertex buffer to bind
  93887. * @param indexBuffer defines the index buffer to bind
  93888. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  93889. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  93890. * @param effect defines the effect associated with the vertex buffer
  93891. */
  93892. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  93893. private _unbindVertexArrayObject;
  93894. /**
  93895. * Bind a list of vertex buffers to the webGL context
  93896. * @param vertexBuffers defines the list of vertex buffers to bind
  93897. * @param indexBuffer defines the index buffer to bind
  93898. * @param effect defines the effect associated with the vertex buffers
  93899. */
  93900. bindBuffers(vertexBuffers: {
  93901. [key: string]: Nullable<VertexBuffer>;
  93902. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  93903. /**
  93904. * Unbind all instance attributes
  93905. */
  93906. unbindInstanceAttributes(): void;
  93907. /**
  93908. * Release and free the memory of a vertex array object
  93909. * @param vao defines the vertex array object to delete
  93910. */
  93911. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  93912. /** @hidden */
  93913. _releaseBuffer(buffer: DataBuffer): boolean;
  93914. /**
  93915. * Creates a webGL buffer to use with instanciation
  93916. * @param capacity defines the size of the buffer
  93917. * @returns the webGL buffer
  93918. */
  93919. createInstancesBuffer(capacity: number): DataBuffer;
  93920. /**
  93921. * Delete a webGL buffer used with instanciation
  93922. * @param buffer defines the webGL buffer to delete
  93923. */
  93924. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  93925. /**
  93926. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  93927. * @param instancesBuffer defines the webGL buffer to update and bind
  93928. * @param data defines the data to store in the buffer
  93929. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  93930. */
  93931. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  93932. /**
  93933. * Apply all cached states (depth, culling, stencil and alpha)
  93934. */
  93935. applyStates(): void;
  93936. /**
  93937. * Send a draw order
  93938. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  93939. * @param indexStart defines the starting index
  93940. * @param indexCount defines the number of index to draw
  93941. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  93942. */
  93943. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  93944. /**
  93945. * Draw a list of points
  93946. * @param verticesStart defines the index of first vertex to draw
  93947. * @param verticesCount defines the count of vertices to draw
  93948. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  93949. */
  93950. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  93951. /**
  93952. * Draw a list of unindexed primitives
  93953. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  93954. * @param verticesStart defines the index of first vertex to draw
  93955. * @param verticesCount defines the count of vertices to draw
  93956. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  93957. */
  93958. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  93959. /**
  93960. * Draw a list of indexed primitives
  93961. * @param fillMode defines the primitive to use
  93962. * @param indexStart defines the starting index
  93963. * @param indexCount defines the number of index to draw
  93964. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  93965. */
  93966. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  93967. /**
  93968. * Draw a list of unindexed primitives
  93969. * @param fillMode defines the primitive to use
  93970. * @param verticesStart defines the index of first vertex to draw
  93971. * @param verticesCount defines the count of vertices to draw
  93972. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  93973. */
  93974. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  93975. private _drawMode;
  93976. /** @hidden */
  93977. _releaseEffect(effect: Effect): void;
  93978. /** @hidden */
  93979. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  93980. /**
  93981. * Create a new effect (used to store vertex/fragment shaders)
  93982. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  93983. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  93984. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  93985. * @param samplers defines an array of string used to represent textures
  93986. * @param defines defines the string containing the defines to use to compile the shaders
  93987. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  93988. * @param onCompiled defines a function to call when the effect creation is successful
  93989. * @param onError defines a function to call when the effect creation has failed
  93990. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  93991. * @returns the new Effect
  93992. */
  93993. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  93994. private _compileShader;
  93995. private _compileRawShader;
  93996. /**
  93997. * Directly creates a webGL program
  93998. * @param pipelineContext defines the pipeline context to attach to
  93999. * @param vertexCode defines the vertex shader code to use
  94000. * @param fragmentCode defines the fragment shader code to use
  94001. * @param context defines the webGL context to use (if not set, the current one will be used)
  94002. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  94003. * @returns the new webGL program
  94004. */
  94005. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  94006. /**
  94007. * Creates a webGL program
  94008. * @param pipelineContext defines the pipeline context to attach to
  94009. * @param vertexCode defines the vertex shader code to use
  94010. * @param fragmentCode defines the fragment shader code to use
  94011. * @param defines defines the string containing the defines to use to compile the shaders
  94012. * @param context defines the webGL context to use (if not set, the current one will be used)
  94013. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  94014. * @returns the new webGL program
  94015. */
  94016. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  94017. /**
  94018. * Creates a new pipeline context
  94019. * @returns the new pipeline
  94020. */
  94021. createPipelineContext(): WebGLPipelineContext;
  94022. private _createShaderProgram;
  94023. private _finalizePipelineContext;
  94024. /** @hidden */
  94025. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  94026. /** @hidden */
  94027. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  94028. /** @hidden */
  94029. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  94030. /**
  94031. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  94032. * @param pipelineContext defines the pipeline context to use
  94033. * @param uniformsNames defines the list of uniform names
  94034. * @returns an array of webGL uniform locations
  94035. */
  94036. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  94037. /**
  94038. * Gets the lsit of active attributes for a given webGL program
  94039. * @param pipelineContext defines the pipeline context to use
  94040. * @param attributesNames defines the list of attribute names to get
  94041. * @returns an array of indices indicating the offset of each attribute
  94042. */
  94043. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  94044. /**
  94045. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  94046. * @param effect defines the effect to activate
  94047. */
  94048. enableEffect(effect: Nullable<Effect>): void;
  94049. /**
  94050. * Set the value of an uniform to an array of int32
  94051. * @param uniform defines the webGL uniform location where to store the value
  94052. * @param array defines the array of int32 to store
  94053. */
  94054. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  94055. /**
  94056. * Set the value of an uniform to an array of int32 (stored as vec2)
  94057. * @param uniform defines the webGL uniform location where to store the value
  94058. * @param array defines the array of int32 to store
  94059. */
  94060. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  94061. /**
  94062. * Set the value of an uniform to an array of int32 (stored as vec3)
  94063. * @param uniform defines the webGL uniform location where to store the value
  94064. * @param array defines the array of int32 to store
  94065. */
  94066. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  94067. /**
  94068. * Set the value of an uniform to an array of int32 (stored as vec4)
  94069. * @param uniform defines the webGL uniform location where to store the value
  94070. * @param array defines the array of int32 to store
  94071. */
  94072. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  94073. /**
  94074. * Set the value of an uniform to an array of float32
  94075. * @param uniform defines the webGL uniform location where to store the value
  94076. * @param array defines the array of float32 to store
  94077. */
  94078. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  94079. /**
  94080. * Set the value of an uniform to an array of float32 (stored as vec2)
  94081. * @param uniform defines the webGL uniform location where to store the value
  94082. * @param array defines the array of float32 to store
  94083. */
  94084. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  94085. /**
  94086. * Set the value of an uniform to an array of float32 (stored as vec3)
  94087. * @param uniform defines the webGL uniform location where to store the value
  94088. * @param array defines the array of float32 to store
  94089. */
  94090. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  94091. /**
  94092. * Set the value of an uniform to an array of float32 (stored as vec4)
  94093. * @param uniform defines the webGL uniform location where to store the value
  94094. * @param array defines the array of float32 to store
  94095. */
  94096. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  94097. /**
  94098. * Set the value of an uniform to an array of number
  94099. * @param uniform defines the webGL uniform location where to store the value
  94100. * @param array defines the array of number to store
  94101. */
  94102. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  94103. /**
  94104. * Set the value of an uniform to an array of number (stored as vec2)
  94105. * @param uniform defines the webGL uniform location where to store the value
  94106. * @param array defines the array of number to store
  94107. */
  94108. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  94109. /**
  94110. * Set the value of an uniform to an array of number (stored as vec3)
  94111. * @param uniform defines the webGL uniform location where to store the value
  94112. * @param array defines the array of number to store
  94113. */
  94114. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  94115. /**
  94116. * Set the value of an uniform to an array of number (stored as vec4)
  94117. * @param uniform defines the webGL uniform location where to store the value
  94118. * @param array defines the array of number to store
  94119. */
  94120. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  94121. /**
  94122. * Set the value of an uniform to an array of float32 (stored as matrices)
  94123. * @param uniform defines the webGL uniform location where to store the value
  94124. * @param matrices defines the array of float32 to store
  94125. */
  94126. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  94127. /**
  94128. * Set the value of an uniform to a matrix (3x3)
  94129. * @param uniform defines the webGL uniform location where to store the value
  94130. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  94131. */
  94132. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  94133. /**
  94134. * Set the value of an uniform to a matrix (2x2)
  94135. * @param uniform defines the webGL uniform location where to store the value
  94136. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  94137. */
  94138. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  94139. /**
  94140. * Set the value of an uniform to a number (int)
  94141. * @param uniform defines the webGL uniform location where to store the value
  94142. * @param value defines the int number to store
  94143. */
  94144. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  94145. /**
  94146. * Set the value of an uniform to a number (float)
  94147. * @param uniform defines the webGL uniform location where to store the value
  94148. * @param value defines the float number to store
  94149. */
  94150. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  94151. /**
  94152. * Set the value of an uniform to a vec2
  94153. * @param uniform defines the webGL uniform location where to store the value
  94154. * @param x defines the 1st component of the value
  94155. * @param y defines the 2nd component of the value
  94156. */
  94157. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  94158. /**
  94159. * Set the value of an uniform to a vec3
  94160. * @param uniform defines the webGL uniform location where to store the value
  94161. * @param x defines the 1st component of the value
  94162. * @param y defines the 2nd component of the value
  94163. * @param z defines the 3rd component of the value
  94164. */
  94165. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  94166. /**
  94167. * Set the value of an uniform to a boolean
  94168. * @param uniform defines the webGL uniform location where to store the value
  94169. * @param bool defines the boolean to store
  94170. */
  94171. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  94172. /**
  94173. * Set the value of an uniform to a vec4
  94174. * @param uniform defines the webGL uniform location where to store the value
  94175. * @param x defines the 1st component of the value
  94176. * @param y defines the 2nd component of the value
  94177. * @param z defines the 3rd component of the value
  94178. * @param w defines the 4th component of the value
  94179. */
  94180. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  94181. /**
  94182. * Sets a Color4 on a uniform variable
  94183. * @param uniform defines the uniform location
  94184. * @param color4 defines the value to be set
  94185. */
  94186. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  94187. /**
  94188. * Set various states to the webGL context
  94189. * @param culling defines backface culling state
  94190. * @param zOffset defines the value to apply to zOffset (0 by default)
  94191. * @param force defines if states must be applied even if cache is up to date
  94192. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  94193. */
  94194. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  94195. /**
  94196. * Set the z offset to apply to current rendering
  94197. * @param value defines the offset to apply
  94198. */
  94199. setZOffset(value: number): void;
  94200. /**
  94201. * Gets the current value of the zOffset
  94202. * @returns the current zOffset state
  94203. */
  94204. getZOffset(): number;
  94205. /**
  94206. * Enable or disable depth buffering
  94207. * @param enable defines the state to set
  94208. */
  94209. setDepthBuffer(enable: boolean): void;
  94210. /**
  94211. * Gets a boolean indicating if depth writing is enabled
  94212. * @returns the current depth writing state
  94213. */
  94214. getDepthWrite(): boolean;
  94215. /**
  94216. * Enable or disable depth writing
  94217. * @param enable defines the state to set
  94218. */
  94219. setDepthWrite(enable: boolean): void;
  94220. /**
  94221. * Enable or disable color writing
  94222. * @param enable defines the state to set
  94223. */
  94224. setColorWrite(enable: boolean): void;
  94225. /**
  94226. * Gets a boolean indicating if color writing is enabled
  94227. * @returns the current color writing state
  94228. */
  94229. getColorWrite(): boolean;
  94230. /**
  94231. * Sets alpha constants used by some alpha blending modes
  94232. * @param r defines the red component
  94233. * @param g defines the green component
  94234. * @param b defines the blue component
  94235. * @param a defines the alpha component
  94236. */
  94237. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  94238. /**
  94239. * Sets the current alpha mode
  94240. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  94241. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  94242. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  94243. */
  94244. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  94245. /**
  94246. * Gets the current alpha mode
  94247. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  94248. * @returns the current alpha mode
  94249. */
  94250. getAlphaMode(): number;
  94251. /**
  94252. * Clears the list of texture accessible through engine.
  94253. * This can help preventing texture load conflict due to name collision.
  94254. */
  94255. clearInternalTexturesCache(): void;
  94256. /**
  94257. * Force the entire cache to be cleared
  94258. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  94259. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  94260. */
  94261. wipeCaches(bruteForce?: boolean): void;
  94262. /**
  94263. * Set the compressed texture format to use, based on the formats you have, and the formats
  94264. * supported by the hardware / browser.
  94265. *
  94266. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  94267. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  94268. * to API arguments needed to compressed textures. This puts the burden on the container
  94269. * generator to house the arcane code for determining these for current & future formats.
  94270. *
  94271. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  94272. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  94273. *
  94274. * Note: The result of this call is not taken into account when a texture is base64.
  94275. *
  94276. * @param formatsAvailable defines the list of those format families you have created
  94277. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  94278. *
  94279. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  94280. * @returns The extension selected.
  94281. */
  94282. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  94283. /** @hidden */
  94284. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  94285. min: number;
  94286. mag: number;
  94287. };
  94288. /** @hidden */
  94289. _createTexture(): WebGLTexture;
  94290. /**
  94291. * Usually called from Texture.ts.
  94292. * Passed information to create a WebGLTexture
  94293. * @param urlArg defines a value which contains one of the following:
  94294. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  94295. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  94296. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  94297. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  94298. * @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)
  94299. * @param scene needed for loading to the correct scene
  94300. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  94301. * @param onLoad optional callback to be called upon successful completion
  94302. * @param onError optional callback to be called upon failure
  94303. * @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
  94304. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  94305. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  94306. * @param forcedExtension defines the extension to use to pick the right loader
  94307. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  94308. * @returns a InternalTexture for assignment back into BABYLON.Texture
  94309. */
  94310. 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 | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  94311. /**
  94312. * @hidden
  94313. * Rescales a texture
  94314. * @param source input texutre
  94315. * @param destination destination texture
  94316. * @param scene scene to use to render the resize
  94317. * @param internalFormat format to use when resizing
  94318. * @param onComplete callback to be called when resize has completed
  94319. */
  94320. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  94321. private _unpackFlipYCached;
  94322. /**
  94323. * In case you are sharing the context with other applications, it might
  94324. * be interested to not cache the unpack flip y state to ensure a consistent
  94325. * value would be set.
  94326. */
  94327. enableUnpackFlipYCached: boolean;
  94328. /** @hidden */
  94329. _unpackFlipY(value: boolean): void;
  94330. /** @hidden */
  94331. _getUnpackAlignement(): number;
  94332. /**
  94333. * Creates a dynamic texture
  94334. * @param width defines the width of the texture
  94335. * @param height defines the height of the texture
  94336. * @param generateMipMaps defines if the engine should generate the mip levels
  94337. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  94338. * @returns the dynamic texture inside an InternalTexture
  94339. */
  94340. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  94341. /**
  94342. * Update the sampling mode of a given texture
  94343. * @param samplingMode defines the required sampling mode
  94344. * @param texture defines the texture to update
  94345. */
  94346. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  94347. /**
  94348. * Update the content of a dynamic texture
  94349. * @param texture defines the texture to update
  94350. * @param canvas defines the canvas containing the source
  94351. * @param invertY defines if data must be stored with Y axis inverted
  94352. * @param premulAlpha defines if alpha is stored as premultiplied
  94353. * @param format defines the format of the data
  94354. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  94355. */
  94356. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  94357. /**
  94358. * Update a video texture
  94359. * @param texture defines the texture to update
  94360. * @param video defines the video element to use
  94361. * @param invertY defines if data must be stored with Y axis inverted
  94362. */
  94363. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  94364. /**
  94365. * Updates a depth texture Comparison Mode and Function.
  94366. * If the comparison Function is equal to 0, the mode will be set to none.
  94367. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  94368. * @param texture The texture to set the comparison function for
  94369. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  94370. */
  94371. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  94372. /** @hidden */
  94373. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  94374. width: number;
  94375. height: number;
  94376. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  94377. /**
  94378. * Creates a depth stencil texture.
  94379. * This is only available in WebGL 2 or with the depth texture extension available.
  94380. * @param size The size of face edge in the texture.
  94381. * @param options The options defining the texture.
  94382. * @returns The texture
  94383. */
  94384. createDepthStencilTexture(size: number | {
  94385. width: number;
  94386. height: number;
  94387. }, options: DepthTextureCreationOptions): InternalTexture;
  94388. /**
  94389. * Creates a depth stencil texture.
  94390. * This is only available in WebGL 2 or with the depth texture extension available.
  94391. * @param size The size of face edge in the texture.
  94392. * @param options The options defining the texture.
  94393. * @returns The texture
  94394. */
  94395. private _createDepthStencilTexture;
  94396. /**
  94397. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  94398. * @param renderTarget The render target to set the frame buffer for
  94399. */
  94400. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  94401. /**
  94402. * Creates a new render target texture
  94403. * @param size defines the size of the texture
  94404. * @param options defines the options used to create the texture
  94405. * @returns a new render target texture stored in an InternalTexture
  94406. */
  94407. createRenderTargetTexture(size: number | {
  94408. width: number;
  94409. height: number;
  94410. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  94411. /** @hidden */
  94412. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  94413. /**
  94414. * Updates the sample count of a render target texture
  94415. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  94416. * @param texture defines the texture to update
  94417. * @param samples defines the sample count to set
  94418. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  94419. */
  94420. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  94421. /** @hidden */
  94422. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  94423. /** @hidden */
  94424. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  94425. /** @hidden */
  94426. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  94427. /** @hidden */
  94428. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  94429. /**
  94430. * @hidden
  94431. */
  94432. _setCubeMapTextureParams(loadMipmap: boolean): void;
  94433. private _prepareWebGLTextureContinuation;
  94434. private _prepareWebGLTexture;
  94435. /** @hidden */
  94436. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  94437. /** @hidden */
  94438. _releaseFramebufferObjects(texture: InternalTexture): void;
  94439. /** @hidden */
  94440. _releaseTexture(texture: InternalTexture): void;
  94441. private setProgram;
  94442. private _boundUniforms;
  94443. /**
  94444. * Binds an effect to the webGL context
  94445. * @param effect defines the effect to bind
  94446. */
  94447. bindSamplers(effect: Effect): void;
  94448. private _activateCurrentTexture;
  94449. /** @hidden */
  94450. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  94451. /** @hidden */
  94452. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  94453. /**
  94454. * Sets a texture to the webGL context from a postprocess
  94455. * @param channel defines the channel to use
  94456. * @param postProcess defines the source postprocess
  94457. */
  94458. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  94459. /**
  94460. * Binds the output of the passed in post process to the texture channel specified
  94461. * @param channel The channel the texture should be bound to
  94462. * @param postProcess The post process which's output should be bound
  94463. */
  94464. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  94465. /**
  94466. * Unbind all textures from the webGL context
  94467. */
  94468. unbindAllTextures(): void;
  94469. /**
  94470. * Sets a texture to the according uniform.
  94471. * @param channel The texture channel
  94472. * @param uniform The uniform to set
  94473. * @param texture The texture to apply
  94474. */
  94475. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  94476. /**
  94477. * Sets a depth stencil texture from a render target to the according uniform.
  94478. * @param channel The texture channel
  94479. * @param uniform The uniform to set
  94480. * @param texture The render target texture containing the depth stencil texture to apply
  94481. */
  94482. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  94483. private _bindSamplerUniformToChannel;
  94484. private _getTextureWrapMode;
  94485. private _setTexture;
  94486. /**
  94487. * Sets an array of texture to the webGL context
  94488. * @param channel defines the channel where the texture array must be set
  94489. * @param uniform defines the associated uniform location
  94490. * @param textures defines the array of textures to bind
  94491. */
  94492. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  94493. /** @hidden */
  94494. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  94495. private _setTextureParameterFloat;
  94496. private _setTextureParameterInteger;
  94497. /**
  94498. * Reads pixels from the current frame buffer. Please note that this function can be slow
  94499. * @param x defines the x coordinate of the rectangle where pixels must be read
  94500. * @param y defines the y coordinate of the rectangle where pixels must be read
  94501. * @param width defines the width of the rectangle where pixels must be read
  94502. * @param height defines the height of the rectangle where pixels must be read
  94503. * @returns a Uint8Array containing RGBA colors
  94504. */
  94505. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  94506. /**
  94507. * Add an externaly attached data from its key.
  94508. * This method call will fail and return false, if such key already exists.
  94509. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  94510. * @param key the unique key that identifies the data
  94511. * @param data the data object to associate to the key for this Engine instance
  94512. * @return true if no such key were already present and the data was added successfully, false otherwise
  94513. */
  94514. addExternalData<T>(key: string, data: T): boolean;
  94515. /**
  94516. * Get an externaly attached data from its key
  94517. * @param key the unique key that identifies the data
  94518. * @return the associated data, if present (can be null), or undefined if not present
  94519. */
  94520. getExternalData<T>(key: string): T;
  94521. /**
  94522. * Get an externaly attached data from its key, create it using a factory if it's not already present
  94523. * @param key the unique key that identifies the data
  94524. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  94525. * @return the associated data, can be null if the factory returned null.
  94526. */
  94527. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  94528. /**
  94529. * Remove an externaly attached data from the Engine instance
  94530. * @param key the unique key that identifies the data
  94531. * @return true if the data was successfully removed, false if it doesn't exist
  94532. */
  94533. removeExternalData(key: string): boolean;
  94534. /**
  94535. * Unbind all vertex attributes from the webGL context
  94536. */
  94537. unbindAllAttributes(): void;
  94538. /**
  94539. * 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
  94540. */
  94541. releaseEffects(): void;
  94542. /**
  94543. * Dispose and release all associated resources
  94544. */
  94545. dispose(): void;
  94546. /**
  94547. * Display the loading screen
  94548. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  94549. */
  94550. displayLoadingUI(): void;
  94551. /**
  94552. * Hide the loading screen
  94553. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  94554. */
  94555. hideLoadingUI(): void;
  94556. /**
  94557. * Gets the current loading screen object
  94558. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  94559. */
  94560. /**
  94561. * Sets the current loading screen object
  94562. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  94563. */
  94564. loadingScreen: ILoadingScreen;
  94565. /**
  94566. * Sets the current loading screen text
  94567. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  94568. */
  94569. loadingUIText: string;
  94570. /**
  94571. * Sets the current loading screen background color
  94572. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  94573. */
  94574. loadingUIBackgroundColor: string;
  94575. /**
  94576. * Attach a new callback raised when context lost event is fired
  94577. * @param callback defines the callback to call
  94578. */
  94579. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  94580. /**
  94581. * Attach a new callback raised when context restored event is fired
  94582. * @param callback defines the callback to call
  94583. */
  94584. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  94585. /**
  94586. * Gets the source code of the vertex shader associated with a specific webGL program
  94587. * @param program defines the program to use
  94588. * @returns a string containing the source code of the vertex shader associated with the program
  94589. */
  94590. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  94591. /**
  94592. * Gets the source code of the fragment shader associated with a specific webGL program
  94593. * @param program defines the program to use
  94594. * @returns a string containing the source code of the fragment shader associated with the program
  94595. */
  94596. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  94597. /**
  94598. * Get the current error code of the webGL context
  94599. * @returns the error code
  94600. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  94601. */
  94602. getError(): number;
  94603. /**
  94604. * Gets the current framerate
  94605. * @returns a number representing the framerate
  94606. */
  94607. getFps(): number;
  94608. /**
  94609. * Gets the time spent between current and previous frame
  94610. * @returns a number representing the delta time in ms
  94611. */
  94612. getDeltaTime(): number;
  94613. private _measureFps;
  94614. /** @hidden */
  94615. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  94616. private _canRenderToFloatFramebuffer;
  94617. private _canRenderToHalfFloatFramebuffer;
  94618. private _canRenderToFramebuffer;
  94619. /** @hidden */
  94620. _getWebGLTextureType(type: number): number;
  94621. /** @hidden */
  94622. _getInternalFormat(format: number): number;
  94623. /** @hidden */
  94624. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  94625. /** @hidden */
  94626. _getRGBAMultiSampleBufferFormat(type: number): number;
  94627. /** @hidden */
  94628. _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;
  94629. /** @hidden */
  94630. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  94631. /**
  94632. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  94633. * @returns true if the engine can be created
  94634. * @ignorenaming
  94635. */
  94636. static isSupported(): boolean;
  94637. /**
  94638. * Find the next highest power of two.
  94639. * @param x Number to start search from.
  94640. * @return Next highest power of two.
  94641. */
  94642. static CeilingPOT(x: number): number;
  94643. /**
  94644. * Find the next lowest power of two.
  94645. * @param x Number to start search from.
  94646. * @return Next lowest power of two.
  94647. */
  94648. static FloorPOT(x: number): number;
  94649. /**
  94650. * Find the nearest power of two.
  94651. * @param x Number to start search from.
  94652. * @return Next nearest power of two.
  94653. */
  94654. static NearestPOT(x: number): number;
  94655. /**
  94656. * Get the closest exponent of two
  94657. * @param value defines the value to approximate
  94658. * @param max defines the maximum value to return
  94659. * @param mode defines how to define the closest value
  94660. * @returns closest exponent of two of the given value
  94661. */
  94662. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  94663. /**
  94664. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  94665. * @param func - the function to be called
  94666. * @param requester - the object that will request the next frame. Falls back to window.
  94667. * @returns frame number
  94668. */
  94669. static QueueNewFrame(func: () => void, requester?: any): number;
  94670. /**
  94671. * Ask the browser to promote the current element to pointerlock mode
  94672. * @param element defines the DOM element to promote
  94673. */
  94674. static _RequestPointerlock(element: HTMLElement): void;
  94675. /**
  94676. * Asks the browser to exit pointerlock mode
  94677. */
  94678. static _ExitPointerlock(): void;
  94679. /**
  94680. * Ask the browser to promote the current element to fullscreen rendering mode
  94681. * @param element defines the DOM element to promote
  94682. */
  94683. static _RequestFullscreen(element: HTMLElement): void;
  94684. /**
  94685. * Asks the browser to exit fullscreen mode
  94686. */
  94687. static _ExitFullscreen(): void;
  94688. }
  94689. }
  94690. declare module BABYLON {
  94691. /**
  94692. * The engine store class is responsible to hold all the instances of Engine and Scene created
  94693. * during the life time of the application.
  94694. */
  94695. export class EngineStore {
  94696. /** Gets the list of created engines */
  94697. static Instances: Engine[];
  94698. /** @hidden */
  94699. static _LastCreatedScene: Nullable<Scene>;
  94700. /**
  94701. * Gets the latest created engine
  94702. */
  94703. static readonly LastCreatedEngine: Nullable<Engine>;
  94704. /**
  94705. * Gets the latest created scene
  94706. */
  94707. static readonly LastCreatedScene: Nullable<Scene>;
  94708. /**
  94709. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  94710. * @ignorenaming
  94711. */
  94712. static UseFallbackTexture: boolean;
  94713. /**
  94714. * Texture content used if a texture cannot loaded
  94715. * @ignorenaming
  94716. */
  94717. static FallbackTexture: string;
  94718. }
  94719. }
  94720. declare module BABYLON {
  94721. /**
  94722. * Helper class that provides a small promise polyfill
  94723. */
  94724. export class PromisePolyfill {
  94725. /**
  94726. * Static function used to check if the polyfill is required
  94727. * If this is the case then the function will inject the polyfill to window.Promise
  94728. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  94729. */
  94730. static Apply(force?: boolean): void;
  94731. }
  94732. }
  94733. declare module BABYLON {
  94734. interface IColor4Like {
  94735. r: float;
  94736. g: float;
  94737. b: float;
  94738. a: float;
  94739. }
  94740. /**
  94741. * Class containing a set of static utilities functions
  94742. */
  94743. export class Tools {
  94744. /**
  94745. * Gets or sets the base URL to use to load assets
  94746. */
  94747. static BaseUrl: string;
  94748. /**
  94749. * Enable/Disable Custom HTTP Request Headers globally.
  94750. * default = false
  94751. * @see CustomRequestHeaders
  94752. */
  94753. static UseCustomRequestHeaders: boolean;
  94754. /**
  94755. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  94756. * i.e. when loading files, where the server/service expects an Authorization header
  94757. */
  94758. static CustomRequestHeaders: {
  94759. [key: string]: string;
  94760. };
  94761. /**
  94762. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  94763. */
  94764. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  94765. /**
  94766. * Default behaviour for cors in the application.
  94767. * It can be a string if the expected behavior is identical in the entire app.
  94768. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  94769. */
  94770. static CorsBehavior: string | ((url: string | string[]) => string);
  94771. /**
  94772. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  94773. * @ignorenaming
  94774. */
  94775. static UseFallbackTexture: boolean;
  94776. /**
  94777. * Use this object to register external classes like custom textures or material
  94778. * to allow the laoders to instantiate them
  94779. */
  94780. static RegisteredExternalClasses: {
  94781. [key: string]: Object;
  94782. };
  94783. /**
  94784. * Texture content used if a texture cannot loaded
  94785. * @ignorenaming
  94786. */
  94787. static fallbackTexture: string;
  94788. /**
  94789. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  94790. * @param u defines the coordinate on X axis
  94791. * @param v defines the coordinate on Y axis
  94792. * @param width defines the width of the source data
  94793. * @param height defines the height of the source data
  94794. * @param pixels defines the source byte array
  94795. * @param color defines the output color
  94796. */
  94797. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  94798. /**
  94799. * Interpolates between a and b via alpha
  94800. * @param a The lower value (returned when alpha = 0)
  94801. * @param b The upper value (returned when alpha = 1)
  94802. * @param alpha The interpolation-factor
  94803. * @return The mixed value
  94804. */
  94805. static Mix(a: number, b: number, alpha: number): number;
  94806. /**
  94807. * Tries to instantiate a new object from a given class name
  94808. * @param className defines the class name to instantiate
  94809. * @returns the new object or null if the system was not able to do the instantiation
  94810. */
  94811. static Instantiate(className: string): any;
  94812. /**
  94813. * Provides a slice function that will work even on IE
  94814. * @param data defines the array to slice
  94815. * @param start defines the start of the data (optional)
  94816. * @param end defines the end of the data (optional)
  94817. * @returns the new sliced array
  94818. */
  94819. static Slice<T>(data: T, start?: number, end?: number): T;
  94820. /**
  94821. * Polyfill for setImmediate
  94822. * @param action defines the action to execute after the current execution block
  94823. */
  94824. static SetImmediate(action: () => void): void;
  94825. /**
  94826. * Function indicating if a number is an exponent of 2
  94827. * @param value defines the value to test
  94828. * @returns true if the value is an exponent of 2
  94829. */
  94830. static IsExponentOfTwo(value: number): boolean;
  94831. private static _tmpFloatArray;
  94832. /**
  94833. * Returns the nearest 32-bit single precision float representation of a Number
  94834. * @param value A Number. If the parameter is of a different type, it will get converted
  94835. * to a number or to NaN if it cannot be converted
  94836. * @returns number
  94837. */
  94838. static FloatRound(value: number): number;
  94839. /**
  94840. * Extracts the filename from a path
  94841. * @param path defines the path to use
  94842. * @returns the filename
  94843. */
  94844. static GetFilename(path: string): string;
  94845. /**
  94846. * Extracts the "folder" part of a path (everything before the filename).
  94847. * @param uri The URI to extract the info from
  94848. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  94849. * @returns The "folder" part of the path
  94850. */
  94851. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  94852. /**
  94853. * Extracts text content from a DOM element hierarchy
  94854. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  94855. */
  94856. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  94857. /**
  94858. * Convert an angle in radians to degrees
  94859. * @param angle defines the angle to convert
  94860. * @returns the angle in degrees
  94861. */
  94862. static ToDegrees(angle: number): number;
  94863. /**
  94864. * Convert an angle in degrees to radians
  94865. * @param angle defines the angle to convert
  94866. * @returns the angle in radians
  94867. */
  94868. static ToRadians(angle: number): number;
  94869. /**
  94870. * Encode a buffer to a base64 string
  94871. * @param buffer defines the buffer to encode
  94872. * @returns the encoded string
  94873. */
  94874. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  94875. /**
  94876. * Returns an array if obj is not an array
  94877. * @param obj defines the object to evaluate as an array
  94878. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  94879. * @returns either obj directly if obj is an array or a new array containing obj
  94880. */
  94881. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  94882. /**
  94883. * Gets the pointer prefix to use
  94884. * @returns "pointer" if touch is enabled. Else returns "mouse"
  94885. */
  94886. static GetPointerPrefix(): string;
  94887. /**
  94888. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  94889. * @param url define the url we are trying
  94890. * @param element define the dom element where to configure the cors policy
  94891. */
  94892. static SetCorsBehavior(url: string | string[], element: {
  94893. crossOrigin: string | null;
  94894. }): void;
  94895. /**
  94896. * Removes unwanted characters from an url
  94897. * @param url defines the url to clean
  94898. * @returns the cleaned url
  94899. */
  94900. static CleanUrl(url: string): string;
  94901. /**
  94902. * Gets or sets a function used to pre-process url before using them to load assets
  94903. */
  94904. static PreprocessUrl: (url: string) => string;
  94905. /**
  94906. * Loads an image as an HTMLImageElement.
  94907. * @param input url string, ArrayBuffer, or Blob to load
  94908. * @param onLoad callback called when the image successfully loads
  94909. * @param onError callback called when the image fails to load
  94910. * @param offlineProvider offline provider for caching
  94911. * @returns the HTMLImageElement of the loaded image
  94912. */
  94913. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  94914. /**
  94915. * Loads a file
  94916. * @param url url string, ArrayBuffer, or Blob to load
  94917. * @param onSuccess callback called when the file successfully loads
  94918. * @param onProgress callback called while file is loading (if the server supports this mode)
  94919. * @param offlineProvider defines the offline provider for caching
  94920. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  94921. * @param onError callback called when the file fails to load
  94922. * @returns a file request object
  94923. */
  94924. 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;
  94925. /**
  94926. * Loads a file from a url
  94927. * @param url the file url to load
  94928. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  94929. */
  94930. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  94931. /**
  94932. * Load a script (identified by an url). When the url returns, the
  94933. * content of this file is added into a new script element, attached to the DOM (body element)
  94934. * @param scriptUrl defines the url of the script to laod
  94935. * @param onSuccess defines the callback called when the script is loaded
  94936. * @param onError defines the callback to call if an error occurs
  94937. * @param scriptId defines the id of the script element
  94938. */
  94939. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  94940. /**
  94941. * Load an asynchronous script (identified by an url). When the url returns, the
  94942. * content of this file is added into a new script element, attached to the DOM (body element)
  94943. * @param scriptUrl defines the url of the script to laod
  94944. * @param scriptId defines the id of the script element
  94945. * @returns a promise request object
  94946. */
  94947. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  94948. /**
  94949. * Loads a file from a blob
  94950. * @param fileToLoad defines the blob to use
  94951. * @param callback defines the callback to call when data is loaded
  94952. * @param progressCallback defines the callback to call during loading process
  94953. * @returns a file request object
  94954. */
  94955. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  94956. /**
  94957. * Loads a file
  94958. * @param fileToLoad defines the file to load
  94959. * @param callback defines the callback to call when data is loaded
  94960. * @param progressCallBack defines the callback to call during loading process
  94961. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  94962. * @returns a file request object
  94963. */
  94964. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  94965. /**
  94966. * Creates a data url from a given string content
  94967. * @param content defines the content to convert
  94968. * @returns the new data url link
  94969. */
  94970. static FileAsURL(content: string): string;
  94971. /**
  94972. * Format the given number to a specific decimal format
  94973. * @param value defines the number to format
  94974. * @param decimals defines the number of decimals to use
  94975. * @returns the formatted string
  94976. */
  94977. static Format(value: number, decimals?: number): string;
  94978. /**
  94979. * Tries to copy an object by duplicating every property
  94980. * @param source defines the source object
  94981. * @param destination defines the target object
  94982. * @param doNotCopyList defines a list of properties to avoid
  94983. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  94984. */
  94985. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  94986. /**
  94987. * Gets a boolean indicating if the given object has no own property
  94988. * @param obj defines the object to test
  94989. * @returns true if object has no own property
  94990. */
  94991. static IsEmpty(obj: any): boolean;
  94992. /**
  94993. * Function used to register events at window level
  94994. * @param events defines the events to register
  94995. */
  94996. static RegisterTopRootEvents(events: {
  94997. name: string;
  94998. handler: Nullable<(e: FocusEvent) => any>;
  94999. }[]): void;
  95000. /**
  95001. * Function used to unregister events from window level
  95002. * @param events defines the events to unregister
  95003. */
  95004. static UnregisterTopRootEvents(events: {
  95005. name: string;
  95006. handler: Nullable<(e: FocusEvent) => any>;
  95007. }[]): void;
  95008. /**
  95009. * @ignore
  95010. */
  95011. static _ScreenshotCanvas: HTMLCanvasElement;
  95012. /**
  95013. * Dumps the current bound framebuffer
  95014. * @param width defines the rendering width
  95015. * @param height defines the rendering height
  95016. * @param engine defines the hosting engine
  95017. * @param successCallback defines the callback triggered once the data are available
  95018. * @param mimeType defines the mime type of the result
  95019. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  95020. */
  95021. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  95022. /**
  95023. * Converts the canvas data to blob.
  95024. * This acts as a polyfill for browsers not supporting the to blob function.
  95025. * @param canvas Defines the canvas to extract the data from
  95026. * @param successCallback Defines the callback triggered once the data are available
  95027. * @param mimeType Defines the mime type of the result
  95028. */
  95029. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  95030. /**
  95031. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  95032. * @param successCallback defines the callback triggered once the data are available
  95033. * @param mimeType defines the mime type of the result
  95034. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  95035. */
  95036. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  95037. /**
  95038. * Downloads a blob in the browser
  95039. * @param blob defines the blob to download
  95040. * @param fileName defines the name of the downloaded file
  95041. */
  95042. static Download(blob: Blob, fileName: string): void;
  95043. /**
  95044. * Captures a screenshot of the current rendering
  95045. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  95046. * @param engine defines the rendering engine
  95047. * @param camera defines the source camera
  95048. * @param size This parameter can be set to a single number or to an object with the
  95049. * following (optional) properties: precision, width, height. If a single number is passed,
  95050. * it will be used for both width and height. If an object is passed, the screenshot size
  95051. * will be derived from the parameters. The precision property is a multiplier allowing
  95052. * rendering at a higher or lower resolution
  95053. * @param successCallback defines the callback receives a single parameter which contains the
  95054. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  95055. * src parameter of an <img> to display it
  95056. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  95057. * Check your browser for supported MIME types
  95058. */
  95059. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  95060. /**
  95061. * Generates an image screenshot from the specified camera.
  95062. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  95063. * @param engine The engine to use for rendering
  95064. * @param camera The camera to use for rendering
  95065. * @param size This parameter can be set to a single number or to an object with the
  95066. * following (optional) properties: precision, width, height. If a single number is passed,
  95067. * it will be used for both width and height. If an object is passed, the screenshot size
  95068. * will be derived from the parameters. The precision property is a multiplier allowing
  95069. * rendering at a higher or lower resolution
  95070. * @param successCallback The callback receives a single parameter which contains the
  95071. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  95072. * src parameter of an <img> to display it
  95073. * @param mimeType The MIME type of the screenshot image (default: image/png).
  95074. * Check your browser for supported MIME types
  95075. * @param samples Texture samples (default: 1)
  95076. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  95077. * @param fileName A name for for the downloaded file.
  95078. */
  95079. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  95080. /**
  95081. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  95082. * Be aware Math.random() could cause collisions, but:
  95083. * "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"
  95084. * @returns a pseudo random id
  95085. */
  95086. static RandomId(): string;
  95087. /**
  95088. * Test if the given uri is a base64 string
  95089. * @param uri The uri to test
  95090. * @return True if the uri is a base64 string or false otherwise
  95091. */
  95092. static IsBase64(uri: string): boolean;
  95093. /**
  95094. * Decode the given base64 uri.
  95095. * @param uri The uri to decode
  95096. * @return The decoded base64 data.
  95097. */
  95098. static DecodeBase64(uri: string): ArrayBuffer;
  95099. /**
  95100. * Gets the absolute url.
  95101. * @param url the input url
  95102. * @return the absolute url
  95103. */
  95104. static GetAbsoluteUrl(url: string): string;
  95105. /**
  95106. * No log
  95107. */
  95108. static readonly NoneLogLevel: number;
  95109. /**
  95110. * Only message logs
  95111. */
  95112. static readonly MessageLogLevel: number;
  95113. /**
  95114. * Only warning logs
  95115. */
  95116. static readonly WarningLogLevel: number;
  95117. /**
  95118. * Only error logs
  95119. */
  95120. static readonly ErrorLogLevel: number;
  95121. /**
  95122. * All logs
  95123. */
  95124. static readonly AllLogLevel: number;
  95125. /**
  95126. * Gets a value indicating the number of loading errors
  95127. * @ignorenaming
  95128. */
  95129. static readonly errorsCount: number;
  95130. /**
  95131. * Callback called when a new log is added
  95132. */
  95133. static OnNewCacheEntry: (entry: string) => void;
  95134. /**
  95135. * Log a message to the console
  95136. * @param message defines the message to log
  95137. */
  95138. static Log(message: string): void;
  95139. /**
  95140. * Write a warning message to the console
  95141. * @param message defines the message to log
  95142. */
  95143. static Warn(message: string): void;
  95144. /**
  95145. * Write an error message to the console
  95146. * @param message defines the message to log
  95147. */
  95148. static Error(message: string): void;
  95149. /**
  95150. * Gets current log cache (list of logs)
  95151. */
  95152. static readonly LogCache: string;
  95153. /**
  95154. * Clears the log cache
  95155. */
  95156. static ClearLogCache(): void;
  95157. /**
  95158. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  95159. */
  95160. static LogLevels: number;
  95161. /**
  95162. * Checks if the window object exists
  95163. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  95164. */
  95165. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  95166. /**
  95167. * No performance log
  95168. */
  95169. static readonly PerformanceNoneLogLevel: number;
  95170. /**
  95171. * Use user marks to log performance
  95172. */
  95173. static readonly PerformanceUserMarkLogLevel: number;
  95174. /**
  95175. * Log performance to the console
  95176. */
  95177. static readonly PerformanceConsoleLogLevel: number;
  95178. private static _performance;
  95179. /**
  95180. * Sets the current performance log level
  95181. */
  95182. static PerformanceLogLevel: number;
  95183. private static _StartPerformanceCounterDisabled;
  95184. private static _EndPerformanceCounterDisabled;
  95185. private static _StartUserMark;
  95186. private static _EndUserMark;
  95187. private static _StartPerformanceConsole;
  95188. private static _EndPerformanceConsole;
  95189. /**
  95190. * Starts a performance counter
  95191. */
  95192. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  95193. /**
  95194. * Ends a specific performance coutner
  95195. */
  95196. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  95197. /**
  95198. * Gets either window.performance.now() if supported or Date.now() else
  95199. */
  95200. static readonly Now: number;
  95201. /**
  95202. * This method will return the name of the class used to create the instance of the given object.
  95203. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  95204. * @param object the object to get the class name from
  95205. * @param isType defines if the object is actually a type
  95206. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  95207. */
  95208. static GetClassName(object: any, isType?: boolean): string;
  95209. /**
  95210. * Gets the first element of an array satisfying a given predicate
  95211. * @param array defines the array to browse
  95212. * @param predicate defines the predicate to use
  95213. * @returns null if not found or the element
  95214. */
  95215. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  95216. /**
  95217. * This method will return the name of the full name of the class, including its owning module (if any).
  95218. * 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).
  95219. * @param object the object to get the class name from
  95220. * @param isType defines if the object is actually a type
  95221. * @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.
  95222. * @ignorenaming
  95223. */
  95224. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  95225. /**
  95226. * Returns a promise that resolves after the given amount of time.
  95227. * @param delay Number of milliseconds to delay
  95228. * @returns Promise that resolves after the given amount of time
  95229. */
  95230. static DelayAsync(delay: number): Promise<void>;
  95231. }
  95232. /**
  95233. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  95234. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  95235. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  95236. * @param name The name of the class, case should be preserved
  95237. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  95238. */
  95239. export function className(name: string, module?: string): (target: Object) => void;
  95240. /**
  95241. * An implementation of a loop for asynchronous functions.
  95242. */
  95243. export class AsyncLoop {
  95244. /**
  95245. * Defines the number of iterations for the loop
  95246. */
  95247. iterations: number;
  95248. /**
  95249. * Defines the current index of the loop.
  95250. */
  95251. index: number;
  95252. private _done;
  95253. private _fn;
  95254. private _successCallback;
  95255. /**
  95256. * Constructor.
  95257. * @param iterations the number of iterations.
  95258. * @param func the function to run each iteration
  95259. * @param successCallback the callback that will be called upon succesful execution
  95260. * @param offset starting offset.
  95261. */
  95262. constructor(
  95263. /**
  95264. * Defines the number of iterations for the loop
  95265. */
  95266. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  95267. /**
  95268. * Execute the next iteration. Must be called after the last iteration was finished.
  95269. */
  95270. executeNext(): void;
  95271. /**
  95272. * Break the loop and run the success callback.
  95273. */
  95274. breakLoop(): void;
  95275. /**
  95276. * Create and run an async loop.
  95277. * @param iterations the number of iterations.
  95278. * @param fn the function to run each iteration
  95279. * @param successCallback the callback that will be called upon succesful execution
  95280. * @param offset starting offset.
  95281. * @returns the created async loop object
  95282. */
  95283. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  95284. /**
  95285. * A for-loop that will run a given number of iterations synchronous and the rest async.
  95286. * @param iterations total number of iterations
  95287. * @param syncedIterations number of synchronous iterations in each async iteration.
  95288. * @param fn the function to call each iteration.
  95289. * @param callback a success call back that will be called when iterating stops.
  95290. * @param breakFunction a break condition (optional)
  95291. * @param timeout timeout settings for the setTimeout function. default - 0.
  95292. * @returns the created async loop object
  95293. */
  95294. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  95295. }
  95296. }
  95297. declare module BABYLON {
  95298. /** @hidden */
  95299. export interface ICollisionCoordinator {
  95300. createCollider(): Collider;
  95301. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  95302. init(scene: Scene): void;
  95303. }
  95304. /** @hidden */
  95305. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  95306. private _scene;
  95307. private _scaledPosition;
  95308. private _scaledVelocity;
  95309. private _finalPosition;
  95310. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  95311. createCollider(): Collider;
  95312. init(scene: Scene): void;
  95313. private _collideWithWorld;
  95314. }
  95315. }
  95316. declare module BABYLON {
  95317. /**
  95318. * Class used to manage all inputs for the scene.
  95319. */
  95320. export class InputManager {
  95321. /** The distance in pixel that you have to move to prevent some events */
  95322. static DragMovementThreshold: number;
  95323. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  95324. static LongPressDelay: number;
  95325. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  95326. static DoubleClickDelay: number;
  95327. /** If you need to check double click without raising a single click at first click, enable this flag */
  95328. static ExclusiveDoubleClickMode: boolean;
  95329. private _wheelEventName;
  95330. private _onPointerMove;
  95331. private _onPointerDown;
  95332. private _onPointerUp;
  95333. private _initClickEvent;
  95334. private _initActionManager;
  95335. private _delayedSimpleClick;
  95336. private _delayedSimpleClickTimeout;
  95337. private _previousDelayedSimpleClickTimeout;
  95338. private _meshPickProceed;
  95339. private _previousButtonPressed;
  95340. private _currentPickResult;
  95341. private _previousPickResult;
  95342. private _totalPointersPressed;
  95343. private _doubleClickOccured;
  95344. private _pointerOverMesh;
  95345. private _pickedDownMesh;
  95346. private _pickedUpMesh;
  95347. private _pointerX;
  95348. private _pointerY;
  95349. private _unTranslatedPointerX;
  95350. private _unTranslatedPointerY;
  95351. private _startingPointerPosition;
  95352. private _previousStartingPointerPosition;
  95353. private _startingPointerTime;
  95354. private _previousStartingPointerTime;
  95355. private _pointerCaptures;
  95356. private _onKeyDown;
  95357. private _onKeyUp;
  95358. private _onCanvasFocusObserver;
  95359. private _onCanvasBlurObserver;
  95360. private _scene;
  95361. /**
  95362. * Creates a new InputManager
  95363. * @param scene defines the hosting scene
  95364. */
  95365. constructor(scene: Scene);
  95366. /**
  95367. * Gets the mesh that is currently under the pointer
  95368. */
  95369. readonly meshUnderPointer: Nullable<AbstractMesh>;
  95370. /**
  95371. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  95372. */
  95373. readonly unTranslatedPointer: Vector2;
  95374. /**
  95375. * Gets or sets the current on-screen X position of the pointer
  95376. */
  95377. pointerX: number;
  95378. /**
  95379. * Gets or sets the current on-screen Y position of the pointer
  95380. */
  95381. pointerY: number;
  95382. private _updatePointerPosition;
  95383. private _processPointerMove;
  95384. private _setRayOnPointerInfo;
  95385. private _checkPrePointerObservable;
  95386. /**
  95387. * Use this method to simulate a pointer move on a mesh
  95388. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95389. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95390. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95391. */
  95392. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  95393. /**
  95394. * Use this method to simulate a pointer down on a mesh
  95395. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95396. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95397. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95398. */
  95399. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  95400. private _processPointerDown;
  95401. /** @hidden */
  95402. _isPointerSwiping(): boolean;
  95403. /**
  95404. * Use this method to simulate a pointer up on a mesh
  95405. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95406. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95407. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95408. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  95409. */
  95410. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  95411. private _processPointerUp;
  95412. /**
  95413. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  95414. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  95415. * @returns true if the pointer was captured
  95416. */
  95417. isPointerCaptured(pointerId?: number): boolean;
  95418. /**
  95419. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  95420. * @param attachUp defines if you want to attach events to pointerup
  95421. * @param attachDown defines if you want to attach events to pointerdown
  95422. * @param attachMove defines if you want to attach events to pointermove
  95423. */
  95424. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  95425. /**
  95426. * Detaches all event handlers
  95427. */
  95428. detachControl(): void;
  95429. /**
  95430. * Force the value of meshUnderPointer
  95431. * @param mesh defines the mesh to use
  95432. */
  95433. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  95434. /**
  95435. * Gets the mesh under the pointer
  95436. * @returns a Mesh or null if no mesh is under the pointer
  95437. */
  95438. getPointerOverMesh(): Nullable<AbstractMesh>;
  95439. }
  95440. }
  95441. declare module BABYLON {
  95442. /**
  95443. * This class defines the direct association between an animation and a target
  95444. */
  95445. export class TargetedAnimation {
  95446. /**
  95447. * Animation to perform
  95448. */
  95449. animation: Animation;
  95450. /**
  95451. * Target to animate
  95452. */
  95453. target: any;
  95454. /**
  95455. * Serialize the object
  95456. * @returns the JSON object representing the current entity
  95457. */
  95458. serialize(): any;
  95459. }
  95460. /**
  95461. * Use this class to create coordinated animations on multiple targets
  95462. */
  95463. export class AnimationGroup implements IDisposable {
  95464. /** The name of the animation group */
  95465. name: string;
  95466. private _scene;
  95467. private _targetedAnimations;
  95468. private _animatables;
  95469. private _from;
  95470. private _to;
  95471. private _isStarted;
  95472. private _isPaused;
  95473. private _speedRatio;
  95474. private _loopAnimation;
  95475. /**
  95476. * Gets or sets the unique id of the node
  95477. */
  95478. uniqueId: number;
  95479. /**
  95480. * This observable will notify when one animation have ended
  95481. */
  95482. onAnimationEndObservable: Observable<TargetedAnimation>;
  95483. /**
  95484. * Observer raised when one animation loops
  95485. */
  95486. onAnimationLoopObservable: Observable<TargetedAnimation>;
  95487. /**
  95488. * This observable will notify when all animations have ended.
  95489. */
  95490. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  95491. /**
  95492. * This observable will notify when all animations have paused.
  95493. */
  95494. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  95495. /**
  95496. * This observable will notify when all animations are playing.
  95497. */
  95498. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  95499. /**
  95500. * Gets the first frame
  95501. */
  95502. readonly from: number;
  95503. /**
  95504. * Gets the last frame
  95505. */
  95506. readonly to: number;
  95507. /**
  95508. * Define if the animations are started
  95509. */
  95510. readonly isStarted: boolean;
  95511. /**
  95512. * Gets a value indicating that the current group is playing
  95513. */
  95514. readonly isPlaying: boolean;
  95515. /**
  95516. * Gets or sets the speed ratio to use for all animations
  95517. */
  95518. /**
  95519. * Gets or sets the speed ratio to use for all animations
  95520. */
  95521. speedRatio: number;
  95522. /**
  95523. * Gets or sets if all animations should loop or not
  95524. */
  95525. loopAnimation: boolean;
  95526. /**
  95527. * Gets the targeted animations for this animation group
  95528. */
  95529. readonly targetedAnimations: Array<TargetedAnimation>;
  95530. /**
  95531. * returning the list of animatables controlled by this animation group.
  95532. */
  95533. readonly animatables: Array<Animatable>;
  95534. /**
  95535. * Instantiates a new Animation Group.
  95536. * This helps managing several animations at once.
  95537. * @see http://doc.babylonjs.com/how_to/group
  95538. * @param name Defines the name of the group
  95539. * @param scene Defines the scene the group belongs to
  95540. */
  95541. constructor(
  95542. /** The name of the animation group */
  95543. name: string, scene?: Nullable<Scene>);
  95544. /**
  95545. * Add an animation (with its target) in the group
  95546. * @param animation defines the animation we want to add
  95547. * @param target defines the target of the animation
  95548. * @returns the TargetedAnimation object
  95549. */
  95550. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  95551. /**
  95552. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  95553. * It can add constant keys at begin or end
  95554. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  95555. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  95556. * @returns the animation group
  95557. */
  95558. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  95559. /**
  95560. * Start all animations on given targets
  95561. * @param loop defines if animations must loop
  95562. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  95563. * @param from defines the from key (optional)
  95564. * @param to defines the to key (optional)
  95565. * @returns the current animation group
  95566. */
  95567. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  95568. /**
  95569. * Pause all animations
  95570. * @returns the animation group
  95571. */
  95572. pause(): AnimationGroup;
  95573. /**
  95574. * Play all animations to initial state
  95575. * This function will start() the animations if they were not started or will restart() them if they were paused
  95576. * @param loop defines if animations must loop
  95577. * @returns the animation group
  95578. */
  95579. play(loop?: boolean): AnimationGroup;
  95580. /**
  95581. * Reset all animations to initial state
  95582. * @returns the animation group
  95583. */
  95584. reset(): AnimationGroup;
  95585. /**
  95586. * Restart animations from key 0
  95587. * @returns the animation group
  95588. */
  95589. restart(): AnimationGroup;
  95590. /**
  95591. * Stop all animations
  95592. * @returns the animation group
  95593. */
  95594. stop(): AnimationGroup;
  95595. /**
  95596. * Set animation weight for all animatables
  95597. * @param weight defines the weight to use
  95598. * @return the animationGroup
  95599. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  95600. */
  95601. setWeightForAllAnimatables(weight: number): AnimationGroup;
  95602. /**
  95603. * Synchronize and normalize all animatables with a source animatable
  95604. * @param root defines the root animatable to synchronize with
  95605. * @return the animationGroup
  95606. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  95607. */
  95608. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  95609. /**
  95610. * Goes to a specific frame in this animation group
  95611. * @param frame the frame number to go to
  95612. * @return the animationGroup
  95613. */
  95614. goToFrame(frame: number): AnimationGroup;
  95615. /**
  95616. * Dispose all associated resources
  95617. */
  95618. dispose(): void;
  95619. private _checkAnimationGroupEnded;
  95620. /**
  95621. * Clone the current animation group and returns a copy
  95622. * @param newName defines the name of the new group
  95623. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  95624. * @returns the new aniamtion group
  95625. */
  95626. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  95627. /**
  95628. * Serializes the animationGroup to an object
  95629. * @returns Serialized object
  95630. */
  95631. serialize(): any;
  95632. /**
  95633. * Returns a new AnimationGroup object parsed from the source provided.
  95634. * @param parsedAnimationGroup defines the source
  95635. * @param scene defines the scene that will receive the animationGroup
  95636. * @returns a new AnimationGroup
  95637. */
  95638. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  95639. /**
  95640. * Returns the string "AnimationGroup"
  95641. * @returns "AnimationGroup"
  95642. */
  95643. getClassName(): string;
  95644. /**
  95645. * Creates a detailled string about the object
  95646. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  95647. * @returns a string representing the object
  95648. */
  95649. toString(fullDetails?: boolean): string;
  95650. }
  95651. }
  95652. declare module BABYLON {
  95653. /**
  95654. * Define an interface for all classes that will hold resources
  95655. */
  95656. export interface IDisposable {
  95657. /**
  95658. * Releases all held resources
  95659. */
  95660. dispose(): void;
  95661. }
  95662. /** Interface defining initialization parameters for Scene class */
  95663. export interface SceneOptions {
  95664. /**
  95665. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  95666. * It will improve performance when the number of geometries becomes important.
  95667. */
  95668. useGeometryUniqueIdsMap?: boolean;
  95669. /**
  95670. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  95671. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  95672. */
  95673. useMaterialMeshMap?: boolean;
  95674. /**
  95675. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  95676. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  95677. */
  95678. useClonedMeshhMap?: boolean;
  95679. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  95680. virtual?: boolean;
  95681. }
  95682. /**
  95683. * Represents a scene to be rendered by the engine.
  95684. * @see http://doc.babylonjs.com/features/scene
  95685. */
  95686. export class Scene extends AbstractScene implements IAnimatable {
  95687. private static _uniqueIdCounter;
  95688. /** The fog is deactivated */
  95689. static readonly FOGMODE_NONE: number;
  95690. /** The fog density is following an exponential function */
  95691. static readonly FOGMODE_EXP: number;
  95692. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  95693. static readonly FOGMODE_EXP2: number;
  95694. /** The fog density is following a linear function. */
  95695. static readonly FOGMODE_LINEAR: number;
  95696. /**
  95697. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  95698. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95699. */
  95700. static MinDeltaTime: number;
  95701. /**
  95702. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  95703. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95704. */
  95705. static MaxDeltaTime: number;
  95706. /**
  95707. * Factory used to create the default material.
  95708. * @param name The name of the material to create
  95709. * @param scene The scene to create the material for
  95710. * @returns The default material
  95711. */
  95712. static DefaultMaterialFactory(scene: Scene): Material;
  95713. /**
  95714. * Factory used to create the a collision coordinator.
  95715. * @returns The collision coordinator
  95716. */
  95717. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  95718. /** @hidden */
  95719. _inputManager: InputManager;
  95720. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  95721. cameraToUseForPointers: Nullable<Camera>;
  95722. /** @hidden */
  95723. readonly _isScene: boolean;
  95724. /**
  95725. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  95726. */
  95727. autoClear: boolean;
  95728. /**
  95729. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  95730. */
  95731. autoClearDepthAndStencil: boolean;
  95732. /**
  95733. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  95734. */
  95735. clearColor: Color4;
  95736. /**
  95737. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  95738. */
  95739. ambientColor: Color3;
  95740. /**
  95741. * This is use to store the default BRDF lookup for PBR materials in your scene.
  95742. * It should only be one of the following (if not the default embedded one):
  95743. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  95744. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  95745. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  95746. * The material properties need to be setup according to the type of texture in use.
  95747. */
  95748. environmentBRDFTexture: BaseTexture;
  95749. /** @hidden */
  95750. protected _environmentTexture: Nullable<BaseTexture>;
  95751. /**
  95752. * Texture used in all pbr material as the reflection texture.
  95753. * As in the majority of the scene they are the same (exception for multi room and so on),
  95754. * this is easier to reference from here than from all the materials.
  95755. */
  95756. /**
  95757. * Texture used in all pbr material as the reflection texture.
  95758. * As in the majority of the scene they are the same (exception for multi room and so on),
  95759. * this is easier to set here than in all the materials.
  95760. */
  95761. environmentTexture: Nullable<BaseTexture>;
  95762. /** @hidden */
  95763. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95764. /**
  95765. * Default image processing configuration used either in the rendering
  95766. * Forward main pass or through the imageProcessingPostProcess if present.
  95767. * As in the majority of the scene they are the same (exception for multi camera),
  95768. * this is easier to reference from here than from all the materials and post process.
  95769. *
  95770. * No setter as we it is a shared configuration, you can set the values instead.
  95771. */
  95772. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  95773. private _forceWireframe;
  95774. /**
  95775. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  95776. */
  95777. forceWireframe: boolean;
  95778. private _forcePointsCloud;
  95779. /**
  95780. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  95781. */
  95782. forcePointsCloud: boolean;
  95783. /**
  95784. * Gets or sets the active clipplane 1
  95785. */
  95786. clipPlane: Nullable<Plane>;
  95787. /**
  95788. * Gets or sets the active clipplane 2
  95789. */
  95790. clipPlane2: Nullable<Plane>;
  95791. /**
  95792. * Gets or sets the active clipplane 3
  95793. */
  95794. clipPlane3: Nullable<Plane>;
  95795. /**
  95796. * Gets or sets the active clipplane 4
  95797. */
  95798. clipPlane4: Nullable<Plane>;
  95799. /**
  95800. * Gets or sets a boolean indicating if animations are enabled
  95801. */
  95802. animationsEnabled: boolean;
  95803. private _animationPropertiesOverride;
  95804. /**
  95805. * Gets or sets the animation properties override
  95806. */
  95807. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  95808. /**
  95809. * Gets or sets a boolean indicating if a constant deltatime has to be used
  95810. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  95811. */
  95812. useConstantAnimationDeltaTime: boolean;
  95813. /**
  95814. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  95815. * Please note that it requires to run a ray cast through the scene on every frame
  95816. */
  95817. constantlyUpdateMeshUnderPointer: boolean;
  95818. /**
  95819. * Defines the HTML cursor to use when hovering over interactive elements
  95820. */
  95821. hoverCursor: string;
  95822. /**
  95823. * Defines the HTML default cursor to use (empty by default)
  95824. */
  95825. defaultCursor: string;
  95826. /**
  95827. * This is used to call preventDefault() on pointer down
  95828. * in order to block unwanted artifacts like system double clicks
  95829. */
  95830. preventDefaultOnPointerDown: boolean;
  95831. /**
  95832. * This is used to call preventDefault() on pointer up
  95833. * in order to block unwanted artifacts like system double clicks
  95834. */
  95835. preventDefaultOnPointerUp: boolean;
  95836. /**
  95837. * Gets or sets user defined metadata
  95838. */
  95839. metadata: any;
  95840. /**
  95841. * For internal use only. Please do not use.
  95842. */
  95843. reservedDataStore: any;
  95844. /**
  95845. * Gets the name of the plugin used to load this scene (null by default)
  95846. */
  95847. loadingPluginName: string;
  95848. /**
  95849. * Use this array to add regular expressions used to disable offline support for specific urls
  95850. */
  95851. disableOfflineSupportExceptionRules: RegExp[];
  95852. /**
  95853. * An event triggered when the scene is disposed.
  95854. */
  95855. onDisposeObservable: Observable<Scene>;
  95856. private _onDisposeObserver;
  95857. /** Sets a function to be executed when this scene is disposed. */
  95858. onDispose: () => void;
  95859. /**
  95860. * An event triggered before rendering the scene (right after animations and physics)
  95861. */
  95862. onBeforeRenderObservable: Observable<Scene>;
  95863. private _onBeforeRenderObserver;
  95864. /** Sets a function to be executed before rendering this scene */
  95865. beforeRender: Nullable<() => void>;
  95866. /**
  95867. * An event triggered after rendering the scene
  95868. */
  95869. onAfterRenderObservable: Observable<Scene>;
  95870. /**
  95871. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  95872. */
  95873. onAfterRenderCameraObservable: Observable<Camera>;
  95874. private _onAfterRenderObserver;
  95875. /** Sets a function to be executed after rendering this scene */
  95876. afterRender: Nullable<() => void>;
  95877. /**
  95878. * An event triggered before animating the scene
  95879. */
  95880. onBeforeAnimationsObservable: Observable<Scene>;
  95881. /**
  95882. * An event triggered after animations processing
  95883. */
  95884. onAfterAnimationsObservable: Observable<Scene>;
  95885. /**
  95886. * An event triggered before draw calls are ready to be sent
  95887. */
  95888. onBeforeDrawPhaseObservable: Observable<Scene>;
  95889. /**
  95890. * An event triggered after draw calls have been sent
  95891. */
  95892. onAfterDrawPhaseObservable: Observable<Scene>;
  95893. /**
  95894. * An event triggered when the scene is ready
  95895. */
  95896. onReadyObservable: Observable<Scene>;
  95897. /**
  95898. * An event triggered before rendering a camera
  95899. */
  95900. onBeforeCameraRenderObservable: Observable<Camera>;
  95901. private _onBeforeCameraRenderObserver;
  95902. /** Sets a function to be executed before rendering a camera*/
  95903. beforeCameraRender: () => void;
  95904. /**
  95905. * An event triggered after rendering a camera
  95906. */
  95907. onAfterCameraRenderObservable: Observable<Camera>;
  95908. private _onAfterCameraRenderObserver;
  95909. /** Sets a function to be executed after rendering a camera*/
  95910. afterCameraRender: () => void;
  95911. /**
  95912. * An event triggered when active meshes evaluation is about to start
  95913. */
  95914. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  95915. /**
  95916. * An event triggered when active meshes evaluation is done
  95917. */
  95918. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  95919. /**
  95920. * An event triggered when particles rendering is about to start
  95921. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  95922. */
  95923. onBeforeParticlesRenderingObservable: Observable<Scene>;
  95924. /**
  95925. * An event triggered when particles rendering is done
  95926. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  95927. */
  95928. onAfterParticlesRenderingObservable: Observable<Scene>;
  95929. /**
  95930. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  95931. */
  95932. onDataLoadedObservable: Observable<Scene>;
  95933. /**
  95934. * An event triggered when a camera is created
  95935. */
  95936. onNewCameraAddedObservable: Observable<Camera>;
  95937. /**
  95938. * An event triggered when a camera is removed
  95939. */
  95940. onCameraRemovedObservable: Observable<Camera>;
  95941. /**
  95942. * An event triggered when a light is created
  95943. */
  95944. onNewLightAddedObservable: Observable<Light>;
  95945. /**
  95946. * An event triggered when a light is removed
  95947. */
  95948. onLightRemovedObservable: Observable<Light>;
  95949. /**
  95950. * An event triggered when a geometry is created
  95951. */
  95952. onNewGeometryAddedObservable: Observable<Geometry>;
  95953. /**
  95954. * An event triggered when a geometry is removed
  95955. */
  95956. onGeometryRemovedObservable: Observable<Geometry>;
  95957. /**
  95958. * An event triggered when a transform node is created
  95959. */
  95960. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  95961. /**
  95962. * An event triggered when a transform node is removed
  95963. */
  95964. onTransformNodeRemovedObservable: Observable<TransformNode>;
  95965. /**
  95966. * An event triggered when a mesh is created
  95967. */
  95968. onNewMeshAddedObservable: Observable<AbstractMesh>;
  95969. /**
  95970. * An event triggered when a mesh is removed
  95971. */
  95972. onMeshRemovedObservable: Observable<AbstractMesh>;
  95973. /**
  95974. * An event triggered when a skeleton is created
  95975. */
  95976. onNewSkeletonAddedObservable: Observable<Skeleton>;
  95977. /**
  95978. * An event triggered when a skeleton is removed
  95979. */
  95980. onSkeletonRemovedObservable: Observable<Skeleton>;
  95981. /**
  95982. * An event triggered when a material is created
  95983. */
  95984. onNewMaterialAddedObservable: Observable<Material>;
  95985. /**
  95986. * An event triggered when a material is removed
  95987. */
  95988. onMaterialRemovedObservable: Observable<Material>;
  95989. /**
  95990. * An event triggered when a texture is created
  95991. */
  95992. onNewTextureAddedObservable: Observable<BaseTexture>;
  95993. /**
  95994. * An event triggered when a texture is removed
  95995. */
  95996. onTextureRemovedObservable: Observable<BaseTexture>;
  95997. /**
  95998. * An event triggered when render targets are about to be rendered
  95999. * Can happen multiple times per frame.
  96000. */
  96001. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  96002. /**
  96003. * An event triggered when render targets were rendered.
  96004. * Can happen multiple times per frame.
  96005. */
  96006. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  96007. /**
  96008. * An event triggered before calculating deterministic simulation step
  96009. */
  96010. onBeforeStepObservable: Observable<Scene>;
  96011. /**
  96012. * An event triggered after calculating deterministic simulation step
  96013. */
  96014. onAfterStepObservable: Observable<Scene>;
  96015. /**
  96016. * An event triggered when the activeCamera property is updated
  96017. */
  96018. onActiveCameraChanged: Observable<Scene>;
  96019. /**
  96020. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  96021. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  96022. * 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)
  96023. */
  96024. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  96025. /**
  96026. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  96027. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  96028. * 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)
  96029. */
  96030. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  96031. /**
  96032. * This Observable will when a mesh has been imported into the scene.
  96033. */
  96034. onMeshImportedObservable: Observable<AbstractMesh>;
  96035. /**
  96036. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  96037. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  96038. */
  96039. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  96040. /** @hidden */
  96041. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  96042. /**
  96043. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  96044. */
  96045. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  96046. /**
  96047. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  96048. */
  96049. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  96050. /**
  96051. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  96052. */
  96053. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  96054. /** Callback called when a pointer move is detected */
  96055. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  96056. /** Callback called when a pointer down is detected */
  96057. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  96058. /** Callback called when a pointer up is detected */
  96059. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  96060. /** Callback called when a pointer pick is detected */
  96061. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  96062. /**
  96063. * 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).
  96064. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  96065. */
  96066. onPrePointerObservable: Observable<PointerInfoPre>;
  96067. /**
  96068. * Observable event triggered each time an input event is received from the rendering canvas
  96069. */
  96070. onPointerObservable: Observable<PointerInfo>;
  96071. /**
  96072. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  96073. */
  96074. readonly unTranslatedPointer: Vector2;
  96075. /**
  96076. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  96077. */
  96078. static DragMovementThreshold: number;
  96079. /**
  96080. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  96081. */
  96082. static LongPressDelay: number;
  96083. /**
  96084. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  96085. */
  96086. static DoubleClickDelay: number;
  96087. /** If you need to check double click without raising a single click at first click, enable this flag */
  96088. static ExclusiveDoubleClickMode: boolean;
  96089. /** @hidden */
  96090. _mirroredCameraPosition: Nullable<Vector3>;
  96091. /**
  96092. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  96093. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  96094. */
  96095. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  96096. /**
  96097. * Observable event triggered each time an keyboard event is received from the hosting window
  96098. */
  96099. onKeyboardObservable: Observable<KeyboardInfo>;
  96100. private _useRightHandedSystem;
  96101. /**
  96102. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  96103. */
  96104. useRightHandedSystem: boolean;
  96105. private _timeAccumulator;
  96106. private _currentStepId;
  96107. private _currentInternalStep;
  96108. /**
  96109. * Sets the step Id used by deterministic lock step
  96110. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96111. * @param newStepId defines the step Id
  96112. */
  96113. setStepId(newStepId: number): void;
  96114. /**
  96115. * Gets the step Id used by deterministic lock step
  96116. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96117. * @returns the step Id
  96118. */
  96119. getStepId(): number;
  96120. /**
  96121. * Gets the internal step used by deterministic lock step
  96122. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96123. * @returns the internal step
  96124. */
  96125. getInternalStep(): number;
  96126. private _fogEnabled;
  96127. /**
  96128. * Gets or sets a boolean indicating if fog is enabled on this scene
  96129. * @see http://doc.babylonjs.com/babylon101/environment#fog
  96130. * (Default is true)
  96131. */
  96132. fogEnabled: boolean;
  96133. private _fogMode;
  96134. /**
  96135. * Gets or sets the fog mode to use
  96136. * @see http://doc.babylonjs.com/babylon101/environment#fog
  96137. * | mode | value |
  96138. * | --- | --- |
  96139. * | FOGMODE_NONE | 0 |
  96140. * | FOGMODE_EXP | 1 |
  96141. * | FOGMODE_EXP2 | 2 |
  96142. * | FOGMODE_LINEAR | 3 |
  96143. */
  96144. fogMode: number;
  96145. /**
  96146. * Gets or sets the fog color to use
  96147. * @see http://doc.babylonjs.com/babylon101/environment#fog
  96148. * (Default is Color3(0.2, 0.2, 0.3))
  96149. */
  96150. fogColor: Color3;
  96151. /**
  96152. * Gets or sets the fog density to use
  96153. * @see http://doc.babylonjs.com/babylon101/environment#fog
  96154. * (Default is 0.1)
  96155. */
  96156. fogDensity: number;
  96157. /**
  96158. * Gets or sets the fog start distance to use
  96159. * @see http://doc.babylonjs.com/babylon101/environment#fog
  96160. * (Default is 0)
  96161. */
  96162. fogStart: number;
  96163. /**
  96164. * Gets or sets the fog end distance to use
  96165. * @see http://doc.babylonjs.com/babylon101/environment#fog
  96166. * (Default is 1000)
  96167. */
  96168. fogEnd: number;
  96169. private _shadowsEnabled;
  96170. /**
  96171. * Gets or sets a boolean indicating if shadows are enabled on this scene
  96172. */
  96173. shadowsEnabled: boolean;
  96174. private _lightsEnabled;
  96175. /**
  96176. * Gets or sets a boolean indicating if lights are enabled on this scene
  96177. */
  96178. lightsEnabled: boolean;
  96179. /** All of the active cameras added to this scene. */
  96180. activeCameras: Camera[];
  96181. /** @hidden */
  96182. _activeCamera: Nullable<Camera>;
  96183. /** Gets or sets the current active camera */
  96184. activeCamera: Nullable<Camera>;
  96185. private _defaultMaterial;
  96186. /** The default material used on meshes when no material is affected */
  96187. /** The default material used on meshes when no material is affected */
  96188. defaultMaterial: Material;
  96189. private _texturesEnabled;
  96190. /**
  96191. * Gets or sets a boolean indicating if textures are enabled on this scene
  96192. */
  96193. texturesEnabled: boolean;
  96194. /**
  96195. * Gets or sets a boolean indicating if particles are enabled on this scene
  96196. */
  96197. particlesEnabled: boolean;
  96198. /**
  96199. * Gets or sets a boolean indicating if sprites are enabled on this scene
  96200. */
  96201. spritesEnabled: boolean;
  96202. private _skeletonsEnabled;
  96203. /**
  96204. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  96205. */
  96206. skeletonsEnabled: boolean;
  96207. /**
  96208. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  96209. */
  96210. lensFlaresEnabled: boolean;
  96211. /**
  96212. * Gets or sets a boolean indicating if collisions are enabled on this scene
  96213. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  96214. */
  96215. collisionsEnabled: boolean;
  96216. private _collisionCoordinator;
  96217. /** @hidden */
  96218. readonly collisionCoordinator: ICollisionCoordinator;
  96219. /**
  96220. * Defines the gravity applied to this scene (used only for collisions)
  96221. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  96222. */
  96223. gravity: Vector3;
  96224. /**
  96225. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  96226. */
  96227. postProcessesEnabled: boolean;
  96228. /**
  96229. * The list of postprocesses added to the scene
  96230. */
  96231. postProcesses: PostProcess[];
  96232. /**
  96233. * Gets the current postprocess manager
  96234. */
  96235. postProcessManager: PostProcessManager;
  96236. /**
  96237. * Gets or sets a boolean indicating if render targets are enabled on this scene
  96238. */
  96239. renderTargetsEnabled: boolean;
  96240. /**
  96241. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  96242. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  96243. */
  96244. dumpNextRenderTargets: boolean;
  96245. /**
  96246. * The list of user defined render targets added to the scene
  96247. */
  96248. customRenderTargets: RenderTargetTexture[];
  96249. /**
  96250. * Defines if texture loading must be delayed
  96251. * If true, textures will only be loaded when they need to be rendered
  96252. */
  96253. useDelayedTextureLoading: boolean;
  96254. /**
  96255. * Gets the list of meshes imported to the scene through SceneLoader
  96256. */
  96257. importedMeshesFiles: String[];
  96258. /**
  96259. * Gets or sets a boolean indicating if probes are enabled on this scene
  96260. */
  96261. probesEnabled: boolean;
  96262. /**
  96263. * Gets or sets the current offline provider to use to store scene data
  96264. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  96265. */
  96266. offlineProvider: IOfflineProvider;
  96267. /**
  96268. * Gets or sets the action manager associated with the scene
  96269. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  96270. */
  96271. actionManager: AbstractActionManager;
  96272. private _meshesForIntersections;
  96273. /**
  96274. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  96275. */
  96276. proceduralTexturesEnabled: boolean;
  96277. private _engine;
  96278. private _totalVertices;
  96279. /** @hidden */
  96280. _activeIndices: PerfCounter;
  96281. /** @hidden */
  96282. _activeParticles: PerfCounter;
  96283. /** @hidden */
  96284. _activeBones: PerfCounter;
  96285. private _animationRatio;
  96286. /** @hidden */
  96287. _animationTimeLast: number;
  96288. /** @hidden */
  96289. _animationTime: number;
  96290. /**
  96291. * Gets or sets a general scale for animation speed
  96292. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  96293. */
  96294. animationTimeScale: number;
  96295. /** @hidden */
  96296. _cachedMaterial: Nullable<Material>;
  96297. /** @hidden */
  96298. _cachedEffect: Nullable<Effect>;
  96299. /** @hidden */
  96300. _cachedVisibility: Nullable<number>;
  96301. private _renderId;
  96302. private _frameId;
  96303. private _executeWhenReadyTimeoutId;
  96304. private _intermediateRendering;
  96305. private _viewUpdateFlag;
  96306. private _projectionUpdateFlag;
  96307. /** @hidden */
  96308. _toBeDisposed: Nullable<IDisposable>[];
  96309. private _activeRequests;
  96310. /** @hidden */
  96311. _pendingData: any[];
  96312. private _isDisposed;
  96313. /**
  96314. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  96315. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  96316. */
  96317. dispatchAllSubMeshesOfActiveMeshes: boolean;
  96318. private _activeMeshes;
  96319. private _processedMaterials;
  96320. private _renderTargets;
  96321. /** @hidden */
  96322. _activeParticleSystems: SmartArray<IParticleSystem>;
  96323. private _activeSkeletons;
  96324. private _softwareSkinnedMeshes;
  96325. private _renderingManager;
  96326. /** @hidden */
  96327. _activeAnimatables: Animatable[];
  96328. private _transformMatrix;
  96329. private _sceneUbo;
  96330. /** @hidden */
  96331. _viewMatrix: Matrix;
  96332. private _projectionMatrix;
  96333. /** @hidden */
  96334. _forcedViewPosition: Nullable<Vector3>;
  96335. /** @hidden */
  96336. _frustumPlanes: Plane[];
  96337. /**
  96338. * Gets the list of frustum planes (built from the active camera)
  96339. */
  96340. readonly frustumPlanes: Plane[];
  96341. /**
  96342. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  96343. * This is useful if there are more lights that the maximum simulteanous authorized
  96344. */
  96345. requireLightSorting: boolean;
  96346. /** @hidden */
  96347. readonly useMaterialMeshMap: boolean;
  96348. /** @hidden */
  96349. readonly useClonedMeshhMap: boolean;
  96350. private _externalData;
  96351. private _uid;
  96352. /**
  96353. * @hidden
  96354. * Backing store of defined scene components.
  96355. */
  96356. _components: ISceneComponent[];
  96357. /**
  96358. * @hidden
  96359. * Backing store of defined scene components.
  96360. */
  96361. _serializableComponents: ISceneSerializableComponent[];
  96362. /**
  96363. * List of components to register on the next registration step.
  96364. */
  96365. private _transientComponents;
  96366. /**
  96367. * Registers the transient components if needed.
  96368. */
  96369. private _registerTransientComponents;
  96370. /**
  96371. * @hidden
  96372. * Add a component to the scene.
  96373. * Note that the ccomponent could be registered on th next frame if this is called after
  96374. * the register component stage.
  96375. * @param component Defines the component to add to the scene
  96376. */
  96377. _addComponent(component: ISceneComponent): void;
  96378. /**
  96379. * @hidden
  96380. * Gets a component from the scene.
  96381. * @param name defines the name of the component to retrieve
  96382. * @returns the component or null if not present
  96383. */
  96384. _getComponent(name: string): Nullable<ISceneComponent>;
  96385. /**
  96386. * @hidden
  96387. * Defines the actions happening before camera updates.
  96388. */
  96389. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  96390. /**
  96391. * @hidden
  96392. * Defines the actions happening before clear the canvas.
  96393. */
  96394. _beforeClearStage: Stage<SimpleStageAction>;
  96395. /**
  96396. * @hidden
  96397. * Defines the actions when collecting render targets for the frame.
  96398. */
  96399. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  96400. /**
  96401. * @hidden
  96402. * Defines the actions happening for one camera in the frame.
  96403. */
  96404. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  96405. /**
  96406. * @hidden
  96407. * Defines the actions happening during the per mesh ready checks.
  96408. */
  96409. _isReadyForMeshStage: Stage<MeshStageAction>;
  96410. /**
  96411. * @hidden
  96412. * Defines the actions happening before evaluate active mesh checks.
  96413. */
  96414. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  96415. /**
  96416. * @hidden
  96417. * Defines the actions happening during the evaluate sub mesh checks.
  96418. */
  96419. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  96420. /**
  96421. * @hidden
  96422. * Defines the actions happening during the active mesh stage.
  96423. */
  96424. _activeMeshStage: Stage<ActiveMeshStageAction>;
  96425. /**
  96426. * @hidden
  96427. * Defines the actions happening during the per camera render target step.
  96428. */
  96429. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  96430. /**
  96431. * @hidden
  96432. * Defines the actions happening just before the active camera is drawing.
  96433. */
  96434. _beforeCameraDrawStage: Stage<CameraStageAction>;
  96435. /**
  96436. * @hidden
  96437. * Defines the actions happening just before a render target is drawing.
  96438. */
  96439. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  96440. /**
  96441. * @hidden
  96442. * Defines the actions happening just before a rendering group is drawing.
  96443. */
  96444. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  96445. /**
  96446. * @hidden
  96447. * Defines the actions happening just before a mesh is drawing.
  96448. */
  96449. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  96450. /**
  96451. * @hidden
  96452. * Defines the actions happening just after a mesh has been drawn.
  96453. */
  96454. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  96455. /**
  96456. * @hidden
  96457. * Defines the actions happening just after a rendering group has been drawn.
  96458. */
  96459. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  96460. /**
  96461. * @hidden
  96462. * Defines the actions happening just after the active camera has been drawn.
  96463. */
  96464. _afterCameraDrawStage: Stage<CameraStageAction>;
  96465. /**
  96466. * @hidden
  96467. * Defines the actions happening just after a render target has been drawn.
  96468. */
  96469. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  96470. /**
  96471. * @hidden
  96472. * Defines the actions happening just after rendering all cameras and computing intersections.
  96473. */
  96474. _afterRenderStage: Stage<SimpleStageAction>;
  96475. /**
  96476. * @hidden
  96477. * Defines the actions happening when a pointer move event happens.
  96478. */
  96479. _pointerMoveStage: Stage<PointerMoveStageAction>;
  96480. /**
  96481. * @hidden
  96482. * Defines the actions happening when a pointer down event happens.
  96483. */
  96484. _pointerDownStage: Stage<PointerUpDownStageAction>;
  96485. /**
  96486. * @hidden
  96487. * Defines the actions happening when a pointer up event happens.
  96488. */
  96489. _pointerUpStage: Stage<PointerUpDownStageAction>;
  96490. /**
  96491. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  96492. */
  96493. private geometriesByUniqueId;
  96494. /**
  96495. * Creates a new Scene
  96496. * @param engine defines the engine to use to render this scene
  96497. * @param options defines the scene options
  96498. */
  96499. constructor(engine: Engine, options?: SceneOptions);
  96500. /**
  96501. * Gets a string idenfifying the name of the class
  96502. * @returns "Scene" string
  96503. */
  96504. getClassName(): string;
  96505. private _defaultMeshCandidates;
  96506. /**
  96507. * @hidden
  96508. */
  96509. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  96510. private _defaultSubMeshCandidates;
  96511. /**
  96512. * @hidden
  96513. */
  96514. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  96515. /**
  96516. * Sets the default candidate providers for the scene.
  96517. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  96518. * and getCollidingSubMeshCandidates to their default function
  96519. */
  96520. setDefaultCandidateProviders(): void;
  96521. /**
  96522. * Gets the mesh that is currently under the pointer
  96523. */
  96524. readonly meshUnderPointer: Nullable<AbstractMesh>;
  96525. /**
  96526. * Gets or sets the current on-screen X position of the pointer
  96527. */
  96528. pointerX: number;
  96529. /**
  96530. * Gets or sets the current on-screen Y position of the pointer
  96531. */
  96532. pointerY: number;
  96533. /**
  96534. * Gets the cached material (ie. the latest rendered one)
  96535. * @returns the cached material
  96536. */
  96537. getCachedMaterial(): Nullable<Material>;
  96538. /**
  96539. * Gets the cached effect (ie. the latest rendered one)
  96540. * @returns the cached effect
  96541. */
  96542. getCachedEffect(): Nullable<Effect>;
  96543. /**
  96544. * Gets the cached visibility state (ie. the latest rendered one)
  96545. * @returns the cached visibility state
  96546. */
  96547. getCachedVisibility(): Nullable<number>;
  96548. /**
  96549. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  96550. * @param material defines the current material
  96551. * @param effect defines the current effect
  96552. * @param visibility defines the current visibility state
  96553. * @returns true if one parameter is not cached
  96554. */
  96555. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  96556. /**
  96557. * Gets the engine associated with the scene
  96558. * @returns an Engine
  96559. */
  96560. getEngine(): Engine;
  96561. /**
  96562. * Gets the total number of vertices rendered per frame
  96563. * @returns the total number of vertices rendered per frame
  96564. */
  96565. getTotalVertices(): number;
  96566. /**
  96567. * Gets the performance counter for total vertices
  96568. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  96569. */
  96570. readonly totalVerticesPerfCounter: PerfCounter;
  96571. /**
  96572. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  96573. * @returns the total number of active indices rendered per frame
  96574. */
  96575. getActiveIndices(): number;
  96576. /**
  96577. * Gets the performance counter for active indices
  96578. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  96579. */
  96580. readonly totalActiveIndicesPerfCounter: PerfCounter;
  96581. /**
  96582. * Gets the total number of active particles rendered per frame
  96583. * @returns the total number of active particles rendered per frame
  96584. */
  96585. getActiveParticles(): number;
  96586. /**
  96587. * Gets the performance counter for active particles
  96588. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  96589. */
  96590. readonly activeParticlesPerfCounter: PerfCounter;
  96591. /**
  96592. * Gets the total number of active bones rendered per frame
  96593. * @returns the total number of active bones rendered per frame
  96594. */
  96595. getActiveBones(): number;
  96596. /**
  96597. * Gets the performance counter for active bones
  96598. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  96599. */
  96600. readonly activeBonesPerfCounter: PerfCounter;
  96601. /**
  96602. * Gets the array of active meshes
  96603. * @returns an array of AbstractMesh
  96604. */
  96605. getActiveMeshes(): SmartArray<AbstractMesh>;
  96606. /**
  96607. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  96608. * @returns a number
  96609. */
  96610. getAnimationRatio(): number;
  96611. /**
  96612. * Gets an unique Id for the current render phase
  96613. * @returns a number
  96614. */
  96615. getRenderId(): number;
  96616. /**
  96617. * Gets an unique Id for the current frame
  96618. * @returns a number
  96619. */
  96620. getFrameId(): number;
  96621. /** Call this function if you want to manually increment the render Id*/
  96622. incrementRenderId(): void;
  96623. private _createUbo;
  96624. /**
  96625. * Use this method to simulate a pointer move on a mesh
  96626. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96627. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96628. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96629. * @returns the current scene
  96630. */
  96631. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  96632. /**
  96633. * Use this method to simulate a pointer down on a mesh
  96634. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96635. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96636. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96637. * @returns the current scene
  96638. */
  96639. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  96640. /**
  96641. * Use this method to simulate a pointer up on a mesh
  96642. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96643. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96644. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96645. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  96646. * @returns the current scene
  96647. */
  96648. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  96649. /**
  96650. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  96651. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  96652. * @returns true if the pointer was captured
  96653. */
  96654. isPointerCaptured(pointerId?: number): boolean;
  96655. /**
  96656. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  96657. * @param attachUp defines if you want to attach events to pointerup
  96658. * @param attachDown defines if you want to attach events to pointerdown
  96659. * @param attachMove defines if you want to attach events to pointermove
  96660. */
  96661. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  96662. /** Detaches all event handlers*/
  96663. detachControl(): void;
  96664. /**
  96665. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  96666. * Delay loaded resources are not taking in account
  96667. * @return true if all required resources are ready
  96668. */
  96669. isReady(): boolean;
  96670. /** Resets all cached information relative to material (including effect and visibility) */
  96671. resetCachedMaterial(): void;
  96672. /**
  96673. * Registers a function to be called before every frame render
  96674. * @param func defines the function to register
  96675. */
  96676. registerBeforeRender(func: () => void): void;
  96677. /**
  96678. * Unregisters a function called before every frame render
  96679. * @param func defines the function to unregister
  96680. */
  96681. unregisterBeforeRender(func: () => void): void;
  96682. /**
  96683. * Registers a function to be called after every frame render
  96684. * @param func defines the function to register
  96685. */
  96686. registerAfterRender(func: () => void): void;
  96687. /**
  96688. * Unregisters a function called after every frame render
  96689. * @param func defines the function to unregister
  96690. */
  96691. unregisterAfterRender(func: () => void): void;
  96692. private _executeOnceBeforeRender;
  96693. /**
  96694. * The provided function will run before render once and will be disposed afterwards.
  96695. * A timeout delay can be provided so that the function will be executed in N ms.
  96696. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  96697. * @param func The function to be executed.
  96698. * @param timeout optional delay in ms
  96699. */
  96700. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  96701. /** @hidden */
  96702. _addPendingData(data: any): void;
  96703. /** @hidden */
  96704. _removePendingData(data: any): void;
  96705. /**
  96706. * Returns the number of items waiting to be loaded
  96707. * @returns the number of items waiting to be loaded
  96708. */
  96709. getWaitingItemsCount(): number;
  96710. /**
  96711. * Returns a boolean indicating if the scene is still loading data
  96712. */
  96713. readonly isLoading: boolean;
  96714. /**
  96715. * Registers a function to be executed when the scene is ready
  96716. * @param {Function} func - the function to be executed
  96717. */
  96718. executeWhenReady(func: () => void): void;
  96719. /**
  96720. * Returns a promise that resolves when the scene is ready
  96721. * @returns A promise that resolves when the scene is ready
  96722. */
  96723. whenReadyAsync(): Promise<void>;
  96724. /** @hidden */
  96725. _checkIsReady(): void;
  96726. /**
  96727. * Gets all animatable attached to the scene
  96728. */
  96729. readonly animatables: Animatable[];
  96730. /**
  96731. * Resets the last animation time frame.
  96732. * Useful to override when animations start running when loading a scene for the first time.
  96733. */
  96734. resetLastAnimationTimeFrame(): void;
  96735. /**
  96736. * Gets the current view matrix
  96737. * @returns a Matrix
  96738. */
  96739. getViewMatrix(): Matrix;
  96740. /**
  96741. * Gets the current projection matrix
  96742. * @returns a Matrix
  96743. */
  96744. getProjectionMatrix(): Matrix;
  96745. /**
  96746. * Gets the current transform matrix
  96747. * @returns a Matrix made of View * Projection
  96748. */
  96749. getTransformMatrix(): Matrix;
  96750. /**
  96751. * Sets the current transform matrix
  96752. * @param viewL defines the View matrix to use
  96753. * @param projectionL defines the Projection matrix to use
  96754. * @param viewR defines the right View matrix to use (if provided)
  96755. * @param projectionR defines the right Projection matrix to use (if provided)
  96756. */
  96757. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  96758. /**
  96759. * Gets the uniform buffer used to store scene data
  96760. * @returns a UniformBuffer
  96761. */
  96762. getSceneUniformBuffer(): UniformBuffer;
  96763. /**
  96764. * Gets an unique (relatively to the current scene) Id
  96765. * @returns an unique number for the scene
  96766. */
  96767. getUniqueId(): number;
  96768. /**
  96769. * Add a mesh to the list of scene's meshes
  96770. * @param newMesh defines the mesh to add
  96771. * @param recursive if all child meshes should also be added to the scene
  96772. */
  96773. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  96774. /**
  96775. * Remove a mesh for the list of scene's meshes
  96776. * @param toRemove defines the mesh to remove
  96777. * @param recursive if all child meshes should also be removed from the scene
  96778. * @returns the index where the mesh was in the mesh list
  96779. */
  96780. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  96781. /**
  96782. * Add a transform node to the list of scene's transform nodes
  96783. * @param newTransformNode defines the transform node to add
  96784. */
  96785. addTransformNode(newTransformNode: TransformNode): void;
  96786. /**
  96787. * Remove a transform node for the list of scene's transform nodes
  96788. * @param toRemove defines the transform node to remove
  96789. * @returns the index where the transform node was in the transform node list
  96790. */
  96791. removeTransformNode(toRemove: TransformNode): number;
  96792. /**
  96793. * Remove a skeleton for the list of scene's skeletons
  96794. * @param toRemove defines the skeleton to remove
  96795. * @returns the index where the skeleton was in the skeleton list
  96796. */
  96797. removeSkeleton(toRemove: Skeleton): number;
  96798. /**
  96799. * Remove a morph target for the list of scene's morph targets
  96800. * @param toRemove defines the morph target to remove
  96801. * @returns the index where the morph target was in the morph target list
  96802. */
  96803. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  96804. /**
  96805. * Remove a light for the list of scene's lights
  96806. * @param toRemove defines the light to remove
  96807. * @returns the index where the light was in the light list
  96808. */
  96809. removeLight(toRemove: Light): number;
  96810. /**
  96811. * Remove a camera for the list of scene's cameras
  96812. * @param toRemove defines the camera to remove
  96813. * @returns the index where the camera was in the camera list
  96814. */
  96815. removeCamera(toRemove: Camera): number;
  96816. /**
  96817. * Remove a particle system for the list of scene's particle systems
  96818. * @param toRemove defines the particle system to remove
  96819. * @returns the index where the particle system was in the particle system list
  96820. */
  96821. removeParticleSystem(toRemove: IParticleSystem): number;
  96822. /**
  96823. * Remove a animation for the list of scene's animations
  96824. * @param toRemove defines the animation to remove
  96825. * @returns the index where the animation was in the animation list
  96826. */
  96827. removeAnimation(toRemove: Animation): number;
  96828. /**
  96829. * Will stop the animation of the given target
  96830. * @param target - the target
  96831. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  96832. * @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)
  96833. */
  96834. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  96835. /**
  96836. * Removes the given animation group from this scene.
  96837. * @param toRemove The animation group to remove
  96838. * @returns The index of the removed animation group
  96839. */
  96840. removeAnimationGroup(toRemove: AnimationGroup): number;
  96841. /**
  96842. * Removes the given multi-material from this scene.
  96843. * @param toRemove The multi-material to remove
  96844. * @returns The index of the removed multi-material
  96845. */
  96846. removeMultiMaterial(toRemove: MultiMaterial): number;
  96847. /**
  96848. * Removes the given material from this scene.
  96849. * @param toRemove The material to remove
  96850. * @returns The index of the removed material
  96851. */
  96852. removeMaterial(toRemove: Material): number;
  96853. /**
  96854. * Removes the given action manager from this scene.
  96855. * @param toRemove The action manager to remove
  96856. * @returns The index of the removed action manager
  96857. */
  96858. removeActionManager(toRemove: AbstractActionManager): number;
  96859. /**
  96860. * Removes the given texture from this scene.
  96861. * @param toRemove The texture to remove
  96862. * @returns The index of the removed texture
  96863. */
  96864. removeTexture(toRemove: BaseTexture): number;
  96865. /**
  96866. * Adds the given light to this scene
  96867. * @param newLight The light to add
  96868. */
  96869. addLight(newLight: Light): void;
  96870. /**
  96871. * Sorts the list list based on light priorities
  96872. */
  96873. sortLightsByPriority(): void;
  96874. /**
  96875. * Adds the given camera to this scene
  96876. * @param newCamera The camera to add
  96877. */
  96878. addCamera(newCamera: Camera): void;
  96879. /**
  96880. * Adds the given skeleton to this scene
  96881. * @param newSkeleton The skeleton to add
  96882. */
  96883. addSkeleton(newSkeleton: Skeleton): void;
  96884. /**
  96885. * Adds the given particle system to this scene
  96886. * @param newParticleSystem The particle system to add
  96887. */
  96888. addParticleSystem(newParticleSystem: IParticleSystem): void;
  96889. /**
  96890. * Adds the given animation to this scene
  96891. * @param newAnimation The animation to add
  96892. */
  96893. addAnimation(newAnimation: Animation): void;
  96894. /**
  96895. * Adds the given animation group to this scene.
  96896. * @param newAnimationGroup The animation group to add
  96897. */
  96898. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  96899. /**
  96900. * Adds the given multi-material to this scene
  96901. * @param newMultiMaterial The multi-material to add
  96902. */
  96903. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  96904. /**
  96905. * Adds the given material to this scene
  96906. * @param newMaterial The material to add
  96907. */
  96908. addMaterial(newMaterial: Material): void;
  96909. /**
  96910. * Adds the given morph target to this scene
  96911. * @param newMorphTargetManager The morph target to add
  96912. */
  96913. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  96914. /**
  96915. * Adds the given geometry to this scene
  96916. * @param newGeometry The geometry to add
  96917. */
  96918. addGeometry(newGeometry: Geometry): void;
  96919. /**
  96920. * Adds the given action manager to this scene
  96921. * @param newActionManager The action manager to add
  96922. */
  96923. addActionManager(newActionManager: AbstractActionManager): void;
  96924. /**
  96925. * Adds the given texture to this scene.
  96926. * @param newTexture The texture to add
  96927. */
  96928. addTexture(newTexture: BaseTexture): void;
  96929. /**
  96930. * Switch active camera
  96931. * @param newCamera defines the new active camera
  96932. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  96933. */
  96934. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  96935. /**
  96936. * sets the active camera of the scene using its ID
  96937. * @param id defines the camera's ID
  96938. * @return the new active camera or null if none found.
  96939. */
  96940. setActiveCameraByID(id: string): Nullable<Camera>;
  96941. /**
  96942. * sets the active camera of the scene using its name
  96943. * @param name defines the camera's name
  96944. * @returns the new active camera or null if none found.
  96945. */
  96946. setActiveCameraByName(name: string): Nullable<Camera>;
  96947. /**
  96948. * get an animation group using its name
  96949. * @param name defines the material's name
  96950. * @return the animation group or null if none found.
  96951. */
  96952. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  96953. /**
  96954. * Get a material using its unique id
  96955. * @param uniqueId defines the material's unique id
  96956. * @return the material or null if none found.
  96957. */
  96958. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  96959. /**
  96960. * get a material using its id
  96961. * @param id defines the material's ID
  96962. * @return the material or null if none found.
  96963. */
  96964. getMaterialByID(id: string): Nullable<Material>;
  96965. /**
  96966. * Gets a the last added material using a given id
  96967. * @param id defines the material's ID
  96968. * @return the last material with the given id or null if none found.
  96969. */
  96970. getLastMaterialByID(id: string): Nullable<Material>;
  96971. /**
  96972. * Gets a material using its name
  96973. * @param name defines the material's name
  96974. * @return the material or null if none found.
  96975. */
  96976. getMaterialByName(name: string): Nullable<Material>;
  96977. /**
  96978. * Gets a camera using its id
  96979. * @param id defines the id to look for
  96980. * @returns the camera or null if not found
  96981. */
  96982. getCameraByID(id: string): Nullable<Camera>;
  96983. /**
  96984. * Gets a camera using its unique id
  96985. * @param uniqueId defines the unique id to look for
  96986. * @returns the camera or null if not found
  96987. */
  96988. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  96989. /**
  96990. * Gets a camera using its name
  96991. * @param name defines the camera's name
  96992. * @return the camera or null if none found.
  96993. */
  96994. getCameraByName(name: string): Nullable<Camera>;
  96995. /**
  96996. * Gets a bone using its id
  96997. * @param id defines the bone's id
  96998. * @return the bone or null if not found
  96999. */
  97000. getBoneByID(id: string): Nullable<Bone>;
  97001. /**
  97002. * Gets a bone using its id
  97003. * @param name defines the bone's name
  97004. * @return the bone or null if not found
  97005. */
  97006. getBoneByName(name: string): Nullable<Bone>;
  97007. /**
  97008. * Gets a light node using its name
  97009. * @param name defines the the light's name
  97010. * @return the light or null if none found.
  97011. */
  97012. getLightByName(name: string): Nullable<Light>;
  97013. /**
  97014. * Gets a light node using its id
  97015. * @param id defines the light's id
  97016. * @return the light or null if none found.
  97017. */
  97018. getLightByID(id: string): Nullable<Light>;
  97019. /**
  97020. * Gets a light node using its scene-generated unique ID
  97021. * @param uniqueId defines the light's unique id
  97022. * @return the light or null if none found.
  97023. */
  97024. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  97025. /**
  97026. * Gets a particle system by id
  97027. * @param id defines the particle system id
  97028. * @return the corresponding system or null if none found
  97029. */
  97030. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  97031. /**
  97032. * Gets a geometry using its ID
  97033. * @param id defines the geometry's id
  97034. * @return the geometry or null if none found.
  97035. */
  97036. getGeometryByID(id: string): Nullable<Geometry>;
  97037. private _getGeometryByUniqueID;
  97038. /**
  97039. * Add a new geometry to this scene
  97040. * @param geometry defines the geometry to be added to the scene.
  97041. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  97042. * @return a boolean defining if the geometry was added or not
  97043. */
  97044. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  97045. /**
  97046. * Removes an existing geometry
  97047. * @param geometry defines the geometry to be removed from the scene
  97048. * @return a boolean defining if the geometry was removed or not
  97049. */
  97050. removeGeometry(geometry: Geometry): boolean;
  97051. /**
  97052. * Gets the list of geometries attached to the scene
  97053. * @returns an array of Geometry
  97054. */
  97055. getGeometries(): Geometry[];
  97056. /**
  97057. * Gets the first added mesh found of a given ID
  97058. * @param id defines the id to search for
  97059. * @return the mesh found or null if not found at all
  97060. */
  97061. getMeshByID(id: string): Nullable<AbstractMesh>;
  97062. /**
  97063. * Gets a list of meshes using their id
  97064. * @param id defines the id to search for
  97065. * @returns a list of meshes
  97066. */
  97067. getMeshesByID(id: string): Array<AbstractMesh>;
  97068. /**
  97069. * Gets the first added transform node found of a given ID
  97070. * @param id defines the id to search for
  97071. * @return the found transform node or null if not found at all.
  97072. */
  97073. getTransformNodeByID(id: string): Nullable<TransformNode>;
  97074. /**
  97075. * Gets a transform node with its auto-generated unique id
  97076. * @param uniqueId efines the unique id to search for
  97077. * @return the found transform node or null if not found at all.
  97078. */
  97079. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  97080. /**
  97081. * Gets a list of transform nodes using their id
  97082. * @param id defines the id to search for
  97083. * @returns a list of transform nodes
  97084. */
  97085. getTransformNodesByID(id: string): Array<TransformNode>;
  97086. /**
  97087. * Gets a mesh with its auto-generated unique id
  97088. * @param uniqueId defines the unique id to search for
  97089. * @return the found mesh or null if not found at all.
  97090. */
  97091. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  97092. /**
  97093. * Gets a the last added mesh using a given id
  97094. * @param id defines the id to search for
  97095. * @return the found mesh or null if not found at all.
  97096. */
  97097. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  97098. /**
  97099. * Gets a the last added node (Mesh, Camera, Light) using a given id
  97100. * @param id defines the id to search for
  97101. * @return the found node or null if not found at all
  97102. */
  97103. getLastEntryByID(id: string): Nullable<Node>;
  97104. /**
  97105. * Gets a node (Mesh, Camera, Light) using a given id
  97106. * @param id defines the id to search for
  97107. * @return the found node or null if not found at all
  97108. */
  97109. getNodeByID(id: string): Nullable<Node>;
  97110. /**
  97111. * Gets a node (Mesh, Camera, Light) using a given name
  97112. * @param name defines the name to search for
  97113. * @return the found node or null if not found at all.
  97114. */
  97115. getNodeByName(name: string): Nullable<Node>;
  97116. /**
  97117. * Gets a mesh using a given name
  97118. * @param name defines the name to search for
  97119. * @return the found mesh or null if not found at all.
  97120. */
  97121. getMeshByName(name: string): Nullable<AbstractMesh>;
  97122. /**
  97123. * Gets a transform node using a given name
  97124. * @param name defines the name to search for
  97125. * @return the found transform node or null if not found at all.
  97126. */
  97127. getTransformNodeByName(name: string): Nullable<TransformNode>;
  97128. /**
  97129. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  97130. * @param id defines the id to search for
  97131. * @return the found skeleton or null if not found at all.
  97132. */
  97133. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  97134. /**
  97135. * Gets a skeleton using a given auto generated unique id
  97136. * @param uniqueId defines the unique id to search for
  97137. * @return the found skeleton or null if not found at all.
  97138. */
  97139. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  97140. /**
  97141. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  97142. * @param id defines the id to search for
  97143. * @return the found skeleton or null if not found at all.
  97144. */
  97145. getSkeletonById(id: string): Nullable<Skeleton>;
  97146. /**
  97147. * Gets a skeleton using a given name
  97148. * @param name defines the name to search for
  97149. * @return the found skeleton or null if not found at all.
  97150. */
  97151. getSkeletonByName(name: string): Nullable<Skeleton>;
  97152. /**
  97153. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  97154. * @param id defines the id to search for
  97155. * @return the found morph target manager or null if not found at all.
  97156. */
  97157. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  97158. /**
  97159. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  97160. * @param id defines the id to search for
  97161. * @return the found morph target or null if not found at all.
  97162. */
  97163. getMorphTargetById(id: string): Nullable<MorphTarget>;
  97164. /**
  97165. * Gets a boolean indicating if the given mesh is active
  97166. * @param mesh defines the mesh to look for
  97167. * @returns true if the mesh is in the active list
  97168. */
  97169. isActiveMesh(mesh: AbstractMesh): boolean;
  97170. /**
  97171. * Return a unique id as a string which can serve as an identifier for the scene
  97172. */
  97173. readonly uid: string;
  97174. /**
  97175. * Add an externaly attached data from its key.
  97176. * This method call will fail and return false, if such key already exists.
  97177. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  97178. * @param key the unique key that identifies the data
  97179. * @param data the data object to associate to the key for this Engine instance
  97180. * @return true if no such key were already present and the data was added successfully, false otherwise
  97181. */
  97182. addExternalData<T>(key: string, data: T): boolean;
  97183. /**
  97184. * Get an externaly attached data from its key
  97185. * @param key the unique key that identifies the data
  97186. * @return the associated data, if present (can be null), or undefined if not present
  97187. */
  97188. getExternalData<T>(key: string): Nullable<T>;
  97189. /**
  97190. * Get an externaly attached data from its key, create it using a factory if it's not already present
  97191. * @param key the unique key that identifies the data
  97192. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  97193. * @return the associated data, can be null if the factory returned null.
  97194. */
  97195. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  97196. /**
  97197. * Remove an externaly attached data from the Engine instance
  97198. * @param key the unique key that identifies the data
  97199. * @return true if the data was successfully removed, false if it doesn't exist
  97200. */
  97201. removeExternalData(key: string): boolean;
  97202. private _evaluateSubMesh;
  97203. /**
  97204. * Clear the processed materials smart array preventing retention point in material dispose.
  97205. */
  97206. freeProcessedMaterials(): void;
  97207. private _preventFreeActiveMeshesAndRenderingGroups;
  97208. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  97209. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  97210. * when disposing several meshes in a row or a hierarchy of meshes.
  97211. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  97212. */
  97213. blockfreeActiveMeshesAndRenderingGroups: boolean;
  97214. /**
  97215. * Clear the active meshes smart array preventing retention point in mesh dispose.
  97216. */
  97217. freeActiveMeshes(): void;
  97218. /**
  97219. * Clear the info related to rendering groups preventing retention points during dispose.
  97220. */
  97221. freeRenderingGroups(): void;
  97222. /** @hidden */
  97223. _isInIntermediateRendering(): boolean;
  97224. /**
  97225. * Lambda returning the list of potentially active meshes.
  97226. */
  97227. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  97228. /**
  97229. * Lambda returning the list of potentially active sub meshes.
  97230. */
  97231. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  97232. /**
  97233. * Lambda returning the list of potentially intersecting sub meshes.
  97234. */
  97235. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  97236. /**
  97237. * Lambda returning the list of potentially colliding sub meshes.
  97238. */
  97239. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  97240. private _activeMeshesFrozen;
  97241. /**
  97242. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  97243. * @returns the current scene
  97244. */
  97245. freezeActiveMeshes(): Scene;
  97246. /**
  97247. * Use this function to restart evaluating active meshes on every frame
  97248. * @returns the current scene
  97249. */
  97250. unfreezeActiveMeshes(): Scene;
  97251. private _evaluateActiveMeshes;
  97252. private _activeMesh;
  97253. /**
  97254. * Update the transform matrix to update from the current active camera
  97255. * @param force defines a boolean used to force the update even if cache is up to date
  97256. */
  97257. updateTransformMatrix(force?: boolean): void;
  97258. private _bindFrameBuffer;
  97259. /** @hidden */
  97260. _allowPostProcessClearColor: boolean;
  97261. /** @hidden */
  97262. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  97263. private _processSubCameras;
  97264. private _checkIntersections;
  97265. /** @hidden */
  97266. _advancePhysicsEngineStep(step: number): void;
  97267. /**
  97268. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  97269. */
  97270. getDeterministicFrameTime: () => number;
  97271. /** @hidden */
  97272. _animate(): void;
  97273. /** Execute all animations (for a frame) */
  97274. animate(): void;
  97275. /**
  97276. * Render the scene
  97277. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  97278. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  97279. */
  97280. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  97281. /**
  97282. * Freeze all materials
  97283. * A frozen material will not be updatable but should be faster to render
  97284. */
  97285. freezeMaterials(): void;
  97286. /**
  97287. * Unfreeze all materials
  97288. * A frozen material will not be updatable but should be faster to render
  97289. */
  97290. unfreezeMaterials(): void;
  97291. /**
  97292. * Releases all held ressources
  97293. */
  97294. dispose(): void;
  97295. /**
  97296. * Gets if the scene is already disposed
  97297. */
  97298. readonly isDisposed: boolean;
  97299. /**
  97300. * Call this function to reduce memory footprint of the scene.
  97301. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  97302. */
  97303. clearCachedVertexData(): void;
  97304. /**
  97305. * This function will remove the local cached buffer data from texture.
  97306. * It will save memory but will prevent the texture from being rebuilt
  97307. */
  97308. cleanCachedTextureBuffer(): void;
  97309. /**
  97310. * Get the world extend vectors with an optional filter
  97311. *
  97312. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  97313. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  97314. */
  97315. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  97316. min: Vector3;
  97317. max: Vector3;
  97318. };
  97319. /**
  97320. * Creates a ray that can be used to pick in the scene
  97321. * @param x defines the x coordinate of the origin (on-screen)
  97322. * @param y defines the y coordinate of the origin (on-screen)
  97323. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  97324. * @param camera defines the camera to use for the picking
  97325. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  97326. * @returns a Ray
  97327. */
  97328. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  97329. /**
  97330. * Creates a ray that can be used to pick in the scene
  97331. * @param x defines the x coordinate of the origin (on-screen)
  97332. * @param y defines the y coordinate of the origin (on-screen)
  97333. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  97334. * @param result defines the ray where to store the picking ray
  97335. * @param camera defines the camera to use for the picking
  97336. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  97337. * @returns the current scene
  97338. */
  97339. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  97340. /**
  97341. * Creates a ray that can be used to pick in the scene
  97342. * @param x defines the x coordinate of the origin (on-screen)
  97343. * @param y defines the y coordinate of the origin (on-screen)
  97344. * @param camera defines the camera to use for the picking
  97345. * @returns a Ray
  97346. */
  97347. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  97348. /**
  97349. * Creates a ray that can be used to pick in the scene
  97350. * @param x defines the x coordinate of the origin (on-screen)
  97351. * @param y defines the y coordinate of the origin (on-screen)
  97352. * @param result defines the ray where to store the picking ray
  97353. * @param camera defines the camera to use for the picking
  97354. * @returns the current scene
  97355. */
  97356. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  97357. /** Launch a ray to try to pick a mesh in the scene
  97358. * @param x position on screen
  97359. * @param y position on screen
  97360. * @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
  97361. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  97362. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  97363. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  97364. * @returns a PickingInfo
  97365. */
  97366. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  97367. /** Use the given ray to pick a mesh in the scene
  97368. * @param ray The ray to use to pick meshes
  97369. * @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
  97370. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  97371. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  97372. * @returns a PickingInfo
  97373. */
  97374. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  97375. /**
  97376. * Launch a ray to try to pick a mesh in the scene
  97377. * @param x X position on screen
  97378. * @param y Y position on screen
  97379. * @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
  97380. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  97381. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  97382. * @returns an array of PickingInfo
  97383. */
  97384. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  97385. /**
  97386. * Launch a ray to try to pick a mesh in the scene
  97387. * @param ray Ray to use
  97388. * @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
  97389. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  97390. * @returns an array of PickingInfo
  97391. */
  97392. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  97393. /**
  97394. * Force the value of meshUnderPointer
  97395. * @param mesh defines the mesh to use
  97396. */
  97397. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  97398. /**
  97399. * Gets the mesh under the pointer
  97400. * @returns a Mesh or null if no mesh is under the pointer
  97401. */
  97402. getPointerOverMesh(): Nullable<AbstractMesh>;
  97403. /** @hidden */
  97404. _rebuildGeometries(): void;
  97405. /** @hidden */
  97406. _rebuildTextures(): void;
  97407. private _getByTags;
  97408. /**
  97409. * Get a list of meshes by tags
  97410. * @param tagsQuery defines the tags query to use
  97411. * @param forEach defines a predicate used to filter results
  97412. * @returns an array of Mesh
  97413. */
  97414. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  97415. /**
  97416. * Get a list of cameras by tags
  97417. * @param tagsQuery defines the tags query to use
  97418. * @param forEach defines a predicate used to filter results
  97419. * @returns an array of Camera
  97420. */
  97421. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  97422. /**
  97423. * Get a list of lights by tags
  97424. * @param tagsQuery defines the tags query to use
  97425. * @param forEach defines a predicate used to filter results
  97426. * @returns an array of Light
  97427. */
  97428. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  97429. /**
  97430. * Get a list of materials by tags
  97431. * @param tagsQuery defines the tags query to use
  97432. * @param forEach defines a predicate used to filter results
  97433. * @returns an array of Material
  97434. */
  97435. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  97436. /**
  97437. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  97438. * This allowed control for front to back rendering or reversly depending of the special needs.
  97439. *
  97440. * @param renderingGroupId The rendering group id corresponding to its index
  97441. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  97442. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  97443. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  97444. */
  97445. 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;
  97446. /**
  97447. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  97448. *
  97449. * @param renderingGroupId The rendering group id corresponding to its index
  97450. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  97451. * @param depth Automatically clears depth between groups if true and autoClear is true.
  97452. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  97453. */
  97454. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  97455. /**
  97456. * Gets the current auto clear configuration for one rendering group of the rendering
  97457. * manager.
  97458. * @param index the rendering group index to get the information for
  97459. * @returns The auto clear setup for the requested rendering group
  97460. */
  97461. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  97462. private _blockMaterialDirtyMechanism;
  97463. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  97464. blockMaterialDirtyMechanism: boolean;
  97465. /**
  97466. * Will flag all materials as dirty to trigger new shader compilation
  97467. * @param flag defines the flag used to specify which material part must be marked as dirty
  97468. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  97469. */
  97470. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  97471. /** @hidden */
  97472. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  97473. /** @hidden */
  97474. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  97475. }
  97476. }
  97477. declare module BABYLON {
  97478. /**
  97479. * Set of assets to keep when moving a scene into an asset container.
  97480. */
  97481. export class KeepAssets extends AbstractScene {
  97482. }
  97483. /**
  97484. * Container with a set of assets that can be added or removed from a scene.
  97485. */
  97486. export class AssetContainer extends AbstractScene {
  97487. /**
  97488. * The scene the AssetContainer belongs to.
  97489. */
  97490. scene: Scene;
  97491. /**
  97492. * Instantiates an AssetContainer.
  97493. * @param scene The scene the AssetContainer belongs to.
  97494. */
  97495. constructor(scene: Scene);
  97496. /**
  97497. * Adds all the assets from the container to the scene.
  97498. */
  97499. addAllToScene(): void;
  97500. /**
  97501. * Removes all the assets in the container from the scene
  97502. */
  97503. removeAllFromScene(): void;
  97504. /**
  97505. * Disposes all the assets in the container
  97506. */
  97507. dispose(): void;
  97508. private _moveAssets;
  97509. /**
  97510. * Removes all the assets contained in the scene and adds them to the container.
  97511. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  97512. */
  97513. moveAllFromScene(keepAssets?: KeepAssets): void;
  97514. /**
  97515. * 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.
  97516. * @returns the root mesh
  97517. */
  97518. createRootMesh(): Mesh;
  97519. }
  97520. }
  97521. declare module BABYLON {
  97522. /**
  97523. * Defines how the parser contract is defined.
  97524. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  97525. */
  97526. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  97527. /**
  97528. * Defines how the individual parser contract is defined.
  97529. * These parser can parse an individual asset
  97530. */
  97531. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  97532. /**
  97533. * Base class of the scene acting as a container for the different elements composing a scene.
  97534. * This class is dynamically extended by the different components of the scene increasing
  97535. * flexibility and reducing coupling
  97536. */
  97537. export abstract class AbstractScene {
  97538. /**
  97539. * Stores the list of available parsers in the application.
  97540. */
  97541. private static _BabylonFileParsers;
  97542. /**
  97543. * Stores the list of available individual parsers in the application.
  97544. */
  97545. private static _IndividualBabylonFileParsers;
  97546. /**
  97547. * Adds a parser in the list of available ones
  97548. * @param name Defines the name of the parser
  97549. * @param parser Defines the parser to add
  97550. */
  97551. static AddParser(name: string, parser: BabylonFileParser): void;
  97552. /**
  97553. * Gets a general parser from the list of avaialble ones
  97554. * @param name Defines the name of the parser
  97555. * @returns the requested parser or null
  97556. */
  97557. static GetParser(name: string): Nullable<BabylonFileParser>;
  97558. /**
  97559. * Adds n individual parser in the list of available ones
  97560. * @param name Defines the name of the parser
  97561. * @param parser Defines the parser to add
  97562. */
  97563. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  97564. /**
  97565. * Gets an individual parser from the list of avaialble ones
  97566. * @param name Defines the name of the parser
  97567. * @returns the requested parser or null
  97568. */
  97569. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  97570. /**
  97571. * Parser json data and populate both a scene and its associated container object
  97572. * @param jsonData Defines the data to parse
  97573. * @param scene Defines the scene to parse the data for
  97574. * @param container Defines the container attached to the parsing sequence
  97575. * @param rootUrl Defines the root url of the data
  97576. */
  97577. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  97578. /**
  97579. * Gets the list of root nodes (ie. nodes with no parent)
  97580. */
  97581. rootNodes: Node[];
  97582. /** All of the cameras added to this scene
  97583. * @see http://doc.babylonjs.com/babylon101/cameras
  97584. */
  97585. cameras: Camera[];
  97586. /**
  97587. * All of the lights added to this scene
  97588. * @see http://doc.babylonjs.com/babylon101/lights
  97589. */
  97590. lights: Light[];
  97591. /**
  97592. * All of the (abstract) meshes added to this scene
  97593. */
  97594. meshes: AbstractMesh[];
  97595. /**
  97596. * The list of skeletons added to the scene
  97597. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  97598. */
  97599. skeletons: Skeleton[];
  97600. /**
  97601. * All of the particle systems added to this scene
  97602. * @see http://doc.babylonjs.com/babylon101/particles
  97603. */
  97604. particleSystems: IParticleSystem[];
  97605. /**
  97606. * Gets a list of Animations associated with the scene
  97607. */
  97608. animations: Animation[];
  97609. /**
  97610. * All of the animation groups added to this scene
  97611. * @see http://doc.babylonjs.com/how_to/group
  97612. */
  97613. animationGroups: AnimationGroup[];
  97614. /**
  97615. * All of the multi-materials added to this scene
  97616. * @see http://doc.babylonjs.com/how_to/multi_materials
  97617. */
  97618. multiMaterials: MultiMaterial[];
  97619. /**
  97620. * All of the materials added to this scene
  97621. * In the context of a Scene, it is not supposed to be modified manually.
  97622. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  97623. * Note also that the order of the Material wihin the array is not significant and might change.
  97624. * @see http://doc.babylonjs.com/babylon101/materials
  97625. */
  97626. materials: Material[];
  97627. /**
  97628. * The list of morph target managers added to the scene
  97629. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  97630. */
  97631. morphTargetManagers: MorphTargetManager[];
  97632. /**
  97633. * The list of geometries used in the scene.
  97634. */
  97635. geometries: Geometry[];
  97636. /**
  97637. * All of the tranform nodes added to this scene
  97638. * In the context of a Scene, it is not supposed to be modified manually.
  97639. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  97640. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  97641. * @see http://doc.babylonjs.com/how_to/transformnode
  97642. */
  97643. transformNodes: TransformNode[];
  97644. /**
  97645. * ActionManagers available on the scene.
  97646. */
  97647. actionManagers: AbstractActionManager[];
  97648. /**
  97649. * Textures to keep.
  97650. */
  97651. textures: BaseTexture[];
  97652. /**
  97653. * Environment texture for the scene
  97654. */
  97655. environmentTexture: Nullable<BaseTexture>;
  97656. }
  97657. }
  97658. declare module BABYLON {
  97659. /**
  97660. * Interface used to define options for Sound class
  97661. */
  97662. export interface ISoundOptions {
  97663. /**
  97664. * Does the sound autoplay once loaded.
  97665. */
  97666. autoplay?: boolean;
  97667. /**
  97668. * Does the sound loop after it finishes playing once.
  97669. */
  97670. loop?: boolean;
  97671. /**
  97672. * Sound's volume
  97673. */
  97674. volume?: number;
  97675. /**
  97676. * Is it a spatial sound?
  97677. */
  97678. spatialSound?: boolean;
  97679. /**
  97680. * Maximum distance to hear that sound
  97681. */
  97682. maxDistance?: number;
  97683. /**
  97684. * Uses user defined attenuation function
  97685. */
  97686. useCustomAttenuation?: boolean;
  97687. /**
  97688. * Define the roll off factor of spatial sounds.
  97689. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97690. */
  97691. rolloffFactor?: number;
  97692. /**
  97693. * Define the reference distance the sound should be heard perfectly.
  97694. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97695. */
  97696. refDistance?: number;
  97697. /**
  97698. * Define the distance attenuation model the sound will follow.
  97699. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97700. */
  97701. distanceModel?: string;
  97702. /**
  97703. * Defines the playback speed (1 by default)
  97704. */
  97705. playbackRate?: number;
  97706. /**
  97707. * Defines if the sound is from a streaming source
  97708. */
  97709. streaming?: boolean;
  97710. /**
  97711. * Defines an optional length (in seconds) inside the sound file
  97712. */
  97713. length?: number;
  97714. /**
  97715. * Defines an optional offset (in seconds) inside the sound file
  97716. */
  97717. offset?: number;
  97718. /**
  97719. * If true, URLs will not be required to state the audio file codec to use.
  97720. */
  97721. skipCodecCheck?: boolean;
  97722. }
  97723. /**
  97724. * Defines a sound that can be played in the application.
  97725. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  97726. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97727. */
  97728. export class Sound {
  97729. /**
  97730. * The name of the sound in the scene.
  97731. */
  97732. name: string;
  97733. /**
  97734. * Does the sound autoplay once loaded.
  97735. */
  97736. autoplay: boolean;
  97737. /**
  97738. * Does the sound loop after it finishes playing once.
  97739. */
  97740. loop: boolean;
  97741. /**
  97742. * Does the sound use a custom attenuation curve to simulate the falloff
  97743. * happening when the source gets further away from the camera.
  97744. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  97745. */
  97746. useCustomAttenuation: boolean;
  97747. /**
  97748. * The sound track id this sound belongs to.
  97749. */
  97750. soundTrackId: number;
  97751. /**
  97752. * Is this sound currently played.
  97753. */
  97754. isPlaying: boolean;
  97755. /**
  97756. * Is this sound currently paused.
  97757. */
  97758. isPaused: boolean;
  97759. /**
  97760. * Does this sound enables spatial sound.
  97761. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97762. */
  97763. spatialSound: boolean;
  97764. /**
  97765. * Define the reference distance the sound should be heard perfectly.
  97766. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97767. */
  97768. refDistance: number;
  97769. /**
  97770. * Define the roll off factor of spatial sounds.
  97771. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97772. */
  97773. rolloffFactor: number;
  97774. /**
  97775. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  97776. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97777. */
  97778. maxDistance: number;
  97779. /**
  97780. * Define the distance attenuation model the sound will follow.
  97781. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97782. */
  97783. distanceModel: string;
  97784. /**
  97785. * @hidden
  97786. * Back Compat
  97787. **/
  97788. onended: () => any;
  97789. /**
  97790. * Observable event when the current playing sound finishes.
  97791. */
  97792. onEndedObservable: Observable<Sound>;
  97793. private _panningModel;
  97794. private _playbackRate;
  97795. private _streaming;
  97796. private _startTime;
  97797. private _startOffset;
  97798. private _position;
  97799. /** @hidden */
  97800. _positionInEmitterSpace: boolean;
  97801. private _localDirection;
  97802. private _volume;
  97803. private _isReadyToPlay;
  97804. private _isDirectional;
  97805. private _readyToPlayCallback;
  97806. private _audioBuffer;
  97807. private _soundSource;
  97808. private _streamingSource;
  97809. private _soundPanner;
  97810. private _soundGain;
  97811. private _inputAudioNode;
  97812. private _outputAudioNode;
  97813. private _coneInnerAngle;
  97814. private _coneOuterAngle;
  97815. private _coneOuterGain;
  97816. private _scene;
  97817. private _connectedTransformNode;
  97818. private _customAttenuationFunction;
  97819. private _registerFunc;
  97820. private _isOutputConnected;
  97821. private _htmlAudioElement;
  97822. private _urlType;
  97823. private _length?;
  97824. private _offset?;
  97825. /** @hidden */
  97826. static _SceneComponentInitialization: (scene: Scene) => void;
  97827. /**
  97828. * Create a sound and attach it to a scene
  97829. * @param name Name of your sound
  97830. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  97831. * @param scene defines the scene the sound belongs to
  97832. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  97833. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  97834. */
  97835. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  97836. /**
  97837. * Release the sound and its associated resources
  97838. */
  97839. dispose(): void;
  97840. /**
  97841. * Gets if the sounds is ready to be played or not.
  97842. * @returns true if ready, otherwise false
  97843. */
  97844. isReady(): boolean;
  97845. private _soundLoaded;
  97846. /**
  97847. * Sets the data of the sound from an audiobuffer
  97848. * @param audioBuffer The audioBuffer containing the data
  97849. */
  97850. setAudioBuffer(audioBuffer: AudioBuffer): void;
  97851. /**
  97852. * Updates the current sounds options such as maxdistance, loop...
  97853. * @param options A JSON object containing values named as the object properties
  97854. */
  97855. updateOptions(options: ISoundOptions): void;
  97856. private _createSpatialParameters;
  97857. private _updateSpatialParameters;
  97858. /**
  97859. * Switch the panning model to HRTF:
  97860. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  97861. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97862. */
  97863. switchPanningModelToHRTF(): void;
  97864. /**
  97865. * Switch the panning model to Equal Power:
  97866. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  97867. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97868. */
  97869. switchPanningModelToEqualPower(): void;
  97870. private _switchPanningModel;
  97871. /**
  97872. * Connect this sound to a sound track audio node like gain...
  97873. * @param soundTrackAudioNode the sound track audio node to connect to
  97874. */
  97875. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  97876. /**
  97877. * Transform this sound into a directional source
  97878. * @param coneInnerAngle Size of the inner cone in degree
  97879. * @param coneOuterAngle Size of the outer cone in degree
  97880. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  97881. */
  97882. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  97883. /**
  97884. * Gets or sets the inner angle for the directional cone.
  97885. */
  97886. /**
  97887. * Gets or sets the inner angle for the directional cone.
  97888. */
  97889. directionalConeInnerAngle: number;
  97890. /**
  97891. * Gets or sets the outer angle for the directional cone.
  97892. */
  97893. /**
  97894. * Gets or sets the outer angle for the directional cone.
  97895. */
  97896. directionalConeOuterAngle: number;
  97897. /**
  97898. * Sets the position of the emitter if spatial sound is enabled
  97899. * @param newPosition Defines the new posisiton
  97900. */
  97901. setPosition(newPosition: Vector3): void;
  97902. /**
  97903. * Sets the local direction of the emitter if spatial sound is enabled
  97904. * @param newLocalDirection Defines the new local direction
  97905. */
  97906. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  97907. private _updateDirection;
  97908. /** @hidden */
  97909. updateDistanceFromListener(): void;
  97910. /**
  97911. * Sets a new custom attenuation function for the sound.
  97912. * @param callback Defines the function used for the attenuation
  97913. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  97914. */
  97915. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  97916. /**
  97917. * Play the sound
  97918. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  97919. * @param offset (optional) Start the sound at a specific time in seconds
  97920. * @param length (optional) Sound duration (in seconds)
  97921. */
  97922. play(time?: number, offset?: number, length?: number): void;
  97923. private _onended;
  97924. /**
  97925. * Stop the sound
  97926. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  97927. */
  97928. stop(time?: number): void;
  97929. /**
  97930. * Put the sound in pause
  97931. */
  97932. pause(): void;
  97933. /**
  97934. * Sets a dedicated volume for this sounds
  97935. * @param newVolume Define the new volume of the sound
  97936. * @param time Define time for gradual change to new volume
  97937. */
  97938. setVolume(newVolume: number, time?: number): void;
  97939. /**
  97940. * Set the sound play back rate
  97941. * @param newPlaybackRate Define the playback rate the sound should be played at
  97942. */
  97943. setPlaybackRate(newPlaybackRate: number): void;
  97944. /**
  97945. * Gets the volume of the sound.
  97946. * @returns the volume of the sound
  97947. */
  97948. getVolume(): number;
  97949. /**
  97950. * Attach the sound to a dedicated mesh
  97951. * @param transformNode The transform node to connect the sound with
  97952. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  97953. */
  97954. attachToMesh(transformNode: TransformNode): void;
  97955. /**
  97956. * Detach the sound from the previously attached mesh
  97957. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  97958. */
  97959. detachFromMesh(): void;
  97960. private _onRegisterAfterWorldMatrixUpdate;
  97961. /**
  97962. * Clone the current sound in the scene.
  97963. * @returns the new sound clone
  97964. */
  97965. clone(): Nullable<Sound>;
  97966. /**
  97967. * Gets the current underlying audio buffer containing the data
  97968. * @returns the audio buffer
  97969. */
  97970. getAudioBuffer(): Nullable<AudioBuffer>;
  97971. /**
  97972. * Serializes the Sound in a JSON representation
  97973. * @returns the JSON representation of the sound
  97974. */
  97975. serialize(): any;
  97976. /**
  97977. * Parse a JSON representation of a sound to innstantiate in a given scene
  97978. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  97979. * @param scene Define the scene the new parsed sound should be created in
  97980. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  97981. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  97982. * @returns the newly parsed sound
  97983. */
  97984. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  97985. }
  97986. }
  97987. declare module BABYLON {
  97988. /**
  97989. * This defines an action helpful to play a defined sound on a triggered action.
  97990. */
  97991. export class PlaySoundAction extends Action {
  97992. private _sound;
  97993. /**
  97994. * Instantiate the action
  97995. * @param triggerOptions defines the trigger options
  97996. * @param sound defines the sound to play
  97997. * @param condition defines the trigger related conditions
  97998. */
  97999. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  98000. /** @hidden */
  98001. _prepare(): void;
  98002. /**
  98003. * Execute the action and play the sound.
  98004. */
  98005. execute(): void;
  98006. /**
  98007. * Serializes the actions and its related information.
  98008. * @param parent defines the object to serialize in
  98009. * @returns the serialized object
  98010. */
  98011. serialize(parent: any): any;
  98012. }
  98013. /**
  98014. * This defines an action helpful to stop a defined sound on a triggered action.
  98015. */
  98016. export class StopSoundAction extends Action {
  98017. private _sound;
  98018. /**
  98019. * Instantiate the action
  98020. * @param triggerOptions defines the trigger options
  98021. * @param sound defines the sound to stop
  98022. * @param condition defines the trigger related conditions
  98023. */
  98024. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  98025. /** @hidden */
  98026. _prepare(): void;
  98027. /**
  98028. * Execute the action and stop the sound.
  98029. */
  98030. execute(): void;
  98031. /**
  98032. * Serializes the actions and its related information.
  98033. * @param parent defines the object to serialize in
  98034. * @returns the serialized object
  98035. */
  98036. serialize(parent: any): any;
  98037. }
  98038. }
  98039. declare module BABYLON {
  98040. /**
  98041. * This defines an action responsible to change the value of a property
  98042. * by interpolating between its current value and the newly set one once triggered.
  98043. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  98044. */
  98045. export class InterpolateValueAction extends Action {
  98046. /**
  98047. * Defines the path of the property where the value should be interpolated
  98048. */
  98049. propertyPath: string;
  98050. /**
  98051. * Defines the target value at the end of the interpolation.
  98052. */
  98053. value: any;
  98054. /**
  98055. * Defines the time it will take for the property to interpolate to the value.
  98056. */
  98057. duration: number;
  98058. /**
  98059. * Defines if the other scene animations should be stopped when the action has been triggered
  98060. */
  98061. stopOtherAnimations?: boolean;
  98062. /**
  98063. * Defines a callback raised once the interpolation animation has been done.
  98064. */
  98065. onInterpolationDone?: () => void;
  98066. /**
  98067. * Observable triggered once the interpolation animation has been done.
  98068. */
  98069. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  98070. private _target;
  98071. private _effectiveTarget;
  98072. private _property;
  98073. /**
  98074. * Instantiate the action
  98075. * @param triggerOptions defines the trigger options
  98076. * @param target defines the object containing the value to interpolate
  98077. * @param propertyPath defines the path to the property in the target object
  98078. * @param value defines the target value at the end of the interpolation
  98079. * @param duration deines the time it will take for the property to interpolate to the value.
  98080. * @param condition defines the trigger related conditions
  98081. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  98082. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  98083. */
  98084. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  98085. /** @hidden */
  98086. _prepare(): void;
  98087. /**
  98088. * Execute the action starts the value interpolation.
  98089. */
  98090. execute(): void;
  98091. /**
  98092. * Serializes the actions and its related information.
  98093. * @param parent defines the object to serialize in
  98094. * @returns the serialized object
  98095. */
  98096. serialize(parent: any): any;
  98097. }
  98098. }
  98099. declare module BABYLON {
  98100. /**
  98101. * Options allowed during the creation of a sound track.
  98102. */
  98103. export interface ISoundTrackOptions {
  98104. /**
  98105. * The volume the sound track should take during creation
  98106. */
  98107. volume?: number;
  98108. /**
  98109. * Define if the sound track is the main sound track of the scene
  98110. */
  98111. mainTrack?: boolean;
  98112. }
  98113. /**
  98114. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  98115. * It will be also used in a future release to apply effects on a specific track.
  98116. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  98117. */
  98118. export class SoundTrack {
  98119. /**
  98120. * The unique identifier of the sound track in the scene.
  98121. */
  98122. id: number;
  98123. /**
  98124. * The list of sounds included in the sound track.
  98125. */
  98126. soundCollection: Array<Sound>;
  98127. private _outputAudioNode;
  98128. private _scene;
  98129. private _isMainTrack;
  98130. private _connectedAnalyser;
  98131. private _options;
  98132. private _isInitialized;
  98133. /**
  98134. * Creates a new sound track.
  98135. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  98136. * @param scene Define the scene the sound track belongs to
  98137. * @param options
  98138. */
  98139. constructor(scene: Scene, options?: ISoundTrackOptions);
  98140. private _initializeSoundTrackAudioGraph;
  98141. /**
  98142. * Release the sound track and its associated resources
  98143. */
  98144. dispose(): void;
  98145. /**
  98146. * Adds a sound to this sound track
  98147. * @param sound define the cound to add
  98148. * @ignoreNaming
  98149. */
  98150. AddSound(sound: Sound): void;
  98151. /**
  98152. * Removes a sound to this sound track
  98153. * @param sound define the cound to remove
  98154. * @ignoreNaming
  98155. */
  98156. RemoveSound(sound: Sound): void;
  98157. /**
  98158. * Set a global volume for the full sound track.
  98159. * @param newVolume Define the new volume of the sound track
  98160. */
  98161. setVolume(newVolume: number): void;
  98162. /**
  98163. * Switch the panning model to HRTF:
  98164. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  98165. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98166. */
  98167. switchPanningModelToHRTF(): void;
  98168. /**
  98169. * Switch the panning model to Equal Power:
  98170. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  98171. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98172. */
  98173. switchPanningModelToEqualPower(): void;
  98174. /**
  98175. * Connect the sound track to an audio analyser allowing some amazing
  98176. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  98177. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  98178. * @param analyser The analyser to connect to the engine
  98179. */
  98180. connectToAnalyser(analyser: Analyser): void;
  98181. }
  98182. }
  98183. declare module BABYLON {
  98184. interface AbstractScene {
  98185. /**
  98186. * The list of sounds used in the scene.
  98187. */
  98188. sounds: Nullable<Array<Sound>>;
  98189. }
  98190. interface Scene {
  98191. /**
  98192. * @hidden
  98193. * Backing field
  98194. */
  98195. _mainSoundTrack: SoundTrack;
  98196. /**
  98197. * The main sound track played by the scene.
  98198. * It cotains your primary collection of sounds.
  98199. */
  98200. mainSoundTrack: SoundTrack;
  98201. /**
  98202. * The list of sound tracks added to the scene
  98203. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98204. */
  98205. soundTracks: Nullable<Array<SoundTrack>>;
  98206. /**
  98207. * Gets a sound using a given name
  98208. * @param name defines the name to search for
  98209. * @return the found sound or null if not found at all.
  98210. */
  98211. getSoundByName(name: string): Nullable<Sound>;
  98212. /**
  98213. * Gets or sets if audio support is enabled
  98214. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98215. */
  98216. audioEnabled: boolean;
  98217. /**
  98218. * Gets or sets if audio will be output to headphones
  98219. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98220. */
  98221. headphone: boolean;
  98222. }
  98223. /**
  98224. * Defines the sound scene component responsible to manage any sounds
  98225. * in a given scene.
  98226. */
  98227. export class AudioSceneComponent implements ISceneSerializableComponent {
  98228. /**
  98229. * The component name helpfull to identify the component in the list of scene components.
  98230. */
  98231. readonly name: string;
  98232. /**
  98233. * The scene the component belongs to.
  98234. */
  98235. scene: Scene;
  98236. private _audioEnabled;
  98237. /**
  98238. * Gets whether audio is enabled or not.
  98239. * Please use related enable/disable method to switch state.
  98240. */
  98241. readonly audioEnabled: boolean;
  98242. private _headphone;
  98243. /**
  98244. * Gets whether audio is outputing to headphone or not.
  98245. * Please use the according Switch methods to change output.
  98246. */
  98247. readonly headphone: boolean;
  98248. /**
  98249. * Creates a new instance of the component for the given scene
  98250. * @param scene Defines the scene to register the component in
  98251. */
  98252. constructor(scene: Scene);
  98253. /**
  98254. * Registers the component in a given scene
  98255. */
  98256. register(): void;
  98257. /**
  98258. * Rebuilds the elements related to this component in case of
  98259. * context lost for instance.
  98260. */
  98261. rebuild(): void;
  98262. /**
  98263. * Serializes the component data to the specified json object
  98264. * @param serializationObject The object to serialize to
  98265. */
  98266. serialize(serializationObject: any): void;
  98267. /**
  98268. * Adds all the elements from the container to the scene
  98269. * @param container the container holding the elements
  98270. */
  98271. addFromContainer(container: AbstractScene): void;
  98272. /**
  98273. * Removes all the elements in the container from the scene
  98274. * @param container contains the elements to remove
  98275. * @param dispose if the removed element should be disposed (default: false)
  98276. */
  98277. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  98278. /**
  98279. * Disposes the component and the associated ressources.
  98280. */
  98281. dispose(): void;
  98282. /**
  98283. * Disables audio in the associated scene.
  98284. */
  98285. disableAudio(): void;
  98286. /**
  98287. * Enables audio in the associated scene.
  98288. */
  98289. enableAudio(): void;
  98290. /**
  98291. * Switch audio to headphone output.
  98292. */
  98293. switchAudioModeForHeadphones(): void;
  98294. /**
  98295. * Switch audio to normal speakers.
  98296. */
  98297. switchAudioModeForNormalSpeakers(): void;
  98298. private _afterRender;
  98299. }
  98300. }
  98301. declare module BABYLON {
  98302. /**
  98303. * Wraps one or more Sound objects and selects one with random weight for playback.
  98304. */
  98305. export class WeightedSound {
  98306. /** When true a Sound will be selected and played when the current playing Sound completes. */
  98307. loop: boolean;
  98308. private _coneInnerAngle;
  98309. private _coneOuterAngle;
  98310. private _volume;
  98311. /** A Sound is currently playing. */
  98312. isPlaying: boolean;
  98313. /** A Sound is currently paused. */
  98314. isPaused: boolean;
  98315. private _sounds;
  98316. private _weights;
  98317. private _currentIndex?;
  98318. /**
  98319. * Creates a new WeightedSound from the list of sounds given.
  98320. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  98321. * @param sounds Array of Sounds that will be selected from.
  98322. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  98323. */
  98324. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  98325. /**
  98326. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  98327. */
  98328. /**
  98329. * The size of cone in degress for a directional sound in which there will be no attenuation.
  98330. */
  98331. directionalConeInnerAngle: number;
  98332. /**
  98333. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  98334. * Listener angles between innerAngle and outerAngle will falloff linearly.
  98335. */
  98336. /**
  98337. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  98338. * Listener angles between innerAngle and outerAngle will falloff linearly.
  98339. */
  98340. directionalConeOuterAngle: number;
  98341. /**
  98342. * Playback volume.
  98343. */
  98344. /**
  98345. * Playback volume.
  98346. */
  98347. volume: number;
  98348. private _onended;
  98349. /**
  98350. * Suspend playback
  98351. */
  98352. pause(): void;
  98353. /**
  98354. * Stop playback
  98355. */
  98356. stop(): void;
  98357. /**
  98358. * Start playback.
  98359. * @param startOffset Position the clip head at a specific time in seconds.
  98360. */
  98361. play(startOffset?: number): void;
  98362. }
  98363. }
  98364. declare module BABYLON {
  98365. /**
  98366. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  98367. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  98368. */
  98369. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  98370. /**
  98371. * Gets the name of the behavior.
  98372. */
  98373. readonly name: string;
  98374. /**
  98375. * The easing function used by animations
  98376. */
  98377. static EasingFunction: BackEase;
  98378. /**
  98379. * The easing mode used by animations
  98380. */
  98381. static EasingMode: number;
  98382. /**
  98383. * The duration of the animation, in milliseconds
  98384. */
  98385. transitionDuration: number;
  98386. /**
  98387. * Length of the distance animated by the transition when lower radius is reached
  98388. */
  98389. lowerRadiusTransitionRange: number;
  98390. /**
  98391. * Length of the distance animated by the transition when upper radius is reached
  98392. */
  98393. upperRadiusTransitionRange: number;
  98394. private _autoTransitionRange;
  98395. /**
  98396. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  98397. */
  98398. /**
  98399. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  98400. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  98401. */
  98402. autoTransitionRange: boolean;
  98403. private _attachedCamera;
  98404. private _onAfterCheckInputsObserver;
  98405. private _onMeshTargetChangedObserver;
  98406. /**
  98407. * Initializes the behavior.
  98408. */
  98409. init(): void;
  98410. /**
  98411. * Attaches the behavior to its arc rotate camera.
  98412. * @param camera Defines the camera to attach the behavior to
  98413. */
  98414. attach(camera: ArcRotateCamera): void;
  98415. /**
  98416. * Detaches the behavior from its current arc rotate camera.
  98417. */
  98418. detach(): void;
  98419. private _radiusIsAnimating;
  98420. private _radiusBounceTransition;
  98421. private _animatables;
  98422. private _cachedWheelPrecision;
  98423. /**
  98424. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  98425. * @param radiusLimit The limit to check against.
  98426. * @return Bool to indicate if at limit.
  98427. */
  98428. private _isRadiusAtLimit;
  98429. /**
  98430. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  98431. * @param radiusDelta The delta by which to animate to. Can be negative.
  98432. */
  98433. private _applyBoundRadiusAnimation;
  98434. /**
  98435. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  98436. */
  98437. protected _clearAnimationLocks(): void;
  98438. /**
  98439. * Stops and removes all animations that have been applied to the camera
  98440. */
  98441. stopAllAnimations(): void;
  98442. }
  98443. }
  98444. declare module BABYLON {
  98445. /**
  98446. * 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.
  98447. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  98448. */
  98449. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  98450. /**
  98451. * Gets the name of the behavior.
  98452. */
  98453. readonly name: string;
  98454. private _mode;
  98455. private _radiusScale;
  98456. private _positionScale;
  98457. private _defaultElevation;
  98458. private _elevationReturnTime;
  98459. private _elevationReturnWaitTime;
  98460. private _zoomStopsAnimation;
  98461. private _framingTime;
  98462. /**
  98463. * The easing function used by animations
  98464. */
  98465. static EasingFunction: ExponentialEase;
  98466. /**
  98467. * The easing mode used by animations
  98468. */
  98469. static EasingMode: number;
  98470. /**
  98471. * Sets the current mode used by the behavior
  98472. */
  98473. /**
  98474. * Gets current mode used by the behavior.
  98475. */
  98476. mode: number;
  98477. /**
  98478. * Sets the scale applied to the radius (1 by default)
  98479. */
  98480. /**
  98481. * Gets the scale applied to the radius
  98482. */
  98483. radiusScale: number;
  98484. /**
  98485. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  98486. */
  98487. /**
  98488. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  98489. */
  98490. positionScale: number;
  98491. /**
  98492. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  98493. * behaviour is triggered, in radians.
  98494. */
  98495. /**
  98496. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  98497. * behaviour is triggered, in radians.
  98498. */
  98499. defaultElevation: number;
  98500. /**
  98501. * Sets the time (in milliseconds) taken to return to the default beta position.
  98502. * Negative value indicates camera should not return to default.
  98503. */
  98504. /**
  98505. * Gets the time (in milliseconds) taken to return to the default beta position.
  98506. * Negative value indicates camera should not return to default.
  98507. */
  98508. elevationReturnTime: number;
  98509. /**
  98510. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  98511. */
  98512. /**
  98513. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  98514. */
  98515. elevationReturnWaitTime: number;
  98516. /**
  98517. * Sets the flag that indicates if user zooming should stop animation.
  98518. */
  98519. /**
  98520. * Gets the flag that indicates if user zooming should stop animation.
  98521. */
  98522. zoomStopsAnimation: boolean;
  98523. /**
  98524. * Sets the transition time when framing the mesh, in milliseconds
  98525. */
  98526. /**
  98527. * Gets the transition time when framing the mesh, in milliseconds
  98528. */
  98529. framingTime: number;
  98530. /**
  98531. * Define if the behavior should automatically change the configured
  98532. * camera limits and sensibilities.
  98533. */
  98534. autoCorrectCameraLimitsAndSensibility: boolean;
  98535. private _onPrePointerObservableObserver;
  98536. private _onAfterCheckInputsObserver;
  98537. private _onMeshTargetChangedObserver;
  98538. private _attachedCamera;
  98539. private _isPointerDown;
  98540. private _lastInteractionTime;
  98541. /**
  98542. * Initializes the behavior.
  98543. */
  98544. init(): void;
  98545. /**
  98546. * Attaches the behavior to its arc rotate camera.
  98547. * @param camera Defines the camera to attach the behavior to
  98548. */
  98549. attach(camera: ArcRotateCamera): void;
  98550. /**
  98551. * Detaches the behavior from its current arc rotate camera.
  98552. */
  98553. detach(): void;
  98554. private _animatables;
  98555. private _betaIsAnimating;
  98556. private _betaTransition;
  98557. private _radiusTransition;
  98558. private _vectorTransition;
  98559. /**
  98560. * Targets the given mesh and updates zoom level accordingly.
  98561. * @param mesh The mesh to target.
  98562. * @param radius Optional. If a cached radius position already exists, overrides default.
  98563. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  98564. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  98565. * @param onAnimationEnd Callback triggered at the end of the framing animation
  98566. */
  98567. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  98568. /**
  98569. * Targets the given mesh with its children and updates zoom level accordingly.
  98570. * @param mesh The mesh to target.
  98571. * @param radius Optional. If a cached radius position already exists, overrides default.
  98572. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  98573. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  98574. * @param onAnimationEnd Callback triggered at the end of the framing animation
  98575. */
  98576. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  98577. /**
  98578. * Targets the given meshes with their children and updates zoom level accordingly.
  98579. * @param meshes The mesh to target.
  98580. * @param radius Optional. If a cached radius position already exists, overrides default.
  98581. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  98582. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  98583. * @param onAnimationEnd Callback triggered at the end of the framing animation
  98584. */
  98585. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  98586. /**
  98587. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  98588. * @param minimumWorld Determines the smaller position of the bounding box extend
  98589. * @param maximumWorld Determines the bigger position of the bounding box extend
  98590. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  98591. * @param onAnimationEnd Callback triggered at the end of the framing animation
  98592. */
  98593. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  98594. /**
  98595. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  98596. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  98597. * frustum width.
  98598. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  98599. * to fully enclose the mesh in the viewing frustum.
  98600. */
  98601. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  98602. /**
  98603. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  98604. * is automatically returned to its default position (expected to be above ground plane).
  98605. */
  98606. private _maintainCameraAboveGround;
  98607. /**
  98608. * Returns the frustum slope based on the canvas ratio and camera FOV
  98609. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  98610. */
  98611. private _getFrustumSlope;
  98612. /**
  98613. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  98614. */
  98615. private _clearAnimationLocks;
  98616. /**
  98617. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  98618. */
  98619. private _applyUserInteraction;
  98620. /**
  98621. * Stops and removes all animations that have been applied to the camera
  98622. */
  98623. stopAllAnimations(): void;
  98624. /**
  98625. * Gets a value indicating if the user is moving the camera
  98626. */
  98627. readonly isUserIsMoving: boolean;
  98628. /**
  98629. * The camera can move all the way towards the mesh.
  98630. */
  98631. static IgnoreBoundsSizeMode: number;
  98632. /**
  98633. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  98634. */
  98635. static FitFrustumSidesMode: number;
  98636. }
  98637. }
  98638. declare module BABYLON {
  98639. /**
  98640. * Base class for Camera Pointer Inputs.
  98641. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  98642. * for example usage.
  98643. */
  98644. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  98645. /**
  98646. * Defines the camera the input is attached to.
  98647. */
  98648. abstract camera: Camera;
  98649. /**
  98650. * Whether keyboard modifier keys are pressed at time of last mouse event.
  98651. */
  98652. protected _altKey: boolean;
  98653. protected _ctrlKey: boolean;
  98654. protected _metaKey: boolean;
  98655. protected _shiftKey: boolean;
  98656. /**
  98657. * Which mouse buttons were pressed at time of last mouse event.
  98658. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  98659. */
  98660. protected _buttonsPressed: number;
  98661. /**
  98662. * Defines the buttons associated with the input to handle camera move.
  98663. */
  98664. buttons: number[];
  98665. /**
  98666. * Attach the input controls to a specific dom element to get the input from.
  98667. * @param element Defines the element the controls should be listened from
  98668. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98669. */
  98670. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98671. /**
  98672. * Detach the current controls from the specified dom element.
  98673. * @param element Defines the element to stop listening the inputs from
  98674. */
  98675. detachControl(element: Nullable<HTMLElement>): void;
  98676. /**
  98677. * Gets the class name of the current input.
  98678. * @returns the class name
  98679. */
  98680. getClassName(): string;
  98681. /**
  98682. * Get the friendly name associated with the input class.
  98683. * @returns the input friendly name
  98684. */
  98685. getSimpleName(): string;
  98686. /**
  98687. * Called on pointer POINTERDOUBLETAP event.
  98688. * Override this method to provide functionality on POINTERDOUBLETAP event.
  98689. */
  98690. protected onDoubleTap(type: string): void;
  98691. /**
  98692. * Called on pointer POINTERMOVE event if only a single touch is active.
  98693. * Override this method to provide functionality.
  98694. */
  98695. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  98696. /**
  98697. * Called on pointer POINTERMOVE event if multiple touches are active.
  98698. * Override this method to provide functionality.
  98699. */
  98700. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  98701. /**
  98702. * Called on JS contextmenu event.
  98703. * Override this method to provide functionality.
  98704. */
  98705. protected onContextMenu(evt: PointerEvent): void;
  98706. /**
  98707. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  98708. * press.
  98709. * Override this method to provide functionality.
  98710. */
  98711. protected onButtonDown(evt: PointerEvent): void;
  98712. /**
  98713. * Called each time a new POINTERUP event occurs. Ie, for each button
  98714. * release.
  98715. * Override this method to provide functionality.
  98716. */
  98717. protected onButtonUp(evt: PointerEvent): void;
  98718. /**
  98719. * Called when window becomes inactive.
  98720. * Override this method to provide functionality.
  98721. */
  98722. protected onLostFocus(): void;
  98723. private _pointerInput;
  98724. private _observer;
  98725. private _onLostFocus;
  98726. private pointA;
  98727. private pointB;
  98728. }
  98729. }
  98730. declare module BABYLON {
  98731. /**
  98732. * Manage the pointers inputs to control an arc rotate camera.
  98733. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98734. */
  98735. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  98736. /**
  98737. * Defines the camera the input is attached to.
  98738. */
  98739. camera: ArcRotateCamera;
  98740. /**
  98741. * Gets the class name of the current input.
  98742. * @returns the class name
  98743. */
  98744. getClassName(): string;
  98745. /**
  98746. * Defines the buttons associated with the input to handle camera move.
  98747. */
  98748. buttons: number[];
  98749. /**
  98750. * Defines the pointer angular sensibility along the X axis or how fast is
  98751. * the camera rotating.
  98752. */
  98753. angularSensibilityX: number;
  98754. /**
  98755. * Defines the pointer angular sensibility along the Y axis or how fast is
  98756. * the camera rotating.
  98757. */
  98758. angularSensibilityY: number;
  98759. /**
  98760. * Defines the pointer pinch precision or how fast is the camera zooming.
  98761. */
  98762. pinchPrecision: number;
  98763. /**
  98764. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  98765. * from 0.
  98766. * It defines the percentage of current camera.radius to use as delta when
  98767. * pinch zoom is used.
  98768. */
  98769. pinchDeltaPercentage: number;
  98770. /**
  98771. * Defines the pointer panning sensibility or how fast is the camera moving.
  98772. */
  98773. panningSensibility: number;
  98774. /**
  98775. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  98776. */
  98777. multiTouchPanning: boolean;
  98778. /**
  98779. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  98780. * zoom (pinch) through multitouch.
  98781. */
  98782. multiTouchPanAndZoom: boolean;
  98783. /**
  98784. * Revers pinch action direction.
  98785. */
  98786. pinchInwards: boolean;
  98787. private _isPanClick;
  98788. private _twoFingerActivityCount;
  98789. private _isPinching;
  98790. /**
  98791. * Called on pointer POINTERMOVE event if only a single touch is active.
  98792. */
  98793. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  98794. /**
  98795. * Called on pointer POINTERDOUBLETAP event.
  98796. */
  98797. protected onDoubleTap(type: string): void;
  98798. /**
  98799. * Called on pointer POINTERMOVE event if multiple touches are active.
  98800. */
  98801. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  98802. /**
  98803. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  98804. * press.
  98805. */
  98806. protected onButtonDown(evt: PointerEvent): void;
  98807. /**
  98808. * Called each time a new POINTERUP event occurs. Ie, for each button
  98809. * release.
  98810. */
  98811. protected onButtonUp(evt: PointerEvent): void;
  98812. /**
  98813. * Called when window becomes inactive.
  98814. */
  98815. protected onLostFocus(): void;
  98816. }
  98817. }
  98818. declare module BABYLON {
  98819. /**
  98820. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  98821. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98822. */
  98823. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  98824. /**
  98825. * Defines the camera the input is attached to.
  98826. */
  98827. camera: ArcRotateCamera;
  98828. /**
  98829. * Defines the list of key codes associated with the up action (increase alpha)
  98830. */
  98831. keysUp: number[];
  98832. /**
  98833. * Defines the list of key codes associated with the down action (decrease alpha)
  98834. */
  98835. keysDown: number[];
  98836. /**
  98837. * Defines the list of key codes associated with the left action (increase beta)
  98838. */
  98839. keysLeft: number[];
  98840. /**
  98841. * Defines the list of key codes associated with the right action (decrease beta)
  98842. */
  98843. keysRight: number[];
  98844. /**
  98845. * Defines the list of key codes associated with the reset action.
  98846. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  98847. */
  98848. keysReset: number[];
  98849. /**
  98850. * Defines the panning sensibility of the inputs.
  98851. * (How fast is the camera paning)
  98852. */
  98853. panningSensibility: number;
  98854. /**
  98855. * Defines the zooming sensibility of the inputs.
  98856. * (How fast is the camera zooming)
  98857. */
  98858. zoomingSensibility: number;
  98859. /**
  98860. * Defines wether maintaining the alt key down switch the movement mode from
  98861. * orientation to zoom.
  98862. */
  98863. useAltToZoom: boolean;
  98864. /**
  98865. * Rotation speed of the camera
  98866. */
  98867. angularSpeed: number;
  98868. private _keys;
  98869. private _ctrlPressed;
  98870. private _altPressed;
  98871. private _onCanvasBlurObserver;
  98872. private _onKeyboardObserver;
  98873. private _engine;
  98874. private _scene;
  98875. /**
  98876. * Attach the input controls to a specific dom element to get the input from.
  98877. * @param element Defines the element the controls should be listened from
  98878. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98879. */
  98880. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98881. /**
  98882. * Detach the current controls from the specified dom element.
  98883. * @param element Defines the element to stop listening the inputs from
  98884. */
  98885. detachControl(element: Nullable<HTMLElement>): void;
  98886. /**
  98887. * Update the current camera state depending on the inputs that have been used this frame.
  98888. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98889. */
  98890. checkInputs(): void;
  98891. /**
  98892. * Gets the class name of the current intput.
  98893. * @returns the class name
  98894. */
  98895. getClassName(): string;
  98896. /**
  98897. * Get the friendly name associated with the input class.
  98898. * @returns the input friendly name
  98899. */
  98900. getSimpleName(): string;
  98901. }
  98902. }
  98903. declare module BABYLON {
  98904. /**
  98905. * Manage the mouse wheel inputs to control an arc rotate camera.
  98906. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98907. */
  98908. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  98909. /**
  98910. * Defines the camera the input is attached to.
  98911. */
  98912. camera: ArcRotateCamera;
  98913. /**
  98914. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  98915. */
  98916. wheelPrecision: number;
  98917. /**
  98918. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  98919. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  98920. */
  98921. wheelDeltaPercentage: number;
  98922. private _wheel;
  98923. private _observer;
  98924. private computeDeltaFromMouseWheelLegacyEvent;
  98925. /**
  98926. * Attach the input controls to a specific dom element to get the input from.
  98927. * @param element Defines the element the controls should be listened from
  98928. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98929. */
  98930. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98931. /**
  98932. * Detach the current controls from the specified dom element.
  98933. * @param element Defines the element to stop listening the inputs from
  98934. */
  98935. detachControl(element: Nullable<HTMLElement>): void;
  98936. /**
  98937. * Gets the class name of the current intput.
  98938. * @returns the class name
  98939. */
  98940. getClassName(): string;
  98941. /**
  98942. * Get the friendly name associated with the input class.
  98943. * @returns the input friendly name
  98944. */
  98945. getSimpleName(): string;
  98946. }
  98947. }
  98948. declare module BABYLON {
  98949. /**
  98950. * Default Inputs manager for the ArcRotateCamera.
  98951. * It groups all the default supported inputs for ease of use.
  98952. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98953. */
  98954. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  98955. /**
  98956. * Instantiates a new ArcRotateCameraInputsManager.
  98957. * @param camera Defines the camera the inputs belong to
  98958. */
  98959. constructor(camera: ArcRotateCamera);
  98960. /**
  98961. * Add mouse wheel input support to the input manager.
  98962. * @returns the current input manager
  98963. */
  98964. addMouseWheel(): ArcRotateCameraInputsManager;
  98965. /**
  98966. * Add pointers input support to the input manager.
  98967. * @returns the current input manager
  98968. */
  98969. addPointers(): ArcRotateCameraInputsManager;
  98970. /**
  98971. * Add keyboard input support to the input manager.
  98972. * @returns the current input manager
  98973. */
  98974. addKeyboard(): ArcRotateCameraInputsManager;
  98975. }
  98976. }
  98977. declare module BABYLON {
  98978. /**
  98979. * This represents an orbital type of camera.
  98980. *
  98981. * 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.
  98982. * 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.
  98983. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  98984. */
  98985. export class ArcRotateCamera extends TargetCamera {
  98986. /**
  98987. * Defines the rotation angle of the camera along the longitudinal axis.
  98988. */
  98989. alpha: number;
  98990. /**
  98991. * Defines the rotation angle of the camera along the latitudinal axis.
  98992. */
  98993. beta: number;
  98994. /**
  98995. * Defines the radius of the camera from it s target point.
  98996. */
  98997. radius: number;
  98998. protected _target: Vector3;
  98999. protected _targetHost: Nullable<AbstractMesh>;
  99000. /**
  99001. * Defines the target point of the camera.
  99002. * The camera looks towards it form the radius distance.
  99003. */
  99004. target: Vector3;
  99005. /**
  99006. * Define the current local position of the camera in the scene
  99007. */
  99008. position: Vector3;
  99009. protected _upVector: Vector3;
  99010. protected _upToYMatrix: Matrix;
  99011. protected _YToUpMatrix: Matrix;
  99012. /**
  99013. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  99014. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  99015. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  99016. */
  99017. upVector: Vector3;
  99018. /**
  99019. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  99020. */
  99021. setMatUp(): void;
  99022. /**
  99023. * Current inertia value on the longitudinal axis.
  99024. * The bigger this number the longer it will take for the camera to stop.
  99025. */
  99026. inertialAlphaOffset: number;
  99027. /**
  99028. * Current inertia value on the latitudinal axis.
  99029. * The bigger this number the longer it will take for the camera to stop.
  99030. */
  99031. inertialBetaOffset: number;
  99032. /**
  99033. * Current inertia value on the radius axis.
  99034. * The bigger this number the longer it will take for the camera to stop.
  99035. */
  99036. inertialRadiusOffset: number;
  99037. /**
  99038. * Minimum allowed angle on the longitudinal axis.
  99039. * This can help limiting how the Camera is able to move in the scene.
  99040. */
  99041. lowerAlphaLimit: Nullable<number>;
  99042. /**
  99043. * Maximum allowed angle on the longitudinal axis.
  99044. * This can help limiting how the Camera is able to move in the scene.
  99045. */
  99046. upperAlphaLimit: Nullable<number>;
  99047. /**
  99048. * Minimum allowed angle on the latitudinal axis.
  99049. * This can help limiting how the Camera is able to move in the scene.
  99050. */
  99051. lowerBetaLimit: number;
  99052. /**
  99053. * Maximum allowed angle on the latitudinal axis.
  99054. * This can help limiting how the Camera is able to move in the scene.
  99055. */
  99056. upperBetaLimit: number;
  99057. /**
  99058. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  99059. * This can help limiting how the Camera is able to move in the scene.
  99060. */
  99061. lowerRadiusLimit: Nullable<number>;
  99062. /**
  99063. * Maximum allowed distance of the camera to the target (The camera can not get further).
  99064. * This can help limiting how the Camera is able to move in the scene.
  99065. */
  99066. upperRadiusLimit: Nullable<number>;
  99067. /**
  99068. * Defines the current inertia value used during panning of the camera along the X axis.
  99069. */
  99070. inertialPanningX: number;
  99071. /**
  99072. * Defines the current inertia value used during panning of the camera along the Y axis.
  99073. */
  99074. inertialPanningY: number;
  99075. /**
  99076. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  99077. * Basically if your fingers moves away from more than this distance you will be considered
  99078. * in pinch mode.
  99079. */
  99080. pinchToPanMaxDistance: number;
  99081. /**
  99082. * Defines the maximum distance the camera can pan.
  99083. * This could help keeping the cammera always in your scene.
  99084. */
  99085. panningDistanceLimit: Nullable<number>;
  99086. /**
  99087. * Defines the target of the camera before paning.
  99088. */
  99089. panningOriginTarget: Vector3;
  99090. /**
  99091. * Defines the value of the inertia used during panning.
  99092. * 0 would mean stop inertia and one would mean no decelleration at all.
  99093. */
  99094. panningInertia: number;
  99095. /**
  99096. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  99097. */
  99098. angularSensibilityX: number;
  99099. /**
  99100. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  99101. */
  99102. angularSensibilityY: number;
  99103. /**
  99104. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  99105. */
  99106. pinchPrecision: number;
  99107. /**
  99108. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  99109. * It will be used instead of pinchDeltaPrecision if different from 0.
  99110. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  99111. */
  99112. pinchDeltaPercentage: number;
  99113. /**
  99114. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  99115. */
  99116. panningSensibility: number;
  99117. /**
  99118. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  99119. */
  99120. keysUp: number[];
  99121. /**
  99122. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  99123. */
  99124. keysDown: number[];
  99125. /**
  99126. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  99127. */
  99128. keysLeft: number[];
  99129. /**
  99130. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  99131. */
  99132. keysRight: number[];
  99133. /**
  99134. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  99135. */
  99136. wheelPrecision: number;
  99137. /**
  99138. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  99139. * It will be used instead of pinchDeltaPrecision if different from 0.
  99140. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  99141. */
  99142. wheelDeltaPercentage: number;
  99143. /**
  99144. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  99145. */
  99146. zoomOnFactor: number;
  99147. /**
  99148. * Defines a screen offset for the camera position.
  99149. */
  99150. targetScreenOffset: Vector2;
  99151. /**
  99152. * Allows the camera to be completely reversed.
  99153. * If false the camera can not arrive upside down.
  99154. */
  99155. allowUpsideDown: boolean;
  99156. /**
  99157. * Define if double tap/click is used to restore the previously saved state of the camera.
  99158. */
  99159. useInputToRestoreState: boolean;
  99160. /** @hidden */
  99161. _viewMatrix: Matrix;
  99162. /** @hidden */
  99163. _useCtrlForPanning: boolean;
  99164. /** @hidden */
  99165. _panningMouseButton: number;
  99166. /**
  99167. * Defines the input associated to the camera.
  99168. */
  99169. inputs: ArcRotateCameraInputsManager;
  99170. /** @hidden */
  99171. _reset: () => void;
  99172. /**
  99173. * Defines the allowed panning axis.
  99174. */
  99175. panningAxis: Vector3;
  99176. protected _localDirection: Vector3;
  99177. protected _transformedDirection: Vector3;
  99178. private _bouncingBehavior;
  99179. /**
  99180. * Gets the bouncing behavior of the camera if it has been enabled.
  99181. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  99182. */
  99183. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  99184. /**
  99185. * Defines if the bouncing behavior of the camera is enabled on the camera.
  99186. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  99187. */
  99188. useBouncingBehavior: boolean;
  99189. private _framingBehavior;
  99190. /**
  99191. * Gets the framing behavior of the camera if it has been enabled.
  99192. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  99193. */
  99194. readonly framingBehavior: Nullable<FramingBehavior>;
  99195. /**
  99196. * Defines if the framing behavior of the camera is enabled on the camera.
  99197. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  99198. */
  99199. useFramingBehavior: boolean;
  99200. private _autoRotationBehavior;
  99201. /**
  99202. * Gets the auto rotation behavior of the camera if it has been enabled.
  99203. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  99204. */
  99205. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  99206. /**
  99207. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  99208. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  99209. */
  99210. useAutoRotationBehavior: boolean;
  99211. /**
  99212. * Observable triggered when the mesh target has been changed on the camera.
  99213. */
  99214. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  99215. /**
  99216. * Event raised when the camera is colliding with a mesh.
  99217. */
  99218. onCollide: (collidedMesh: AbstractMesh) => void;
  99219. /**
  99220. * Defines whether the camera should check collision with the objects oh the scene.
  99221. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  99222. */
  99223. checkCollisions: boolean;
  99224. /**
  99225. * Defines the collision radius of the camera.
  99226. * This simulates a sphere around the camera.
  99227. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  99228. */
  99229. collisionRadius: Vector3;
  99230. protected _collider: Collider;
  99231. protected _previousPosition: Vector3;
  99232. protected _collisionVelocity: Vector3;
  99233. protected _newPosition: Vector3;
  99234. protected _previousAlpha: number;
  99235. protected _previousBeta: number;
  99236. protected _previousRadius: number;
  99237. protected _collisionTriggered: boolean;
  99238. protected _targetBoundingCenter: Nullable<Vector3>;
  99239. private _computationVector;
  99240. /**
  99241. * Instantiates a new ArcRotateCamera in a given scene
  99242. * @param name Defines the name of the camera
  99243. * @param alpha Defines the camera rotation along the logitudinal axis
  99244. * @param beta Defines the camera rotation along the latitudinal axis
  99245. * @param radius Defines the camera distance from its target
  99246. * @param target Defines the camera target
  99247. * @param scene Defines the scene the camera belongs to
  99248. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  99249. */
  99250. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99251. /** @hidden */
  99252. _initCache(): void;
  99253. /** @hidden */
  99254. _updateCache(ignoreParentClass?: boolean): void;
  99255. protected _getTargetPosition(): Vector3;
  99256. private _storedAlpha;
  99257. private _storedBeta;
  99258. private _storedRadius;
  99259. private _storedTarget;
  99260. /**
  99261. * Stores the current state of the camera (alpha, beta, radius and target)
  99262. * @returns the camera itself
  99263. */
  99264. storeState(): Camera;
  99265. /**
  99266. * @hidden
  99267. * Restored camera state. You must call storeState() first
  99268. */
  99269. _restoreStateValues(): boolean;
  99270. /** @hidden */
  99271. _isSynchronizedViewMatrix(): boolean;
  99272. /**
  99273. * Attached controls to the current camera.
  99274. * @param element Defines the element the controls should be listened from
  99275. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99276. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  99277. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  99278. */
  99279. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  99280. /**
  99281. * Detach the current controls from the camera.
  99282. * The camera will stop reacting to inputs.
  99283. * @param element Defines the element to stop listening the inputs from
  99284. */
  99285. detachControl(element: HTMLElement): void;
  99286. /** @hidden */
  99287. _checkInputs(): void;
  99288. protected _checkLimits(): void;
  99289. /**
  99290. * Rebuilds angles (alpha, beta) and radius from the give position and target
  99291. */
  99292. rebuildAnglesAndRadius(): void;
  99293. /**
  99294. * Use a position to define the current camera related information like aplha, beta and radius
  99295. * @param position Defines the position to set the camera at
  99296. */
  99297. setPosition(position: Vector3): void;
  99298. /**
  99299. * Defines the target the camera should look at.
  99300. * This will automatically adapt alpha beta and radius to fit within the new target.
  99301. * @param target Defines the new target as a Vector or a mesh
  99302. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  99303. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  99304. */
  99305. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  99306. /** @hidden */
  99307. _getViewMatrix(): Matrix;
  99308. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  99309. /**
  99310. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  99311. * @param meshes Defines the mesh to zoom on
  99312. * @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)
  99313. */
  99314. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  99315. /**
  99316. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  99317. * The target will be changed but the radius
  99318. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  99319. * @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)
  99320. */
  99321. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  99322. min: Vector3;
  99323. max: Vector3;
  99324. distance: number;
  99325. }, doNotUpdateMaxZ?: boolean): void;
  99326. /**
  99327. * @override
  99328. * Override Camera.createRigCamera
  99329. */
  99330. createRigCamera(name: string, cameraIndex: number): Camera;
  99331. /**
  99332. * @hidden
  99333. * @override
  99334. * Override Camera._updateRigCameras
  99335. */
  99336. _updateRigCameras(): void;
  99337. /**
  99338. * Destroy the camera and release the current resources hold by it.
  99339. */
  99340. dispose(): void;
  99341. /**
  99342. * Gets the current object class name.
  99343. * @return the class name
  99344. */
  99345. getClassName(): string;
  99346. }
  99347. }
  99348. declare module BABYLON {
  99349. /**
  99350. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  99351. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  99352. */
  99353. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  99354. /**
  99355. * Gets the name of the behavior.
  99356. */
  99357. readonly name: string;
  99358. private _zoomStopsAnimation;
  99359. private _idleRotationSpeed;
  99360. private _idleRotationWaitTime;
  99361. private _idleRotationSpinupTime;
  99362. /**
  99363. * Sets the flag that indicates if user zooming should stop animation.
  99364. */
  99365. /**
  99366. * Gets the flag that indicates if user zooming should stop animation.
  99367. */
  99368. zoomStopsAnimation: boolean;
  99369. /**
  99370. * Sets the default speed at which the camera rotates around the model.
  99371. */
  99372. /**
  99373. * Gets the default speed at which the camera rotates around the model.
  99374. */
  99375. idleRotationSpeed: number;
  99376. /**
  99377. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  99378. */
  99379. /**
  99380. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  99381. */
  99382. idleRotationWaitTime: number;
  99383. /**
  99384. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  99385. */
  99386. /**
  99387. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  99388. */
  99389. idleRotationSpinupTime: number;
  99390. /**
  99391. * Gets a value indicating if the camera is currently rotating because of this behavior
  99392. */
  99393. readonly rotationInProgress: boolean;
  99394. private _onPrePointerObservableObserver;
  99395. private _onAfterCheckInputsObserver;
  99396. private _attachedCamera;
  99397. private _isPointerDown;
  99398. private _lastFrameTime;
  99399. private _lastInteractionTime;
  99400. private _cameraRotationSpeed;
  99401. /**
  99402. * Initializes the behavior.
  99403. */
  99404. init(): void;
  99405. /**
  99406. * Attaches the behavior to its arc rotate camera.
  99407. * @param camera Defines the camera to attach the behavior to
  99408. */
  99409. attach(camera: ArcRotateCamera): void;
  99410. /**
  99411. * Detaches the behavior from its current arc rotate camera.
  99412. */
  99413. detach(): void;
  99414. /**
  99415. * Returns true if user is scrolling.
  99416. * @return true if user is scrolling.
  99417. */
  99418. private _userIsZooming;
  99419. private _lastFrameRadius;
  99420. private _shouldAnimationStopForInteraction;
  99421. /**
  99422. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  99423. */
  99424. private _applyUserInteraction;
  99425. private _userIsMoving;
  99426. }
  99427. }
  99428. declare module BABYLON {
  99429. /**
  99430. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  99431. */
  99432. export class AttachToBoxBehavior implements Behavior<Mesh> {
  99433. private ui;
  99434. /**
  99435. * The name of the behavior
  99436. */
  99437. name: string;
  99438. /**
  99439. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  99440. */
  99441. distanceAwayFromFace: number;
  99442. /**
  99443. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  99444. */
  99445. distanceAwayFromBottomOfFace: number;
  99446. private _faceVectors;
  99447. private _target;
  99448. private _scene;
  99449. private _onRenderObserver;
  99450. private _tmpMatrix;
  99451. private _tmpVector;
  99452. /**
  99453. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  99454. * @param ui The transform node that should be attched to the mesh
  99455. */
  99456. constructor(ui: TransformNode);
  99457. /**
  99458. * Initializes the behavior
  99459. */
  99460. init(): void;
  99461. private _closestFace;
  99462. private _zeroVector;
  99463. private _lookAtTmpMatrix;
  99464. private _lookAtToRef;
  99465. /**
  99466. * Attaches the AttachToBoxBehavior to the passed in mesh
  99467. * @param target The mesh that the specified node will be attached to
  99468. */
  99469. attach(target: Mesh): void;
  99470. /**
  99471. * Detaches the behavior from the mesh
  99472. */
  99473. detach(): void;
  99474. }
  99475. }
  99476. declare module BABYLON {
  99477. /**
  99478. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  99479. */
  99480. export class FadeInOutBehavior implements Behavior<Mesh> {
  99481. /**
  99482. * Time in milliseconds to delay before fading in (Default: 0)
  99483. */
  99484. delay: number;
  99485. /**
  99486. * Time in milliseconds for the mesh to fade in (Default: 300)
  99487. */
  99488. fadeInTime: number;
  99489. private _millisecondsPerFrame;
  99490. private _hovered;
  99491. private _hoverValue;
  99492. private _ownerNode;
  99493. /**
  99494. * Instatiates the FadeInOutBehavior
  99495. */
  99496. constructor();
  99497. /**
  99498. * The name of the behavior
  99499. */
  99500. readonly name: string;
  99501. /**
  99502. * Initializes the behavior
  99503. */
  99504. init(): void;
  99505. /**
  99506. * Attaches the fade behavior on the passed in mesh
  99507. * @param ownerNode The mesh that will be faded in/out once attached
  99508. */
  99509. attach(ownerNode: Mesh): void;
  99510. /**
  99511. * Detaches the behavior from the mesh
  99512. */
  99513. detach(): void;
  99514. /**
  99515. * Triggers the mesh to begin fading in or out
  99516. * @param value if the object should fade in or out (true to fade in)
  99517. */
  99518. fadeIn(value: boolean): void;
  99519. private _update;
  99520. private _setAllVisibility;
  99521. }
  99522. }
  99523. declare module BABYLON {
  99524. /**
  99525. * Class containing a set of static utilities functions for managing Pivots
  99526. * @hidden
  99527. */
  99528. export class PivotTools {
  99529. private static _PivotCached;
  99530. private static _OldPivotPoint;
  99531. private static _PivotTranslation;
  99532. private static _PivotTmpVector;
  99533. /** @hidden */
  99534. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  99535. /** @hidden */
  99536. static _RestorePivotPoint(mesh: AbstractMesh): void;
  99537. }
  99538. }
  99539. declare module BABYLON {
  99540. /**
  99541. * Class containing static functions to help procedurally build meshes
  99542. */
  99543. export class PlaneBuilder {
  99544. /**
  99545. * Creates a plane mesh
  99546. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  99547. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  99548. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  99549. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99550. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99552. * @param name defines the name of the mesh
  99553. * @param options defines the options used to create the mesh
  99554. * @param scene defines the hosting scene
  99555. * @returns the plane mesh
  99556. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  99557. */
  99558. static CreatePlane(name: string, options: {
  99559. size?: number;
  99560. width?: number;
  99561. height?: number;
  99562. sideOrientation?: number;
  99563. frontUVs?: Vector4;
  99564. backUVs?: Vector4;
  99565. updatable?: boolean;
  99566. sourcePlane?: Plane;
  99567. }, scene?: Nullable<Scene>): Mesh;
  99568. }
  99569. }
  99570. declare module BABYLON {
  99571. /**
  99572. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  99573. */
  99574. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  99575. private static _AnyMouseID;
  99576. /**
  99577. * Abstract mesh the behavior is set on
  99578. */
  99579. attachedNode: AbstractMesh;
  99580. private _dragPlane;
  99581. private _scene;
  99582. private _pointerObserver;
  99583. private _beforeRenderObserver;
  99584. private static _planeScene;
  99585. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  99586. /**
  99587. * 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)
  99588. */
  99589. maxDragAngle: number;
  99590. /**
  99591. * @hidden
  99592. */
  99593. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  99594. /**
  99595. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  99596. */
  99597. currentDraggingPointerID: number;
  99598. /**
  99599. * The last position where the pointer hit the drag plane in world space
  99600. */
  99601. lastDragPosition: Vector3;
  99602. /**
  99603. * If the behavior is currently in a dragging state
  99604. */
  99605. dragging: boolean;
  99606. /**
  99607. * 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)
  99608. */
  99609. dragDeltaRatio: number;
  99610. /**
  99611. * If the drag plane orientation should be updated during the dragging (Default: true)
  99612. */
  99613. updateDragPlane: boolean;
  99614. private _debugMode;
  99615. private _moving;
  99616. /**
  99617. * Fires each time the attached mesh is dragged with the pointer
  99618. * * delta between last drag position and current drag position in world space
  99619. * * dragDistance along the drag axis
  99620. * * dragPlaneNormal normal of the current drag plane used during the drag
  99621. * * dragPlanePoint in world space where the drag intersects the drag plane
  99622. */
  99623. onDragObservable: Observable<{
  99624. delta: Vector3;
  99625. dragPlanePoint: Vector3;
  99626. dragPlaneNormal: Vector3;
  99627. dragDistance: number;
  99628. pointerId: number;
  99629. }>;
  99630. /**
  99631. * Fires each time a drag begins (eg. mouse down on mesh)
  99632. */
  99633. onDragStartObservable: Observable<{
  99634. dragPlanePoint: Vector3;
  99635. pointerId: number;
  99636. }>;
  99637. /**
  99638. * Fires each time a drag ends (eg. mouse release after drag)
  99639. */
  99640. onDragEndObservable: Observable<{
  99641. dragPlanePoint: Vector3;
  99642. pointerId: number;
  99643. }>;
  99644. /**
  99645. * If the attached mesh should be moved when dragged
  99646. */
  99647. moveAttached: boolean;
  99648. /**
  99649. * If the drag behavior will react to drag events (Default: true)
  99650. */
  99651. enabled: boolean;
  99652. /**
  99653. * If pointer events should start and release the drag (Default: true)
  99654. */
  99655. startAndReleaseDragOnPointerEvents: boolean;
  99656. /**
  99657. * If camera controls should be detached during the drag
  99658. */
  99659. detachCameraControls: boolean;
  99660. /**
  99661. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  99662. */
  99663. useObjectOrienationForDragging: boolean;
  99664. private _options;
  99665. /**
  99666. * Creates a pointer drag behavior that can be attached to a mesh
  99667. * @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)
  99668. */
  99669. constructor(options?: {
  99670. dragAxis?: Vector3;
  99671. dragPlaneNormal?: Vector3;
  99672. });
  99673. /**
  99674. * Predicate to determine if it is valid to move the object to a new position when it is moved
  99675. */
  99676. validateDrag: (targetPosition: Vector3) => boolean;
  99677. /**
  99678. * The name of the behavior
  99679. */
  99680. readonly name: string;
  99681. /**
  99682. * Initializes the behavior
  99683. */
  99684. init(): void;
  99685. private _tmpVector;
  99686. private _alternatePickedPoint;
  99687. private _worldDragAxis;
  99688. private _targetPosition;
  99689. private _attachedElement;
  99690. /**
  99691. * Attaches the drag behavior the passed in mesh
  99692. * @param ownerNode The mesh that will be dragged around once attached
  99693. */
  99694. attach(ownerNode: AbstractMesh): void;
  99695. /**
  99696. * Force relase the drag action by code.
  99697. */
  99698. releaseDrag(): void;
  99699. private _startDragRay;
  99700. private _lastPointerRay;
  99701. /**
  99702. * Simulates the start of a pointer drag event on the behavior
  99703. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  99704. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  99705. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  99706. */
  99707. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  99708. private _startDrag;
  99709. private _dragDelta;
  99710. private _moveDrag;
  99711. private _pickWithRayOnDragPlane;
  99712. private _pointA;
  99713. private _pointB;
  99714. private _pointC;
  99715. private _lineA;
  99716. private _lineB;
  99717. private _localAxis;
  99718. private _lookAt;
  99719. private _updateDragPlanePosition;
  99720. /**
  99721. * Detaches the behavior from the mesh
  99722. */
  99723. detach(): void;
  99724. }
  99725. }
  99726. declare module BABYLON {
  99727. /**
  99728. * A behavior that when attached to a mesh will allow the mesh to be scaled
  99729. */
  99730. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  99731. private _dragBehaviorA;
  99732. private _dragBehaviorB;
  99733. private _startDistance;
  99734. private _initialScale;
  99735. private _targetScale;
  99736. private _ownerNode;
  99737. private _sceneRenderObserver;
  99738. /**
  99739. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  99740. */
  99741. constructor();
  99742. /**
  99743. * The name of the behavior
  99744. */
  99745. readonly name: string;
  99746. /**
  99747. * Initializes the behavior
  99748. */
  99749. init(): void;
  99750. private _getCurrentDistance;
  99751. /**
  99752. * Attaches the scale behavior the passed in mesh
  99753. * @param ownerNode The mesh that will be scaled around once attached
  99754. */
  99755. attach(ownerNode: Mesh): void;
  99756. /**
  99757. * Detaches the behavior from the mesh
  99758. */
  99759. detach(): void;
  99760. }
  99761. }
  99762. declare module BABYLON {
  99763. /**
  99764. * 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
  99765. */
  99766. export class SixDofDragBehavior implements Behavior<Mesh> {
  99767. private static _virtualScene;
  99768. private _ownerNode;
  99769. private _sceneRenderObserver;
  99770. private _scene;
  99771. private _targetPosition;
  99772. private _virtualOriginMesh;
  99773. private _virtualDragMesh;
  99774. private _pointerObserver;
  99775. private _moving;
  99776. private _startingOrientation;
  99777. /**
  99778. * 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)
  99779. */
  99780. private zDragFactor;
  99781. /**
  99782. * If the object should rotate to face the drag origin
  99783. */
  99784. rotateDraggedObject: boolean;
  99785. /**
  99786. * If the behavior is currently in a dragging state
  99787. */
  99788. dragging: boolean;
  99789. /**
  99790. * 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)
  99791. */
  99792. dragDeltaRatio: number;
  99793. /**
  99794. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  99795. */
  99796. currentDraggingPointerID: number;
  99797. /**
  99798. * If camera controls should be detached during the drag
  99799. */
  99800. detachCameraControls: boolean;
  99801. /**
  99802. * Fires each time a drag starts
  99803. */
  99804. onDragStartObservable: Observable<{}>;
  99805. /**
  99806. * Fires each time a drag ends (eg. mouse release after drag)
  99807. */
  99808. onDragEndObservable: Observable<{}>;
  99809. /**
  99810. * 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
  99811. */
  99812. constructor();
  99813. /**
  99814. * The name of the behavior
  99815. */
  99816. readonly name: string;
  99817. /**
  99818. * Initializes the behavior
  99819. */
  99820. init(): void;
  99821. /**
  99822. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  99823. */
  99824. private readonly _pointerCamera;
  99825. /**
  99826. * Attaches the scale behavior the passed in mesh
  99827. * @param ownerNode The mesh that will be scaled around once attached
  99828. */
  99829. attach(ownerNode: Mesh): void;
  99830. /**
  99831. * Detaches the behavior from the mesh
  99832. */
  99833. detach(): void;
  99834. }
  99835. }
  99836. declare module BABYLON {
  99837. /**
  99838. * Class used to apply inverse kinematics to bones
  99839. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  99840. */
  99841. export class BoneIKController {
  99842. private static _tmpVecs;
  99843. private static _tmpQuat;
  99844. private static _tmpMats;
  99845. /**
  99846. * Gets or sets the target mesh
  99847. */
  99848. targetMesh: AbstractMesh;
  99849. /** Gets or sets the mesh used as pole */
  99850. poleTargetMesh: AbstractMesh;
  99851. /**
  99852. * Gets or sets the bone used as pole
  99853. */
  99854. poleTargetBone: Nullable<Bone>;
  99855. /**
  99856. * Gets or sets the target position
  99857. */
  99858. targetPosition: Vector3;
  99859. /**
  99860. * Gets or sets the pole target position
  99861. */
  99862. poleTargetPosition: Vector3;
  99863. /**
  99864. * Gets or sets the pole target local offset
  99865. */
  99866. poleTargetLocalOffset: Vector3;
  99867. /**
  99868. * Gets or sets the pole angle
  99869. */
  99870. poleAngle: number;
  99871. /**
  99872. * Gets or sets the mesh associated with the controller
  99873. */
  99874. mesh: AbstractMesh;
  99875. /**
  99876. * 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)
  99877. */
  99878. slerpAmount: number;
  99879. private _bone1Quat;
  99880. private _bone1Mat;
  99881. private _bone2Ang;
  99882. private _bone1;
  99883. private _bone2;
  99884. private _bone1Length;
  99885. private _bone2Length;
  99886. private _maxAngle;
  99887. private _maxReach;
  99888. private _rightHandedSystem;
  99889. private _bendAxis;
  99890. private _slerping;
  99891. private _adjustRoll;
  99892. /**
  99893. * Gets or sets maximum allowed angle
  99894. */
  99895. maxAngle: number;
  99896. /**
  99897. * Creates a new BoneIKController
  99898. * @param mesh defines the mesh to control
  99899. * @param bone defines the bone to control
  99900. * @param options defines options to set up the controller
  99901. */
  99902. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  99903. targetMesh?: AbstractMesh;
  99904. poleTargetMesh?: AbstractMesh;
  99905. poleTargetBone?: Bone;
  99906. poleTargetLocalOffset?: Vector3;
  99907. poleAngle?: number;
  99908. bendAxis?: Vector3;
  99909. maxAngle?: number;
  99910. slerpAmount?: number;
  99911. });
  99912. private _setMaxAngle;
  99913. /**
  99914. * Force the controller to update the bones
  99915. */
  99916. update(): void;
  99917. }
  99918. }
  99919. declare module BABYLON {
  99920. /**
  99921. * Class used to make a bone look toward a point in space
  99922. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  99923. */
  99924. export class BoneLookController {
  99925. private static _tmpVecs;
  99926. private static _tmpQuat;
  99927. private static _tmpMats;
  99928. /**
  99929. * The target Vector3 that the bone will look at
  99930. */
  99931. target: Vector3;
  99932. /**
  99933. * The mesh that the bone is attached to
  99934. */
  99935. mesh: AbstractMesh;
  99936. /**
  99937. * The bone that will be looking to the target
  99938. */
  99939. bone: Bone;
  99940. /**
  99941. * The up axis of the coordinate system that is used when the bone is rotated
  99942. */
  99943. upAxis: Vector3;
  99944. /**
  99945. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  99946. */
  99947. upAxisSpace: Space;
  99948. /**
  99949. * Used to make an adjustment to the yaw of the bone
  99950. */
  99951. adjustYaw: number;
  99952. /**
  99953. * Used to make an adjustment to the pitch of the bone
  99954. */
  99955. adjustPitch: number;
  99956. /**
  99957. * Used to make an adjustment to the roll of the bone
  99958. */
  99959. adjustRoll: number;
  99960. /**
  99961. * 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)
  99962. */
  99963. slerpAmount: number;
  99964. private _minYaw;
  99965. private _maxYaw;
  99966. private _minPitch;
  99967. private _maxPitch;
  99968. private _minYawSin;
  99969. private _minYawCos;
  99970. private _maxYawSin;
  99971. private _maxYawCos;
  99972. private _midYawConstraint;
  99973. private _minPitchTan;
  99974. private _maxPitchTan;
  99975. private _boneQuat;
  99976. private _slerping;
  99977. private _transformYawPitch;
  99978. private _transformYawPitchInv;
  99979. private _firstFrameSkipped;
  99980. private _yawRange;
  99981. private _fowardAxis;
  99982. /**
  99983. * Gets or sets the minimum yaw angle that the bone can look to
  99984. */
  99985. minYaw: number;
  99986. /**
  99987. * Gets or sets the maximum yaw angle that the bone can look to
  99988. */
  99989. maxYaw: number;
  99990. /**
  99991. * Gets or sets the minimum pitch angle that the bone can look to
  99992. */
  99993. minPitch: number;
  99994. /**
  99995. * Gets or sets the maximum pitch angle that the bone can look to
  99996. */
  99997. maxPitch: number;
  99998. /**
  99999. * Create a BoneLookController
  100000. * @param mesh the mesh that the bone belongs to
  100001. * @param bone the bone that will be looking to the target
  100002. * @param target the target Vector3 to look at
  100003. * @param options optional settings:
  100004. * * maxYaw: the maximum angle the bone will yaw to
  100005. * * minYaw: the minimum angle the bone will yaw to
  100006. * * maxPitch: the maximum angle the bone will pitch to
  100007. * * minPitch: the minimum angle the bone will yaw to
  100008. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  100009. * * upAxis: the up axis of the coordinate system
  100010. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  100011. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  100012. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  100013. * * adjustYaw: used to make an adjustment to the yaw of the bone
  100014. * * adjustPitch: used to make an adjustment to the pitch of the bone
  100015. * * adjustRoll: used to make an adjustment to the roll of the bone
  100016. **/
  100017. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  100018. maxYaw?: number;
  100019. minYaw?: number;
  100020. maxPitch?: number;
  100021. minPitch?: number;
  100022. slerpAmount?: number;
  100023. upAxis?: Vector3;
  100024. upAxisSpace?: Space;
  100025. yawAxis?: Vector3;
  100026. pitchAxis?: Vector3;
  100027. adjustYaw?: number;
  100028. adjustPitch?: number;
  100029. adjustRoll?: number;
  100030. });
  100031. /**
  100032. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  100033. */
  100034. update(): void;
  100035. private _getAngleDiff;
  100036. private _getAngleBetween;
  100037. private _isAngleBetween;
  100038. }
  100039. }
  100040. declare module BABYLON {
  100041. /**
  100042. * Manage the gamepad inputs to control an arc rotate camera.
  100043. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100044. */
  100045. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  100046. /**
  100047. * Defines the camera the input is attached to.
  100048. */
  100049. camera: ArcRotateCamera;
  100050. /**
  100051. * Defines the gamepad the input is gathering event from.
  100052. */
  100053. gamepad: Nullable<Gamepad>;
  100054. /**
  100055. * Defines the gamepad rotation sensiblity.
  100056. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  100057. */
  100058. gamepadRotationSensibility: number;
  100059. /**
  100060. * Defines the gamepad move sensiblity.
  100061. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  100062. */
  100063. gamepadMoveSensibility: number;
  100064. private _onGamepadConnectedObserver;
  100065. private _onGamepadDisconnectedObserver;
  100066. /**
  100067. * Attach the input controls to a specific dom element to get the input from.
  100068. * @param element Defines the element the controls should be listened from
  100069. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100070. */
  100071. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100072. /**
  100073. * Detach the current controls from the specified dom element.
  100074. * @param element Defines the element to stop listening the inputs from
  100075. */
  100076. detachControl(element: Nullable<HTMLElement>): void;
  100077. /**
  100078. * Update the current camera state depending on the inputs that have been used this frame.
  100079. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100080. */
  100081. checkInputs(): void;
  100082. /**
  100083. * Gets the class name of the current intput.
  100084. * @returns the class name
  100085. */
  100086. getClassName(): string;
  100087. /**
  100088. * Get the friendly name associated with the input class.
  100089. * @returns the input friendly name
  100090. */
  100091. getSimpleName(): string;
  100092. }
  100093. }
  100094. declare module BABYLON {
  100095. interface ArcRotateCameraInputsManager {
  100096. /**
  100097. * Add orientation input support to the input manager.
  100098. * @returns the current input manager
  100099. */
  100100. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  100101. }
  100102. /**
  100103. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  100104. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100105. */
  100106. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  100107. /**
  100108. * Defines the camera the input is attached to.
  100109. */
  100110. camera: ArcRotateCamera;
  100111. /**
  100112. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  100113. */
  100114. alphaCorrection: number;
  100115. /**
  100116. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  100117. */
  100118. gammaCorrection: number;
  100119. private _alpha;
  100120. private _gamma;
  100121. private _dirty;
  100122. private _deviceOrientationHandler;
  100123. /**
  100124. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  100125. */
  100126. constructor();
  100127. /**
  100128. * Attach the input controls to a specific dom element to get the input from.
  100129. * @param element Defines the element the controls should be listened from
  100130. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100131. */
  100132. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100133. /** @hidden */
  100134. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  100135. /**
  100136. * Update the current camera state depending on the inputs that have been used this frame.
  100137. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100138. */
  100139. checkInputs(): void;
  100140. /**
  100141. * Detach the current controls from the specified dom element.
  100142. * @param element Defines the element to stop listening the inputs from
  100143. */
  100144. detachControl(element: Nullable<HTMLElement>): void;
  100145. /**
  100146. * Gets the class name of the current intput.
  100147. * @returns the class name
  100148. */
  100149. getClassName(): string;
  100150. /**
  100151. * Get the friendly name associated with the input class.
  100152. * @returns the input friendly name
  100153. */
  100154. getSimpleName(): string;
  100155. }
  100156. }
  100157. declare module BABYLON {
  100158. /**
  100159. * Listen to mouse events to control the camera.
  100160. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100161. */
  100162. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  100163. /**
  100164. * Defines the camera the input is attached to.
  100165. */
  100166. camera: FlyCamera;
  100167. /**
  100168. * Defines if touch is enabled. (Default is true.)
  100169. */
  100170. touchEnabled: boolean;
  100171. /**
  100172. * Defines the buttons associated with the input to handle camera rotation.
  100173. */
  100174. buttons: number[];
  100175. /**
  100176. * Assign buttons for Yaw control.
  100177. */
  100178. buttonsYaw: number[];
  100179. /**
  100180. * Assign buttons for Pitch control.
  100181. */
  100182. buttonsPitch: number[];
  100183. /**
  100184. * Assign buttons for Roll control.
  100185. */
  100186. buttonsRoll: number[];
  100187. /**
  100188. * Detect if any button is being pressed while mouse is moved.
  100189. * -1 = Mouse locked.
  100190. * 0 = Left button.
  100191. * 1 = Middle Button.
  100192. * 2 = Right Button.
  100193. */
  100194. activeButton: number;
  100195. /**
  100196. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  100197. * Higher values reduce its sensitivity.
  100198. */
  100199. angularSensibility: number;
  100200. private _mousemoveCallback;
  100201. private _observer;
  100202. private _rollObserver;
  100203. private previousPosition;
  100204. private noPreventDefault;
  100205. private element;
  100206. /**
  100207. * Listen to mouse events to control the camera.
  100208. * @param touchEnabled Define if touch is enabled. (Default is true.)
  100209. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100210. */
  100211. constructor(touchEnabled?: boolean);
  100212. /**
  100213. * Attach the mouse control to the HTML DOM element.
  100214. * @param element Defines the element that listens to the input events.
  100215. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  100216. */
  100217. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100218. /**
  100219. * Detach the current controls from the specified dom element.
  100220. * @param element Defines the element to stop listening the inputs from
  100221. */
  100222. detachControl(element: Nullable<HTMLElement>): void;
  100223. /**
  100224. * Gets the class name of the current input.
  100225. * @returns the class name.
  100226. */
  100227. getClassName(): string;
  100228. /**
  100229. * Get the friendly name associated with the input class.
  100230. * @returns the input's friendly name.
  100231. */
  100232. getSimpleName(): string;
  100233. private _pointerInput;
  100234. private _onMouseMove;
  100235. /**
  100236. * Rotate camera by mouse offset.
  100237. */
  100238. private rotateCamera;
  100239. }
  100240. }
  100241. declare module BABYLON {
  100242. /**
  100243. * Default Inputs manager for the FlyCamera.
  100244. * It groups all the default supported inputs for ease of use.
  100245. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100246. */
  100247. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  100248. /**
  100249. * Instantiates a new FlyCameraInputsManager.
  100250. * @param camera Defines the camera the inputs belong to.
  100251. */
  100252. constructor(camera: FlyCamera);
  100253. /**
  100254. * Add keyboard input support to the input manager.
  100255. * @returns the new FlyCameraKeyboardMoveInput().
  100256. */
  100257. addKeyboard(): FlyCameraInputsManager;
  100258. /**
  100259. * Add mouse input support to the input manager.
  100260. * @param touchEnabled Enable touch screen support.
  100261. * @returns the new FlyCameraMouseInput().
  100262. */
  100263. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  100264. }
  100265. }
  100266. declare module BABYLON {
  100267. /**
  100268. * This is a flying camera, designed for 3D movement and rotation in all directions,
  100269. * such as in a 3D Space Shooter or a Flight Simulator.
  100270. */
  100271. export class FlyCamera extends TargetCamera {
  100272. /**
  100273. * Define the collision ellipsoid of the camera.
  100274. * This is helpful for simulating a camera body, like a player's body.
  100275. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  100276. */
  100277. ellipsoid: Vector3;
  100278. /**
  100279. * Define an offset for the position of the ellipsoid around the camera.
  100280. * This can be helpful if the camera is attached away from the player's body center,
  100281. * such as at its head.
  100282. */
  100283. ellipsoidOffset: Vector3;
  100284. /**
  100285. * Enable or disable collisions of the camera with the rest of the scene objects.
  100286. */
  100287. checkCollisions: boolean;
  100288. /**
  100289. * Enable or disable gravity on the camera.
  100290. */
  100291. applyGravity: boolean;
  100292. /**
  100293. * Define the current direction the camera is moving to.
  100294. */
  100295. cameraDirection: Vector3;
  100296. /**
  100297. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  100298. * This overrides and empties cameraRotation.
  100299. */
  100300. rotationQuaternion: Quaternion;
  100301. /**
  100302. * Track Roll to maintain the wanted Rolling when looking around.
  100303. */
  100304. _trackRoll: number;
  100305. /**
  100306. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  100307. */
  100308. rollCorrect: number;
  100309. /**
  100310. * Mimic a banked turn, Rolling the camera when Yawing.
  100311. * It's recommended to use rollCorrect = 10 for faster banking correction.
  100312. */
  100313. bankedTurn: boolean;
  100314. /**
  100315. * Limit in radians for how much Roll banking will add. (Default: 90°)
  100316. */
  100317. bankedTurnLimit: number;
  100318. /**
  100319. * Value of 0 disables the banked Roll.
  100320. * Value of 1 is equal to the Yaw angle in radians.
  100321. */
  100322. bankedTurnMultiplier: number;
  100323. /**
  100324. * The inputs manager loads all the input sources, such as keyboard and mouse.
  100325. */
  100326. inputs: FlyCameraInputsManager;
  100327. /**
  100328. * Gets the input sensibility for mouse input.
  100329. * Higher values reduce sensitivity.
  100330. */
  100331. /**
  100332. * Sets the input sensibility for a mouse input.
  100333. * Higher values reduce sensitivity.
  100334. */
  100335. angularSensibility: number;
  100336. /**
  100337. * Get the keys for camera movement forward.
  100338. */
  100339. /**
  100340. * Set the keys for camera movement forward.
  100341. */
  100342. keysForward: number[];
  100343. /**
  100344. * Get the keys for camera movement backward.
  100345. */
  100346. keysBackward: number[];
  100347. /**
  100348. * Get the keys for camera movement up.
  100349. */
  100350. /**
  100351. * Set the keys for camera movement up.
  100352. */
  100353. keysUp: number[];
  100354. /**
  100355. * Get the keys for camera movement down.
  100356. */
  100357. /**
  100358. * Set the keys for camera movement down.
  100359. */
  100360. keysDown: number[];
  100361. /**
  100362. * Get the keys for camera movement left.
  100363. */
  100364. /**
  100365. * Set the keys for camera movement left.
  100366. */
  100367. keysLeft: number[];
  100368. /**
  100369. * Set the keys for camera movement right.
  100370. */
  100371. /**
  100372. * Set the keys for camera movement right.
  100373. */
  100374. keysRight: number[];
  100375. /**
  100376. * Event raised when the camera collides with a mesh in the scene.
  100377. */
  100378. onCollide: (collidedMesh: AbstractMesh) => void;
  100379. private _collider;
  100380. private _needMoveForGravity;
  100381. private _oldPosition;
  100382. private _diffPosition;
  100383. private _newPosition;
  100384. /** @hidden */
  100385. _localDirection: Vector3;
  100386. /** @hidden */
  100387. _transformedDirection: Vector3;
  100388. /**
  100389. * Instantiates a FlyCamera.
  100390. * This is a flying camera, designed for 3D movement and rotation in all directions,
  100391. * such as in a 3D Space Shooter or a Flight Simulator.
  100392. * @param name Define the name of the camera in the scene.
  100393. * @param position Define the starting position of the camera in the scene.
  100394. * @param scene Define the scene the camera belongs to.
  100395. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  100396. */
  100397. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  100398. /**
  100399. * Attach a control to the HTML DOM element.
  100400. * @param element Defines the element that listens to the input events.
  100401. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  100402. */
  100403. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100404. /**
  100405. * Detach a control from the HTML DOM element.
  100406. * The camera will stop reacting to that input.
  100407. * @param element Defines the element that listens to the input events.
  100408. */
  100409. detachControl(element: HTMLElement): void;
  100410. private _collisionMask;
  100411. /**
  100412. * Get the mask that the camera ignores in collision events.
  100413. */
  100414. /**
  100415. * Set the mask that the camera ignores in collision events.
  100416. */
  100417. collisionMask: number;
  100418. /** @hidden */
  100419. _collideWithWorld(displacement: Vector3): void;
  100420. /** @hidden */
  100421. private _onCollisionPositionChange;
  100422. /** @hidden */
  100423. _checkInputs(): void;
  100424. /** @hidden */
  100425. _decideIfNeedsToMove(): boolean;
  100426. /** @hidden */
  100427. _updatePosition(): void;
  100428. /**
  100429. * Restore the Roll to its target value at the rate specified.
  100430. * @param rate - Higher means slower restoring.
  100431. * @hidden
  100432. */
  100433. restoreRoll(rate: number): void;
  100434. /**
  100435. * Destroy the camera and release the current resources held by it.
  100436. */
  100437. dispose(): void;
  100438. /**
  100439. * Get the current object class name.
  100440. * @returns the class name.
  100441. */
  100442. getClassName(): string;
  100443. }
  100444. }
  100445. declare module BABYLON {
  100446. /**
  100447. * Listen to keyboard events to control the camera.
  100448. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100449. */
  100450. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  100451. /**
  100452. * Defines the camera the input is attached to.
  100453. */
  100454. camera: FlyCamera;
  100455. /**
  100456. * The list of keyboard keys used to control the forward move of the camera.
  100457. */
  100458. keysForward: number[];
  100459. /**
  100460. * The list of keyboard keys used to control the backward move of the camera.
  100461. */
  100462. keysBackward: number[];
  100463. /**
  100464. * The list of keyboard keys used to control the forward move of the camera.
  100465. */
  100466. keysUp: number[];
  100467. /**
  100468. * The list of keyboard keys used to control the backward move of the camera.
  100469. */
  100470. keysDown: number[];
  100471. /**
  100472. * The list of keyboard keys used to control the right strafe move of the camera.
  100473. */
  100474. keysRight: number[];
  100475. /**
  100476. * The list of keyboard keys used to control the left strafe move of the camera.
  100477. */
  100478. keysLeft: number[];
  100479. private _keys;
  100480. private _onCanvasBlurObserver;
  100481. private _onKeyboardObserver;
  100482. private _engine;
  100483. private _scene;
  100484. /**
  100485. * Attach the input controls to a specific dom element to get the input from.
  100486. * @param element Defines the element the controls should be listened from
  100487. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100488. */
  100489. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100490. /**
  100491. * Detach the current controls from the specified dom element.
  100492. * @param element Defines the element to stop listening the inputs from
  100493. */
  100494. detachControl(element: Nullable<HTMLElement>): void;
  100495. /**
  100496. * Gets the class name of the current intput.
  100497. * @returns the class name
  100498. */
  100499. getClassName(): string;
  100500. /** @hidden */
  100501. _onLostFocus(e: FocusEvent): void;
  100502. /**
  100503. * Get the friendly name associated with the input class.
  100504. * @returns the input friendly name
  100505. */
  100506. getSimpleName(): string;
  100507. /**
  100508. * Update the current camera state depending on the inputs that have been used this frame.
  100509. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100510. */
  100511. checkInputs(): void;
  100512. }
  100513. }
  100514. declare module BABYLON {
  100515. /**
  100516. * Manage the mouse wheel inputs to control a follow camera.
  100517. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100518. */
  100519. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  100520. /**
  100521. * Defines the camera the input is attached to.
  100522. */
  100523. camera: FollowCamera;
  100524. /**
  100525. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  100526. */
  100527. axisControlRadius: boolean;
  100528. /**
  100529. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  100530. */
  100531. axisControlHeight: boolean;
  100532. /**
  100533. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  100534. */
  100535. axisControlRotation: boolean;
  100536. /**
  100537. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  100538. * relation to mouseWheel events.
  100539. */
  100540. wheelPrecision: number;
  100541. /**
  100542. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  100543. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  100544. */
  100545. wheelDeltaPercentage: number;
  100546. private _wheel;
  100547. private _observer;
  100548. /**
  100549. * Attach the input controls to a specific dom element to get the input from.
  100550. * @param element Defines the element the controls should be listened from
  100551. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100552. */
  100553. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100554. /**
  100555. * Detach the current controls from the specified dom element.
  100556. * @param element Defines the element to stop listening the inputs from
  100557. */
  100558. detachControl(element: Nullable<HTMLElement>): void;
  100559. /**
  100560. * Gets the class name of the current intput.
  100561. * @returns the class name
  100562. */
  100563. getClassName(): string;
  100564. /**
  100565. * Get the friendly name associated with the input class.
  100566. * @returns the input friendly name
  100567. */
  100568. getSimpleName(): string;
  100569. }
  100570. }
  100571. declare module BABYLON {
  100572. /**
  100573. * Manage the pointers inputs to control an follow camera.
  100574. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100575. */
  100576. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  100577. /**
  100578. * Defines the camera the input is attached to.
  100579. */
  100580. camera: FollowCamera;
  100581. /**
  100582. * Gets the class name of the current input.
  100583. * @returns the class name
  100584. */
  100585. getClassName(): string;
  100586. /**
  100587. * Defines the pointer angular sensibility along the X axis or how fast is
  100588. * the camera rotating.
  100589. * A negative number will reverse the axis direction.
  100590. */
  100591. angularSensibilityX: number;
  100592. /**
  100593. * Defines the pointer angular sensibility along the Y axis or how fast is
  100594. * the camera rotating.
  100595. * A negative number will reverse the axis direction.
  100596. */
  100597. angularSensibilityY: number;
  100598. /**
  100599. * Defines the pointer pinch precision or how fast is the camera zooming.
  100600. * A negative number will reverse the axis direction.
  100601. */
  100602. pinchPrecision: number;
  100603. /**
  100604. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  100605. * from 0.
  100606. * It defines the percentage of current camera.radius to use as delta when
  100607. * pinch zoom is used.
  100608. */
  100609. pinchDeltaPercentage: number;
  100610. /**
  100611. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  100612. */
  100613. axisXControlRadius: boolean;
  100614. /**
  100615. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  100616. */
  100617. axisXControlHeight: boolean;
  100618. /**
  100619. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  100620. */
  100621. axisXControlRotation: boolean;
  100622. /**
  100623. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  100624. */
  100625. axisYControlRadius: boolean;
  100626. /**
  100627. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  100628. */
  100629. axisYControlHeight: boolean;
  100630. /**
  100631. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  100632. */
  100633. axisYControlRotation: boolean;
  100634. /**
  100635. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  100636. */
  100637. axisPinchControlRadius: boolean;
  100638. /**
  100639. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  100640. */
  100641. axisPinchControlHeight: boolean;
  100642. /**
  100643. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  100644. */
  100645. axisPinchControlRotation: boolean;
  100646. /**
  100647. * Log error messages if basic misconfiguration has occurred.
  100648. */
  100649. warningEnable: boolean;
  100650. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  100651. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  100652. private _warningCounter;
  100653. private _warning;
  100654. }
  100655. }
  100656. declare module BABYLON {
  100657. /**
  100658. * Default Inputs manager for the FollowCamera.
  100659. * It groups all the default supported inputs for ease of use.
  100660. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100661. */
  100662. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  100663. /**
  100664. * Instantiates a new FollowCameraInputsManager.
  100665. * @param camera Defines the camera the inputs belong to
  100666. */
  100667. constructor(camera: FollowCamera);
  100668. /**
  100669. * Add keyboard input support to the input manager.
  100670. * @returns the current input manager
  100671. */
  100672. addKeyboard(): FollowCameraInputsManager;
  100673. /**
  100674. * Add mouse wheel input support to the input manager.
  100675. * @returns the current input manager
  100676. */
  100677. addMouseWheel(): FollowCameraInputsManager;
  100678. /**
  100679. * Add pointers input support to the input manager.
  100680. * @returns the current input manager
  100681. */
  100682. addPointers(): FollowCameraInputsManager;
  100683. /**
  100684. * Add orientation input support to the input manager.
  100685. * @returns the current input manager
  100686. */
  100687. addVRDeviceOrientation(): FollowCameraInputsManager;
  100688. }
  100689. }
  100690. declare module BABYLON {
  100691. /**
  100692. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  100693. * an arc rotate version arcFollowCamera are available.
  100694. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  100695. */
  100696. export class FollowCamera extends TargetCamera {
  100697. /**
  100698. * Distance the follow camera should follow an object at
  100699. */
  100700. radius: number;
  100701. /**
  100702. * Minimum allowed distance of the camera to the axis of rotation
  100703. * (The camera can not get closer).
  100704. * This can help limiting how the Camera is able to move in the scene.
  100705. */
  100706. lowerRadiusLimit: Nullable<number>;
  100707. /**
  100708. * Maximum allowed distance of the camera to the axis of rotation
  100709. * (The camera can not get further).
  100710. * This can help limiting how the Camera is able to move in the scene.
  100711. */
  100712. upperRadiusLimit: Nullable<number>;
  100713. /**
  100714. * Define a rotation offset between the camera and the object it follows
  100715. */
  100716. rotationOffset: number;
  100717. /**
  100718. * Minimum allowed angle to camera position relative to target object.
  100719. * This can help limiting how the Camera is able to move in the scene.
  100720. */
  100721. lowerRotationOffsetLimit: Nullable<number>;
  100722. /**
  100723. * Maximum allowed angle to camera position relative to target object.
  100724. * This can help limiting how the Camera is able to move in the scene.
  100725. */
  100726. upperRotationOffsetLimit: Nullable<number>;
  100727. /**
  100728. * Define a height offset between the camera and the object it follows.
  100729. * It can help following an object from the top (like a car chaing a plane)
  100730. */
  100731. heightOffset: number;
  100732. /**
  100733. * Minimum allowed height of camera position relative to target object.
  100734. * This can help limiting how the Camera is able to move in the scene.
  100735. */
  100736. lowerHeightOffsetLimit: Nullable<number>;
  100737. /**
  100738. * Maximum allowed height of camera position relative to target object.
  100739. * This can help limiting how the Camera is able to move in the scene.
  100740. */
  100741. upperHeightOffsetLimit: Nullable<number>;
  100742. /**
  100743. * Define how fast the camera can accelerate to follow it s target.
  100744. */
  100745. cameraAcceleration: number;
  100746. /**
  100747. * Define the speed limit of the camera following an object.
  100748. */
  100749. maxCameraSpeed: number;
  100750. /**
  100751. * Define the target of the camera.
  100752. */
  100753. lockedTarget: Nullable<AbstractMesh>;
  100754. /**
  100755. * Defines the input associated with the camera.
  100756. */
  100757. inputs: FollowCameraInputsManager;
  100758. /**
  100759. * Instantiates the follow camera.
  100760. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  100761. * @param name Define the name of the camera in the scene
  100762. * @param position Define the position of the camera
  100763. * @param scene Define the scene the camera belong to
  100764. * @param lockedTarget Define the target of the camera
  100765. */
  100766. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  100767. private _follow;
  100768. /**
  100769. * Attached controls to the current camera.
  100770. * @param element Defines the element the controls should be listened from
  100771. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100772. */
  100773. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100774. /**
  100775. * Detach the current controls from the camera.
  100776. * The camera will stop reacting to inputs.
  100777. * @param element Defines the element to stop listening the inputs from
  100778. */
  100779. detachControl(element: HTMLElement): void;
  100780. /** @hidden */
  100781. _checkInputs(): void;
  100782. private _checkLimits;
  100783. /**
  100784. * Gets the camera class name.
  100785. * @returns the class name
  100786. */
  100787. getClassName(): string;
  100788. }
  100789. /**
  100790. * Arc Rotate version of the follow camera.
  100791. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  100792. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  100793. */
  100794. export class ArcFollowCamera extends TargetCamera {
  100795. /** The longitudinal angle of the camera */
  100796. alpha: number;
  100797. /** The latitudinal angle of the camera */
  100798. beta: number;
  100799. /** The radius of the camera from its target */
  100800. radius: number;
  100801. /** Define the camera target (the messh it should follow) */
  100802. target: Nullable<AbstractMesh>;
  100803. private _cartesianCoordinates;
  100804. /**
  100805. * Instantiates a new ArcFollowCamera
  100806. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  100807. * @param name Define the name of the camera
  100808. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  100809. * @param beta Define the rotation angle of the camera around the elevation axis
  100810. * @param radius Define the radius of the camera from its target point
  100811. * @param target Define the target of the camera
  100812. * @param scene Define the scene the camera belongs to
  100813. */
  100814. constructor(name: string,
  100815. /** The longitudinal angle of the camera */
  100816. alpha: number,
  100817. /** The latitudinal angle of the camera */
  100818. beta: number,
  100819. /** The radius of the camera from its target */
  100820. radius: number,
  100821. /** Define the camera target (the messh it should follow) */
  100822. target: Nullable<AbstractMesh>, scene: Scene);
  100823. private _follow;
  100824. /** @hidden */
  100825. _checkInputs(): void;
  100826. /**
  100827. * Returns the class name of the object.
  100828. * It is mostly used internally for serialization purposes.
  100829. */
  100830. getClassName(): string;
  100831. }
  100832. }
  100833. declare module BABYLON {
  100834. /**
  100835. * Manage the keyboard inputs to control the movement of a follow camera.
  100836. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100837. */
  100838. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  100839. /**
  100840. * Defines the camera the input is attached to.
  100841. */
  100842. camera: FollowCamera;
  100843. /**
  100844. * Defines the list of key codes associated with the up action (increase heightOffset)
  100845. */
  100846. keysHeightOffsetIncr: number[];
  100847. /**
  100848. * Defines the list of key codes associated with the down action (decrease heightOffset)
  100849. */
  100850. keysHeightOffsetDecr: number[];
  100851. /**
  100852. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  100853. */
  100854. keysHeightOffsetModifierAlt: boolean;
  100855. /**
  100856. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  100857. */
  100858. keysHeightOffsetModifierCtrl: boolean;
  100859. /**
  100860. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  100861. */
  100862. keysHeightOffsetModifierShift: boolean;
  100863. /**
  100864. * Defines the list of key codes associated with the left action (increase rotationOffset)
  100865. */
  100866. keysRotationOffsetIncr: number[];
  100867. /**
  100868. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  100869. */
  100870. keysRotationOffsetDecr: number[];
  100871. /**
  100872. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  100873. */
  100874. keysRotationOffsetModifierAlt: boolean;
  100875. /**
  100876. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  100877. */
  100878. keysRotationOffsetModifierCtrl: boolean;
  100879. /**
  100880. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  100881. */
  100882. keysRotationOffsetModifierShift: boolean;
  100883. /**
  100884. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  100885. */
  100886. keysRadiusIncr: number[];
  100887. /**
  100888. * Defines the list of key codes associated with the zoom-out action (increase radius)
  100889. */
  100890. keysRadiusDecr: number[];
  100891. /**
  100892. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  100893. */
  100894. keysRadiusModifierAlt: boolean;
  100895. /**
  100896. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  100897. */
  100898. keysRadiusModifierCtrl: boolean;
  100899. /**
  100900. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  100901. */
  100902. keysRadiusModifierShift: boolean;
  100903. /**
  100904. * Defines the rate of change of heightOffset.
  100905. */
  100906. heightSensibility: number;
  100907. /**
  100908. * Defines the rate of change of rotationOffset.
  100909. */
  100910. rotationSensibility: number;
  100911. /**
  100912. * Defines the rate of change of radius.
  100913. */
  100914. radiusSensibility: number;
  100915. private _keys;
  100916. private _ctrlPressed;
  100917. private _altPressed;
  100918. private _shiftPressed;
  100919. private _onCanvasBlurObserver;
  100920. private _onKeyboardObserver;
  100921. private _engine;
  100922. private _scene;
  100923. /**
  100924. * Attach the input controls to a specific dom element to get the input from.
  100925. * @param element Defines the element the controls should be listened from
  100926. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100927. */
  100928. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100929. /**
  100930. * Detach the current controls from the specified dom element.
  100931. * @param element Defines the element to stop listening the inputs from
  100932. */
  100933. detachControl(element: Nullable<HTMLElement>): void;
  100934. /**
  100935. * Update the current camera state depending on the inputs that have been used this frame.
  100936. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100937. */
  100938. checkInputs(): void;
  100939. /**
  100940. * Gets the class name of the current input.
  100941. * @returns the class name
  100942. */
  100943. getClassName(): string;
  100944. /**
  100945. * Get the friendly name associated with the input class.
  100946. * @returns the input friendly name
  100947. */
  100948. getSimpleName(): string;
  100949. /**
  100950. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  100951. * allow modification of the heightOffset value.
  100952. */
  100953. private _modifierHeightOffset;
  100954. /**
  100955. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  100956. * allow modification of the rotationOffset value.
  100957. */
  100958. private _modifierRotationOffset;
  100959. /**
  100960. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  100961. * allow modification of the radius value.
  100962. */
  100963. private _modifierRadius;
  100964. }
  100965. }
  100966. declare module BABYLON {
  100967. interface FreeCameraInputsManager {
  100968. /**
  100969. * @hidden
  100970. */
  100971. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  100972. /**
  100973. * Add orientation input support to the input manager.
  100974. * @returns the current input manager
  100975. */
  100976. addDeviceOrientation(): FreeCameraInputsManager;
  100977. }
  100978. /**
  100979. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  100980. * Screen rotation is taken into account.
  100981. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100982. */
  100983. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  100984. private _camera;
  100985. private _screenOrientationAngle;
  100986. private _constantTranform;
  100987. private _screenQuaternion;
  100988. private _alpha;
  100989. private _beta;
  100990. private _gamma;
  100991. /**
  100992. * Can be used to detect if a device orientation sensor is availible on a device
  100993. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  100994. * @returns a promise that will resolve on orientation change
  100995. */
  100996. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  100997. /**
  100998. * @hidden
  100999. */
  101000. _onDeviceOrientationChangedObservable: Observable<void>;
  101001. /**
  101002. * Instantiates a new input
  101003. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101004. */
  101005. constructor();
  101006. /**
  101007. * Define the camera controlled by the input.
  101008. */
  101009. camera: FreeCamera;
  101010. /**
  101011. * Attach the input controls to a specific dom element to get the input from.
  101012. * @param element Defines the element the controls should be listened from
  101013. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101014. */
  101015. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101016. private _orientationChanged;
  101017. private _deviceOrientation;
  101018. /**
  101019. * Detach the current controls from the specified dom element.
  101020. * @param element Defines the element to stop listening the inputs from
  101021. */
  101022. detachControl(element: Nullable<HTMLElement>): void;
  101023. /**
  101024. * Update the current camera state depending on the inputs that have been used this frame.
  101025. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101026. */
  101027. checkInputs(): void;
  101028. /**
  101029. * Gets the class name of the current intput.
  101030. * @returns the class name
  101031. */
  101032. getClassName(): string;
  101033. /**
  101034. * Get the friendly name associated with the input class.
  101035. * @returns the input friendly name
  101036. */
  101037. getSimpleName(): string;
  101038. }
  101039. }
  101040. declare module BABYLON {
  101041. /**
  101042. * Manage the gamepad inputs to control a free camera.
  101043. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101044. */
  101045. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  101046. /**
  101047. * Define the camera the input is attached to.
  101048. */
  101049. camera: FreeCamera;
  101050. /**
  101051. * Define the Gamepad controlling the input
  101052. */
  101053. gamepad: Nullable<Gamepad>;
  101054. /**
  101055. * Defines the gamepad rotation sensiblity.
  101056. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  101057. */
  101058. gamepadAngularSensibility: number;
  101059. /**
  101060. * Defines the gamepad move sensiblity.
  101061. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  101062. */
  101063. gamepadMoveSensibility: number;
  101064. private _onGamepadConnectedObserver;
  101065. private _onGamepadDisconnectedObserver;
  101066. private _cameraTransform;
  101067. private _deltaTransform;
  101068. private _vector3;
  101069. private _vector2;
  101070. /**
  101071. * Attach the input controls to a specific dom element to get the input from.
  101072. * @param element Defines the element the controls should be listened from
  101073. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101074. */
  101075. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101076. /**
  101077. * Detach the current controls from the specified dom element.
  101078. * @param element Defines the element to stop listening the inputs from
  101079. */
  101080. detachControl(element: Nullable<HTMLElement>): void;
  101081. /**
  101082. * Update the current camera state depending on the inputs that have been used this frame.
  101083. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101084. */
  101085. checkInputs(): void;
  101086. /**
  101087. * Gets the class name of the current intput.
  101088. * @returns the class name
  101089. */
  101090. getClassName(): string;
  101091. /**
  101092. * Get the friendly name associated with the input class.
  101093. * @returns the input friendly name
  101094. */
  101095. getSimpleName(): string;
  101096. }
  101097. }
  101098. declare module BABYLON {
  101099. /**
  101100. * Defines the potential axis of a Joystick
  101101. */
  101102. export enum JoystickAxis {
  101103. /** X axis */
  101104. X = 0,
  101105. /** Y axis */
  101106. Y = 1,
  101107. /** Z axis */
  101108. Z = 2
  101109. }
  101110. /**
  101111. * Class used to define virtual joystick (used in touch mode)
  101112. */
  101113. export class VirtualJoystick {
  101114. /**
  101115. * Gets or sets a boolean indicating that left and right values must be inverted
  101116. */
  101117. reverseLeftRight: boolean;
  101118. /**
  101119. * Gets or sets a boolean indicating that up and down values must be inverted
  101120. */
  101121. reverseUpDown: boolean;
  101122. /**
  101123. * Gets the offset value for the position (ie. the change of the position value)
  101124. */
  101125. deltaPosition: Vector3;
  101126. /**
  101127. * Gets a boolean indicating if the virtual joystick was pressed
  101128. */
  101129. pressed: boolean;
  101130. /**
  101131. * Canvas the virtual joystick will render onto, default z-index of this is 5
  101132. */
  101133. static Canvas: Nullable<HTMLCanvasElement>;
  101134. private static _globalJoystickIndex;
  101135. private static vjCanvasContext;
  101136. private static vjCanvasWidth;
  101137. private static vjCanvasHeight;
  101138. private static halfWidth;
  101139. private _action;
  101140. private _axisTargetedByLeftAndRight;
  101141. private _axisTargetedByUpAndDown;
  101142. private _joystickSensibility;
  101143. private _inversedSensibility;
  101144. private _joystickPointerID;
  101145. private _joystickColor;
  101146. private _joystickPointerPos;
  101147. private _joystickPreviousPointerPos;
  101148. private _joystickPointerStartPos;
  101149. private _deltaJoystickVector;
  101150. private _leftJoystick;
  101151. private _touches;
  101152. private _onPointerDownHandlerRef;
  101153. private _onPointerMoveHandlerRef;
  101154. private _onPointerUpHandlerRef;
  101155. private _onResize;
  101156. /**
  101157. * Creates a new virtual joystick
  101158. * @param leftJoystick defines that the joystick is for left hand (false by default)
  101159. */
  101160. constructor(leftJoystick?: boolean);
  101161. /**
  101162. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  101163. * @param newJoystickSensibility defines the new sensibility
  101164. */
  101165. setJoystickSensibility(newJoystickSensibility: number): void;
  101166. private _onPointerDown;
  101167. private _onPointerMove;
  101168. private _onPointerUp;
  101169. /**
  101170. * Change the color of the virtual joystick
  101171. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  101172. */
  101173. setJoystickColor(newColor: string): void;
  101174. /**
  101175. * Defines a callback to call when the joystick is touched
  101176. * @param action defines the callback
  101177. */
  101178. setActionOnTouch(action: () => any): void;
  101179. /**
  101180. * Defines which axis you'd like to control for left & right
  101181. * @param axis defines the axis to use
  101182. */
  101183. setAxisForLeftRight(axis: JoystickAxis): void;
  101184. /**
  101185. * Defines which axis you'd like to control for up & down
  101186. * @param axis defines the axis to use
  101187. */
  101188. setAxisForUpDown(axis: JoystickAxis): void;
  101189. private _drawVirtualJoystick;
  101190. /**
  101191. * Release internal HTML canvas
  101192. */
  101193. releaseCanvas(): void;
  101194. }
  101195. }
  101196. declare module BABYLON {
  101197. interface FreeCameraInputsManager {
  101198. /**
  101199. * Add virtual joystick input support to the input manager.
  101200. * @returns the current input manager
  101201. */
  101202. addVirtualJoystick(): FreeCameraInputsManager;
  101203. }
  101204. /**
  101205. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  101206. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101207. */
  101208. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  101209. /**
  101210. * Defines the camera the input is attached to.
  101211. */
  101212. camera: FreeCamera;
  101213. private _leftjoystick;
  101214. private _rightjoystick;
  101215. /**
  101216. * Gets the left stick of the virtual joystick.
  101217. * @returns The virtual Joystick
  101218. */
  101219. getLeftJoystick(): VirtualJoystick;
  101220. /**
  101221. * Gets the right stick of the virtual joystick.
  101222. * @returns The virtual Joystick
  101223. */
  101224. getRightJoystick(): VirtualJoystick;
  101225. /**
  101226. * Update the current camera state depending on the inputs that have been used this frame.
  101227. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101228. */
  101229. checkInputs(): void;
  101230. /**
  101231. * Attach the input controls to a specific dom element to get the input from.
  101232. * @param element Defines the element the controls should be listened from
  101233. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101234. */
  101235. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101236. /**
  101237. * Detach the current controls from the specified dom element.
  101238. * @param element Defines the element to stop listening the inputs from
  101239. */
  101240. detachControl(element: Nullable<HTMLElement>): void;
  101241. /**
  101242. * Gets the class name of the current intput.
  101243. * @returns the class name
  101244. */
  101245. getClassName(): string;
  101246. /**
  101247. * Get the friendly name associated with the input class.
  101248. * @returns the input friendly name
  101249. */
  101250. getSimpleName(): string;
  101251. }
  101252. }
  101253. declare module BABYLON {
  101254. /**
  101255. * This represents a FPS type of camera controlled by touch.
  101256. * This is like a universal camera minus the Gamepad controls.
  101257. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  101258. */
  101259. export class TouchCamera extends FreeCamera {
  101260. /**
  101261. * Defines the touch sensibility for rotation.
  101262. * The higher the faster.
  101263. */
  101264. touchAngularSensibility: number;
  101265. /**
  101266. * Defines the touch sensibility for move.
  101267. * The higher the faster.
  101268. */
  101269. touchMoveSensibility: number;
  101270. /**
  101271. * Instantiates a new touch camera.
  101272. * This represents a FPS type of camera controlled by touch.
  101273. * This is like a universal camera minus the Gamepad controls.
  101274. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  101275. * @param name Define the name of the camera in the scene
  101276. * @param position Define the start position of the camera in the scene
  101277. * @param scene Define the scene the camera belongs to
  101278. */
  101279. constructor(name: string, position: Vector3, scene: Scene);
  101280. /**
  101281. * Gets the current object class name.
  101282. * @return the class name
  101283. */
  101284. getClassName(): string;
  101285. /** @hidden */
  101286. _setupInputs(): void;
  101287. }
  101288. }
  101289. declare module BABYLON {
  101290. /**
  101291. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  101292. * being tilted forward or back and left or right.
  101293. */
  101294. export class DeviceOrientationCamera extends FreeCamera {
  101295. private _initialQuaternion;
  101296. private _quaternionCache;
  101297. private _tmpDragQuaternion;
  101298. /**
  101299. * Creates a new device orientation camera
  101300. * @param name The name of the camera
  101301. * @param position The start position camera
  101302. * @param scene The scene the camera belongs to
  101303. */
  101304. constructor(name: string, position: Vector3, scene: Scene);
  101305. /**
  101306. * @hidden
  101307. * Disabled pointer input on first orientation sensor update (Default: true)
  101308. */
  101309. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  101310. private _dragFactor;
  101311. /**
  101312. * Enabled turning on the y axis when the orientation sensor is active
  101313. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  101314. */
  101315. enableHorizontalDragging(dragFactor?: number): void;
  101316. /**
  101317. * Gets the current instance class name ("DeviceOrientationCamera").
  101318. * This helps avoiding instanceof at run time.
  101319. * @returns the class name
  101320. */
  101321. getClassName(): string;
  101322. /**
  101323. * @hidden
  101324. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  101325. */
  101326. _checkInputs(): void;
  101327. /**
  101328. * Reset the camera to its default orientation on the specified axis only.
  101329. * @param axis The axis to reset
  101330. */
  101331. resetToCurrentRotation(axis?: Axis): void;
  101332. }
  101333. }
  101334. declare module BABYLON {
  101335. /**
  101336. * Defines supported buttons for XBox360 compatible gamepads
  101337. */
  101338. export enum Xbox360Button {
  101339. /** A */
  101340. A = 0,
  101341. /** B */
  101342. B = 1,
  101343. /** X */
  101344. X = 2,
  101345. /** Y */
  101346. Y = 3,
  101347. /** Start */
  101348. Start = 4,
  101349. /** Back */
  101350. Back = 5,
  101351. /** Left button */
  101352. LB = 6,
  101353. /** Right button */
  101354. RB = 7,
  101355. /** Left stick */
  101356. LeftStick = 8,
  101357. /** Right stick */
  101358. RightStick = 9
  101359. }
  101360. /** Defines values for XBox360 DPad */
  101361. export enum Xbox360Dpad {
  101362. /** Up */
  101363. Up = 0,
  101364. /** Down */
  101365. Down = 1,
  101366. /** Left */
  101367. Left = 2,
  101368. /** Right */
  101369. Right = 3
  101370. }
  101371. /**
  101372. * Defines a XBox360 gamepad
  101373. */
  101374. export class Xbox360Pad extends Gamepad {
  101375. private _leftTrigger;
  101376. private _rightTrigger;
  101377. private _onlefttriggerchanged;
  101378. private _onrighttriggerchanged;
  101379. private _onbuttondown;
  101380. private _onbuttonup;
  101381. private _ondpaddown;
  101382. private _ondpadup;
  101383. /** Observable raised when a button is pressed */
  101384. onButtonDownObservable: Observable<Xbox360Button>;
  101385. /** Observable raised when a button is released */
  101386. onButtonUpObservable: Observable<Xbox360Button>;
  101387. /** Observable raised when a pad is pressed */
  101388. onPadDownObservable: Observable<Xbox360Dpad>;
  101389. /** Observable raised when a pad is released */
  101390. onPadUpObservable: Observable<Xbox360Dpad>;
  101391. private _buttonA;
  101392. private _buttonB;
  101393. private _buttonX;
  101394. private _buttonY;
  101395. private _buttonBack;
  101396. private _buttonStart;
  101397. private _buttonLB;
  101398. private _buttonRB;
  101399. private _buttonLeftStick;
  101400. private _buttonRightStick;
  101401. private _dPadUp;
  101402. private _dPadDown;
  101403. private _dPadLeft;
  101404. private _dPadRight;
  101405. private _isXboxOnePad;
  101406. /**
  101407. * Creates a new XBox360 gamepad object
  101408. * @param id defines the id of this gamepad
  101409. * @param index defines its index
  101410. * @param gamepad defines the internal HTML gamepad object
  101411. * @param xboxOne defines if it is a XBox One gamepad
  101412. */
  101413. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  101414. /**
  101415. * Defines the callback to call when left trigger is pressed
  101416. * @param callback defines the callback to use
  101417. */
  101418. onlefttriggerchanged(callback: (value: number) => void): void;
  101419. /**
  101420. * Defines the callback to call when right trigger is pressed
  101421. * @param callback defines the callback to use
  101422. */
  101423. onrighttriggerchanged(callback: (value: number) => void): void;
  101424. /**
  101425. * Gets the left trigger value
  101426. */
  101427. /**
  101428. * Sets the left trigger value
  101429. */
  101430. leftTrigger: number;
  101431. /**
  101432. * Gets the right trigger value
  101433. */
  101434. /**
  101435. * Sets the right trigger value
  101436. */
  101437. rightTrigger: number;
  101438. /**
  101439. * Defines the callback to call when a button is pressed
  101440. * @param callback defines the callback to use
  101441. */
  101442. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  101443. /**
  101444. * Defines the callback to call when a button is released
  101445. * @param callback defines the callback to use
  101446. */
  101447. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  101448. /**
  101449. * Defines the callback to call when a pad is pressed
  101450. * @param callback defines the callback to use
  101451. */
  101452. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  101453. /**
  101454. * Defines the callback to call when a pad is released
  101455. * @param callback defines the callback to use
  101456. */
  101457. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  101458. private _setButtonValue;
  101459. private _setDPadValue;
  101460. /**
  101461. * Gets the value of the `A` button
  101462. */
  101463. /**
  101464. * Sets the value of the `A` button
  101465. */
  101466. buttonA: number;
  101467. /**
  101468. * Gets the value of the `B` button
  101469. */
  101470. /**
  101471. * Sets the value of the `B` button
  101472. */
  101473. buttonB: number;
  101474. /**
  101475. * Gets the value of the `X` button
  101476. */
  101477. /**
  101478. * Sets the value of the `X` button
  101479. */
  101480. buttonX: number;
  101481. /**
  101482. * Gets the value of the `Y` button
  101483. */
  101484. /**
  101485. * Sets the value of the `Y` button
  101486. */
  101487. buttonY: number;
  101488. /**
  101489. * Gets the value of the `Start` button
  101490. */
  101491. /**
  101492. * Sets the value of the `Start` button
  101493. */
  101494. buttonStart: number;
  101495. /**
  101496. * Gets the value of the `Back` button
  101497. */
  101498. /**
  101499. * Sets the value of the `Back` button
  101500. */
  101501. buttonBack: number;
  101502. /**
  101503. * Gets the value of the `Left` button
  101504. */
  101505. /**
  101506. * Sets the value of the `Left` button
  101507. */
  101508. buttonLB: number;
  101509. /**
  101510. * Gets the value of the `Right` button
  101511. */
  101512. /**
  101513. * Sets the value of the `Right` button
  101514. */
  101515. buttonRB: number;
  101516. /**
  101517. * Gets the value of the Left joystick
  101518. */
  101519. /**
  101520. * Sets the value of the Left joystick
  101521. */
  101522. buttonLeftStick: number;
  101523. /**
  101524. * Gets the value of the Right joystick
  101525. */
  101526. /**
  101527. * Sets the value of the Right joystick
  101528. */
  101529. buttonRightStick: number;
  101530. /**
  101531. * Gets the value of D-pad up
  101532. */
  101533. /**
  101534. * Sets the value of D-pad up
  101535. */
  101536. dPadUp: number;
  101537. /**
  101538. * Gets the value of D-pad down
  101539. */
  101540. /**
  101541. * Sets the value of D-pad down
  101542. */
  101543. dPadDown: number;
  101544. /**
  101545. * Gets the value of D-pad left
  101546. */
  101547. /**
  101548. * Sets the value of D-pad left
  101549. */
  101550. dPadLeft: number;
  101551. /**
  101552. * Gets the value of D-pad right
  101553. */
  101554. /**
  101555. * Sets the value of D-pad right
  101556. */
  101557. dPadRight: number;
  101558. /**
  101559. * Force the gamepad to synchronize with device values
  101560. */
  101561. update(): void;
  101562. /**
  101563. * Disposes the gamepad
  101564. */
  101565. dispose(): void;
  101566. }
  101567. }
  101568. declare module BABYLON {
  101569. /**
  101570. * Manager for handling gamepads
  101571. */
  101572. export class GamepadManager {
  101573. private _scene?;
  101574. private _babylonGamepads;
  101575. private _oneGamepadConnected;
  101576. /** @hidden */
  101577. _isMonitoring: boolean;
  101578. private _gamepadEventSupported;
  101579. private _gamepadSupport;
  101580. /**
  101581. * observable to be triggered when the gamepad controller has been connected
  101582. */
  101583. onGamepadConnectedObservable: Observable<Gamepad>;
  101584. /**
  101585. * observable to be triggered when the gamepad controller has been disconnected
  101586. */
  101587. onGamepadDisconnectedObservable: Observable<Gamepad>;
  101588. private _onGamepadConnectedEvent;
  101589. private _onGamepadDisconnectedEvent;
  101590. /**
  101591. * Initializes the gamepad manager
  101592. * @param _scene BabylonJS scene
  101593. */
  101594. constructor(_scene?: Scene | undefined);
  101595. /**
  101596. * The gamepads in the game pad manager
  101597. */
  101598. readonly gamepads: Gamepad[];
  101599. /**
  101600. * Get the gamepad controllers based on type
  101601. * @param type The type of gamepad controller
  101602. * @returns Nullable gamepad
  101603. */
  101604. getGamepadByType(type?: number): Nullable<Gamepad>;
  101605. /**
  101606. * Disposes the gamepad manager
  101607. */
  101608. dispose(): void;
  101609. private _addNewGamepad;
  101610. private _startMonitoringGamepads;
  101611. private _stopMonitoringGamepads;
  101612. /** @hidden */
  101613. _checkGamepadsStatus(): void;
  101614. private _updateGamepadObjects;
  101615. }
  101616. }
  101617. declare module BABYLON {
  101618. interface Scene {
  101619. /** @hidden */
  101620. _gamepadManager: Nullable<GamepadManager>;
  101621. /**
  101622. * Gets the gamepad manager associated with the scene
  101623. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  101624. */
  101625. gamepadManager: GamepadManager;
  101626. }
  101627. /**
  101628. * Interface representing a free camera inputs manager
  101629. */
  101630. interface FreeCameraInputsManager {
  101631. /**
  101632. * Adds gamepad input support to the FreeCameraInputsManager.
  101633. * @returns the FreeCameraInputsManager
  101634. */
  101635. addGamepad(): FreeCameraInputsManager;
  101636. }
  101637. /**
  101638. * Interface representing an arc rotate camera inputs manager
  101639. */
  101640. interface ArcRotateCameraInputsManager {
  101641. /**
  101642. * Adds gamepad input support to the ArcRotateCamera InputManager.
  101643. * @returns the camera inputs manager
  101644. */
  101645. addGamepad(): ArcRotateCameraInputsManager;
  101646. }
  101647. /**
  101648. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  101649. */
  101650. export class GamepadSystemSceneComponent implements ISceneComponent {
  101651. /**
  101652. * The component name helpfull to identify the component in the list of scene components.
  101653. */
  101654. readonly name: string;
  101655. /**
  101656. * The scene the component belongs to.
  101657. */
  101658. scene: Scene;
  101659. /**
  101660. * Creates a new instance of the component for the given scene
  101661. * @param scene Defines the scene to register the component in
  101662. */
  101663. constructor(scene: Scene);
  101664. /**
  101665. * Registers the component in a given scene
  101666. */
  101667. register(): void;
  101668. /**
  101669. * Rebuilds the elements related to this component in case of
  101670. * context lost for instance.
  101671. */
  101672. rebuild(): void;
  101673. /**
  101674. * Disposes the component and the associated ressources
  101675. */
  101676. dispose(): void;
  101677. private _beforeCameraUpdate;
  101678. }
  101679. }
  101680. declare module BABYLON {
  101681. /**
  101682. * 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,
  101683. * which still works and will still be found in many Playgrounds.
  101684. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  101685. */
  101686. export class UniversalCamera extends TouchCamera {
  101687. /**
  101688. * Defines the gamepad rotation sensiblity.
  101689. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  101690. */
  101691. gamepadAngularSensibility: number;
  101692. /**
  101693. * Defines the gamepad move sensiblity.
  101694. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  101695. */
  101696. gamepadMoveSensibility: number;
  101697. /**
  101698. * 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,
  101699. * which still works and will still be found in many Playgrounds.
  101700. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  101701. * @param name Define the name of the camera in the scene
  101702. * @param position Define the start position of the camera in the scene
  101703. * @param scene Define the scene the camera belongs to
  101704. */
  101705. constructor(name: string, position: Vector3, scene: Scene);
  101706. /**
  101707. * Gets the current object class name.
  101708. * @return the class name
  101709. */
  101710. getClassName(): string;
  101711. }
  101712. }
  101713. declare module BABYLON {
  101714. /**
  101715. * This represents a FPS type of camera. This is only here for back compat purpose.
  101716. * Please use the UniversalCamera instead as both are identical.
  101717. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  101718. */
  101719. export class GamepadCamera extends UniversalCamera {
  101720. /**
  101721. * Instantiates a new Gamepad Camera
  101722. * This represents a FPS type of camera. This is only here for back compat purpose.
  101723. * Please use the UniversalCamera instead as both are identical.
  101724. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  101725. * @param name Define the name of the camera in the scene
  101726. * @param position Define the start position of the camera in the scene
  101727. * @param scene Define the scene the camera belongs to
  101728. */
  101729. constructor(name: string, position: Vector3, scene: Scene);
  101730. /**
  101731. * Gets the current object class name.
  101732. * @return the class name
  101733. */
  101734. getClassName(): string;
  101735. }
  101736. }
  101737. declare module BABYLON {
  101738. /** @hidden */
  101739. export var passPixelShader: {
  101740. name: string;
  101741. shader: string;
  101742. };
  101743. }
  101744. declare module BABYLON {
  101745. /** @hidden */
  101746. export var passCubePixelShader: {
  101747. name: string;
  101748. shader: string;
  101749. };
  101750. }
  101751. declare module BABYLON {
  101752. /**
  101753. * PassPostProcess which produces an output the same as it's input
  101754. */
  101755. export class PassPostProcess extends PostProcess {
  101756. /**
  101757. * Creates the PassPostProcess
  101758. * @param name The name of the effect.
  101759. * @param options The required width/height ratio to downsize to before computing the render pass.
  101760. * @param camera The camera to apply the render pass to.
  101761. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101762. * @param engine The engine which the post process will be applied. (default: current engine)
  101763. * @param reusable If the post process can be reused on the same frame. (default: false)
  101764. * @param textureType The type of texture to be used when performing the post processing.
  101765. * @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)
  101766. */
  101767. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  101768. }
  101769. /**
  101770. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  101771. */
  101772. export class PassCubePostProcess extends PostProcess {
  101773. private _face;
  101774. /**
  101775. * Gets or sets the cube face to display.
  101776. * * 0 is +X
  101777. * * 1 is -X
  101778. * * 2 is +Y
  101779. * * 3 is -Y
  101780. * * 4 is +Z
  101781. * * 5 is -Z
  101782. */
  101783. face: number;
  101784. /**
  101785. * Creates the PassCubePostProcess
  101786. * @param name The name of the effect.
  101787. * @param options The required width/height ratio to downsize to before computing the render pass.
  101788. * @param camera The camera to apply the render pass to.
  101789. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101790. * @param engine The engine which the post process will be applied. (default: current engine)
  101791. * @param reusable If the post process can be reused on the same frame. (default: false)
  101792. * @param textureType The type of texture to be used when performing the post processing.
  101793. * @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)
  101794. */
  101795. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  101796. }
  101797. }
  101798. declare module BABYLON {
  101799. /** @hidden */
  101800. export var anaglyphPixelShader: {
  101801. name: string;
  101802. shader: string;
  101803. };
  101804. }
  101805. declare module BABYLON {
  101806. /**
  101807. * Postprocess used to generate anaglyphic rendering
  101808. */
  101809. export class AnaglyphPostProcess extends PostProcess {
  101810. private _passedProcess;
  101811. /**
  101812. * Creates a new AnaglyphPostProcess
  101813. * @param name defines postprocess name
  101814. * @param options defines creation options or target ratio scale
  101815. * @param rigCameras defines cameras using this postprocess
  101816. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  101817. * @param engine defines hosting engine
  101818. * @param reusable defines if the postprocess will be reused multiple times per frame
  101819. */
  101820. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  101821. }
  101822. }
  101823. declare module BABYLON {
  101824. /**
  101825. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  101826. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101827. */
  101828. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  101829. /**
  101830. * Creates a new AnaglyphArcRotateCamera
  101831. * @param name defines camera name
  101832. * @param alpha defines alpha angle (in radians)
  101833. * @param beta defines beta angle (in radians)
  101834. * @param radius defines radius
  101835. * @param target defines camera target
  101836. * @param interaxialDistance defines distance between each color axis
  101837. * @param scene defines the hosting scene
  101838. */
  101839. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  101840. /**
  101841. * Gets camera class name
  101842. * @returns AnaglyphArcRotateCamera
  101843. */
  101844. getClassName(): string;
  101845. }
  101846. }
  101847. declare module BABYLON {
  101848. /**
  101849. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  101850. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101851. */
  101852. export class AnaglyphFreeCamera extends FreeCamera {
  101853. /**
  101854. * Creates a new AnaglyphFreeCamera
  101855. * @param name defines camera name
  101856. * @param position defines initial position
  101857. * @param interaxialDistance defines distance between each color axis
  101858. * @param scene defines the hosting scene
  101859. */
  101860. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  101861. /**
  101862. * Gets camera class name
  101863. * @returns AnaglyphFreeCamera
  101864. */
  101865. getClassName(): string;
  101866. }
  101867. }
  101868. declare module BABYLON {
  101869. /**
  101870. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  101871. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101872. */
  101873. export class AnaglyphGamepadCamera extends GamepadCamera {
  101874. /**
  101875. * Creates a new AnaglyphGamepadCamera
  101876. * @param name defines camera name
  101877. * @param position defines initial position
  101878. * @param interaxialDistance defines distance between each color axis
  101879. * @param scene defines the hosting scene
  101880. */
  101881. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  101882. /**
  101883. * Gets camera class name
  101884. * @returns AnaglyphGamepadCamera
  101885. */
  101886. getClassName(): string;
  101887. }
  101888. }
  101889. declare module BABYLON {
  101890. /**
  101891. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  101892. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101893. */
  101894. export class AnaglyphUniversalCamera extends UniversalCamera {
  101895. /**
  101896. * Creates a new AnaglyphUniversalCamera
  101897. * @param name defines camera name
  101898. * @param position defines initial position
  101899. * @param interaxialDistance defines distance between each color axis
  101900. * @param scene defines the hosting scene
  101901. */
  101902. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  101903. /**
  101904. * Gets camera class name
  101905. * @returns AnaglyphUniversalCamera
  101906. */
  101907. getClassName(): string;
  101908. }
  101909. }
  101910. declare module BABYLON {
  101911. /** @hidden */
  101912. export var stereoscopicInterlacePixelShader: {
  101913. name: string;
  101914. shader: string;
  101915. };
  101916. }
  101917. declare module BABYLON {
  101918. /**
  101919. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  101920. */
  101921. export class StereoscopicInterlacePostProcess extends PostProcess {
  101922. private _stepSize;
  101923. private _passedProcess;
  101924. /**
  101925. * Initializes a StereoscopicInterlacePostProcess
  101926. * @param name The name of the effect.
  101927. * @param rigCameras The rig cameras to be appled to the post process
  101928. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  101929. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101930. * @param engine The engine which the post process will be applied. (default: current engine)
  101931. * @param reusable If the post process can be reused on the same frame. (default: false)
  101932. */
  101933. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  101934. }
  101935. }
  101936. declare module BABYLON {
  101937. /**
  101938. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  101939. * @see http://doc.babylonjs.com/features/cameras
  101940. */
  101941. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  101942. /**
  101943. * Creates a new StereoscopicArcRotateCamera
  101944. * @param name defines camera name
  101945. * @param alpha defines alpha angle (in radians)
  101946. * @param beta defines beta angle (in radians)
  101947. * @param radius defines radius
  101948. * @param target defines camera target
  101949. * @param interaxialDistance defines distance between each color axis
  101950. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101951. * @param scene defines the hosting scene
  101952. */
  101953. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101954. /**
  101955. * Gets camera class name
  101956. * @returns StereoscopicArcRotateCamera
  101957. */
  101958. getClassName(): string;
  101959. }
  101960. }
  101961. declare module BABYLON {
  101962. /**
  101963. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  101964. * @see http://doc.babylonjs.com/features/cameras
  101965. */
  101966. export class StereoscopicFreeCamera extends FreeCamera {
  101967. /**
  101968. * Creates a new StereoscopicFreeCamera
  101969. * @param name defines camera name
  101970. * @param position defines initial position
  101971. * @param interaxialDistance defines distance between each color axis
  101972. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101973. * @param scene defines the hosting scene
  101974. */
  101975. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101976. /**
  101977. * Gets camera class name
  101978. * @returns StereoscopicFreeCamera
  101979. */
  101980. getClassName(): string;
  101981. }
  101982. }
  101983. declare module BABYLON {
  101984. /**
  101985. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  101986. * @see http://doc.babylonjs.com/features/cameras
  101987. */
  101988. export class StereoscopicGamepadCamera extends GamepadCamera {
  101989. /**
  101990. * Creates a new StereoscopicGamepadCamera
  101991. * @param name defines camera name
  101992. * @param position defines initial position
  101993. * @param interaxialDistance defines distance between each color axis
  101994. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101995. * @param scene defines the hosting scene
  101996. */
  101997. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101998. /**
  101999. * Gets camera class name
  102000. * @returns StereoscopicGamepadCamera
  102001. */
  102002. getClassName(): string;
  102003. }
  102004. }
  102005. declare module BABYLON {
  102006. /**
  102007. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  102008. * @see http://doc.babylonjs.com/features/cameras
  102009. */
  102010. export class StereoscopicUniversalCamera extends UniversalCamera {
  102011. /**
  102012. * Creates a new StereoscopicUniversalCamera
  102013. * @param name defines camera name
  102014. * @param position defines initial position
  102015. * @param interaxialDistance defines distance between each color axis
  102016. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  102017. * @param scene defines the hosting scene
  102018. */
  102019. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  102020. /**
  102021. * Gets camera class name
  102022. * @returns StereoscopicUniversalCamera
  102023. */
  102024. getClassName(): string;
  102025. }
  102026. }
  102027. declare module BABYLON {
  102028. /**
  102029. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  102030. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  102031. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  102032. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  102033. */
  102034. export class VirtualJoysticksCamera extends FreeCamera {
  102035. /**
  102036. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  102037. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  102038. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  102039. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  102040. * @param name Define the name of the camera in the scene
  102041. * @param position Define the start position of the camera in the scene
  102042. * @param scene Define the scene the camera belongs to
  102043. */
  102044. constructor(name: string, position: Vector3, scene: Scene);
  102045. /**
  102046. * Gets the current object class name.
  102047. * @return the class name
  102048. */
  102049. getClassName(): string;
  102050. }
  102051. }
  102052. declare module BABYLON {
  102053. /**
  102054. * This represents all the required metrics to create a VR camera.
  102055. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  102056. */
  102057. export class VRCameraMetrics {
  102058. /**
  102059. * Define the horizontal resolution off the screen.
  102060. */
  102061. hResolution: number;
  102062. /**
  102063. * Define the vertical resolution off the screen.
  102064. */
  102065. vResolution: number;
  102066. /**
  102067. * Define the horizontal screen size.
  102068. */
  102069. hScreenSize: number;
  102070. /**
  102071. * Define the vertical screen size.
  102072. */
  102073. vScreenSize: number;
  102074. /**
  102075. * Define the vertical screen center position.
  102076. */
  102077. vScreenCenter: number;
  102078. /**
  102079. * Define the distance of the eyes to the screen.
  102080. */
  102081. eyeToScreenDistance: number;
  102082. /**
  102083. * Define the distance between both lenses
  102084. */
  102085. lensSeparationDistance: number;
  102086. /**
  102087. * Define the distance between both viewer's eyes.
  102088. */
  102089. interpupillaryDistance: number;
  102090. /**
  102091. * Define the distortion factor of the VR postprocess.
  102092. * Please, touch with care.
  102093. */
  102094. distortionK: number[];
  102095. /**
  102096. * Define the chromatic aberration correction factors for the VR post process.
  102097. */
  102098. chromaAbCorrection: number[];
  102099. /**
  102100. * Define the scale factor of the post process.
  102101. * The smaller the better but the slower.
  102102. */
  102103. postProcessScaleFactor: number;
  102104. /**
  102105. * Define an offset for the lens center.
  102106. */
  102107. lensCenterOffset: number;
  102108. /**
  102109. * Define if the current vr camera should compensate the distortion of the lense or not.
  102110. */
  102111. compensateDistortion: boolean;
  102112. /**
  102113. * Defines if multiview should be enabled when rendering (Default: false)
  102114. */
  102115. multiviewEnabled: boolean;
  102116. /**
  102117. * Gets the rendering aspect ratio based on the provided resolutions.
  102118. */
  102119. readonly aspectRatio: number;
  102120. /**
  102121. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  102122. */
  102123. readonly aspectRatioFov: number;
  102124. /**
  102125. * @hidden
  102126. */
  102127. readonly leftHMatrix: Matrix;
  102128. /**
  102129. * @hidden
  102130. */
  102131. readonly rightHMatrix: Matrix;
  102132. /**
  102133. * @hidden
  102134. */
  102135. readonly leftPreViewMatrix: Matrix;
  102136. /**
  102137. * @hidden
  102138. */
  102139. readonly rightPreViewMatrix: Matrix;
  102140. /**
  102141. * Get the default VRMetrics based on the most generic setup.
  102142. * @returns the default vr metrics
  102143. */
  102144. static GetDefault(): VRCameraMetrics;
  102145. }
  102146. }
  102147. declare module BABYLON {
  102148. /** @hidden */
  102149. export var vrDistortionCorrectionPixelShader: {
  102150. name: string;
  102151. shader: string;
  102152. };
  102153. }
  102154. declare module BABYLON {
  102155. /**
  102156. * VRDistortionCorrectionPostProcess used for mobile VR
  102157. */
  102158. export class VRDistortionCorrectionPostProcess extends PostProcess {
  102159. private _isRightEye;
  102160. private _distortionFactors;
  102161. private _postProcessScaleFactor;
  102162. private _lensCenterOffset;
  102163. private _scaleIn;
  102164. private _scaleFactor;
  102165. private _lensCenter;
  102166. /**
  102167. * Initializes the VRDistortionCorrectionPostProcess
  102168. * @param name The name of the effect.
  102169. * @param camera The camera to apply the render pass to.
  102170. * @param isRightEye If this is for the right eye distortion
  102171. * @param vrMetrics All the required metrics for the VR camera
  102172. */
  102173. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  102174. }
  102175. }
  102176. declare module BABYLON {
  102177. /**
  102178. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  102179. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  102180. */
  102181. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  102182. /**
  102183. * Creates a new VRDeviceOrientationArcRotateCamera
  102184. * @param name defines camera name
  102185. * @param alpha defines the camera rotation along the logitudinal axis
  102186. * @param beta defines the camera rotation along the latitudinal axis
  102187. * @param radius defines the camera distance from its target
  102188. * @param target defines the camera target
  102189. * @param scene defines the scene the camera belongs to
  102190. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  102191. * @param vrCameraMetrics defines the vr metrics associated to the camera
  102192. */
  102193. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  102194. /**
  102195. * Gets camera class name
  102196. * @returns VRDeviceOrientationArcRotateCamera
  102197. */
  102198. getClassName(): string;
  102199. }
  102200. }
  102201. declare module BABYLON {
  102202. /**
  102203. * Camera used to simulate VR rendering (based on FreeCamera)
  102204. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  102205. */
  102206. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  102207. /**
  102208. * Creates a new VRDeviceOrientationFreeCamera
  102209. * @param name defines camera name
  102210. * @param position defines the start position of the camera
  102211. * @param scene defines the scene the camera belongs to
  102212. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  102213. * @param vrCameraMetrics defines the vr metrics associated to the camera
  102214. */
  102215. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  102216. /**
  102217. * Gets camera class name
  102218. * @returns VRDeviceOrientationFreeCamera
  102219. */
  102220. getClassName(): string;
  102221. }
  102222. }
  102223. declare module BABYLON {
  102224. /**
  102225. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  102226. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  102227. */
  102228. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  102229. /**
  102230. * Creates a new VRDeviceOrientationGamepadCamera
  102231. * @param name defines camera name
  102232. * @param position defines the start position of the camera
  102233. * @param scene defines the scene the camera belongs to
  102234. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  102235. * @param vrCameraMetrics defines the vr metrics associated to the camera
  102236. */
  102237. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  102238. /**
  102239. * Gets camera class name
  102240. * @returns VRDeviceOrientationGamepadCamera
  102241. */
  102242. getClassName(): string;
  102243. }
  102244. }
  102245. declare module BABYLON {
  102246. /**
  102247. * Base class of materials working in push mode in babylon JS
  102248. * @hidden
  102249. */
  102250. export class PushMaterial extends Material {
  102251. protected _activeEffect: Effect;
  102252. protected _normalMatrix: Matrix;
  102253. /**
  102254. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  102255. * This means that the material can keep using a previous shader while a new one is being compiled.
  102256. * This is mostly used when shader parallel compilation is supported (true by default)
  102257. */
  102258. allowShaderHotSwapping: boolean;
  102259. constructor(name: string, scene: Scene);
  102260. getEffect(): Effect;
  102261. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  102262. /**
  102263. * Binds the given world matrix to the active effect
  102264. *
  102265. * @param world the matrix to bind
  102266. */
  102267. bindOnlyWorldMatrix(world: Matrix): void;
  102268. /**
  102269. * Binds the given normal matrix to the active effect
  102270. *
  102271. * @param normalMatrix the matrix to bind
  102272. */
  102273. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  102274. bind(world: Matrix, mesh?: Mesh): void;
  102275. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  102276. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  102277. }
  102278. }
  102279. declare module BABYLON {
  102280. /**
  102281. * This groups all the flags used to control the materials channel.
  102282. */
  102283. export class MaterialFlags {
  102284. private static _DiffuseTextureEnabled;
  102285. /**
  102286. * Are diffuse textures enabled in the application.
  102287. */
  102288. static DiffuseTextureEnabled: boolean;
  102289. private static _AmbientTextureEnabled;
  102290. /**
  102291. * Are ambient textures enabled in the application.
  102292. */
  102293. static AmbientTextureEnabled: boolean;
  102294. private static _OpacityTextureEnabled;
  102295. /**
  102296. * Are opacity textures enabled in the application.
  102297. */
  102298. static OpacityTextureEnabled: boolean;
  102299. private static _ReflectionTextureEnabled;
  102300. /**
  102301. * Are reflection textures enabled in the application.
  102302. */
  102303. static ReflectionTextureEnabled: boolean;
  102304. private static _EmissiveTextureEnabled;
  102305. /**
  102306. * Are emissive textures enabled in the application.
  102307. */
  102308. static EmissiveTextureEnabled: boolean;
  102309. private static _SpecularTextureEnabled;
  102310. /**
  102311. * Are specular textures enabled in the application.
  102312. */
  102313. static SpecularTextureEnabled: boolean;
  102314. private static _BumpTextureEnabled;
  102315. /**
  102316. * Are bump textures enabled in the application.
  102317. */
  102318. static BumpTextureEnabled: boolean;
  102319. private static _LightmapTextureEnabled;
  102320. /**
  102321. * Are lightmap textures enabled in the application.
  102322. */
  102323. static LightmapTextureEnabled: boolean;
  102324. private static _RefractionTextureEnabled;
  102325. /**
  102326. * Are refraction textures enabled in the application.
  102327. */
  102328. static RefractionTextureEnabled: boolean;
  102329. private static _ColorGradingTextureEnabled;
  102330. /**
  102331. * Are color grading textures enabled in the application.
  102332. */
  102333. static ColorGradingTextureEnabled: boolean;
  102334. private static _FresnelEnabled;
  102335. /**
  102336. * Are fresnels enabled in the application.
  102337. */
  102338. static FresnelEnabled: boolean;
  102339. private static _ClearCoatTextureEnabled;
  102340. /**
  102341. * Are clear coat textures enabled in the application.
  102342. */
  102343. static ClearCoatTextureEnabled: boolean;
  102344. private static _ClearCoatBumpTextureEnabled;
  102345. /**
  102346. * Are clear coat bump textures enabled in the application.
  102347. */
  102348. static ClearCoatBumpTextureEnabled: boolean;
  102349. private static _ClearCoatTintTextureEnabled;
  102350. /**
  102351. * Are clear coat tint textures enabled in the application.
  102352. */
  102353. static ClearCoatTintTextureEnabled: boolean;
  102354. private static _SheenTextureEnabled;
  102355. /**
  102356. * Are sheen textures enabled in the application.
  102357. */
  102358. static SheenTextureEnabled: boolean;
  102359. private static _AnisotropicTextureEnabled;
  102360. /**
  102361. * Are anisotropic textures enabled in the application.
  102362. */
  102363. static AnisotropicTextureEnabled: boolean;
  102364. private static _ThicknessTextureEnabled;
  102365. /**
  102366. * Are thickness textures enabled in the application.
  102367. */
  102368. static ThicknessTextureEnabled: boolean;
  102369. }
  102370. }
  102371. declare module BABYLON {
  102372. /** @hidden */
  102373. export var defaultFragmentDeclaration: {
  102374. name: string;
  102375. shader: string;
  102376. };
  102377. }
  102378. declare module BABYLON {
  102379. /** @hidden */
  102380. export var defaultUboDeclaration: {
  102381. name: string;
  102382. shader: string;
  102383. };
  102384. }
  102385. declare module BABYLON {
  102386. /** @hidden */
  102387. export var lightFragmentDeclaration: {
  102388. name: string;
  102389. shader: string;
  102390. };
  102391. }
  102392. declare module BABYLON {
  102393. /** @hidden */
  102394. export var lightUboDeclaration: {
  102395. name: string;
  102396. shader: string;
  102397. };
  102398. }
  102399. declare module BABYLON {
  102400. /** @hidden */
  102401. export var lightsFragmentFunctions: {
  102402. name: string;
  102403. shader: string;
  102404. };
  102405. }
  102406. declare module BABYLON {
  102407. /** @hidden */
  102408. export var shadowsFragmentFunctions: {
  102409. name: string;
  102410. shader: string;
  102411. };
  102412. }
  102413. declare module BABYLON {
  102414. /** @hidden */
  102415. export var fresnelFunction: {
  102416. name: string;
  102417. shader: string;
  102418. };
  102419. }
  102420. declare module BABYLON {
  102421. /** @hidden */
  102422. export var reflectionFunction: {
  102423. name: string;
  102424. shader: string;
  102425. };
  102426. }
  102427. declare module BABYLON {
  102428. /** @hidden */
  102429. export var bumpFragmentFunctions: {
  102430. name: string;
  102431. shader: string;
  102432. };
  102433. }
  102434. declare module BABYLON {
  102435. /** @hidden */
  102436. export var logDepthDeclaration: {
  102437. name: string;
  102438. shader: string;
  102439. };
  102440. }
  102441. declare module BABYLON {
  102442. /** @hidden */
  102443. export var bumpFragment: {
  102444. name: string;
  102445. shader: string;
  102446. };
  102447. }
  102448. declare module BABYLON {
  102449. /** @hidden */
  102450. export var depthPrePass: {
  102451. name: string;
  102452. shader: string;
  102453. };
  102454. }
  102455. declare module BABYLON {
  102456. /** @hidden */
  102457. export var lightFragment: {
  102458. name: string;
  102459. shader: string;
  102460. };
  102461. }
  102462. declare module BABYLON {
  102463. /** @hidden */
  102464. export var logDepthFragment: {
  102465. name: string;
  102466. shader: string;
  102467. };
  102468. }
  102469. declare module BABYLON {
  102470. /** @hidden */
  102471. export var defaultPixelShader: {
  102472. name: string;
  102473. shader: string;
  102474. };
  102475. }
  102476. declare module BABYLON {
  102477. /** @hidden */
  102478. export var defaultVertexDeclaration: {
  102479. name: string;
  102480. shader: string;
  102481. };
  102482. }
  102483. declare module BABYLON {
  102484. /** @hidden */
  102485. export var bumpVertexDeclaration: {
  102486. name: string;
  102487. shader: string;
  102488. };
  102489. }
  102490. declare module BABYLON {
  102491. /** @hidden */
  102492. export var bumpVertex: {
  102493. name: string;
  102494. shader: string;
  102495. };
  102496. }
  102497. declare module BABYLON {
  102498. /** @hidden */
  102499. export var fogVertex: {
  102500. name: string;
  102501. shader: string;
  102502. };
  102503. }
  102504. declare module BABYLON {
  102505. /** @hidden */
  102506. export var shadowsVertex: {
  102507. name: string;
  102508. shader: string;
  102509. };
  102510. }
  102511. declare module BABYLON {
  102512. /** @hidden */
  102513. export var pointCloudVertex: {
  102514. name: string;
  102515. shader: string;
  102516. };
  102517. }
  102518. declare module BABYLON {
  102519. /** @hidden */
  102520. export var logDepthVertex: {
  102521. name: string;
  102522. shader: string;
  102523. };
  102524. }
  102525. declare module BABYLON {
  102526. /** @hidden */
  102527. export var defaultVertexShader: {
  102528. name: string;
  102529. shader: string;
  102530. };
  102531. }
  102532. declare module BABYLON {
  102533. /** @hidden */
  102534. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  102535. MAINUV1: boolean;
  102536. MAINUV2: boolean;
  102537. DIFFUSE: boolean;
  102538. DIFFUSEDIRECTUV: number;
  102539. AMBIENT: boolean;
  102540. AMBIENTDIRECTUV: number;
  102541. OPACITY: boolean;
  102542. OPACITYDIRECTUV: number;
  102543. OPACITYRGB: boolean;
  102544. REFLECTION: boolean;
  102545. EMISSIVE: boolean;
  102546. EMISSIVEDIRECTUV: number;
  102547. SPECULAR: boolean;
  102548. SPECULARDIRECTUV: number;
  102549. BUMP: boolean;
  102550. BUMPDIRECTUV: number;
  102551. PARALLAX: boolean;
  102552. PARALLAXOCCLUSION: boolean;
  102553. SPECULAROVERALPHA: boolean;
  102554. CLIPPLANE: boolean;
  102555. CLIPPLANE2: boolean;
  102556. CLIPPLANE3: boolean;
  102557. CLIPPLANE4: boolean;
  102558. ALPHATEST: boolean;
  102559. DEPTHPREPASS: boolean;
  102560. ALPHAFROMDIFFUSE: boolean;
  102561. POINTSIZE: boolean;
  102562. FOG: boolean;
  102563. SPECULARTERM: boolean;
  102564. DIFFUSEFRESNEL: boolean;
  102565. OPACITYFRESNEL: boolean;
  102566. REFLECTIONFRESNEL: boolean;
  102567. REFRACTIONFRESNEL: boolean;
  102568. EMISSIVEFRESNEL: boolean;
  102569. FRESNEL: boolean;
  102570. NORMAL: boolean;
  102571. UV1: boolean;
  102572. UV2: boolean;
  102573. VERTEXCOLOR: boolean;
  102574. VERTEXALPHA: boolean;
  102575. NUM_BONE_INFLUENCERS: number;
  102576. BonesPerMesh: number;
  102577. BONETEXTURE: boolean;
  102578. INSTANCES: boolean;
  102579. GLOSSINESS: boolean;
  102580. ROUGHNESS: boolean;
  102581. EMISSIVEASILLUMINATION: boolean;
  102582. LINKEMISSIVEWITHDIFFUSE: boolean;
  102583. REFLECTIONFRESNELFROMSPECULAR: boolean;
  102584. LIGHTMAP: boolean;
  102585. LIGHTMAPDIRECTUV: number;
  102586. OBJECTSPACE_NORMALMAP: boolean;
  102587. USELIGHTMAPASSHADOWMAP: boolean;
  102588. REFLECTIONMAP_3D: boolean;
  102589. REFLECTIONMAP_SPHERICAL: boolean;
  102590. REFLECTIONMAP_PLANAR: boolean;
  102591. REFLECTIONMAP_CUBIC: boolean;
  102592. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  102593. REFLECTIONMAP_PROJECTION: boolean;
  102594. REFLECTIONMAP_SKYBOX: boolean;
  102595. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  102596. REFLECTIONMAP_EXPLICIT: boolean;
  102597. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  102598. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  102599. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  102600. INVERTCUBICMAP: boolean;
  102601. LOGARITHMICDEPTH: boolean;
  102602. REFRACTION: boolean;
  102603. REFRACTIONMAP_3D: boolean;
  102604. REFLECTIONOVERALPHA: boolean;
  102605. TWOSIDEDLIGHTING: boolean;
  102606. SHADOWFLOAT: boolean;
  102607. MORPHTARGETS: boolean;
  102608. MORPHTARGETS_NORMAL: boolean;
  102609. MORPHTARGETS_TANGENT: boolean;
  102610. MORPHTARGETS_UV: boolean;
  102611. NUM_MORPH_INFLUENCERS: number;
  102612. NONUNIFORMSCALING: boolean;
  102613. PREMULTIPLYALPHA: boolean;
  102614. IMAGEPROCESSING: boolean;
  102615. VIGNETTE: boolean;
  102616. VIGNETTEBLENDMODEMULTIPLY: boolean;
  102617. VIGNETTEBLENDMODEOPAQUE: boolean;
  102618. TONEMAPPING: boolean;
  102619. TONEMAPPING_ACES: boolean;
  102620. CONTRAST: boolean;
  102621. COLORCURVES: boolean;
  102622. COLORGRADING: boolean;
  102623. COLORGRADING3D: boolean;
  102624. SAMPLER3DGREENDEPTH: boolean;
  102625. SAMPLER3DBGRMAP: boolean;
  102626. IMAGEPROCESSINGPOSTPROCESS: boolean;
  102627. MULTIVIEW: boolean;
  102628. /**
  102629. * If the reflection texture on this material is in linear color space
  102630. * @hidden
  102631. */
  102632. IS_REFLECTION_LINEAR: boolean;
  102633. /**
  102634. * If the refraction texture on this material is in linear color space
  102635. * @hidden
  102636. */
  102637. IS_REFRACTION_LINEAR: boolean;
  102638. EXPOSURE: boolean;
  102639. constructor();
  102640. setReflectionMode(modeToEnable: string): void;
  102641. }
  102642. /**
  102643. * This is the default material used in Babylon. It is the best trade off between quality
  102644. * and performances.
  102645. * @see http://doc.babylonjs.com/babylon101/materials
  102646. */
  102647. export class StandardMaterial extends PushMaterial {
  102648. private _diffuseTexture;
  102649. /**
  102650. * The basic texture of the material as viewed under a light.
  102651. */
  102652. diffuseTexture: Nullable<BaseTexture>;
  102653. private _ambientTexture;
  102654. /**
  102655. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  102656. */
  102657. ambientTexture: Nullable<BaseTexture>;
  102658. private _opacityTexture;
  102659. /**
  102660. * Define the transparency of the material from a texture.
  102661. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  102662. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  102663. */
  102664. opacityTexture: Nullable<BaseTexture>;
  102665. private _reflectionTexture;
  102666. /**
  102667. * Define the texture used to display the reflection.
  102668. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102669. */
  102670. reflectionTexture: Nullable<BaseTexture>;
  102671. private _emissiveTexture;
  102672. /**
  102673. * Define texture of the material as if self lit.
  102674. * This will be mixed in the final result even in the absence of light.
  102675. */
  102676. emissiveTexture: Nullable<BaseTexture>;
  102677. private _specularTexture;
  102678. /**
  102679. * Define how the color and intensity of the highlight given by the light in the material.
  102680. */
  102681. specularTexture: Nullable<BaseTexture>;
  102682. private _bumpTexture;
  102683. /**
  102684. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  102685. * 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.
  102686. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  102687. */
  102688. bumpTexture: Nullable<BaseTexture>;
  102689. private _lightmapTexture;
  102690. /**
  102691. * Complex lighting can be computationally expensive to compute at runtime.
  102692. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  102693. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  102694. */
  102695. lightmapTexture: Nullable<BaseTexture>;
  102696. private _refractionTexture;
  102697. /**
  102698. * Define the texture used to display the refraction.
  102699. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102700. */
  102701. refractionTexture: Nullable<BaseTexture>;
  102702. /**
  102703. * The color of the material lit by the environmental background lighting.
  102704. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  102705. */
  102706. ambientColor: Color3;
  102707. /**
  102708. * The basic color of the material as viewed under a light.
  102709. */
  102710. diffuseColor: Color3;
  102711. /**
  102712. * Define how the color and intensity of the highlight given by the light in the material.
  102713. */
  102714. specularColor: Color3;
  102715. /**
  102716. * Define the color of the material as if self lit.
  102717. * This will be mixed in the final result even in the absence of light.
  102718. */
  102719. emissiveColor: Color3;
  102720. /**
  102721. * Defines how sharp are the highlights in the material.
  102722. * The bigger the value the sharper giving a more glossy feeling to the result.
  102723. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  102724. */
  102725. specularPower: number;
  102726. private _useAlphaFromDiffuseTexture;
  102727. /**
  102728. * Does the transparency come from the diffuse texture alpha channel.
  102729. */
  102730. useAlphaFromDiffuseTexture: boolean;
  102731. private _useEmissiveAsIllumination;
  102732. /**
  102733. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  102734. */
  102735. useEmissiveAsIllumination: boolean;
  102736. private _linkEmissiveWithDiffuse;
  102737. /**
  102738. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  102739. * the emissive level when the final color is close to one.
  102740. */
  102741. linkEmissiveWithDiffuse: boolean;
  102742. private _useSpecularOverAlpha;
  102743. /**
  102744. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  102745. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  102746. */
  102747. useSpecularOverAlpha: boolean;
  102748. private _useReflectionOverAlpha;
  102749. /**
  102750. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  102751. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  102752. */
  102753. useReflectionOverAlpha: boolean;
  102754. private _disableLighting;
  102755. /**
  102756. * Does lights from the scene impacts this material.
  102757. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  102758. */
  102759. disableLighting: boolean;
  102760. private _useObjectSpaceNormalMap;
  102761. /**
  102762. * Allows using an object space normal map (instead of tangent space).
  102763. */
  102764. useObjectSpaceNormalMap: boolean;
  102765. private _useParallax;
  102766. /**
  102767. * Is parallax enabled or not.
  102768. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  102769. */
  102770. useParallax: boolean;
  102771. private _useParallaxOcclusion;
  102772. /**
  102773. * Is parallax occlusion enabled or not.
  102774. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  102775. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  102776. */
  102777. useParallaxOcclusion: boolean;
  102778. /**
  102779. * 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.
  102780. */
  102781. parallaxScaleBias: number;
  102782. private _roughness;
  102783. /**
  102784. * Helps to define how blurry the reflections should appears in the material.
  102785. */
  102786. roughness: number;
  102787. /**
  102788. * In case of refraction, define the value of the index of refraction.
  102789. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102790. */
  102791. indexOfRefraction: number;
  102792. /**
  102793. * Invert the refraction texture alongside the y axis.
  102794. * It can be useful with procedural textures or probe for instance.
  102795. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  102796. */
  102797. invertRefractionY: boolean;
  102798. /**
  102799. * Defines the alpha limits in alpha test mode.
  102800. */
  102801. alphaCutOff: number;
  102802. private _useLightmapAsShadowmap;
  102803. /**
  102804. * In case of light mapping, define whether the map contains light or shadow informations.
  102805. */
  102806. useLightmapAsShadowmap: boolean;
  102807. private _diffuseFresnelParameters;
  102808. /**
  102809. * Define the diffuse fresnel parameters of the material.
  102810. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102811. */
  102812. diffuseFresnelParameters: FresnelParameters;
  102813. private _opacityFresnelParameters;
  102814. /**
  102815. * Define the opacity fresnel parameters of the material.
  102816. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102817. */
  102818. opacityFresnelParameters: FresnelParameters;
  102819. private _reflectionFresnelParameters;
  102820. /**
  102821. * Define the reflection fresnel parameters of the material.
  102822. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102823. */
  102824. reflectionFresnelParameters: FresnelParameters;
  102825. private _refractionFresnelParameters;
  102826. /**
  102827. * Define the refraction fresnel parameters of the material.
  102828. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102829. */
  102830. refractionFresnelParameters: FresnelParameters;
  102831. private _emissiveFresnelParameters;
  102832. /**
  102833. * Define the emissive fresnel parameters of the material.
  102834. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102835. */
  102836. emissiveFresnelParameters: FresnelParameters;
  102837. private _useReflectionFresnelFromSpecular;
  102838. /**
  102839. * If true automatically deducts the fresnels values from the material specularity.
  102840. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102841. */
  102842. useReflectionFresnelFromSpecular: boolean;
  102843. private _useGlossinessFromSpecularMapAlpha;
  102844. /**
  102845. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  102846. */
  102847. useGlossinessFromSpecularMapAlpha: boolean;
  102848. private _maxSimultaneousLights;
  102849. /**
  102850. * Defines the maximum number of lights that can be used in the material
  102851. */
  102852. maxSimultaneousLights: number;
  102853. private _invertNormalMapX;
  102854. /**
  102855. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  102856. */
  102857. invertNormalMapX: boolean;
  102858. private _invertNormalMapY;
  102859. /**
  102860. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  102861. */
  102862. invertNormalMapY: boolean;
  102863. private _twoSidedLighting;
  102864. /**
  102865. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102866. */
  102867. twoSidedLighting: boolean;
  102868. /**
  102869. * Default configuration related to image processing available in the standard Material.
  102870. */
  102871. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102872. /**
  102873. * Gets the image processing configuration used either in this material.
  102874. */
  102875. /**
  102876. * Sets the Default image processing configuration used either in the this material.
  102877. *
  102878. * If sets to null, the scene one is in use.
  102879. */
  102880. imageProcessingConfiguration: ImageProcessingConfiguration;
  102881. /**
  102882. * Keep track of the image processing observer to allow dispose and replace.
  102883. */
  102884. private _imageProcessingObserver;
  102885. /**
  102886. * Attaches a new image processing configuration to the Standard Material.
  102887. * @param configuration
  102888. */
  102889. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102890. /**
  102891. * Gets wether the color curves effect is enabled.
  102892. */
  102893. /**
  102894. * Sets wether the color curves effect is enabled.
  102895. */
  102896. cameraColorCurvesEnabled: boolean;
  102897. /**
  102898. * Gets wether the color grading effect is enabled.
  102899. */
  102900. /**
  102901. * Gets wether the color grading effect is enabled.
  102902. */
  102903. cameraColorGradingEnabled: boolean;
  102904. /**
  102905. * Gets wether tonemapping is enabled or not.
  102906. */
  102907. /**
  102908. * Sets wether tonemapping is enabled or not
  102909. */
  102910. cameraToneMappingEnabled: boolean;
  102911. /**
  102912. * The camera exposure used on this material.
  102913. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102914. * This corresponds to a photographic exposure.
  102915. */
  102916. /**
  102917. * The camera exposure used on this material.
  102918. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102919. * This corresponds to a photographic exposure.
  102920. */
  102921. cameraExposure: number;
  102922. /**
  102923. * Gets The camera contrast used on this material.
  102924. */
  102925. /**
  102926. * Sets The camera contrast used on this material.
  102927. */
  102928. cameraContrast: number;
  102929. /**
  102930. * Gets the Color Grading 2D Lookup Texture.
  102931. */
  102932. /**
  102933. * Sets the Color Grading 2D Lookup Texture.
  102934. */
  102935. cameraColorGradingTexture: Nullable<BaseTexture>;
  102936. /**
  102937. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102938. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102939. * 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;
  102940. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102941. */
  102942. /**
  102943. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102944. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102945. * 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;
  102946. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102947. */
  102948. cameraColorCurves: Nullable<ColorCurves>;
  102949. /**
  102950. * Custom callback helping to override the default shader used in the material.
  102951. */
  102952. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  102953. protected _renderTargets: SmartArray<RenderTargetTexture>;
  102954. protected _worldViewProjectionMatrix: Matrix;
  102955. protected _globalAmbientColor: Color3;
  102956. protected _useLogarithmicDepth: boolean;
  102957. /**
  102958. * Instantiates a new standard material.
  102959. * This is the default material used in Babylon. It is the best trade off between quality
  102960. * and performances.
  102961. * @see http://doc.babylonjs.com/babylon101/materials
  102962. * @param name Define the name of the material in the scene
  102963. * @param scene Define the scene the material belong to
  102964. */
  102965. constructor(name: string, scene: Scene);
  102966. /**
  102967. * Gets a boolean indicating that current material needs to register RTT
  102968. */
  102969. readonly hasRenderTargetTextures: boolean;
  102970. /**
  102971. * Gets the current class name of the material e.g. "StandardMaterial"
  102972. * Mainly use in serialization.
  102973. * @returns the class name
  102974. */
  102975. getClassName(): string;
  102976. /**
  102977. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  102978. * You can try switching to logarithmic depth.
  102979. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  102980. */
  102981. useLogarithmicDepth: boolean;
  102982. /**
  102983. * Specifies if the material will require alpha blending
  102984. * @returns a boolean specifying if alpha blending is needed
  102985. */
  102986. needAlphaBlending(): boolean;
  102987. /**
  102988. * Specifies if this material should be rendered in alpha test mode
  102989. * @returns a boolean specifying if an alpha test is needed.
  102990. */
  102991. needAlphaTesting(): boolean;
  102992. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  102993. /**
  102994. * Get the texture used for alpha test purpose.
  102995. * @returns the diffuse texture in case of the standard material.
  102996. */
  102997. getAlphaTestTexture(): Nullable<BaseTexture>;
  102998. /**
  102999. * Get if the submesh is ready to be used and all its information available.
  103000. * Child classes can use it to update shaders
  103001. * @param mesh defines the mesh to check
  103002. * @param subMesh defines which submesh to check
  103003. * @param useInstances specifies that instances should be used
  103004. * @returns a boolean indicating that the submesh is ready or not
  103005. */
  103006. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103007. /**
  103008. * Builds the material UBO layouts.
  103009. * Used internally during the effect preparation.
  103010. */
  103011. buildUniformLayout(): void;
  103012. /**
  103013. * Unbinds the material from the mesh
  103014. */
  103015. unbind(): void;
  103016. /**
  103017. * Binds the submesh to this material by preparing the effect and shader to draw
  103018. * @param world defines the world transformation matrix
  103019. * @param mesh defines the mesh containing the submesh
  103020. * @param subMesh defines the submesh to bind the material to
  103021. */
  103022. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103023. /**
  103024. * Get the list of animatables in the material.
  103025. * @returns the list of animatables object used in the material
  103026. */
  103027. getAnimatables(): IAnimatable[];
  103028. /**
  103029. * Gets the active textures from the material
  103030. * @returns an array of textures
  103031. */
  103032. getActiveTextures(): BaseTexture[];
  103033. /**
  103034. * Specifies if the material uses a texture
  103035. * @param texture defines the texture to check against the material
  103036. * @returns a boolean specifying if the material uses the texture
  103037. */
  103038. hasTexture(texture: BaseTexture): boolean;
  103039. /**
  103040. * Disposes the material
  103041. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  103042. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  103043. */
  103044. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  103045. /**
  103046. * Makes a duplicate of the material, and gives it a new name
  103047. * @param name defines the new name for the duplicated material
  103048. * @returns the cloned material
  103049. */
  103050. clone(name: string): StandardMaterial;
  103051. /**
  103052. * Serializes this material in a JSON representation
  103053. * @returns the serialized material object
  103054. */
  103055. serialize(): any;
  103056. /**
  103057. * Creates a standard material from parsed material data
  103058. * @param source defines the JSON representation of the material
  103059. * @param scene defines the hosting scene
  103060. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103061. * @returns a new standard material
  103062. */
  103063. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  103064. /**
  103065. * Are diffuse textures enabled in the application.
  103066. */
  103067. static DiffuseTextureEnabled: boolean;
  103068. /**
  103069. * Are ambient textures enabled in the application.
  103070. */
  103071. static AmbientTextureEnabled: boolean;
  103072. /**
  103073. * Are opacity textures enabled in the application.
  103074. */
  103075. static OpacityTextureEnabled: boolean;
  103076. /**
  103077. * Are reflection textures enabled in the application.
  103078. */
  103079. static ReflectionTextureEnabled: boolean;
  103080. /**
  103081. * Are emissive textures enabled in the application.
  103082. */
  103083. static EmissiveTextureEnabled: boolean;
  103084. /**
  103085. * Are specular textures enabled in the application.
  103086. */
  103087. static SpecularTextureEnabled: boolean;
  103088. /**
  103089. * Are bump textures enabled in the application.
  103090. */
  103091. static BumpTextureEnabled: boolean;
  103092. /**
  103093. * Are lightmap textures enabled in the application.
  103094. */
  103095. static LightmapTextureEnabled: boolean;
  103096. /**
  103097. * Are refraction textures enabled in the application.
  103098. */
  103099. static RefractionTextureEnabled: boolean;
  103100. /**
  103101. * Are color grading textures enabled in the application.
  103102. */
  103103. static ColorGradingTextureEnabled: boolean;
  103104. /**
  103105. * Are fresnels enabled in the application.
  103106. */
  103107. static FresnelEnabled: boolean;
  103108. }
  103109. }
  103110. declare module BABYLON {
  103111. /**
  103112. * A class extending Texture allowing drawing on a texture
  103113. * @see http://doc.babylonjs.com/how_to/dynamictexture
  103114. */
  103115. export class DynamicTexture extends Texture {
  103116. private _generateMipMaps;
  103117. private _canvas;
  103118. private _context;
  103119. private _engine;
  103120. /**
  103121. * Creates a DynamicTexture
  103122. * @param name defines the name of the texture
  103123. * @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
  103124. * @param scene defines the scene where you want the texture
  103125. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  103126. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  103127. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  103128. */
  103129. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  103130. /**
  103131. * Get the current class name of the texture useful for serialization or dynamic coding.
  103132. * @returns "DynamicTexture"
  103133. */
  103134. getClassName(): string;
  103135. /**
  103136. * Gets the current state of canRescale
  103137. */
  103138. readonly canRescale: boolean;
  103139. private _recreate;
  103140. /**
  103141. * Scales the texture
  103142. * @param ratio the scale factor to apply to both width and height
  103143. */
  103144. scale(ratio: number): void;
  103145. /**
  103146. * Resizes the texture
  103147. * @param width the new width
  103148. * @param height the new height
  103149. */
  103150. scaleTo(width: number, height: number): void;
  103151. /**
  103152. * Gets the context of the canvas used by the texture
  103153. * @returns the canvas context of the dynamic texture
  103154. */
  103155. getContext(): CanvasRenderingContext2D;
  103156. /**
  103157. * Clears the texture
  103158. */
  103159. clear(): void;
  103160. /**
  103161. * Updates the texture
  103162. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  103163. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  103164. */
  103165. update(invertY?: boolean, premulAlpha?: boolean): void;
  103166. /**
  103167. * Draws text onto the texture
  103168. * @param text defines the text to be drawn
  103169. * @param x defines the placement of the text from the left
  103170. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  103171. * @param font defines the font to be used with font-style, font-size, font-name
  103172. * @param color defines the color used for the text
  103173. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  103174. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  103175. * @param update defines whether texture is immediately update (default is true)
  103176. */
  103177. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  103178. /**
  103179. * Clones the texture
  103180. * @returns the clone of the texture.
  103181. */
  103182. clone(): DynamicTexture;
  103183. /**
  103184. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  103185. * @returns a serialized dynamic texture object
  103186. */
  103187. serialize(): any;
  103188. /** @hidden */
  103189. _rebuild(): void;
  103190. }
  103191. }
  103192. declare module BABYLON {
  103193. /** @hidden */
  103194. export var imageProcessingPixelShader: {
  103195. name: string;
  103196. shader: string;
  103197. };
  103198. }
  103199. declare module BABYLON {
  103200. /**
  103201. * ImageProcessingPostProcess
  103202. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  103203. */
  103204. export class ImageProcessingPostProcess extends PostProcess {
  103205. /**
  103206. * Default configuration related to image processing available in the PBR Material.
  103207. */
  103208. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103209. /**
  103210. * Gets the image processing configuration used either in this material.
  103211. */
  103212. /**
  103213. * Sets the Default image processing configuration used either in the this material.
  103214. *
  103215. * If sets to null, the scene one is in use.
  103216. */
  103217. imageProcessingConfiguration: ImageProcessingConfiguration;
  103218. /**
  103219. * Keep track of the image processing observer to allow dispose and replace.
  103220. */
  103221. private _imageProcessingObserver;
  103222. /**
  103223. * Attaches a new image processing configuration to the PBR Material.
  103224. * @param configuration
  103225. */
  103226. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  103227. /**
  103228. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103229. */
  103230. /**
  103231. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103232. */
  103233. colorCurves: Nullable<ColorCurves>;
  103234. /**
  103235. * Gets wether the color curves effect is enabled.
  103236. */
  103237. /**
  103238. * Sets wether the color curves effect is enabled.
  103239. */
  103240. colorCurvesEnabled: boolean;
  103241. /**
  103242. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103243. */
  103244. /**
  103245. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103246. */
  103247. colorGradingTexture: Nullable<BaseTexture>;
  103248. /**
  103249. * Gets wether the color grading effect is enabled.
  103250. */
  103251. /**
  103252. * Gets wether the color grading effect is enabled.
  103253. */
  103254. colorGradingEnabled: boolean;
  103255. /**
  103256. * Gets exposure used in the effect.
  103257. */
  103258. /**
  103259. * Sets exposure used in the effect.
  103260. */
  103261. exposure: number;
  103262. /**
  103263. * Gets wether tonemapping is enabled or not.
  103264. */
  103265. /**
  103266. * Sets wether tonemapping is enabled or not
  103267. */
  103268. toneMappingEnabled: boolean;
  103269. /**
  103270. * Gets the type of tone mapping effect.
  103271. */
  103272. /**
  103273. * Sets the type of tone mapping effect.
  103274. */
  103275. toneMappingType: number;
  103276. /**
  103277. * Gets contrast used in the effect.
  103278. */
  103279. /**
  103280. * Sets contrast used in the effect.
  103281. */
  103282. contrast: number;
  103283. /**
  103284. * Gets Vignette stretch size.
  103285. */
  103286. /**
  103287. * Sets Vignette stretch size.
  103288. */
  103289. vignetteStretch: number;
  103290. /**
  103291. * Gets Vignette centre X Offset.
  103292. */
  103293. /**
  103294. * Sets Vignette centre X Offset.
  103295. */
  103296. vignetteCentreX: number;
  103297. /**
  103298. * Gets Vignette centre Y Offset.
  103299. */
  103300. /**
  103301. * Sets Vignette centre Y Offset.
  103302. */
  103303. vignetteCentreY: number;
  103304. /**
  103305. * Gets Vignette weight or intensity of the vignette effect.
  103306. */
  103307. /**
  103308. * Sets Vignette weight or intensity of the vignette effect.
  103309. */
  103310. vignetteWeight: number;
  103311. /**
  103312. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103313. * if vignetteEnabled is set to true.
  103314. */
  103315. /**
  103316. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103317. * if vignetteEnabled is set to true.
  103318. */
  103319. vignetteColor: Color4;
  103320. /**
  103321. * Gets Camera field of view used by the Vignette effect.
  103322. */
  103323. /**
  103324. * Sets Camera field of view used by the Vignette effect.
  103325. */
  103326. vignetteCameraFov: number;
  103327. /**
  103328. * Gets the vignette blend mode allowing different kind of effect.
  103329. */
  103330. /**
  103331. * Sets the vignette blend mode allowing different kind of effect.
  103332. */
  103333. vignetteBlendMode: number;
  103334. /**
  103335. * Gets wether the vignette effect is enabled.
  103336. */
  103337. /**
  103338. * Sets wether the vignette effect is enabled.
  103339. */
  103340. vignetteEnabled: boolean;
  103341. private _fromLinearSpace;
  103342. /**
  103343. * Gets wether the input of the processing is in Gamma or Linear Space.
  103344. */
  103345. /**
  103346. * Sets wether the input of the processing is in Gamma or Linear Space.
  103347. */
  103348. fromLinearSpace: boolean;
  103349. /**
  103350. * Defines cache preventing GC.
  103351. */
  103352. private _defines;
  103353. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  103354. /**
  103355. * "ImageProcessingPostProcess"
  103356. * @returns "ImageProcessingPostProcess"
  103357. */
  103358. getClassName(): string;
  103359. protected _updateParameters(): void;
  103360. dispose(camera?: Camera): void;
  103361. }
  103362. }
  103363. declare module BABYLON {
  103364. /**
  103365. * Class containing static functions to help procedurally build meshes
  103366. */
  103367. export class GroundBuilder {
  103368. /**
  103369. * Creates a ground mesh
  103370. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  103371. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  103372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103373. * @param name defines the name of the mesh
  103374. * @param options defines the options used to create the mesh
  103375. * @param scene defines the hosting scene
  103376. * @returns the ground mesh
  103377. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  103378. */
  103379. static CreateGround(name: string, options: {
  103380. width?: number;
  103381. height?: number;
  103382. subdivisions?: number;
  103383. subdivisionsX?: number;
  103384. subdivisionsY?: number;
  103385. updatable?: boolean;
  103386. }, scene: any): Mesh;
  103387. /**
  103388. * Creates a tiled ground mesh
  103389. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  103390. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  103391. * * 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
  103392. * * 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
  103393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103394. * @param name defines the name of the mesh
  103395. * @param options defines the options used to create the mesh
  103396. * @param scene defines the hosting scene
  103397. * @returns the tiled ground mesh
  103398. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  103399. */
  103400. static CreateTiledGround(name: string, options: {
  103401. xmin: number;
  103402. zmin: number;
  103403. xmax: number;
  103404. zmax: number;
  103405. subdivisions?: {
  103406. w: number;
  103407. h: number;
  103408. };
  103409. precision?: {
  103410. w: number;
  103411. h: number;
  103412. };
  103413. updatable?: boolean;
  103414. }, scene?: Nullable<Scene>): Mesh;
  103415. /**
  103416. * Creates a ground mesh from a height map
  103417. * * The parameter `url` sets the URL of the height map image resource.
  103418. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  103419. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  103420. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  103421. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  103422. * * 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.
  103423. * * 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).
  103424. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  103425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103426. * @param name defines the name of the mesh
  103427. * @param url defines the url to the height map
  103428. * @param options defines the options used to create the mesh
  103429. * @param scene defines the hosting scene
  103430. * @returns the ground mesh
  103431. * @see https://doc.babylonjs.com/babylon101/height_map
  103432. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  103433. */
  103434. static CreateGroundFromHeightMap(name: string, url: string, options: {
  103435. width?: number;
  103436. height?: number;
  103437. subdivisions?: number;
  103438. minHeight?: number;
  103439. maxHeight?: number;
  103440. colorFilter?: Color3;
  103441. alphaFilter?: number;
  103442. updatable?: boolean;
  103443. onReady?: (mesh: GroundMesh) => void;
  103444. }, scene?: Nullable<Scene>): GroundMesh;
  103445. }
  103446. }
  103447. declare module BABYLON {
  103448. /**
  103449. * Class containing static functions to help procedurally build meshes
  103450. */
  103451. export class TorusBuilder {
  103452. /**
  103453. * Creates a torus mesh
  103454. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  103455. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  103456. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  103457. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103458. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103459. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103460. * @param name defines the name of the mesh
  103461. * @param options defines the options used to create the mesh
  103462. * @param scene defines the hosting scene
  103463. * @returns the torus mesh
  103464. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  103465. */
  103466. static CreateTorus(name: string, options: {
  103467. diameter?: number;
  103468. thickness?: number;
  103469. tessellation?: number;
  103470. updatable?: boolean;
  103471. sideOrientation?: number;
  103472. frontUVs?: Vector4;
  103473. backUVs?: Vector4;
  103474. }, scene: any): Mesh;
  103475. }
  103476. }
  103477. declare module BABYLON {
  103478. /**
  103479. * Class containing static functions to help procedurally build meshes
  103480. */
  103481. export class CylinderBuilder {
  103482. /**
  103483. * Creates a cylinder or a cone mesh
  103484. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  103485. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  103486. * * 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.
  103487. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  103488. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  103489. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  103490. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  103491. * * 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).
  103492. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  103493. * * 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).
  103494. * * 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
  103495. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  103496. * * 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
  103497. * * 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.
  103498. * * If `enclose` is false, a ring surface is one element.
  103499. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  103500. * * 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
  103501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103502. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103504. * @param name defines the name of the mesh
  103505. * @param options defines the options used to create the mesh
  103506. * @param scene defines the hosting scene
  103507. * @returns the cylinder mesh
  103508. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  103509. */
  103510. static CreateCylinder(name: string, options: {
  103511. height?: number;
  103512. diameterTop?: number;
  103513. diameterBottom?: number;
  103514. diameter?: number;
  103515. tessellation?: number;
  103516. subdivisions?: number;
  103517. arc?: number;
  103518. faceColors?: Color4[];
  103519. faceUV?: Vector4[];
  103520. updatable?: boolean;
  103521. hasRings?: boolean;
  103522. enclose?: boolean;
  103523. cap?: number;
  103524. sideOrientation?: number;
  103525. frontUVs?: Vector4;
  103526. backUVs?: Vector4;
  103527. }, scene: any): Mesh;
  103528. }
  103529. }
  103530. declare module BABYLON {
  103531. /**
  103532. * Options to modify the vr teleportation behavior.
  103533. */
  103534. export interface VRTeleportationOptions {
  103535. /**
  103536. * The name of the mesh which should be used as the teleportation floor. (default: null)
  103537. */
  103538. floorMeshName?: string;
  103539. /**
  103540. * A list of meshes to be used as the teleportation floor. (default: empty)
  103541. */
  103542. floorMeshes?: Mesh[];
  103543. }
  103544. /**
  103545. * Options to modify the vr experience helper's behavior.
  103546. */
  103547. export interface VRExperienceHelperOptions extends WebVROptions {
  103548. /**
  103549. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  103550. */
  103551. createDeviceOrientationCamera?: boolean;
  103552. /**
  103553. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  103554. */
  103555. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  103556. /**
  103557. * Uses the main button on the controller to toggle the laser casted. (default: true)
  103558. */
  103559. laserToggle?: boolean;
  103560. /**
  103561. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  103562. */
  103563. floorMeshes?: Mesh[];
  103564. /**
  103565. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  103566. */
  103567. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  103568. }
  103569. /**
  103570. * Event containing information after VR has been entered
  103571. */
  103572. export class OnAfterEnteringVRObservableEvent {
  103573. /**
  103574. * If entering vr was successful
  103575. */
  103576. success: boolean;
  103577. }
  103578. /**
  103579. * Helps to quickly add VR support to an existing scene.
  103580. * See http://doc.babylonjs.com/how_to/webvr_helper
  103581. */
  103582. export class VRExperienceHelper {
  103583. /** Options to modify the vr experience helper's behavior. */
  103584. webVROptions: VRExperienceHelperOptions;
  103585. private _scene;
  103586. private _position;
  103587. private _btnVR;
  103588. private _btnVRDisplayed;
  103589. private _webVRsupported;
  103590. private _webVRready;
  103591. private _webVRrequesting;
  103592. private _webVRpresenting;
  103593. private _hasEnteredVR;
  103594. private _fullscreenVRpresenting;
  103595. private _canvas;
  103596. private _webVRCamera;
  103597. private _vrDeviceOrientationCamera;
  103598. private _deviceOrientationCamera;
  103599. private _existingCamera;
  103600. private _onKeyDown;
  103601. private _onVrDisplayPresentChange;
  103602. private _onVRDisplayChanged;
  103603. private _onVRRequestPresentStart;
  103604. private _onVRRequestPresentComplete;
  103605. /**
  103606. * Observable raised right before entering VR.
  103607. */
  103608. onEnteringVRObservable: Observable<VRExperienceHelper>;
  103609. /**
  103610. * Observable raised when entering VR has completed.
  103611. */
  103612. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  103613. /**
  103614. * Observable raised when exiting VR.
  103615. */
  103616. onExitingVRObservable: Observable<VRExperienceHelper>;
  103617. /**
  103618. * Observable raised when controller mesh is loaded.
  103619. */
  103620. onControllerMeshLoadedObservable: Observable<WebVRController>;
  103621. /** Return this.onEnteringVRObservable
  103622. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  103623. */
  103624. readonly onEnteringVR: Observable<VRExperienceHelper>;
  103625. /** Return this.onExitingVRObservable
  103626. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  103627. */
  103628. readonly onExitingVR: Observable<VRExperienceHelper>;
  103629. /** Return this.onControllerMeshLoadedObservable
  103630. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  103631. */
  103632. readonly onControllerMeshLoaded: Observable<WebVRController>;
  103633. private _rayLength;
  103634. private _useCustomVRButton;
  103635. private _teleportationRequested;
  103636. private _teleportActive;
  103637. private _floorMeshName;
  103638. private _floorMeshesCollection;
  103639. private _rotationAllowed;
  103640. private _teleportBackwardsVector;
  103641. private _teleportationTarget;
  103642. private _isDefaultTeleportationTarget;
  103643. private _postProcessMove;
  103644. private _teleportationFillColor;
  103645. private _teleportationBorderColor;
  103646. private _rotationAngle;
  103647. private _haloCenter;
  103648. private _cameraGazer;
  103649. private _padSensibilityUp;
  103650. private _padSensibilityDown;
  103651. private _leftController;
  103652. private _rightController;
  103653. /**
  103654. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  103655. */
  103656. onNewMeshSelected: Observable<AbstractMesh>;
  103657. /**
  103658. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  103659. */
  103660. onNewMeshPicked: Observable<PickingInfo>;
  103661. private _circleEase;
  103662. /**
  103663. * Observable raised before camera teleportation
  103664. */
  103665. onBeforeCameraTeleport: Observable<Vector3>;
  103666. /**
  103667. * Observable raised after camera teleportation
  103668. */
  103669. onAfterCameraTeleport: Observable<Vector3>;
  103670. /**
  103671. * Observable raised when current selected mesh gets unselected
  103672. */
  103673. onSelectedMeshUnselected: Observable<AbstractMesh>;
  103674. private _raySelectionPredicate;
  103675. /**
  103676. * To be optionaly changed by user to define custom ray selection
  103677. */
  103678. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  103679. /**
  103680. * To be optionaly changed by user to define custom selection logic (after ray selection)
  103681. */
  103682. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  103683. /**
  103684. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  103685. */
  103686. teleportationEnabled: boolean;
  103687. private _defaultHeight;
  103688. private _teleportationInitialized;
  103689. private _interactionsEnabled;
  103690. private _interactionsRequested;
  103691. private _displayGaze;
  103692. private _displayLaserPointer;
  103693. /**
  103694. * The mesh used to display where the user is going to teleport.
  103695. */
  103696. /**
  103697. * Sets the mesh to be used to display where the user is going to teleport.
  103698. */
  103699. teleportationTarget: Mesh;
  103700. /**
  103701. * 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
  103702. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  103703. * See http://doc.babylonjs.com/resources/baking_transformations
  103704. */
  103705. gazeTrackerMesh: Mesh;
  103706. /**
  103707. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  103708. */
  103709. updateGazeTrackerScale: boolean;
  103710. /**
  103711. * If the gaze trackers color should be updated when selecting meshes
  103712. */
  103713. updateGazeTrackerColor: boolean;
  103714. /**
  103715. * The gaze tracking mesh corresponding to the left controller
  103716. */
  103717. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  103718. /**
  103719. * The gaze tracking mesh corresponding to the right controller
  103720. */
  103721. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  103722. /**
  103723. * If the ray of the gaze should be displayed.
  103724. */
  103725. /**
  103726. * Sets if the ray of the gaze should be displayed.
  103727. */
  103728. displayGaze: boolean;
  103729. /**
  103730. * If the ray of the LaserPointer should be displayed.
  103731. */
  103732. /**
  103733. * Sets if the ray of the LaserPointer should be displayed.
  103734. */
  103735. displayLaserPointer: boolean;
  103736. /**
  103737. * The deviceOrientationCamera used as the camera when not in VR.
  103738. */
  103739. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  103740. /**
  103741. * Based on the current WebVR support, returns the current VR camera used.
  103742. */
  103743. readonly currentVRCamera: Nullable<Camera>;
  103744. /**
  103745. * The webVRCamera which is used when in VR.
  103746. */
  103747. readonly webVRCamera: WebVRFreeCamera;
  103748. /**
  103749. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  103750. */
  103751. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  103752. private readonly _teleportationRequestInitiated;
  103753. /**
  103754. * Defines wether or not Pointer lock should be requested when switching to
  103755. * full screen.
  103756. */
  103757. requestPointerLockOnFullScreen: boolean;
  103758. /**
  103759. * Instantiates a VRExperienceHelper.
  103760. * Helps to quickly add VR support to an existing scene.
  103761. * @param scene The scene the VRExperienceHelper belongs to.
  103762. * @param webVROptions Options to modify the vr experience helper's behavior.
  103763. */
  103764. constructor(scene: Scene,
  103765. /** Options to modify the vr experience helper's behavior. */
  103766. webVROptions?: VRExperienceHelperOptions);
  103767. private _onDefaultMeshLoaded;
  103768. private _onResize;
  103769. private _onFullscreenChange;
  103770. /**
  103771. * Gets a value indicating if we are currently in VR mode.
  103772. */
  103773. readonly isInVRMode: boolean;
  103774. private onVrDisplayPresentChange;
  103775. private onVRDisplayChanged;
  103776. private moveButtonToBottomRight;
  103777. private displayVRButton;
  103778. private updateButtonVisibility;
  103779. private _cachedAngularSensibility;
  103780. /**
  103781. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  103782. * Otherwise, will use the fullscreen API.
  103783. */
  103784. enterVR(): void;
  103785. /**
  103786. * Attempt to exit VR, or fullscreen.
  103787. */
  103788. exitVR(): void;
  103789. /**
  103790. * The position of the vr experience helper.
  103791. */
  103792. /**
  103793. * Sets the position of the vr experience helper.
  103794. */
  103795. position: Vector3;
  103796. /**
  103797. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  103798. */
  103799. enableInteractions(): void;
  103800. private readonly _noControllerIsActive;
  103801. private beforeRender;
  103802. private _isTeleportationFloor;
  103803. /**
  103804. * Adds a floor mesh to be used for teleportation.
  103805. * @param floorMesh the mesh to be used for teleportation.
  103806. */
  103807. addFloorMesh(floorMesh: Mesh): void;
  103808. /**
  103809. * Removes a floor mesh from being used for teleportation.
  103810. * @param floorMesh the mesh to be removed.
  103811. */
  103812. removeFloorMesh(floorMesh: Mesh): void;
  103813. /**
  103814. * Enables interactions and teleportation using the VR controllers and gaze.
  103815. * @param vrTeleportationOptions options to modify teleportation behavior.
  103816. */
  103817. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  103818. private _onNewGamepadConnected;
  103819. private _tryEnableInteractionOnController;
  103820. private _onNewGamepadDisconnected;
  103821. private _enableInteractionOnController;
  103822. private _checkTeleportWithRay;
  103823. private _checkRotate;
  103824. private _checkTeleportBackwards;
  103825. private _enableTeleportationOnController;
  103826. private _createTeleportationCircles;
  103827. private _displayTeleportationTarget;
  103828. private _hideTeleportationTarget;
  103829. private _rotateCamera;
  103830. private _moveTeleportationSelectorTo;
  103831. private _workingVector;
  103832. private _workingQuaternion;
  103833. private _workingMatrix;
  103834. /**
  103835. * Teleports the users feet to the desired location
  103836. * @param location The location where the user's feet should be placed
  103837. */
  103838. teleportCamera(location: Vector3): void;
  103839. private _convertNormalToDirectionOfRay;
  103840. private _castRayAndSelectObject;
  103841. private _notifySelectedMeshUnselected;
  103842. /**
  103843. * Sets the color of the laser ray from the vr controllers.
  103844. * @param color new color for the ray.
  103845. */
  103846. changeLaserColor(color: Color3): void;
  103847. /**
  103848. * Sets the color of the ray from the vr headsets gaze.
  103849. * @param color new color for the ray.
  103850. */
  103851. changeGazeColor(color: Color3): void;
  103852. /**
  103853. * Exits VR and disposes of the vr experience helper
  103854. */
  103855. dispose(): void;
  103856. /**
  103857. * Gets the name of the VRExperienceHelper class
  103858. * @returns "VRExperienceHelper"
  103859. */
  103860. getClassName(): string;
  103861. }
  103862. }
  103863. declare module BABYLON {
  103864. /**
  103865. * Manages an XRSession to work with Babylon's engine
  103866. * @see https://doc.babylonjs.com/how_to/webxr
  103867. */
  103868. export class WebXRSessionManager implements IDisposable {
  103869. private scene;
  103870. /**
  103871. * Fires every time a new xrFrame arrives which can be used to update the camera
  103872. */
  103873. onXRFrameObservable: Observable<any>;
  103874. /**
  103875. * Fires when the xr session is ended either by the device or manually done
  103876. */
  103877. onXRSessionEnded: Observable<any>;
  103878. /**
  103879. * Underlying xr session
  103880. */
  103881. session: XRSession;
  103882. /**
  103883. * Type of reference space used when creating the session
  103884. */
  103885. referenceSpace: XRReferenceSpace;
  103886. /** @hidden */
  103887. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  103888. /**
  103889. * Current XR frame
  103890. */
  103891. currentFrame: Nullable<XRFrame>;
  103892. private _xrNavigator;
  103893. private baseLayer;
  103894. /**
  103895. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  103896. * @param scene The scene which the session should be created for
  103897. */
  103898. constructor(scene: Scene);
  103899. /**
  103900. * Initializes the manager
  103901. * After initialization enterXR can be called to start an XR session
  103902. * @returns Promise which resolves after it is initialized
  103903. */
  103904. initializeAsync(): Promise<void>;
  103905. /**
  103906. * Initializes an xr session
  103907. * @param xrSessionMode mode to initialize
  103908. * @returns a promise which will resolve once the session has been initialized
  103909. */
  103910. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  103911. /**
  103912. * Sets the reference space on the xr session
  103913. * @param referenceSpace space to set
  103914. * @returns a promise that will resolve once the reference space has been set
  103915. */
  103916. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  103917. /**
  103918. * Updates the render state of the session
  103919. * @param state state to set
  103920. * @returns a promise that resolves once the render state has been updated
  103921. */
  103922. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  103923. /**
  103924. * Starts rendering to the xr layer
  103925. * @returns a promise that will resolve once rendering has started
  103926. */
  103927. startRenderingToXRAsync(): Promise<void>;
  103928. /**
  103929. * Stops the xrSession and restores the renderloop
  103930. * @returns Promise which resolves after it exits XR
  103931. */
  103932. exitXRAsync(): Promise<unknown>;
  103933. /**
  103934. * Checks if a session would be supported for the creation options specified
  103935. * @param sessionMode session mode to check if supported eg. immersive-vr
  103936. * @returns true if supported
  103937. */
  103938. supportsSessionAsync(sessionMode: XRSessionMode): any;
  103939. /**
  103940. * @hidden
  103941. * Converts the render layer of xrSession to a render target
  103942. * @param session session to create render target for
  103943. * @param scene scene the new render target should be created for
  103944. */
  103945. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  103946. /**
  103947. * Disposes of the session manager
  103948. */
  103949. dispose(): void;
  103950. }
  103951. }
  103952. declare module BABYLON {
  103953. /**
  103954. * WebXR Camera which holds the views for the xrSession
  103955. * @see https://doc.babylonjs.com/how_to/webxr
  103956. */
  103957. export class WebXRCamera extends FreeCamera {
  103958. private static _TmpMatrix;
  103959. /**
  103960. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  103961. * @param name the name of the camera
  103962. * @param scene the scene to add the camera to
  103963. */
  103964. constructor(name: string, scene: Scene);
  103965. private _updateNumberOfRigCameras;
  103966. /** @hidden */
  103967. _updateForDualEyeDebugging(pupilDistance?: number): void;
  103968. /**
  103969. * Updates the cameras position from the current pose information of the XR session
  103970. * @param xrSessionManager the session containing pose information
  103971. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  103972. */
  103973. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  103974. }
  103975. }
  103976. declare module BABYLON {
  103977. /**
  103978. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  103979. */
  103980. export class WebXRManagedOutputCanvas implements IDisposable {
  103981. private helper;
  103982. private _canvas;
  103983. /**
  103984. * xrpresent context of the canvas which can be used to display/mirror xr content
  103985. */
  103986. canvasContext: WebGLRenderingContext;
  103987. /**
  103988. * xr layer for the canvas
  103989. */
  103990. xrLayer: Nullable<XRWebGLLayer>;
  103991. /**
  103992. * Initializes the xr layer for the session
  103993. * @param xrSession xr session
  103994. * @returns a promise that will resolve once the XR Layer has been created
  103995. */
  103996. initializeXRLayerAsync(xrSession: any): any;
  103997. /**
  103998. * Initializes the canvas to be added/removed upon entering/exiting xr
  103999. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  104000. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  104001. */
  104002. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  104003. /**
  104004. * Disposes of the object
  104005. */
  104006. dispose(): void;
  104007. private _setManagedOutputCanvas;
  104008. private _addCanvas;
  104009. private _removeCanvas;
  104010. }
  104011. }
  104012. declare module BABYLON {
  104013. /**
  104014. * States of the webXR experience
  104015. */
  104016. export enum WebXRState {
  104017. /**
  104018. * Transitioning to being in XR mode
  104019. */
  104020. ENTERING_XR = 0,
  104021. /**
  104022. * Transitioning to non XR mode
  104023. */
  104024. EXITING_XR = 1,
  104025. /**
  104026. * In XR mode and presenting
  104027. */
  104028. IN_XR = 2,
  104029. /**
  104030. * Not entered XR mode
  104031. */
  104032. NOT_IN_XR = 3
  104033. }
  104034. /**
  104035. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  104036. * @see https://doc.babylonjs.com/how_to/webxr
  104037. */
  104038. export class WebXRExperienceHelper implements IDisposable {
  104039. private scene;
  104040. /**
  104041. * 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
  104042. */
  104043. container: AbstractMesh;
  104044. /**
  104045. * Camera used to render xr content
  104046. */
  104047. camera: WebXRCamera;
  104048. /**
  104049. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  104050. */
  104051. state: WebXRState;
  104052. private _setState;
  104053. private static _TmpVector;
  104054. /**
  104055. * Fires when the state of the experience helper has changed
  104056. */
  104057. onStateChangedObservable: Observable<WebXRState>;
  104058. /** Session manager used to keep track of xr session */
  104059. sessionManager: WebXRSessionManager;
  104060. private _nonVRCamera;
  104061. private _originalSceneAutoClear;
  104062. private _supported;
  104063. /**
  104064. * Creates the experience helper
  104065. * @param scene the scene to attach the experience helper to
  104066. * @returns a promise for the experience helper
  104067. */
  104068. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  104069. /**
  104070. * Creates a WebXRExperienceHelper
  104071. * @param scene The scene the helper should be created in
  104072. */
  104073. private constructor();
  104074. /**
  104075. * Exits XR mode and returns the scene to its original state
  104076. * @returns promise that resolves after xr mode has exited
  104077. */
  104078. exitXRAsync(): Promise<unknown>;
  104079. /**
  104080. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  104081. * @param sessionCreationOptions options for the XR session
  104082. * @param referenceSpaceType frame of reference of the XR session
  104083. * @param outputCanvas the output canvas that will be used to enter XR mode
  104084. * @returns promise that resolves after xr mode has entered
  104085. */
  104086. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  104087. /**
  104088. * Updates the global position of the camera by moving the camera's container
  104089. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  104090. * @param position The desired global position of the camera
  104091. */
  104092. setPositionOfCameraUsingContainer(position: Vector3): void;
  104093. /**
  104094. * Rotates the xr camera by rotating the camera's container around the camera's position
  104095. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  104096. * @param rotation the desired quaternion rotation to apply to the camera
  104097. */
  104098. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  104099. /**
  104100. * Disposes of the experience helper
  104101. */
  104102. dispose(): void;
  104103. }
  104104. }
  104105. declare module BABYLON {
  104106. /**
  104107. * Button which can be used to enter a different mode of XR
  104108. */
  104109. export class WebXREnterExitUIButton {
  104110. /** button element */
  104111. element: HTMLElement;
  104112. /** XR initialization options for the button */
  104113. sessionMode: XRSessionMode;
  104114. /** Reference space type */
  104115. referenceSpaceType: XRReferenceSpaceType;
  104116. /**
  104117. * Creates a WebXREnterExitUIButton
  104118. * @param element button element
  104119. * @param sessionMode XR initialization session mode
  104120. * @param referenceSpaceType the type of reference space to be used
  104121. */
  104122. constructor(
  104123. /** button element */
  104124. element: HTMLElement,
  104125. /** XR initialization options for the button */
  104126. sessionMode: XRSessionMode,
  104127. /** Reference space type */
  104128. referenceSpaceType: XRReferenceSpaceType);
  104129. /**
  104130. * Overwritable function which can be used to update the button's visuals when the state changes
  104131. * @param activeButton the current active button in the UI
  104132. */
  104133. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  104134. }
  104135. /**
  104136. * Options to create the webXR UI
  104137. */
  104138. export class WebXREnterExitUIOptions {
  104139. /**
  104140. * Context to enter xr with
  104141. */
  104142. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  104143. /**
  104144. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  104145. */
  104146. customButtons?: Array<WebXREnterExitUIButton>;
  104147. }
  104148. /**
  104149. * UI to allow the user to enter/exit XR mode
  104150. */
  104151. export class WebXREnterExitUI implements IDisposable {
  104152. private scene;
  104153. private _overlay;
  104154. private _buttons;
  104155. private _activeButton;
  104156. /**
  104157. * Fired every time the active button is changed.
  104158. *
  104159. * When xr is entered via a button that launches xr that button will be the callback parameter
  104160. *
  104161. * When exiting xr the callback parameter will be null)
  104162. */
  104163. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  104164. /**
  104165. * Creates UI to allow the user to enter/exit XR mode
  104166. * @param scene the scene to add the ui to
  104167. * @param helper the xr experience helper to enter/exit xr with
  104168. * @param options options to configure the UI
  104169. * @returns the created ui
  104170. */
  104171. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  104172. private constructor();
  104173. private _updateButtons;
  104174. /**
  104175. * Disposes of the object
  104176. */
  104177. dispose(): void;
  104178. }
  104179. }
  104180. declare module BABYLON {
  104181. /**
  104182. * Represents an XR input
  104183. */
  104184. export class WebXRController {
  104185. private scene;
  104186. /** The underlying input source for the controller */
  104187. inputSource: XRInputSource;
  104188. private parentContainer;
  104189. /**
  104190. * 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
  104191. */
  104192. grip?: AbstractMesh;
  104193. /**
  104194. * Pointer which can be used to select objects or attach a visible laser to
  104195. */
  104196. pointer: AbstractMesh;
  104197. /**
  104198. * Event that fires when the controller is removed/disposed
  104199. */
  104200. onDisposeObservable: Observable<{}>;
  104201. private _tmpMatrix;
  104202. private _tmpQuaternion;
  104203. private _tmpVector;
  104204. /**
  104205. * Creates the controller
  104206. * @see https://doc.babylonjs.com/how_to/webxr
  104207. * @param scene the scene which the controller should be associated to
  104208. * @param inputSource the underlying input source for the controller
  104209. * @param parentContainer parent that the controller meshes should be children of
  104210. */
  104211. constructor(scene: Scene,
  104212. /** The underlying input source for the controller */
  104213. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  104214. /**
  104215. * Updates the controller pose based on the given XRFrame
  104216. * @param xrFrame xr frame to update the pose with
  104217. * @param referenceSpace reference space to use
  104218. */
  104219. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  104220. /**
  104221. * Gets a world space ray coming from the controller
  104222. * @param result the resulting ray
  104223. */
  104224. getWorldPointerRayToRef(result: Ray): void;
  104225. /**
  104226. * Disposes of the object
  104227. */
  104228. dispose(): void;
  104229. }
  104230. }
  104231. declare module BABYLON {
  104232. /**
  104233. * XR input used to track XR inputs such as controllers/rays
  104234. */
  104235. export class WebXRInput implements IDisposable {
  104236. /**
  104237. * Base experience the input listens to
  104238. */
  104239. baseExperience: WebXRExperienceHelper;
  104240. /**
  104241. * XR controllers being tracked
  104242. */
  104243. controllers: Array<WebXRController>;
  104244. private _frameObserver;
  104245. private _stateObserver;
  104246. /**
  104247. * Event when a controller has been connected/added
  104248. */
  104249. onControllerAddedObservable: Observable<WebXRController>;
  104250. /**
  104251. * Event when a controller has been removed/disconnected
  104252. */
  104253. onControllerRemovedObservable: Observable<WebXRController>;
  104254. /**
  104255. * Initializes the WebXRInput
  104256. * @param baseExperience experience helper which the input should be created for
  104257. */
  104258. constructor(
  104259. /**
  104260. * Base experience the input listens to
  104261. */
  104262. baseExperience: WebXRExperienceHelper);
  104263. private _onInputSourcesChange;
  104264. private _addAndRemoveControllers;
  104265. /**
  104266. * Disposes of the object
  104267. */
  104268. dispose(): void;
  104269. }
  104270. }
  104271. declare module BABYLON {
  104272. /**
  104273. * Enables teleportation
  104274. */
  104275. export class WebXRControllerTeleportation {
  104276. private _teleportationFillColor;
  104277. private _teleportationBorderColor;
  104278. private _tmpRay;
  104279. private _tmpVector;
  104280. /**
  104281. * Creates a WebXRControllerTeleportation
  104282. * @param input input manager to add teleportation to
  104283. * @param floorMeshes floormeshes which can be teleported to
  104284. */
  104285. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  104286. }
  104287. }
  104288. declare module BABYLON {
  104289. /**
  104290. * Handles pointer input automatically for the pointer of XR controllers
  104291. */
  104292. export class WebXRControllerPointerSelection {
  104293. private static _idCounter;
  104294. private _tmpRay;
  104295. /**
  104296. * Creates a WebXRControllerPointerSelection
  104297. * @param input input manager to setup pointer selection
  104298. */
  104299. constructor(input: WebXRInput);
  104300. private _convertNormalToDirectionOfRay;
  104301. private _updatePointerDistance;
  104302. }
  104303. }
  104304. declare module BABYLON {
  104305. /**
  104306. * Class used to represent data loading progression
  104307. */
  104308. export class SceneLoaderProgressEvent {
  104309. /** defines if data length to load can be evaluated */
  104310. readonly lengthComputable: boolean;
  104311. /** defines the loaded data length */
  104312. readonly loaded: number;
  104313. /** defines the data length to load */
  104314. readonly total: number;
  104315. /**
  104316. * Create a new progress event
  104317. * @param lengthComputable defines if data length to load can be evaluated
  104318. * @param loaded defines the loaded data length
  104319. * @param total defines the data length to load
  104320. */
  104321. constructor(
  104322. /** defines if data length to load can be evaluated */
  104323. lengthComputable: boolean,
  104324. /** defines the loaded data length */
  104325. loaded: number,
  104326. /** defines the data length to load */
  104327. total: number);
  104328. /**
  104329. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  104330. * @param event defines the source event
  104331. * @returns a new SceneLoaderProgressEvent
  104332. */
  104333. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  104334. }
  104335. /**
  104336. * Interface used by SceneLoader plugins to define supported file extensions
  104337. */
  104338. export interface ISceneLoaderPluginExtensions {
  104339. /**
  104340. * Defines the list of supported extensions
  104341. */
  104342. [extension: string]: {
  104343. isBinary: boolean;
  104344. };
  104345. }
  104346. /**
  104347. * Interface used by SceneLoader plugin factory
  104348. */
  104349. export interface ISceneLoaderPluginFactory {
  104350. /**
  104351. * Defines the name of the factory
  104352. */
  104353. name: string;
  104354. /**
  104355. * Function called to create a new plugin
  104356. * @return the new plugin
  104357. */
  104358. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  104359. /**
  104360. * Boolean indicating if the plugin can direct load specific data
  104361. */
  104362. canDirectLoad?: (data: string) => boolean;
  104363. }
  104364. /**
  104365. * Interface used to define a SceneLoader plugin
  104366. */
  104367. export interface ISceneLoaderPlugin {
  104368. /**
  104369. * The friendly name of this plugin.
  104370. */
  104371. name: string;
  104372. /**
  104373. * The file extensions supported by this plugin.
  104374. */
  104375. extensions: string | ISceneLoaderPluginExtensions;
  104376. /**
  104377. * Import meshes into a scene.
  104378. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  104379. * @param scene The scene to import into
  104380. * @param data The data to import
  104381. * @param rootUrl The root url for scene and resources
  104382. * @param meshes The meshes array to import into
  104383. * @param particleSystems The particle systems array to import into
  104384. * @param skeletons The skeletons array to import into
  104385. * @param onError The callback when import fails
  104386. * @returns True if successful or false otherwise
  104387. */
  104388. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  104389. /**
  104390. * Load into a scene.
  104391. * @param scene The scene to load into
  104392. * @param data The data to import
  104393. * @param rootUrl The root url for scene and resources
  104394. * @param onError The callback when import fails
  104395. * @returns true if successful or false otherwise
  104396. */
  104397. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  104398. /**
  104399. * The callback that returns true if the data can be directly loaded.
  104400. */
  104401. canDirectLoad?: (data: string) => boolean;
  104402. /**
  104403. * The callback that allows custom handling of the root url based on the response url.
  104404. */
  104405. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  104406. /**
  104407. * Load into an asset container.
  104408. * @param scene The scene to load into
  104409. * @param data The data to import
  104410. * @param rootUrl The root url for scene and resources
  104411. * @param onError The callback when import fails
  104412. * @returns The loaded asset container
  104413. */
  104414. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  104415. }
  104416. /**
  104417. * Interface used to define an async SceneLoader plugin
  104418. */
  104419. export interface ISceneLoaderPluginAsync {
  104420. /**
  104421. * The friendly name of this plugin.
  104422. */
  104423. name: string;
  104424. /**
  104425. * The file extensions supported by this plugin.
  104426. */
  104427. extensions: string | ISceneLoaderPluginExtensions;
  104428. /**
  104429. * Import meshes into a scene.
  104430. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  104431. * @param scene The scene to import into
  104432. * @param data The data to import
  104433. * @param rootUrl The root url for scene and resources
  104434. * @param onProgress The callback when the load progresses
  104435. * @param fileName Defines the name of the file to load
  104436. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  104437. */
  104438. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  104439. meshes: AbstractMesh[];
  104440. particleSystems: IParticleSystem[];
  104441. skeletons: Skeleton[];
  104442. animationGroups: AnimationGroup[];
  104443. }>;
  104444. /**
  104445. * Load into a scene.
  104446. * @param scene The scene to load into
  104447. * @param data The data to import
  104448. * @param rootUrl The root url for scene and resources
  104449. * @param onProgress The callback when the load progresses
  104450. * @param fileName Defines the name of the file to load
  104451. * @returns Nothing
  104452. */
  104453. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  104454. /**
  104455. * The callback that returns true if the data can be directly loaded.
  104456. */
  104457. canDirectLoad?: (data: string) => boolean;
  104458. /**
  104459. * The callback that allows custom handling of the root url based on the response url.
  104460. */
  104461. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  104462. /**
  104463. * Load into an asset container.
  104464. * @param scene The scene to load into
  104465. * @param data The data to import
  104466. * @param rootUrl The root url for scene and resources
  104467. * @param onProgress The callback when the load progresses
  104468. * @param fileName Defines the name of the file to load
  104469. * @returns The loaded asset container
  104470. */
  104471. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  104472. }
  104473. /**
  104474. * Class used to load scene from various file formats using registered plugins
  104475. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  104476. */
  104477. export class SceneLoader {
  104478. /**
  104479. * No logging while loading
  104480. */
  104481. static readonly NO_LOGGING: number;
  104482. /**
  104483. * Minimal logging while loading
  104484. */
  104485. static readonly MINIMAL_LOGGING: number;
  104486. /**
  104487. * Summary logging while loading
  104488. */
  104489. static readonly SUMMARY_LOGGING: number;
  104490. /**
  104491. * Detailled logging while loading
  104492. */
  104493. static readonly DETAILED_LOGGING: number;
  104494. /**
  104495. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  104496. */
  104497. static ForceFullSceneLoadingForIncremental: boolean;
  104498. /**
  104499. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  104500. */
  104501. static ShowLoadingScreen: boolean;
  104502. /**
  104503. * Defines the current logging level (while loading the scene)
  104504. * @ignorenaming
  104505. */
  104506. static loggingLevel: number;
  104507. /**
  104508. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  104509. */
  104510. static CleanBoneMatrixWeights: boolean;
  104511. /**
  104512. * Event raised when a plugin is used to load a scene
  104513. */
  104514. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  104515. private static _registeredPlugins;
  104516. private static _getDefaultPlugin;
  104517. private static _getPluginForExtension;
  104518. private static _getPluginForDirectLoad;
  104519. private static _getPluginForFilename;
  104520. private static _getDirectLoad;
  104521. private static _loadData;
  104522. private static _getFileInfo;
  104523. /**
  104524. * Gets a plugin that can load the given extension
  104525. * @param extension defines the extension to load
  104526. * @returns a plugin or null if none works
  104527. */
  104528. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  104529. /**
  104530. * Gets a boolean indicating that the given extension can be loaded
  104531. * @param extension defines the extension to load
  104532. * @returns true if the extension is supported
  104533. */
  104534. static IsPluginForExtensionAvailable(extension: string): boolean;
  104535. /**
  104536. * Adds a new plugin to the list of registered plugins
  104537. * @param plugin defines the plugin to add
  104538. */
  104539. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  104540. /**
  104541. * Import meshes into a scene
  104542. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  104543. * @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)
  104544. * @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)
  104545. * @param scene the instance of BABYLON.Scene to append to
  104546. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  104547. * @param onProgress a callback with a progress event for each file being loaded
  104548. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  104549. * @param pluginExtension the extension used to determine the plugin
  104550. * @returns The loaded plugin
  104551. */
  104552. 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>;
  104553. /**
  104554. * Import meshes into a scene
  104555. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  104556. * @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)
  104557. * @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)
  104558. * @param scene the instance of BABYLON.Scene to append to
  104559. * @param onProgress a callback with a progress event for each file being loaded
  104560. * @param pluginExtension the extension used to determine the plugin
  104561. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  104562. */
  104563. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  104564. meshes: AbstractMesh[];
  104565. particleSystems: IParticleSystem[];
  104566. skeletons: Skeleton[];
  104567. animationGroups: AnimationGroup[];
  104568. }>;
  104569. /**
  104570. * Load a scene
  104571. * @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)
  104572. * @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)
  104573. * @param engine is the instance of BABYLON.Engine to use to create the scene
  104574. * @param onSuccess a callback with the scene when import succeeds
  104575. * @param onProgress a callback with a progress event for each file being loaded
  104576. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  104577. * @param pluginExtension the extension used to determine the plugin
  104578. * @returns The loaded plugin
  104579. */
  104580. 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>;
  104581. /**
  104582. * Load a scene
  104583. * @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)
  104584. * @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)
  104585. * @param engine is the instance of BABYLON.Engine to use to create the scene
  104586. * @param onProgress a callback with a progress event for each file being loaded
  104587. * @param pluginExtension the extension used to determine the plugin
  104588. * @returns The loaded scene
  104589. */
  104590. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  104591. /**
  104592. * Append a scene
  104593. * @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)
  104594. * @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)
  104595. * @param scene is the instance of BABYLON.Scene to append to
  104596. * @param onSuccess a callback with the scene when import succeeds
  104597. * @param onProgress a callback with a progress event for each file being loaded
  104598. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  104599. * @param pluginExtension the extension used to determine the plugin
  104600. * @returns The loaded plugin
  104601. */
  104602. 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>;
  104603. /**
  104604. * Append a scene
  104605. * @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)
  104606. * @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)
  104607. * @param scene is the instance of BABYLON.Scene to append to
  104608. * @param onProgress a callback with a progress event for each file being loaded
  104609. * @param pluginExtension the extension used to determine the plugin
  104610. * @returns The given scene
  104611. */
  104612. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  104613. /**
  104614. * Load a scene into an asset container
  104615. * @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)
  104616. * @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)
  104617. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  104618. * @param onSuccess a callback with the scene when import succeeds
  104619. * @param onProgress a callback with a progress event for each file being loaded
  104620. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  104621. * @param pluginExtension the extension used to determine the plugin
  104622. * @returns The loaded plugin
  104623. */
  104624. 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>;
  104625. /**
  104626. * Load a scene into an asset container
  104627. * @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)
  104628. * @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)
  104629. * @param scene is the instance of Scene to append to
  104630. * @param onProgress a callback with a progress event for each file being loaded
  104631. * @param pluginExtension the extension used to determine the plugin
  104632. * @returns The loaded asset container
  104633. */
  104634. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  104635. }
  104636. }
  104637. declare module BABYLON {
  104638. /**
  104639. * Generic Controller
  104640. */
  104641. export class GenericController extends WebVRController {
  104642. /**
  104643. * Base Url for the controller model.
  104644. */
  104645. static readonly MODEL_BASE_URL: string;
  104646. /**
  104647. * File name for the controller model.
  104648. */
  104649. static readonly MODEL_FILENAME: string;
  104650. /**
  104651. * Creates a new GenericController from a gamepad
  104652. * @param vrGamepad the gamepad that the controller should be created from
  104653. */
  104654. constructor(vrGamepad: any);
  104655. /**
  104656. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  104657. * @param scene scene in which to add meshes
  104658. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  104659. */
  104660. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  104661. /**
  104662. * Called once for each button that changed state since the last frame
  104663. * @param buttonIdx Which button index changed
  104664. * @param state New state of the button
  104665. * @param changes Which properties on the state changed since last frame
  104666. */
  104667. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  104668. }
  104669. }
  104670. declare module BABYLON {
  104671. /**
  104672. * Defines the WindowsMotionController object that the state of the windows motion controller
  104673. */
  104674. export class WindowsMotionController extends WebVRController {
  104675. /**
  104676. * The base url used to load the left and right controller models
  104677. */
  104678. static MODEL_BASE_URL: string;
  104679. /**
  104680. * The name of the left controller model file
  104681. */
  104682. static MODEL_LEFT_FILENAME: string;
  104683. /**
  104684. * The name of the right controller model file
  104685. */
  104686. static MODEL_RIGHT_FILENAME: string;
  104687. /**
  104688. * The controller name prefix for this controller type
  104689. */
  104690. static readonly GAMEPAD_ID_PREFIX: string;
  104691. /**
  104692. * The controller id pattern for this controller type
  104693. */
  104694. private static readonly GAMEPAD_ID_PATTERN;
  104695. private _loadedMeshInfo;
  104696. private readonly _mapping;
  104697. /**
  104698. * Fired when the trackpad on this controller is clicked
  104699. */
  104700. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  104701. /**
  104702. * Fired when the trackpad on this controller is modified
  104703. */
  104704. onTrackpadValuesChangedObservable: Observable<StickValues>;
  104705. /**
  104706. * The current x and y values of this controller's trackpad
  104707. */
  104708. trackpad: StickValues;
  104709. /**
  104710. * Creates a new WindowsMotionController from a gamepad
  104711. * @param vrGamepad the gamepad that the controller should be created from
  104712. */
  104713. constructor(vrGamepad: any);
  104714. /**
  104715. * Fired when the trigger on this controller is modified
  104716. */
  104717. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104718. /**
  104719. * Fired when the menu button on this controller is modified
  104720. */
  104721. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104722. /**
  104723. * Fired when the grip button on this controller is modified
  104724. */
  104725. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104726. /**
  104727. * Fired when the thumbstick button on this controller is modified
  104728. */
  104729. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104730. /**
  104731. * Fired when the touchpad button on this controller is modified
  104732. */
  104733. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104734. /**
  104735. * Fired when the touchpad values on this controller are modified
  104736. */
  104737. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  104738. private _updateTrackpad;
  104739. /**
  104740. * Called once per frame by the engine.
  104741. */
  104742. update(): void;
  104743. /**
  104744. * Called once for each button that changed state since the last frame
  104745. * @param buttonIdx Which button index changed
  104746. * @param state New state of the button
  104747. * @param changes Which properties on the state changed since last frame
  104748. */
  104749. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  104750. /**
  104751. * Moves the buttons on the controller mesh based on their current state
  104752. * @param buttonName the name of the button to move
  104753. * @param buttonValue the value of the button which determines the buttons new position
  104754. */
  104755. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  104756. /**
  104757. * Moves the axis on the controller mesh based on its current state
  104758. * @param axis the index of the axis
  104759. * @param axisValue the value of the axis which determines the meshes new position
  104760. * @hidden
  104761. */
  104762. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  104763. /**
  104764. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  104765. * @param scene scene in which to add meshes
  104766. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  104767. */
  104768. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  104769. /**
  104770. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  104771. * can be transformed by button presses and axes values, based on this._mapping.
  104772. *
  104773. * @param scene scene in which the meshes exist
  104774. * @param meshes list of meshes that make up the controller model to process
  104775. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  104776. */
  104777. private processModel;
  104778. private createMeshInfo;
  104779. /**
  104780. * Gets the ray of the controller in the direction the controller is pointing
  104781. * @param length the length the resulting ray should be
  104782. * @returns a ray in the direction the controller is pointing
  104783. */
  104784. getForwardRay(length?: number): Ray;
  104785. /**
  104786. * Disposes of the controller
  104787. */
  104788. dispose(): void;
  104789. }
  104790. }
  104791. declare module BABYLON {
  104792. /**
  104793. * Oculus Touch Controller
  104794. */
  104795. export class OculusTouchController extends WebVRController {
  104796. /**
  104797. * Base Url for the controller model.
  104798. */
  104799. static MODEL_BASE_URL: string;
  104800. /**
  104801. * File name for the left controller model.
  104802. */
  104803. static MODEL_LEFT_FILENAME: string;
  104804. /**
  104805. * File name for the right controller model.
  104806. */
  104807. static MODEL_RIGHT_FILENAME: string;
  104808. /**
  104809. * Base Url for the Quest controller model.
  104810. */
  104811. static QUEST_MODEL_BASE_URL: string;
  104812. /**
  104813. * @hidden
  104814. * If the controllers are running on a device that needs the updated Quest controller models
  104815. */
  104816. static _IsQuest: boolean;
  104817. /**
  104818. * Fired when the secondary trigger on this controller is modified
  104819. */
  104820. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  104821. /**
  104822. * Fired when the thumb rest on this controller is modified
  104823. */
  104824. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  104825. /**
  104826. * Creates a new OculusTouchController from a gamepad
  104827. * @param vrGamepad the gamepad that the controller should be created from
  104828. */
  104829. constructor(vrGamepad: any);
  104830. /**
  104831. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  104832. * @param scene scene in which to add meshes
  104833. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  104834. */
  104835. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  104836. /**
  104837. * Fired when the A button on this controller is modified
  104838. */
  104839. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104840. /**
  104841. * Fired when the B button on this controller is modified
  104842. */
  104843. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104844. /**
  104845. * Fired when the X button on this controller is modified
  104846. */
  104847. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104848. /**
  104849. * Fired when the Y button on this controller is modified
  104850. */
  104851. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104852. /**
  104853. * Called once for each button that changed state since the last frame
  104854. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  104855. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  104856. * 2) secondary trigger (same)
  104857. * 3) A (right) X (left), touch, pressed = value
  104858. * 4) B / Y
  104859. * 5) thumb rest
  104860. * @param buttonIdx Which button index changed
  104861. * @param state New state of the button
  104862. * @param changes Which properties on the state changed since last frame
  104863. */
  104864. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  104865. }
  104866. }
  104867. declare module BABYLON {
  104868. /**
  104869. * Vive Controller
  104870. */
  104871. export class ViveController extends WebVRController {
  104872. /**
  104873. * Base Url for the controller model.
  104874. */
  104875. static MODEL_BASE_URL: string;
  104876. /**
  104877. * File name for the controller model.
  104878. */
  104879. static MODEL_FILENAME: string;
  104880. /**
  104881. * Creates a new ViveController from a gamepad
  104882. * @param vrGamepad the gamepad that the controller should be created from
  104883. */
  104884. constructor(vrGamepad: any);
  104885. /**
  104886. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  104887. * @param scene scene in which to add meshes
  104888. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  104889. */
  104890. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  104891. /**
  104892. * Fired when the left button on this controller is modified
  104893. */
  104894. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104895. /**
  104896. * Fired when the right button on this controller is modified
  104897. */
  104898. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104899. /**
  104900. * Fired when the menu button on this controller is modified
  104901. */
  104902. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104903. /**
  104904. * Called once for each button that changed state since the last frame
  104905. * Vive mapping:
  104906. * 0: touchpad
  104907. * 1: trigger
  104908. * 2: left AND right buttons
  104909. * 3: menu button
  104910. * @param buttonIdx Which button index changed
  104911. * @param state New state of the button
  104912. * @param changes Which properties on the state changed since last frame
  104913. */
  104914. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  104915. }
  104916. }
  104917. declare module BABYLON {
  104918. /**
  104919. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  104920. */
  104921. export class WebXRControllerModelLoader {
  104922. /**
  104923. * Creates the WebXRControllerModelLoader
  104924. * @param input xr input that creates the controllers
  104925. */
  104926. constructor(input: WebXRInput);
  104927. }
  104928. }
  104929. declare module BABYLON {
  104930. /**
  104931. * Contains an array of blocks representing the octree
  104932. */
  104933. export interface IOctreeContainer<T> {
  104934. /**
  104935. * Blocks within the octree
  104936. */
  104937. blocks: Array<OctreeBlock<T>>;
  104938. }
  104939. /**
  104940. * Class used to store a cell in an octree
  104941. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  104942. */
  104943. export class OctreeBlock<T> {
  104944. /**
  104945. * Gets the content of the current block
  104946. */
  104947. entries: T[];
  104948. /**
  104949. * Gets the list of block children
  104950. */
  104951. blocks: Array<OctreeBlock<T>>;
  104952. private _depth;
  104953. private _maxDepth;
  104954. private _capacity;
  104955. private _minPoint;
  104956. private _maxPoint;
  104957. private _boundingVectors;
  104958. private _creationFunc;
  104959. /**
  104960. * Creates a new block
  104961. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  104962. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  104963. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  104964. * @param depth defines the current depth of this block in the octree
  104965. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  104966. * @param creationFunc defines a callback to call when an element is added to the block
  104967. */
  104968. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  104969. /**
  104970. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  104971. */
  104972. readonly capacity: number;
  104973. /**
  104974. * Gets the minimum vector (in world space) of the block's bounding box
  104975. */
  104976. readonly minPoint: Vector3;
  104977. /**
  104978. * Gets the maximum vector (in world space) of the block's bounding box
  104979. */
  104980. readonly maxPoint: Vector3;
  104981. /**
  104982. * Add a new element to this block
  104983. * @param entry defines the element to add
  104984. */
  104985. addEntry(entry: T): void;
  104986. /**
  104987. * Remove an element from this block
  104988. * @param entry defines the element to remove
  104989. */
  104990. removeEntry(entry: T): void;
  104991. /**
  104992. * Add an array of elements to this block
  104993. * @param entries defines the array of elements to add
  104994. */
  104995. addEntries(entries: T[]): void;
  104996. /**
  104997. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  104998. * @param frustumPlanes defines the frustum planes to test
  104999. * @param selection defines the array to store current content if selection is positive
  105000. * @param allowDuplicate defines if the selection array can contains duplicated entries
  105001. */
  105002. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  105003. /**
  105004. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  105005. * @param sphereCenter defines the bounding sphere center
  105006. * @param sphereRadius defines the bounding sphere radius
  105007. * @param selection defines the array to store current content if selection is positive
  105008. * @param allowDuplicate defines if the selection array can contains duplicated entries
  105009. */
  105010. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  105011. /**
  105012. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  105013. * @param ray defines the ray to test with
  105014. * @param selection defines the array to store current content if selection is positive
  105015. */
  105016. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  105017. /**
  105018. * Subdivide the content into child blocks (this block will then be empty)
  105019. */
  105020. createInnerBlocks(): void;
  105021. /**
  105022. * @hidden
  105023. */
  105024. 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;
  105025. }
  105026. }
  105027. declare module BABYLON {
  105028. /**
  105029. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  105030. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  105031. */
  105032. export class Octree<T> {
  105033. /** 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.) */
  105034. maxDepth: number;
  105035. /**
  105036. * Blocks within the octree containing objects
  105037. */
  105038. blocks: Array<OctreeBlock<T>>;
  105039. /**
  105040. * Content stored in the octree
  105041. */
  105042. dynamicContent: T[];
  105043. private _maxBlockCapacity;
  105044. private _selectionContent;
  105045. private _creationFunc;
  105046. /**
  105047. * Creates a octree
  105048. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  105049. * @param creationFunc function to be used to instatiate the octree
  105050. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  105051. * @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.)
  105052. */
  105053. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  105054. /** 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.) */
  105055. maxDepth?: number);
  105056. /**
  105057. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  105058. * @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);
  105059. * @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);
  105060. * @param entries meshes to be added to the octree blocks
  105061. */
  105062. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  105063. /**
  105064. * Adds a mesh to the octree
  105065. * @param entry Mesh to add to the octree
  105066. */
  105067. addMesh(entry: T): void;
  105068. /**
  105069. * Remove an element from the octree
  105070. * @param entry defines the element to remove
  105071. */
  105072. removeMesh(entry: T): void;
  105073. /**
  105074. * Selects an array of meshes within the frustum
  105075. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  105076. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  105077. * @returns array of meshes within the frustum
  105078. */
  105079. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  105080. /**
  105081. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  105082. * @param sphereCenter defines the bounding sphere center
  105083. * @param sphereRadius defines the bounding sphere radius
  105084. * @param allowDuplicate defines if the selection array can contains duplicated entries
  105085. * @returns an array of objects that intersect the sphere
  105086. */
  105087. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  105088. /**
  105089. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  105090. * @param ray defines the ray to test with
  105091. * @returns array of intersected objects
  105092. */
  105093. intersectsRay(ray: Ray): SmartArray<T>;
  105094. /**
  105095. * Adds a mesh into the octree block if it intersects the block
  105096. */
  105097. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  105098. /**
  105099. * Adds a submesh into the octree block if it intersects the block
  105100. */
  105101. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  105102. }
  105103. }
  105104. declare module BABYLON {
  105105. interface Scene {
  105106. /**
  105107. * @hidden
  105108. * Backing Filed
  105109. */
  105110. _selectionOctree: Octree<AbstractMesh>;
  105111. /**
  105112. * Gets the octree used to boost mesh selection (picking)
  105113. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  105114. */
  105115. selectionOctree: Octree<AbstractMesh>;
  105116. /**
  105117. * Creates or updates the octree used to boost selection (picking)
  105118. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  105119. * @param maxCapacity defines the maximum capacity per leaf
  105120. * @param maxDepth defines the maximum depth of the octree
  105121. * @returns an octree of AbstractMesh
  105122. */
  105123. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  105124. }
  105125. interface AbstractMesh {
  105126. /**
  105127. * @hidden
  105128. * Backing Field
  105129. */
  105130. _submeshesOctree: Octree<SubMesh>;
  105131. /**
  105132. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  105133. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  105134. * @param maxCapacity defines the maximum size of each block (64 by default)
  105135. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  105136. * @returns the new octree
  105137. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  105138. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  105139. */
  105140. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  105141. }
  105142. /**
  105143. * Defines the octree scene component responsible to manage any octrees
  105144. * in a given scene.
  105145. */
  105146. export class OctreeSceneComponent {
  105147. /**
  105148. * The component name help to identify the component in the list of scene components.
  105149. */
  105150. readonly name: string;
  105151. /**
  105152. * The scene the component belongs to.
  105153. */
  105154. scene: Scene;
  105155. /**
  105156. * Indicates if the meshes have been checked to make sure they are isEnabled()
  105157. */
  105158. readonly checksIsEnabled: boolean;
  105159. /**
  105160. * Creates a new instance of the component for the given scene
  105161. * @param scene Defines the scene to register the component in
  105162. */
  105163. constructor(scene: Scene);
  105164. /**
  105165. * Registers the component in a given scene
  105166. */
  105167. register(): void;
  105168. /**
  105169. * Return the list of active meshes
  105170. * @returns the list of active meshes
  105171. */
  105172. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  105173. /**
  105174. * Return the list of active sub meshes
  105175. * @param mesh The mesh to get the candidates sub meshes from
  105176. * @returns the list of active sub meshes
  105177. */
  105178. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  105179. private _tempRay;
  105180. /**
  105181. * Return the list of sub meshes intersecting with a given local ray
  105182. * @param mesh defines the mesh to find the submesh for
  105183. * @param localRay defines the ray in local space
  105184. * @returns the list of intersecting sub meshes
  105185. */
  105186. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  105187. /**
  105188. * Return the list of sub meshes colliding with a collider
  105189. * @param mesh defines the mesh to find the submesh for
  105190. * @param collider defines the collider to evaluate the collision against
  105191. * @returns the list of colliding sub meshes
  105192. */
  105193. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  105194. /**
  105195. * Rebuilds the elements related to this component in case of
  105196. * context lost for instance.
  105197. */
  105198. rebuild(): void;
  105199. /**
  105200. * Disposes the component and the associated ressources.
  105201. */
  105202. dispose(): void;
  105203. }
  105204. }
  105205. declare module BABYLON {
  105206. /**
  105207. * Renders a layer on top of an existing scene
  105208. */
  105209. export class UtilityLayerRenderer implements IDisposable {
  105210. /** the original scene that will be rendered on top of */
  105211. originalScene: Scene;
  105212. private _pointerCaptures;
  105213. private _lastPointerEvents;
  105214. private static _DefaultUtilityLayer;
  105215. private static _DefaultKeepDepthUtilityLayer;
  105216. private _sharedGizmoLight;
  105217. private _renderCamera;
  105218. /**
  105219. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  105220. * @returns the camera that is used when rendering the utility layer
  105221. */
  105222. getRenderCamera(): Nullable<Camera>;
  105223. /**
  105224. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  105225. * @param cam the camera that should be used when rendering the utility layer
  105226. */
  105227. setRenderCamera(cam: Nullable<Camera>): void;
  105228. /**
  105229. * @hidden
  105230. * Light which used by gizmos to get light shading
  105231. */
  105232. _getSharedGizmoLight(): HemisphericLight;
  105233. /**
  105234. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  105235. */
  105236. pickUtilitySceneFirst: boolean;
  105237. /**
  105238. * 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)
  105239. */
  105240. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  105241. /**
  105242. * 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)
  105243. */
  105244. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  105245. /**
  105246. * The scene that is rendered on top of the original scene
  105247. */
  105248. utilityLayerScene: Scene;
  105249. /**
  105250. * If the utility layer should automatically be rendered on top of existing scene
  105251. */
  105252. shouldRender: boolean;
  105253. /**
  105254. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  105255. */
  105256. onlyCheckPointerDownEvents: boolean;
  105257. /**
  105258. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  105259. */
  105260. processAllEvents: boolean;
  105261. /**
  105262. * Observable raised when the pointer move from the utility layer scene to the main scene
  105263. */
  105264. onPointerOutObservable: Observable<number>;
  105265. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  105266. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  105267. private _afterRenderObserver;
  105268. private _sceneDisposeObserver;
  105269. private _originalPointerObserver;
  105270. /**
  105271. * Instantiates a UtilityLayerRenderer
  105272. * @param originalScene the original scene that will be rendered on top of
  105273. * @param handleEvents boolean indicating if the utility layer should handle events
  105274. */
  105275. constructor(
  105276. /** the original scene that will be rendered on top of */
  105277. originalScene: Scene, handleEvents?: boolean);
  105278. private _notifyObservers;
  105279. /**
  105280. * Renders the utility layers scene on top of the original scene
  105281. */
  105282. render(): void;
  105283. /**
  105284. * Disposes of the renderer
  105285. */
  105286. dispose(): void;
  105287. private _updateCamera;
  105288. }
  105289. }
  105290. declare module BABYLON {
  105291. /**
  105292. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  105293. */
  105294. export class Gizmo implements IDisposable {
  105295. /** The utility layer the gizmo will be added to */
  105296. gizmoLayer: UtilityLayerRenderer;
  105297. /**
  105298. * The root mesh of the gizmo
  105299. */
  105300. _rootMesh: Mesh;
  105301. private _attachedMesh;
  105302. /**
  105303. * Ratio for the scale of the gizmo (Default: 1)
  105304. */
  105305. scaleRatio: number;
  105306. /**
  105307. * If a custom mesh has been set (Default: false)
  105308. */
  105309. protected _customMeshSet: boolean;
  105310. /**
  105311. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  105312. * * When set, interactions will be enabled
  105313. */
  105314. attachedMesh: Nullable<AbstractMesh>;
  105315. /**
  105316. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  105317. * @param mesh The mesh to replace the default mesh of the gizmo
  105318. */
  105319. setCustomMesh(mesh: Mesh): void;
  105320. /**
  105321. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  105322. */
  105323. updateGizmoRotationToMatchAttachedMesh: boolean;
  105324. /**
  105325. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  105326. */
  105327. updateGizmoPositionToMatchAttachedMesh: boolean;
  105328. /**
  105329. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  105330. */
  105331. updateScale: boolean;
  105332. protected _interactionsEnabled: boolean;
  105333. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  105334. private _beforeRenderObserver;
  105335. private _tempVector;
  105336. /**
  105337. * Creates a gizmo
  105338. * @param gizmoLayer The utility layer the gizmo will be added to
  105339. */
  105340. constructor(
  105341. /** The utility layer the gizmo will be added to */
  105342. gizmoLayer?: UtilityLayerRenderer);
  105343. /**
  105344. * Updates the gizmo to match the attached mesh's position/rotation
  105345. */
  105346. protected _update(): void;
  105347. /**
  105348. * Disposes of the gizmo
  105349. */
  105350. dispose(): void;
  105351. }
  105352. }
  105353. declare module BABYLON {
  105354. /**
  105355. * Single plane drag gizmo
  105356. */
  105357. export class PlaneDragGizmo extends Gizmo {
  105358. /**
  105359. * Drag behavior responsible for the gizmos dragging interactions
  105360. */
  105361. dragBehavior: PointerDragBehavior;
  105362. private _pointerObserver;
  105363. /**
  105364. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  105365. */
  105366. snapDistance: number;
  105367. /**
  105368. * Event that fires each time the gizmo snaps to a new location.
  105369. * * snapDistance is the the change in distance
  105370. */
  105371. onSnapObservable: Observable<{
  105372. snapDistance: number;
  105373. }>;
  105374. private _plane;
  105375. private _coloredMaterial;
  105376. private _hoverMaterial;
  105377. private _isEnabled;
  105378. private _parent;
  105379. /** @hidden */
  105380. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  105381. /** @hidden */
  105382. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  105383. /**
  105384. * Creates a PlaneDragGizmo
  105385. * @param gizmoLayer The utility layer the gizmo will be added to
  105386. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  105387. * @param color The color of the gizmo
  105388. */
  105389. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  105390. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  105391. /**
  105392. * If the gizmo is enabled
  105393. */
  105394. isEnabled: boolean;
  105395. /**
  105396. * Disposes of the gizmo
  105397. */
  105398. dispose(): void;
  105399. }
  105400. }
  105401. declare module BABYLON {
  105402. /**
  105403. * Gizmo that enables dragging a mesh along 3 axis
  105404. */
  105405. export class PositionGizmo extends Gizmo {
  105406. /**
  105407. * Internal gizmo used for interactions on the x axis
  105408. */
  105409. xGizmo: AxisDragGizmo;
  105410. /**
  105411. * Internal gizmo used for interactions on the y axis
  105412. */
  105413. yGizmo: AxisDragGizmo;
  105414. /**
  105415. * Internal gizmo used for interactions on the z axis
  105416. */
  105417. zGizmo: AxisDragGizmo;
  105418. /**
  105419. * Internal gizmo used for interactions on the yz plane
  105420. */
  105421. xPlaneGizmo: PlaneDragGizmo;
  105422. /**
  105423. * Internal gizmo used for interactions on the xz plane
  105424. */
  105425. yPlaneGizmo: PlaneDragGizmo;
  105426. /**
  105427. * Internal gizmo used for interactions on the xy plane
  105428. */
  105429. zPlaneGizmo: PlaneDragGizmo;
  105430. /**
  105431. * private variables
  105432. */
  105433. private _meshAttached;
  105434. private _updateGizmoRotationToMatchAttachedMesh;
  105435. private _snapDistance;
  105436. private _scaleRatio;
  105437. /** Fires an event when any of it's sub gizmos are dragged */
  105438. onDragStartObservable: Observable<unknown>;
  105439. /** Fires an event when any of it's sub gizmos are released from dragging */
  105440. onDragEndObservable: Observable<unknown>;
  105441. /**
  105442. * If set to true, planar drag is enabled
  105443. */
  105444. private _planarGizmoEnabled;
  105445. attachedMesh: Nullable<AbstractMesh>;
  105446. /**
  105447. * Creates a PositionGizmo
  105448. * @param gizmoLayer The utility layer the gizmo will be added to
  105449. */
  105450. constructor(gizmoLayer?: UtilityLayerRenderer);
  105451. /**
  105452. * If the planar drag gizmo is enabled
  105453. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  105454. */
  105455. planarGizmoEnabled: boolean;
  105456. updateGizmoRotationToMatchAttachedMesh: boolean;
  105457. /**
  105458. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  105459. */
  105460. snapDistance: number;
  105461. /**
  105462. * Ratio for the scale of the gizmo (Default: 1)
  105463. */
  105464. scaleRatio: number;
  105465. /**
  105466. * Disposes of the gizmo
  105467. */
  105468. dispose(): void;
  105469. /**
  105470. * CustomMeshes are not supported by this gizmo
  105471. * @param mesh The mesh to replace the default mesh of the gizmo
  105472. */
  105473. setCustomMesh(mesh: Mesh): void;
  105474. }
  105475. }
  105476. declare module BABYLON {
  105477. /**
  105478. * Single axis drag gizmo
  105479. */
  105480. export class AxisDragGizmo extends Gizmo {
  105481. /**
  105482. * Drag behavior responsible for the gizmos dragging interactions
  105483. */
  105484. dragBehavior: PointerDragBehavior;
  105485. private _pointerObserver;
  105486. /**
  105487. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  105488. */
  105489. snapDistance: number;
  105490. /**
  105491. * Event that fires each time the gizmo snaps to a new location.
  105492. * * snapDistance is the the change in distance
  105493. */
  105494. onSnapObservable: Observable<{
  105495. snapDistance: number;
  105496. }>;
  105497. private _isEnabled;
  105498. private _parent;
  105499. private _arrow;
  105500. private _coloredMaterial;
  105501. private _hoverMaterial;
  105502. /** @hidden */
  105503. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  105504. /** @hidden */
  105505. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  105506. /**
  105507. * Creates an AxisDragGizmo
  105508. * @param gizmoLayer The utility layer the gizmo will be added to
  105509. * @param dragAxis The axis which the gizmo will be able to drag on
  105510. * @param color The color of the gizmo
  105511. */
  105512. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  105513. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  105514. /**
  105515. * If the gizmo is enabled
  105516. */
  105517. isEnabled: boolean;
  105518. /**
  105519. * Disposes of the gizmo
  105520. */
  105521. dispose(): void;
  105522. }
  105523. }
  105524. declare module BABYLON.Debug {
  105525. /**
  105526. * The Axes viewer will show 3 axes in a specific point in space
  105527. */
  105528. export class AxesViewer {
  105529. private _xAxis;
  105530. private _yAxis;
  105531. private _zAxis;
  105532. private _scaleLinesFactor;
  105533. private _instanced;
  105534. /**
  105535. * Gets the hosting scene
  105536. */
  105537. scene: Scene;
  105538. /**
  105539. * Gets or sets a number used to scale line length
  105540. */
  105541. scaleLines: number;
  105542. /** Gets the node hierarchy used to render x-axis */
  105543. readonly xAxis: TransformNode;
  105544. /** Gets the node hierarchy used to render y-axis */
  105545. readonly yAxis: TransformNode;
  105546. /** Gets the node hierarchy used to render z-axis */
  105547. readonly zAxis: TransformNode;
  105548. /**
  105549. * Creates a new AxesViewer
  105550. * @param scene defines the hosting scene
  105551. * @param scaleLines defines a number used to scale line length (1 by default)
  105552. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  105553. * @param xAxis defines the node hierarchy used to render the x-axis
  105554. * @param yAxis defines the node hierarchy used to render the y-axis
  105555. * @param zAxis defines the node hierarchy used to render the z-axis
  105556. */
  105557. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  105558. /**
  105559. * Force the viewer to update
  105560. * @param position defines the position of the viewer
  105561. * @param xaxis defines the x axis of the viewer
  105562. * @param yaxis defines the y axis of the viewer
  105563. * @param zaxis defines the z axis of the viewer
  105564. */
  105565. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  105566. /**
  105567. * Creates an instance of this axes viewer.
  105568. * @returns a new axes viewer with instanced meshes
  105569. */
  105570. createInstance(): AxesViewer;
  105571. /** Releases resources */
  105572. dispose(): void;
  105573. private static _SetRenderingGroupId;
  105574. }
  105575. }
  105576. declare module BABYLON.Debug {
  105577. /**
  105578. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  105579. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  105580. */
  105581. export class BoneAxesViewer extends AxesViewer {
  105582. /**
  105583. * Gets or sets the target mesh where to display the axes viewer
  105584. */
  105585. mesh: Nullable<Mesh>;
  105586. /**
  105587. * Gets or sets the target bone where to display the axes viewer
  105588. */
  105589. bone: Nullable<Bone>;
  105590. /** Gets current position */
  105591. pos: Vector3;
  105592. /** Gets direction of X axis */
  105593. xaxis: Vector3;
  105594. /** Gets direction of Y axis */
  105595. yaxis: Vector3;
  105596. /** Gets direction of Z axis */
  105597. zaxis: Vector3;
  105598. /**
  105599. * Creates a new BoneAxesViewer
  105600. * @param scene defines the hosting scene
  105601. * @param bone defines the target bone
  105602. * @param mesh defines the target mesh
  105603. * @param scaleLines defines a scaling factor for line length (1 by default)
  105604. */
  105605. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  105606. /**
  105607. * Force the viewer to update
  105608. */
  105609. update(): void;
  105610. /** Releases resources */
  105611. dispose(): void;
  105612. }
  105613. }
  105614. declare module BABYLON {
  105615. /**
  105616. * Interface used to define scene explorer extensibility option
  105617. */
  105618. export interface IExplorerExtensibilityOption {
  105619. /**
  105620. * Define the option label
  105621. */
  105622. label: string;
  105623. /**
  105624. * Defines the action to execute on click
  105625. */
  105626. action: (entity: any) => void;
  105627. }
  105628. /**
  105629. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  105630. */
  105631. export interface IExplorerExtensibilityGroup {
  105632. /**
  105633. * Defines a predicate to test if a given type mut be extended
  105634. */
  105635. predicate: (entity: any) => boolean;
  105636. /**
  105637. * Gets the list of options added to a type
  105638. */
  105639. entries: IExplorerExtensibilityOption[];
  105640. }
  105641. /**
  105642. * Interface used to define the options to use to create the Inspector
  105643. */
  105644. export interface IInspectorOptions {
  105645. /**
  105646. * Display in overlay mode (default: false)
  105647. */
  105648. overlay?: boolean;
  105649. /**
  105650. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  105651. */
  105652. globalRoot?: HTMLElement;
  105653. /**
  105654. * Display the Scene explorer
  105655. */
  105656. showExplorer?: boolean;
  105657. /**
  105658. * Display the property inspector
  105659. */
  105660. showInspector?: boolean;
  105661. /**
  105662. * Display in embed mode (both panes on the right)
  105663. */
  105664. embedMode?: boolean;
  105665. /**
  105666. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  105667. */
  105668. handleResize?: boolean;
  105669. /**
  105670. * Allow the panes to popup (default: true)
  105671. */
  105672. enablePopup?: boolean;
  105673. /**
  105674. * Allow the panes to be closed by users (default: true)
  105675. */
  105676. enableClose?: boolean;
  105677. /**
  105678. * Optional list of extensibility entries
  105679. */
  105680. explorerExtensibility?: IExplorerExtensibilityGroup[];
  105681. /**
  105682. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  105683. */
  105684. inspectorURL?: string;
  105685. }
  105686. interface Scene {
  105687. /**
  105688. * @hidden
  105689. * Backing field
  105690. */
  105691. _debugLayer: DebugLayer;
  105692. /**
  105693. * Gets the debug layer (aka Inspector) associated with the scene
  105694. * @see http://doc.babylonjs.com/features/playground_debuglayer
  105695. */
  105696. debugLayer: DebugLayer;
  105697. }
  105698. /**
  105699. * The debug layer (aka Inspector) is the go to tool in order to better understand
  105700. * what is happening in your scene
  105701. * @see http://doc.babylonjs.com/features/playground_debuglayer
  105702. */
  105703. export class DebugLayer {
  105704. /**
  105705. * Define the url to get the inspector script from.
  105706. * By default it uses the babylonjs CDN.
  105707. * @ignoreNaming
  105708. */
  105709. static InspectorURL: string;
  105710. private _scene;
  105711. private BJSINSPECTOR;
  105712. private _onPropertyChangedObservable?;
  105713. /**
  105714. * Observable triggered when a property is changed through the inspector.
  105715. */
  105716. readonly onPropertyChangedObservable: any;
  105717. /**
  105718. * Instantiates a new debug layer.
  105719. * The debug layer (aka Inspector) is the go to tool in order to better understand
  105720. * what is happening in your scene
  105721. * @see http://doc.babylonjs.com/features/playground_debuglayer
  105722. * @param scene Defines the scene to inspect
  105723. */
  105724. constructor(scene: Scene);
  105725. /** Creates the inspector window. */
  105726. private _createInspector;
  105727. /**
  105728. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  105729. * @param entity defines the entity to select
  105730. * @param lineContainerTitle defines the specific block to highlight
  105731. */
  105732. select(entity: any, lineContainerTitle?: string): void;
  105733. /** Get the inspector from bundle or global */
  105734. private _getGlobalInspector;
  105735. /**
  105736. * Get if the inspector is visible or not.
  105737. * @returns true if visible otherwise, false
  105738. */
  105739. isVisible(): boolean;
  105740. /**
  105741. * Hide the inspector and close its window.
  105742. */
  105743. hide(): void;
  105744. /**
  105745. * Launch the debugLayer.
  105746. * @param config Define the configuration of the inspector
  105747. * @return a promise fulfilled when the debug layer is visible
  105748. */
  105749. show(config?: IInspectorOptions): Promise<DebugLayer>;
  105750. }
  105751. }
  105752. declare module BABYLON {
  105753. /**
  105754. * Class containing static functions to help procedurally build meshes
  105755. */
  105756. export class BoxBuilder {
  105757. /**
  105758. * Creates a box mesh
  105759. * * The parameter `size` sets the size (float) of each box side (default 1)
  105760. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  105761. * * 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)
  105762. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  105763. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105764. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105765. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105766. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  105767. * @param name defines the name of the mesh
  105768. * @param options defines the options used to create the mesh
  105769. * @param scene defines the hosting scene
  105770. * @returns the box mesh
  105771. */
  105772. static CreateBox(name: string, options: {
  105773. size?: number;
  105774. width?: number;
  105775. height?: number;
  105776. depth?: number;
  105777. faceUV?: Vector4[];
  105778. faceColors?: Color4[];
  105779. sideOrientation?: number;
  105780. frontUVs?: Vector4;
  105781. backUVs?: Vector4;
  105782. wrap?: boolean;
  105783. topBaseAt?: number;
  105784. bottomBaseAt?: number;
  105785. updatable?: boolean;
  105786. }, scene?: Nullable<Scene>): Mesh;
  105787. }
  105788. }
  105789. declare module BABYLON {
  105790. /**
  105791. * Class containing static functions to help procedurally build meshes
  105792. */
  105793. export class SphereBuilder {
  105794. /**
  105795. * Creates a sphere mesh
  105796. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  105797. * * 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`)
  105798. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  105799. * * 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
  105800. * * 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)
  105801. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105802. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105803. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105804. * @param name defines the name of the mesh
  105805. * @param options defines the options used to create the mesh
  105806. * @param scene defines the hosting scene
  105807. * @returns the sphere mesh
  105808. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  105809. */
  105810. static CreateSphere(name: string, options: {
  105811. segments?: number;
  105812. diameter?: number;
  105813. diameterX?: number;
  105814. diameterY?: number;
  105815. diameterZ?: number;
  105816. arc?: number;
  105817. slice?: number;
  105818. sideOrientation?: number;
  105819. frontUVs?: Vector4;
  105820. backUVs?: Vector4;
  105821. updatable?: boolean;
  105822. }, scene: any): Mesh;
  105823. }
  105824. }
  105825. declare module BABYLON.Debug {
  105826. /**
  105827. * Used to show the physics impostor around the specific mesh
  105828. */
  105829. export class PhysicsViewer {
  105830. /** @hidden */
  105831. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  105832. /** @hidden */
  105833. protected _meshes: Array<Nullable<AbstractMesh>>;
  105834. /** @hidden */
  105835. protected _scene: Nullable<Scene>;
  105836. /** @hidden */
  105837. protected _numMeshes: number;
  105838. /** @hidden */
  105839. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  105840. private _renderFunction;
  105841. private _utilityLayer;
  105842. private _debugBoxMesh;
  105843. private _debugSphereMesh;
  105844. private _debugCylinderMesh;
  105845. private _debugMaterial;
  105846. private _debugMeshMeshes;
  105847. /**
  105848. * Creates a new PhysicsViewer
  105849. * @param scene defines the hosting scene
  105850. */
  105851. constructor(scene: Scene);
  105852. /** @hidden */
  105853. protected _updateDebugMeshes(): void;
  105854. /**
  105855. * Renders a specified physic impostor
  105856. * @param impostor defines the impostor to render
  105857. * @param targetMesh defines the mesh represented by the impostor
  105858. * @returns the new debug mesh used to render the impostor
  105859. */
  105860. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  105861. /**
  105862. * Hides a specified physic impostor
  105863. * @param impostor defines the impostor to hide
  105864. */
  105865. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  105866. private _getDebugMaterial;
  105867. private _getDebugBoxMesh;
  105868. private _getDebugSphereMesh;
  105869. private _getDebugCylinderMesh;
  105870. private _getDebugMeshMesh;
  105871. private _getDebugMesh;
  105872. /** Releases all resources */
  105873. dispose(): void;
  105874. }
  105875. }
  105876. declare module BABYLON {
  105877. /**
  105878. * Class containing static functions to help procedurally build meshes
  105879. */
  105880. export class LinesBuilder {
  105881. /**
  105882. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  105883. * * 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
  105884. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  105885. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  105886. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  105887. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  105888. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  105889. * * 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
  105890. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  105891. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105892. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  105893. * @param name defines the name of the new line system
  105894. * @param options defines the options used to create the line system
  105895. * @param scene defines the hosting scene
  105896. * @returns a new line system mesh
  105897. */
  105898. static CreateLineSystem(name: string, options: {
  105899. lines: Vector3[][];
  105900. updatable?: boolean;
  105901. instance?: Nullable<LinesMesh>;
  105902. colors?: Nullable<Color4[][]>;
  105903. useVertexAlpha?: boolean;
  105904. }, scene: Nullable<Scene>): LinesMesh;
  105905. /**
  105906. * Creates a line mesh
  105907. * 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
  105908. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  105909. * * The parameter `points` is an array successive Vector3
  105910. * * 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
  105911. * * The optional parameter `colors` is an array of successive Color4, one per line point
  105912. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  105913. * * When updating an instance, remember that only point positions can change, not the number of points
  105914. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105915. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  105916. * @param name defines the name of the new line system
  105917. * @param options defines the options used to create the line system
  105918. * @param scene defines the hosting scene
  105919. * @returns a new line mesh
  105920. */
  105921. static CreateLines(name: string, options: {
  105922. points: Vector3[];
  105923. updatable?: boolean;
  105924. instance?: Nullable<LinesMesh>;
  105925. colors?: Color4[];
  105926. useVertexAlpha?: boolean;
  105927. }, scene?: Nullable<Scene>): LinesMesh;
  105928. /**
  105929. * Creates a dashed line mesh
  105930. * * 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
  105931. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  105932. * * The parameter `points` is an array successive Vector3
  105933. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  105934. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  105935. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  105936. * * 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
  105937. * * When updating an instance, remember that only point positions can change, not the number of points
  105938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105939. * @param name defines the name of the mesh
  105940. * @param options defines the options used to create the mesh
  105941. * @param scene defines the hosting scene
  105942. * @returns the dashed line mesh
  105943. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  105944. */
  105945. static CreateDashedLines(name: string, options: {
  105946. points: Vector3[];
  105947. dashSize?: number;
  105948. gapSize?: number;
  105949. dashNb?: number;
  105950. updatable?: boolean;
  105951. instance?: LinesMesh;
  105952. }, scene?: Nullable<Scene>): LinesMesh;
  105953. }
  105954. }
  105955. declare module BABYLON {
  105956. /**
  105957. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  105958. * in order to better appreciate the issue one might have.
  105959. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  105960. */
  105961. export class RayHelper {
  105962. /**
  105963. * Defines the ray we are currently tryin to visualize.
  105964. */
  105965. ray: Nullable<Ray>;
  105966. private _renderPoints;
  105967. private _renderLine;
  105968. private _renderFunction;
  105969. private _scene;
  105970. private _updateToMeshFunction;
  105971. private _attachedToMesh;
  105972. private _meshSpaceDirection;
  105973. private _meshSpaceOrigin;
  105974. /**
  105975. * Helper function to create a colored helper in a scene in one line.
  105976. * @param ray Defines the ray we are currently tryin to visualize
  105977. * @param scene Defines the scene the ray is used in
  105978. * @param color Defines the color we want to see the ray in
  105979. * @returns The newly created ray helper.
  105980. */
  105981. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  105982. /**
  105983. * Instantiate a new ray helper.
  105984. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  105985. * in order to better appreciate the issue one might have.
  105986. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  105987. * @param ray Defines the ray we are currently tryin to visualize
  105988. */
  105989. constructor(ray: Ray);
  105990. /**
  105991. * Shows the ray we are willing to debug.
  105992. * @param scene Defines the scene the ray needs to be rendered in
  105993. * @param color Defines the color the ray needs to be rendered in
  105994. */
  105995. show(scene: Scene, color?: Color3): void;
  105996. /**
  105997. * Hides the ray we are debugging.
  105998. */
  105999. hide(): void;
  106000. private _render;
  106001. /**
  106002. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  106003. * @param mesh Defines the mesh we want the helper attached to
  106004. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  106005. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  106006. * @param length Defines the length of the ray
  106007. */
  106008. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  106009. /**
  106010. * Detach the ray helper from the mesh it has previously been attached to.
  106011. */
  106012. detachFromMesh(): void;
  106013. private _updateToMesh;
  106014. /**
  106015. * Dispose the helper and release its associated resources.
  106016. */
  106017. dispose(): void;
  106018. }
  106019. }
  106020. declare module BABYLON.Debug {
  106021. /**
  106022. * Class used to render a debug view of a given skeleton
  106023. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  106024. */
  106025. export class SkeletonViewer {
  106026. /** defines the skeleton to render */
  106027. skeleton: Skeleton;
  106028. /** defines the mesh attached to the skeleton */
  106029. mesh: AbstractMesh;
  106030. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  106031. autoUpdateBonesMatrices: boolean;
  106032. /** defines the rendering group id to use with the viewer */
  106033. renderingGroupId: number;
  106034. /** Gets or sets the color used to render the skeleton */
  106035. color: Color3;
  106036. private _scene;
  106037. private _debugLines;
  106038. private _debugMesh;
  106039. private _isEnabled;
  106040. private _renderFunction;
  106041. private _utilityLayer;
  106042. /**
  106043. * Returns the mesh used to render the bones
  106044. */
  106045. readonly debugMesh: Nullable<LinesMesh>;
  106046. /**
  106047. * Creates a new SkeletonViewer
  106048. * @param skeleton defines the skeleton to render
  106049. * @param mesh defines the mesh attached to the skeleton
  106050. * @param scene defines the hosting scene
  106051. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  106052. * @param renderingGroupId defines the rendering group id to use with the viewer
  106053. */
  106054. constructor(
  106055. /** defines the skeleton to render */
  106056. skeleton: Skeleton,
  106057. /** defines the mesh attached to the skeleton */
  106058. mesh: AbstractMesh, scene: Scene,
  106059. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  106060. autoUpdateBonesMatrices?: boolean,
  106061. /** defines the rendering group id to use with the viewer */
  106062. renderingGroupId?: number);
  106063. /** Gets or sets a boolean indicating if the viewer is enabled */
  106064. isEnabled: boolean;
  106065. private _getBonePosition;
  106066. private _getLinesForBonesWithLength;
  106067. private _getLinesForBonesNoLength;
  106068. /** Update the viewer to sync with current skeleton state */
  106069. update(): void;
  106070. /** Release associated resources */
  106071. dispose(): void;
  106072. }
  106073. }
  106074. declare module BABYLON {
  106075. /**
  106076. * Options to create the null engine
  106077. */
  106078. export class NullEngineOptions {
  106079. /**
  106080. * Render width (Default: 512)
  106081. */
  106082. renderWidth: number;
  106083. /**
  106084. * Render height (Default: 256)
  106085. */
  106086. renderHeight: number;
  106087. /**
  106088. * Texture size (Default: 512)
  106089. */
  106090. textureSize: number;
  106091. /**
  106092. * If delta time between frames should be constant
  106093. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106094. */
  106095. deterministicLockstep: boolean;
  106096. /**
  106097. * Maximum about of steps between frames (Default: 4)
  106098. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106099. */
  106100. lockstepMaxSteps: number;
  106101. }
  106102. /**
  106103. * The null engine class provides support for headless version of babylon.js.
  106104. * This can be used in server side scenario or for testing purposes
  106105. */
  106106. export class NullEngine extends Engine {
  106107. private _options;
  106108. /**
  106109. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106110. */
  106111. isDeterministicLockStep(): boolean;
  106112. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  106113. getLockstepMaxSteps(): number;
  106114. /**
  106115. * Sets hardware scaling, used to save performance if needed
  106116. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  106117. */
  106118. getHardwareScalingLevel(): number;
  106119. constructor(options?: NullEngineOptions);
  106120. createVertexBuffer(vertices: FloatArray): DataBuffer;
  106121. createIndexBuffer(indices: IndicesArray): DataBuffer;
  106122. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  106123. getRenderWidth(useScreen?: boolean): number;
  106124. getRenderHeight(useScreen?: boolean): number;
  106125. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  106126. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  106127. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  106128. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  106129. bindSamplers(effect: Effect): void;
  106130. enableEffect(effect: Effect): void;
  106131. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  106132. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  106133. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  106134. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  106135. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  106136. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  106137. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  106138. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  106139. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  106140. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  106141. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  106142. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  106143. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  106144. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  106145. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  106146. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  106147. setFloat(uniform: WebGLUniformLocation, value: number): void;
  106148. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  106149. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  106150. setBool(uniform: WebGLUniformLocation, bool: number): void;
  106151. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  106152. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  106153. bindBuffers(vertexBuffers: {
  106154. [key: string]: VertexBuffer;
  106155. }, indexBuffer: DataBuffer, effect: Effect): void;
  106156. wipeCaches(bruteForce?: boolean): void;
  106157. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  106158. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  106159. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  106160. /** @hidden */
  106161. _createTexture(): WebGLTexture;
  106162. /** @hidden */
  106163. _releaseTexture(texture: InternalTexture): void;
  106164. 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;
  106165. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  106166. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  106167. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  106168. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  106169. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  106170. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  106171. areAllEffectsReady(): boolean;
  106172. /**
  106173. * @hidden
  106174. * Get the current error code of the webGL context
  106175. * @returns the error code
  106176. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  106177. */
  106178. getError(): number;
  106179. /** @hidden */
  106180. _getUnpackAlignement(): number;
  106181. /** @hidden */
  106182. _unpackFlipY(value: boolean): void;
  106183. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  106184. /**
  106185. * Updates a dynamic vertex buffer.
  106186. * @param vertexBuffer the vertex buffer to update
  106187. * @param data the data used to update the vertex buffer
  106188. * @param byteOffset the byte offset of the data (optional)
  106189. * @param byteLength the byte length of the data (optional)
  106190. */
  106191. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  106192. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  106193. /** @hidden */
  106194. _bindTexture(channel: number, texture: InternalTexture): void;
  106195. /** @hidden */
  106196. _releaseBuffer(buffer: DataBuffer): boolean;
  106197. releaseEffects(): void;
  106198. displayLoadingUI(): void;
  106199. hideLoadingUI(): void;
  106200. /** @hidden */
  106201. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  106202. /** @hidden */
  106203. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  106204. /** @hidden */
  106205. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  106206. /** @hidden */
  106207. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  106208. }
  106209. }
  106210. declare module BABYLON {
  106211. /** @hidden */
  106212. export class _OcclusionDataStorage {
  106213. /** @hidden */
  106214. occlusionInternalRetryCounter: number;
  106215. /** @hidden */
  106216. isOcclusionQueryInProgress: boolean;
  106217. /** @hidden */
  106218. isOccluded: boolean;
  106219. /** @hidden */
  106220. occlusionRetryCount: number;
  106221. /** @hidden */
  106222. occlusionType: number;
  106223. /** @hidden */
  106224. occlusionQueryAlgorithmType: number;
  106225. }
  106226. interface Engine {
  106227. /**
  106228. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  106229. * @return the new query
  106230. */
  106231. createQuery(): WebGLQuery;
  106232. /**
  106233. * Delete and release a webGL query
  106234. * @param query defines the query to delete
  106235. * @return the current engine
  106236. */
  106237. deleteQuery(query: WebGLQuery): Engine;
  106238. /**
  106239. * Check if a given query has resolved and got its value
  106240. * @param query defines the query to check
  106241. * @returns true if the query got its value
  106242. */
  106243. isQueryResultAvailable(query: WebGLQuery): boolean;
  106244. /**
  106245. * Gets the value of a given query
  106246. * @param query defines the query to check
  106247. * @returns the value of the query
  106248. */
  106249. getQueryResult(query: WebGLQuery): number;
  106250. /**
  106251. * Initiates an occlusion query
  106252. * @param algorithmType defines the algorithm to use
  106253. * @param query defines the query to use
  106254. * @returns the current engine
  106255. * @see http://doc.babylonjs.com/features/occlusionquery
  106256. */
  106257. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  106258. /**
  106259. * Ends an occlusion query
  106260. * @see http://doc.babylonjs.com/features/occlusionquery
  106261. * @param algorithmType defines the algorithm to use
  106262. * @returns the current engine
  106263. */
  106264. endOcclusionQuery(algorithmType: number): Engine;
  106265. /**
  106266. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  106267. * Please note that only one query can be issued at a time
  106268. * @returns a time token used to track the time span
  106269. */
  106270. startTimeQuery(): Nullable<_TimeToken>;
  106271. /**
  106272. * Ends a time query
  106273. * @param token defines the token used to measure the time span
  106274. * @returns the time spent (in ns)
  106275. */
  106276. endTimeQuery(token: _TimeToken): int;
  106277. /** @hidden */
  106278. _currentNonTimestampToken: Nullable<_TimeToken>;
  106279. /** @hidden */
  106280. _createTimeQuery(): WebGLQuery;
  106281. /** @hidden */
  106282. _deleteTimeQuery(query: WebGLQuery): void;
  106283. /** @hidden */
  106284. _getGlAlgorithmType(algorithmType: number): number;
  106285. /** @hidden */
  106286. _getTimeQueryResult(query: WebGLQuery): any;
  106287. /** @hidden */
  106288. _getTimeQueryAvailability(query: WebGLQuery): any;
  106289. }
  106290. interface AbstractMesh {
  106291. /**
  106292. * Backing filed
  106293. * @hidden
  106294. */
  106295. __occlusionDataStorage: _OcclusionDataStorage;
  106296. /**
  106297. * Access property
  106298. * @hidden
  106299. */
  106300. _occlusionDataStorage: _OcclusionDataStorage;
  106301. /**
  106302. * 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.
  106303. * The default value is -1 which means don't break the query and wait till the result
  106304. * @see http://doc.babylonjs.com/features/occlusionquery
  106305. */
  106306. occlusionRetryCount: number;
  106307. /**
  106308. * 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:
  106309. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  106310. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  106311. * * 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.
  106312. * @see http://doc.babylonjs.com/features/occlusionquery
  106313. */
  106314. occlusionType: number;
  106315. /**
  106316. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  106317. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  106318. * * 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.
  106319. * @see http://doc.babylonjs.com/features/occlusionquery
  106320. */
  106321. occlusionQueryAlgorithmType: number;
  106322. /**
  106323. * 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
  106324. * @see http://doc.babylonjs.com/features/occlusionquery
  106325. */
  106326. isOccluded: boolean;
  106327. /**
  106328. * Flag to check the progress status of the query
  106329. * @see http://doc.babylonjs.com/features/occlusionquery
  106330. */
  106331. isOcclusionQueryInProgress: boolean;
  106332. }
  106333. }
  106334. declare module BABYLON {
  106335. /** @hidden */
  106336. export var _forceTransformFeedbackToBundle: boolean;
  106337. interface Engine {
  106338. /**
  106339. * Creates a webGL transform feedback object
  106340. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  106341. * @returns the webGL transform feedback object
  106342. */
  106343. createTransformFeedback(): WebGLTransformFeedback;
  106344. /**
  106345. * Delete a webGL transform feedback object
  106346. * @param value defines the webGL transform feedback object to delete
  106347. */
  106348. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  106349. /**
  106350. * Bind a webGL transform feedback object to the webgl context
  106351. * @param value defines the webGL transform feedback object to bind
  106352. */
  106353. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  106354. /**
  106355. * Begins a transform feedback operation
  106356. * @param usePoints defines if points or triangles must be used
  106357. */
  106358. beginTransformFeedback(usePoints: boolean): void;
  106359. /**
  106360. * Ends a transform feedback operation
  106361. */
  106362. endTransformFeedback(): void;
  106363. /**
  106364. * Specify the varyings to use with transform feedback
  106365. * @param program defines the associated webGL program
  106366. * @param value defines the list of strings representing the varying names
  106367. */
  106368. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  106369. /**
  106370. * Bind a webGL buffer for a transform feedback operation
  106371. * @param value defines the webGL buffer to bind
  106372. */
  106373. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  106374. }
  106375. }
  106376. declare module BABYLON {
  106377. /**
  106378. * Creation options of the multi render target texture.
  106379. */
  106380. export interface IMultiRenderTargetOptions {
  106381. /**
  106382. * Define if the texture needs to create mip maps after render.
  106383. */
  106384. generateMipMaps?: boolean;
  106385. /**
  106386. * Define the types of all the draw buffers we want to create
  106387. */
  106388. types?: number[];
  106389. /**
  106390. * Define the sampling modes of all the draw buffers we want to create
  106391. */
  106392. samplingModes?: number[];
  106393. /**
  106394. * Define if a depth buffer is required
  106395. */
  106396. generateDepthBuffer?: boolean;
  106397. /**
  106398. * Define if a stencil buffer is required
  106399. */
  106400. generateStencilBuffer?: boolean;
  106401. /**
  106402. * Define if a depth texture is required instead of a depth buffer
  106403. */
  106404. generateDepthTexture?: boolean;
  106405. /**
  106406. * Define the number of desired draw buffers
  106407. */
  106408. textureCount?: number;
  106409. /**
  106410. * Define if aspect ratio should be adapted to the texture or stay the scene one
  106411. */
  106412. doNotChangeAspectRatio?: boolean;
  106413. /**
  106414. * Define the default type of the buffers we are creating
  106415. */
  106416. defaultType?: number;
  106417. }
  106418. /**
  106419. * A multi render target, like a render target provides the ability to render to a texture.
  106420. * Unlike the render target, it can render to several draw buffers in one draw.
  106421. * This is specially interesting in deferred rendering or for any effects requiring more than
  106422. * just one color from a single pass.
  106423. */
  106424. export class MultiRenderTarget extends RenderTargetTexture {
  106425. private _internalTextures;
  106426. private _textures;
  106427. private _multiRenderTargetOptions;
  106428. /**
  106429. * Get if draw buffers are currently supported by the used hardware and browser.
  106430. */
  106431. readonly isSupported: boolean;
  106432. /**
  106433. * Get the list of textures generated by the multi render target.
  106434. */
  106435. readonly textures: Texture[];
  106436. /**
  106437. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  106438. */
  106439. readonly depthTexture: Texture;
  106440. /**
  106441. * Set the wrapping mode on U of all the textures we are rendering to.
  106442. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  106443. */
  106444. wrapU: number;
  106445. /**
  106446. * Set the wrapping mode on V of all the textures we are rendering to.
  106447. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  106448. */
  106449. wrapV: number;
  106450. /**
  106451. * Instantiate a new multi render target texture.
  106452. * A multi render target, like a render target provides the ability to render to a texture.
  106453. * Unlike the render target, it can render to several draw buffers in one draw.
  106454. * This is specially interesting in deferred rendering or for any effects requiring more than
  106455. * just one color from a single pass.
  106456. * @param name Define the name of the texture
  106457. * @param size Define the size of the buffers to render to
  106458. * @param count Define the number of target we are rendering into
  106459. * @param scene Define the scene the texture belongs to
  106460. * @param options Define the options used to create the multi render target
  106461. */
  106462. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  106463. /** @hidden */
  106464. _rebuild(): void;
  106465. private _createInternalTextures;
  106466. private _createTextures;
  106467. /**
  106468. * Define the number of samples used if MSAA is enabled.
  106469. */
  106470. samples: number;
  106471. /**
  106472. * Resize all the textures in the multi render target.
  106473. * Be carrefull as it will recreate all the data in the new texture.
  106474. * @param size Define the new size
  106475. */
  106476. resize(size: any): void;
  106477. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  106478. /**
  106479. * Dispose the render targets and their associated resources
  106480. */
  106481. dispose(): void;
  106482. /**
  106483. * Release all the underlying texture used as draw buffers.
  106484. */
  106485. releaseInternalTextures(): void;
  106486. }
  106487. }
  106488. declare module BABYLON {
  106489. interface Engine {
  106490. /**
  106491. * Unbind a list of render target textures from the webGL context
  106492. * This is used only when drawBuffer extension or webGL2 are active
  106493. * @param textures defines the render target textures to unbind
  106494. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  106495. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  106496. */
  106497. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  106498. /**
  106499. * Create a multi render target texture
  106500. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  106501. * @param size defines the size of the texture
  106502. * @param options defines the creation options
  106503. * @returns the cube texture as an InternalTexture
  106504. */
  106505. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  106506. /**
  106507. * Update the sample count for a given multiple render target texture
  106508. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  106509. * @param textures defines the textures to update
  106510. * @param samples defines the sample count to set
  106511. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  106512. */
  106513. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  106514. }
  106515. }
  106516. declare module BABYLON {
  106517. /**
  106518. * Gather the list of clipboard event types as constants.
  106519. */
  106520. export class ClipboardEventTypes {
  106521. /**
  106522. * The clipboard event is fired when a copy command is active (pressed).
  106523. */
  106524. static readonly COPY: number;
  106525. /**
  106526. * The clipboard event is fired when a cut command is active (pressed).
  106527. */
  106528. static readonly CUT: number;
  106529. /**
  106530. * The clipboard event is fired when a paste command is active (pressed).
  106531. */
  106532. static readonly PASTE: number;
  106533. }
  106534. /**
  106535. * This class is used to store clipboard related info for the onClipboardObservable event.
  106536. */
  106537. export class ClipboardInfo {
  106538. /**
  106539. * Defines the type of event (BABYLON.ClipboardEventTypes)
  106540. */
  106541. type: number;
  106542. /**
  106543. * Defines the related dom event
  106544. */
  106545. event: ClipboardEvent;
  106546. /**
  106547. *Creates an instance of ClipboardInfo.
  106548. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  106549. * @param event Defines the related dom event
  106550. */
  106551. constructor(
  106552. /**
  106553. * Defines the type of event (BABYLON.ClipboardEventTypes)
  106554. */
  106555. type: number,
  106556. /**
  106557. * Defines the related dom event
  106558. */
  106559. event: ClipboardEvent);
  106560. /**
  106561. * Get the clipboard event's type from the keycode.
  106562. * @param keyCode Defines the keyCode for the current keyboard event.
  106563. * @return {number}
  106564. */
  106565. static GetTypeFromCharacter(keyCode: number): number;
  106566. }
  106567. }
  106568. declare module BABYLON {
  106569. /**
  106570. * Google Daydream controller
  106571. */
  106572. export class DaydreamController extends WebVRController {
  106573. /**
  106574. * Base Url for the controller model.
  106575. */
  106576. static MODEL_BASE_URL: string;
  106577. /**
  106578. * File name for the controller model.
  106579. */
  106580. static MODEL_FILENAME: string;
  106581. /**
  106582. * Gamepad Id prefix used to identify Daydream Controller.
  106583. */
  106584. static readonly GAMEPAD_ID_PREFIX: string;
  106585. /**
  106586. * Creates a new DaydreamController from a gamepad
  106587. * @param vrGamepad the gamepad that the controller should be created from
  106588. */
  106589. constructor(vrGamepad: any);
  106590. /**
  106591. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  106592. * @param scene scene in which to add meshes
  106593. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  106594. */
  106595. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  106596. /**
  106597. * Called once for each button that changed state since the last frame
  106598. * @param buttonIdx Which button index changed
  106599. * @param state New state of the button
  106600. * @param changes Which properties on the state changed since last frame
  106601. */
  106602. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  106603. }
  106604. }
  106605. declare module BABYLON {
  106606. /**
  106607. * Gear VR Controller
  106608. */
  106609. export class GearVRController extends WebVRController {
  106610. /**
  106611. * Base Url for the controller model.
  106612. */
  106613. static MODEL_BASE_URL: string;
  106614. /**
  106615. * File name for the controller model.
  106616. */
  106617. static MODEL_FILENAME: string;
  106618. /**
  106619. * Gamepad Id prefix used to identify this controller.
  106620. */
  106621. static readonly GAMEPAD_ID_PREFIX: string;
  106622. private readonly _buttonIndexToObservableNameMap;
  106623. /**
  106624. * Creates a new GearVRController from a gamepad
  106625. * @param vrGamepad the gamepad that the controller should be created from
  106626. */
  106627. constructor(vrGamepad: any);
  106628. /**
  106629. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  106630. * @param scene scene in which to add meshes
  106631. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  106632. */
  106633. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  106634. /**
  106635. * Called once for each button that changed state since the last frame
  106636. * @param buttonIdx Which button index changed
  106637. * @param state New state of the button
  106638. * @param changes Which properties on the state changed since last frame
  106639. */
  106640. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  106641. }
  106642. }
  106643. declare module BABYLON {
  106644. /**
  106645. * Class containing static functions to help procedurally build meshes
  106646. */
  106647. export class PolyhedronBuilder {
  106648. /**
  106649. * Creates a polyhedron mesh
  106650. * * 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
  106651. * * The parameter `size` (positive float, default 1) sets the polygon size
  106652. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  106653. * * 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`
  106654. * * 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
  106655. * * 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)`)
  106656. * * 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
  106657. * * 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
  106658. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106659. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106661. * @param name defines the name of the mesh
  106662. * @param options defines the options used to create the mesh
  106663. * @param scene defines the hosting scene
  106664. * @returns the polyhedron mesh
  106665. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  106666. */
  106667. static CreatePolyhedron(name: string, options: {
  106668. type?: number;
  106669. size?: number;
  106670. sizeX?: number;
  106671. sizeY?: number;
  106672. sizeZ?: number;
  106673. custom?: any;
  106674. faceUV?: Vector4[];
  106675. faceColors?: Color4[];
  106676. flat?: boolean;
  106677. updatable?: boolean;
  106678. sideOrientation?: number;
  106679. frontUVs?: Vector4;
  106680. backUVs?: Vector4;
  106681. }, scene?: Nullable<Scene>): Mesh;
  106682. }
  106683. }
  106684. declare module BABYLON {
  106685. /**
  106686. * Gizmo that enables scaling a mesh along 3 axis
  106687. */
  106688. export class ScaleGizmo extends Gizmo {
  106689. /**
  106690. * Internal gizmo used for interactions on the x axis
  106691. */
  106692. xGizmo: AxisScaleGizmo;
  106693. /**
  106694. * Internal gizmo used for interactions on the y axis
  106695. */
  106696. yGizmo: AxisScaleGizmo;
  106697. /**
  106698. * Internal gizmo used for interactions on the z axis
  106699. */
  106700. zGizmo: AxisScaleGizmo;
  106701. /**
  106702. * Internal gizmo used to scale all axis equally
  106703. */
  106704. uniformScaleGizmo: AxisScaleGizmo;
  106705. private _meshAttached;
  106706. private _updateGizmoRotationToMatchAttachedMesh;
  106707. private _snapDistance;
  106708. private _scaleRatio;
  106709. private _uniformScalingMesh;
  106710. private _octahedron;
  106711. /** Fires an event when any of it's sub gizmos are dragged */
  106712. onDragStartObservable: Observable<unknown>;
  106713. /** Fires an event when any of it's sub gizmos are released from dragging */
  106714. onDragEndObservable: Observable<unknown>;
  106715. attachedMesh: Nullable<AbstractMesh>;
  106716. /**
  106717. * Creates a ScaleGizmo
  106718. * @param gizmoLayer The utility layer the gizmo will be added to
  106719. */
  106720. constructor(gizmoLayer?: UtilityLayerRenderer);
  106721. updateGizmoRotationToMatchAttachedMesh: boolean;
  106722. /**
  106723. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106724. */
  106725. snapDistance: number;
  106726. /**
  106727. * Ratio for the scale of the gizmo (Default: 1)
  106728. */
  106729. scaleRatio: number;
  106730. /**
  106731. * Disposes of the gizmo
  106732. */
  106733. dispose(): void;
  106734. }
  106735. }
  106736. declare module BABYLON {
  106737. /**
  106738. * Single axis scale gizmo
  106739. */
  106740. export class AxisScaleGizmo extends Gizmo {
  106741. /**
  106742. * Drag behavior responsible for the gizmos dragging interactions
  106743. */
  106744. dragBehavior: PointerDragBehavior;
  106745. private _pointerObserver;
  106746. /**
  106747. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106748. */
  106749. snapDistance: number;
  106750. /**
  106751. * Event that fires each time the gizmo snaps to a new location.
  106752. * * snapDistance is the the change in distance
  106753. */
  106754. onSnapObservable: Observable<{
  106755. snapDistance: number;
  106756. }>;
  106757. /**
  106758. * If the scaling operation should be done on all axis (default: false)
  106759. */
  106760. uniformScaling: boolean;
  106761. private _isEnabled;
  106762. private _parent;
  106763. private _arrow;
  106764. private _coloredMaterial;
  106765. private _hoverMaterial;
  106766. /**
  106767. * Creates an AxisScaleGizmo
  106768. * @param gizmoLayer The utility layer the gizmo will be added to
  106769. * @param dragAxis The axis which the gizmo will be able to scale on
  106770. * @param color The color of the gizmo
  106771. */
  106772. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  106773. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106774. /**
  106775. * If the gizmo is enabled
  106776. */
  106777. isEnabled: boolean;
  106778. /**
  106779. * Disposes of the gizmo
  106780. */
  106781. dispose(): void;
  106782. /**
  106783. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  106784. * @param mesh The mesh to replace the default mesh of the gizmo
  106785. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  106786. */
  106787. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  106788. }
  106789. }
  106790. declare module BABYLON {
  106791. /**
  106792. * Bounding box gizmo
  106793. */
  106794. export class BoundingBoxGizmo extends Gizmo {
  106795. private _lineBoundingBox;
  106796. private _rotateSpheresParent;
  106797. private _scaleBoxesParent;
  106798. private _boundingDimensions;
  106799. private _renderObserver;
  106800. private _pointerObserver;
  106801. private _scaleDragSpeed;
  106802. private _tmpQuaternion;
  106803. private _tmpVector;
  106804. private _tmpRotationMatrix;
  106805. /**
  106806. * 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)
  106807. */
  106808. ignoreChildren: boolean;
  106809. /**
  106810. * 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)
  106811. */
  106812. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  106813. /**
  106814. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  106815. */
  106816. rotationSphereSize: number;
  106817. /**
  106818. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  106819. */
  106820. scaleBoxSize: number;
  106821. /**
  106822. * 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)
  106823. */
  106824. fixedDragMeshScreenSize: boolean;
  106825. /**
  106826. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  106827. */
  106828. fixedDragMeshScreenSizeDistanceFactor: number;
  106829. /**
  106830. * Fired when a rotation sphere or scale box is dragged
  106831. */
  106832. onDragStartObservable: Observable<{}>;
  106833. /**
  106834. * Fired when a scale box is dragged
  106835. */
  106836. onScaleBoxDragObservable: Observable<{}>;
  106837. /**
  106838. * Fired when a scale box drag is ended
  106839. */
  106840. onScaleBoxDragEndObservable: Observable<{}>;
  106841. /**
  106842. * Fired when a rotation sphere is dragged
  106843. */
  106844. onRotationSphereDragObservable: Observable<{}>;
  106845. /**
  106846. * Fired when a rotation sphere drag is ended
  106847. */
  106848. onRotationSphereDragEndObservable: Observable<{}>;
  106849. /**
  106850. * 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)
  106851. */
  106852. scalePivot: Nullable<Vector3>;
  106853. /**
  106854. * Mesh used as a pivot to rotate the attached mesh
  106855. */
  106856. private _anchorMesh;
  106857. private _existingMeshScale;
  106858. private _dragMesh;
  106859. private pointerDragBehavior;
  106860. private coloredMaterial;
  106861. private hoverColoredMaterial;
  106862. /**
  106863. * Sets the color of the bounding box gizmo
  106864. * @param color the color to set
  106865. */
  106866. setColor(color: Color3): void;
  106867. /**
  106868. * Creates an BoundingBoxGizmo
  106869. * @param gizmoLayer The utility layer the gizmo will be added to
  106870. * @param color The color of the gizmo
  106871. */
  106872. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  106873. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106874. private _selectNode;
  106875. /**
  106876. * Updates the bounding box information for the Gizmo
  106877. */
  106878. updateBoundingBox(): void;
  106879. private _updateRotationSpheres;
  106880. private _updateScaleBoxes;
  106881. /**
  106882. * Enables rotation on the specified axis and disables rotation on the others
  106883. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  106884. */
  106885. setEnabledRotationAxis(axis: string): void;
  106886. /**
  106887. * Enables/disables scaling
  106888. * @param enable if scaling should be enabled
  106889. */
  106890. setEnabledScaling(enable: boolean): void;
  106891. private _updateDummy;
  106892. /**
  106893. * Enables a pointer drag behavior on the bounding box of the gizmo
  106894. */
  106895. enableDragBehavior(): void;
  106896. /**
  106897. * Disposes of the gizmo
  106898. */
  106899. dispose(): void;
  106900. /**
  106901. * 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)
  106902. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  106903. * @returns the bounding box mesh with the passed in mesh as a child
  106904. */
  106905. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  106906. /**
  106907. * CustomMeshes are not supported by this gizmo
  106908. * @param mesh The mesh to replace the default mesh of the gizmo
  106909. */
  106910. setCustomMesh(mesh: Mesh): void;
  106911. }
  106912. }
  106913. declare module BABYLON {
  106914. /**
  106915. * Single plane rotation gizmo
  106916. */
  106917. export class PlaneRotationGizmo extends Gizmo {
  106918. /**
  106919. * Drag behavior responsible for the gizmos dragging interactions
  106920. */
  106921. dragBehavior: PointerDragBehavior;
  106922. private _pointerObserver;
  106923. /**
  106924. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  106925. */
  106926. snapDistance: number;
  106927. /**
  106928. * Event that fires each time the gizmo snaps to a new location.
  106929. * * snapDistance is the the change in distance
  106930. */
  106931. onSnapObservable: Observable<{
  106932. snapDistance: number;
  106933. }>;
  106934. private _isEnabled;
  106935. private _parent;
  106936. /**
  106937. * Creates a PlaneRotationGizmo
  106938. * @param gizmoLayer The utility layer the gizmo will be added to
  106939. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  106940. * @param color The color of the gizmo
  106941. * @param tessellation Amount of tessellation to be used when creating rotation circles
  106942. */
  106943. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  106944. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106945. /**
  106946. * If the gizmo is enabled
  106947. */
  106948. isEnabled: boolean;
  106949. /**
  106950. * Disposes of the gizmo
  106951. */
  106952. dispose(): void;
  106953. }
  106954. }
  106955. declare module BABYLON {
  106956. /**
  106957. * Gizmo that enables rotating a mesh along 3 axis
  106958. */
  106959. export class RotationGizmo extends Gizmo {
  106960. /**
  106961. * Internal gizmo used for interactions on the x axis
  106962. */
  106963. xGizmo: PlaneRotationGizmo;
  106964. /**
  106965. * Internal gizmo used for interactions on the y axis
  106966. */
  106967. yGizmo: PlaneRotationGizmo;
  106968. /**
  106969. * Internal gizmo used for interactions on the z axis
  106970. */
  106971. zGizmo: PlaneRotationGizmo;
  106972. /** Fires an event when any of it's sub gizmos are dragged */
  106973. onDragStartObservable: Observable<unknown>;
  106974. /** Fires an event when any of it's sub gizmos are released from dragging */
  106975. onDragEndObservable: Observable<unknown>;
  106976. private _meshAttached;
  106977. attachedMesh: Nullable<AbstractMesh>;
  106978. /**
  106979. * Creates a RotationGizmo
  106980. * @param gizmoLayer The utility layer the gizmo will be added to
  106981. * @param tessellation Amount of tessellation to be used when creating rotation circles
  106982. */
  106983. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  106984. updateGizmoRotationToMatchAttachedMesh: boolean;
  106985. /**
  106986. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106987. */
  106988. snapDistance: number;
  106989. /**
  106990. * Ratio for the scale of the gizmo (Default: 1)
  106991. */
  106992. scaleRatio: number;
  106993. /**
  106994. * Disposes of the gizmo
  106995. */
  106996. dispose(): void;
  106997. /**
  106998. * CustomMeshes are not supported by this gizmo
  106999. * @param mesh The mesh to replace the default mesh of the gizmo
  107000. */
  107001. setCustomMesh(mesh: Mesh): void;
  107002. }
  107003. }
  107004. declare module BABYLON {
  107005. /**
  107006. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  107007. */
  107008. export class GizmoManager implements IDisposable {
  107009. private scene;
  107010. /**
  107011. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  107012. */
  107013. gizmos: {
  107014. positionGizmo: Nullable<PositionGizmo>;
  107015. rotationGizmo: Nullable<RotationGizmo>;
  107016. scaleGizmo: Nullable<ScaleGizmo>;
  107017. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  107018. };
  107019. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  107020. clearGizmoOnEmptyPointerEvent: boolean;
  107021. /** Fires an event when the manager is attached to a mesh */
  107022. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  107023. private _gizmosEnabled;
  107024. private _pointerObserver;
  107025. private _attachedMesh;
  107026. private _boundingBoxColor;
  107027. private _defaultUtilityLayer;
  107028. private _defaultKeepDepthUtilityLayer;
  107029. /**
  107030. * When bounding box gizmo is enabled, this can be used to track drag/end events
  107031. */
  107032. boundingBoxDragBehavior: SixDofDragBehavior;
  107033. /**
  107034. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  107035. */
  107036. attachableMeshes: Nullable<Array<AbstractMesh>>;
  107037. /**
  107038. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  107039. */
  107040. usePointerToAttachGizmos: boolean;
  107041. /**
  107042. * Utility layer that the bounding box gizmo belongs to
  107043. */
  107044. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  107045. /**
  107046. * Utility layer that all gizmos besides bounding box belong to
  107047. */
  107048. readonly utilityLayer: UtilityLayerRenderer;
  107049. /**
  107050. * Instatiates a gizmo manager
  107051. * @param scene the scene to overlay the gizmos on top of
  107052. */
  107053. constructor(scene: Scene);
  107054. /**
  107055. * Attaches a set of gizmos to the specified mesh
  107056. * @param mesh The mesh the gizmo's should be attached to
  107057. */
  107058. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  107059. /**
  107060. * If the position gizmo is enabled
  107061. */
  107062. positionGizmoEnabled: boolean;
  107063. /**
  107064. * If the rotation gizmo is enabled
  107065. */
  107066. rotationGizmoEnabled: boolean;
  107067. /**
  107068. * If the scale gizmo is enabled
  107069. */
  107070. scaleGizmoEnabled: boolean;
  107071. /**
  107072. * If the boundingBox gizmo is enabled
  107073. */
  107074. boundingBoxGizmoEnabled: boolean;
  107075. /**
  107076. * Disposes of the gizmo manager
  107077. */
  107078. dispose(): void;
  107079. }
  107080. }
  107081. declare module BABYLON {
  107082. /**
  107083. * A directional light is defined by a direction (what a surprise!).
  107084. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  107085. * 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.
  107086. * Documentation: https://doc.babylonjs.com/babylon101/lights
  107087. */
  107088. export class DirectionalLight extends ShadowLight {
  107089. private _shadowFrustumSize;
  107090. /**
  107091. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  107092. */
  107093. /**
  107094. * Specifies a fix frustum size for the shadow generation.
  107095. */
  107096. shadowFrustumSize: number;
  107097. private _shadowOrthoScale;
  107098. /**
  107099. * Gets the shadow projection scale against the optimal computed one.
  107100. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  107101. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  107102. */
  107103. /**
  107104. * Sets the shadow projection scale against the optimal computed one.
  107105. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  107106. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  107107. */
  107108. shadowOrthoScale: number;
  107109. /**
  107110. * Automatically compute the projection matrix to best fit (including all the casters)
  107111. * on each frame.
  107112. */
  107113. autoUpdateExtends: boolean;
  107114. private _orthoLeft;
  107115. private _orthoRight;
  107116. private _orthoTop;
  107117. private _orthoBottom;
  107118. /**
  107119. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  107120. * The directional light is emitted from everywhere in the given direction.
  107121. * It can cast shadows.
  107122. * Documentation : https://doc.babylonjs.com/babylon101/lights
  107123. * @param name The friendly name of the light
  107124. * @param direction The direction of the light
  107125. * @param scene The scene the light belongs to
  107126. */
  107127. constructor(name: string, direction: Vector3, scene: Scene);
  107128. /**
  107129. * Returns the string "DirectionalLight".
  107130. * @return The class name
  107131. */
  107132. getClassName(): string;
  107133. /**
  107134. * Returns the integer 1.
  107135. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  107136. */
  107137. getTypeID(): number;
  107138. /**
  107139. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  107140. * Returns the DirectionalLight Shadow projection matrix.
  107141. */
  107142. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  107143. /**
  107144. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  107145. * Returns the DirectionalLight Shadow projection matrix.
  107146. */
  107147. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  107148. /**
  107149. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  107150. * Returns the DirectionalLight Shadow projection matrix.
  107151. */
  107152. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  107153. protected _buildUniformLayout(): void;
  107154. /**
  107155. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  107156. * @param effect The effect to update
  107157. * @param lightIndex The index of the light in the effect to update
  107158. * @returns The directional light
  107159. */
  107160. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  107161. /**
  107162. * Gets the minZ used for shadow according to both the scene and the light.
  107163. *
  107164. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  107165. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  107166. * @param activeCamera The camera we are returning the min for
  107167. * @returns the depth min z
  107168. */
  107169. getDepthMinZ(activeCamera: Camera): number;
  107170. /**
  107171. * Gets the maxZ used for shadow according to both the scene and the light.
  107172. *
  107173. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  107174. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  107175. * @param activeCamera The camera we are returning the max for
  107176. * @returns the depth max z
  107177. */
  107178. getDepthMaxZ(activeCamera: Camera): number;
  107179. /**
  107180. * Prepares the list of defines specific to the light type.
  107181. * @param defines the list of defines
  107182. * @param lightIndex defines the index of the light for the effect
  107183. */
  107184. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  107185. }
  107186. }
  107187. declare module BABYLON {
  107188. /**
  107189. * Class containing static functions to help procedurally build meshes
  107190. */
  107191. export class HemisphereBuilder {
  107192. /**
  107193. * Creates a hemisphere mesh
  107194. * @param name defines the name of the mesh
  107195. * @param options defines the options used to create the mesh
  107196. * @param scene defines the hosting scene
  107197. * @returns the hemisphere mesh
  107198. */
  107199. static CreateHemisphere(name: string, options: {
  107200. segments?: number;
  107201. diameter?: number;
  107202. sideOrientation?: number;
  107203. }, scene: any): Mesh;
  107204. }
  107205. }
  107206. declare module BABYLON {
  107207. /**
  107208. * A spot light is defined by a position, a direction, an angle, and an exponent.
  107209. * These values define a cone of light starting from the position, emitting toward the direction.
  107210. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  107211. * and the exponent defines the speed of the decay of the light with distance (reach).
  107212. * Documentation: https://doc.babylonjs.com/babylon101/lights
  107213. */
  107214. export class SpotLight extends ShadowLight {
  107215. private _angle;
  107216. private _innerAngle;
  107217. private _cosHalfAngle;
  107218. private _lightAngleScale;
  107219. private _lightAngleOffset;
  107220. /**
  107221. * Gets the cone angle of the spot light in Radians.
  107222. */
  107223. /**
  107224. * Sets the cone angle of the spot light in Radians.
  107225. */
  107226. angle: number;
  107227. /**
  107228. * Only used in gltf falloff mode, this defines the angle where
  107229. * the directional falloff will start before cutting at angle which could be seen
  107230. * as outer angle.
  107231. */
  107232. /**
  107233. * Only used in gltf falloff mode, this defines the angle where
  107234. * the directional falloff will start before cutting at angle which could be seen
  107235. * as outer angle.
  107236. */
  107237. innerAngle: number;
  107238. private _shadowAngleScale;
  107239. /**
  107240. * Allows scaling the angle of the light for shadow generation only.
  107241. */
  107242. /**
  107243. * Allows scaling the angle of the light for shadow generation only.
  107244. */
  107245. shadowAngleScale: number;
  107246. /**
  107247. * The light decay speed with the distance from the emission spot.
  107248. */
  107249. exponent: number;
  107250. private _projectionTextureMatrix;
  107251. /**
  107252. * Allows reading the projecton texture
  107253. */
  107254. readonly projectionTextureMatrix: Matrix;
  107255. protected _projectionTextureLightNear: number;
  107256. /**
  107257. * Gets the near clip of the Spotlight for texture projection.
  107258. */
  107259. /**
  107260. * Sets the near clip of the Spotlight for texture projection.
  107261. */
  107262. projectionTextureLightNear: number;
  107263. protected _projectionTextureLightFar: number;
  107264. /**
  107265. * Gets the far clip of the Spotlight for texture projection.
  107266. */
  107267. /**
  107268. * Sets the far clip of the Spotlight for texture projection.
  107269. */
  107270. projectionTextureLightFar: number;
  107271. protected _projectionTextureUpDirection: Vector3;
  107272. /**
  107273. * Gets the Up vector of the Spotlight for texture projection.
  107274. */
  107275. /**
  107276. * Sets the Up vector of the Spotlight for texture projection.
  107277. */
  107278. projectionTextureUpDirection: Vector3;
  107279. private _projectionTexture;
  107280. /**
  107281. * Gets the projection texture of the light.
  107282. */
  107283. /**
  107284. * Sets the projection texture of the light.
  107285. */
  107286. projectionTexture: Nullable<BaseTexture>;
  107287. private _projectionTextureViewLightDirty;
  107288. private _projectionTextureProjectionLightDirty;
  107289. private _projectionTextureDirty;
  107290. private _projectionTextureViewTargetVector;
  107291. private _projectionTextureViewLightMatrix;
  107292. private _projectionTextureProjectionLightMatrix;
  107293. private _projectionTextureScalingMatrix;
  107294. /**
  107295. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  107296. * It can cast shadows.
  107297. * Documentation : https://doc.babylonjs.com/babylon101/lights
  107298. * @param name The light friendly name
  107299. * @param position The position of the spot light in the scene
  107300. * @param direction The direction of the light in the scene
  107301. * @param angle The cone angle of the light in Radians
  107302. * @param exponent The light decay speed with the distance from the emission spot
  107303. * @param scene The scene the lights belongs to
  107304. */
  107305. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  107306. /**
  107307. * Returns the string "SpotLight".
  107308. * @returns the class name
  107309. */
  107310. getClassName(): string;
  107311. /**
  107312. * Returns the integer 2.
  107313. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  107314. */
  107315. getTypeID(): number;
  107316. /**
  107317. * Overrides the direction setter to recompute the projection texture view light Matrix.
  107318. */
  107319. protected _setDirection(value: Vector3): void;
  107320. /**
  107321. * Overrides the position setter to recompute the projection texture view light Matrix.
  107322. */
  107323. protected _setPosition(value: Vector3): void;
  107324. /**
  107325. * 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.
  107326. * Returns the SpotLight.
  107327. */
  107328. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  107329. protected _computeProjectionTextureViewLightMatrix(): void;
  107330. protected _computeProjectionTextureProjectionLightMatrix(): void;
  107331. /**
  107332. * Main function for light texture projection matrix computing.
  107333. */
  107334. protected _computeProjectionTextureMatrix(): void;
  107335. protected _buildUniformLayout(): void;
  107336. private _computeAngleValues;
  107337. /**
  107338. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  107339. * @param effect The effect to update
  107340. * @param lightIndex The index of the light in the effect to update
  107341. * @returns The spot light
  107342. */
  107343. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  107344. /**
  107345. * Disposes the light and the associated resources.
  107346. */
  107347. dispose(): void;
  107348. /**
  107349. * Prepares the list of defines specific to the light type.
  107350. * @param defines the list of defines
  107351. * @param lightIndex defines the index of the light for the effect
  107352. */
  107353. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  107354. }
  107355. }
  107356. declare module BABYLON {
  107357. /**
  107358. * Gizmo that enables viewing a light
  107359. */
  107360. export class LightGizmo extends Gizmo {
  107361. private _lightMesh;
  107362. private _material;
  107363. private cachedPosition;
  107364. private cachedForward;
  107365. /**
  107366. * Creates a LightGizmo
  107367. * @param gizmoLayer The utility layer the gizmo will be added to
  107368. */
  107369. constructor(gizmoLayer?: UtilityLayerRenderer);
  107370. private _light;
  107371. /**
  107372. * The light that the gizmo is attached to
  107373. */
  107374. light: Nullable<Light>;
  107375. /**
  107376. * @hidden
  107377. * Updates the gizmo to match the attached mesh's position/rotation
  107378. */
  107379. protected _update(): void;
  107380. private static _Scale;
  107381. /**
  107382. * Creates the lines for a light mesh
  107383. */
  107384. private static _createLightLines;
  107385. /**
  107386. * Disposes of the light gizmo
  107387. */
  107388. dispose(): void;
  107389. private static _CreateHemisphericLightMesh;
  107390. private static _CreatePointLightMesh;
  107391. private static _CreateSpotLightMesh;
  107392. private static _CreateDirectionalLightMesh;
  107393. }
  107394. }
  107395. declare module BABYLON {
  107396. /** @hidden */
  107397. export var backgroundFragmentDeclaration: {
  107398. name: string;
  107399. shader: string;
  107400. };
  107401. }
  107402. declare module BABYLON {
  107403. /** @hidden */
  107404. export var backgroundUboDeclaration: {
  107405. name: string;
  107406. shader: string;
  107407. };
  107408. }
  107409. declare module BABYLON {
  107410. /** @hidden */
  107411. export var backgroundPixelShader: {
  107412. name: string;
  107413. shader: string;
  107414. };
  107415. }
  107416. declare module BABYLON {
  107417. /** @hidden */
  107418. export var backgroundVertexDeclaration: {
  107419. name: string;
  107420. shader: string;
  107421. };
  107422. }
  107423. declare module BABYLON {
  107424. /** @hidden */
  107425. export var backgroundVertexShader: {
  107426. name: string;
  107427. shader: string;
  107428. };
  107429. }
  107430. declare module BABYLON {
  107431. /**
  107432. * Background material used to create an efficient environement around your scene.
  107433. */
  107434. export class BackgroundMaterial extends PushMaterial {
  107435. /**
  107436. * Standard reflectance value at parallel view angle.
  107437. */
  107438. static StandardReflectance0: number;
  107439. /**
  107440. * Standard reflectance value at grazing angle.
  107441. */
  107442. static StandardReflectance90: number;
  107443. protected _primaryColor: Color3;
  107444. /**
  107445. * Key light Color (multiply against the environement texture)
  107446. */
  107447. primaryColor: Color3;
  107448. protected __perceptualColor: Nullable<Color3>;
  107449. /**
  107450. * Experimental Internal Use Only.
  107451. *
  107452. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  107453. * This acts as a helper to set the primary color to a more "human friendly" value.
  107454. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  107455. * output color as close as possible from the chosen value.
  107456. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  107457. * part of lighting setup.)
  107458. */
  107459. _perceptualColor: Nullable<Color3>;
  107460. protected _primaryColorShadowLevel: float;
  107461. /**
  107462. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  107463. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  107464. */
  107465. primaryColorShadowLevel: float;
  107466. protected _primaryColorHighlightLevel: float;
  107467. /**
  107468. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  107469. * The primary color is used at the level chosen to define what the white area would look.
  107470. */
  107471. primaryColorHighlightLevel: float;
  107472. protected _reflectionTexture: Nullable<BaseTexture>;
  107473. /**
  107474. * Reflection Texture used in the material.
  107475. * Should be author in a specific way for the best result (refer to the documentation).
  107476. */
  107477. reflectionTexture: Nullable<BaseTexture>;
  107478. protected _reflectionBlur: float;
  107479. /**
  107480. * Reflection Texture level of blur.
  107481. *
  107482. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  107483. * texture twice.
  107484. */
  107485. reflectionBlur: float;
  107486. protected _diffuseTexture: Nullable<BaseTexture>;
  107487. /**
  107488. * Diffuse Texture used in the material.
  107489. * Should be author in a specific way for the best result (refer to the documentation).
  107490. */
  107491. diffuseTexture: Nullable<BaseTexture>;
  107492. protected _shadowLights: Nullable<IShadowLight[]>;
  107493. /**
  107494. * Specify the list of lights casting shadow on the material.
  107495. * All scene shadow lights will be included if null.
  107496. */
  107497. shadowLights: Nullable<IShadowLight[]>;
  107498. protected _shadowLevel: float;
  107499. /**
  107500. * Helps adjusting the shadow to a softer level if required.
  107501. * 0 means black shadows and 1 means no shadows.
  107502. */
  107503. shadowLevel: float;
  107504. protected _sceneCenter: Vector3;
  107505. /**
  107506. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  107507. * It is usually zero but might be interesting to modify according to your setup.
  107508. */
  107509. sceneCenter: Vector3;
  107510. protected _opacityFresnel: boolean;
  107511. /**
  107512. * This helps specifying that the material is falling off to the sky box at grazing angle.
  107513. * This helps ensuring a nice transition when the camera goes under the ground.
  107514. */
  107515. opacityFresnel: boolean;
  107516. protected _reflectionFresnel: boolean;
  107517. /**
  107518. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  107519. * This helps adding a mirror texture on the ground.
  107520. */
  107521. reflectionFresnel: boolean;
  107522. protected _reflectionFalloffDistance: number;
  107523. /**
  107524. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  107525. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  107526. */
  107527. reflectionFalloffDistance: number;
  107528. protected _reflectionAmount: number;
  107529. /**
  107530. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  107531. */
  107532. reflectionAmount: number;
  107533. protected _reflectionReflectance0: number;
  107534. /**
  107535. * This specifies the weight of the reflection at grazing angle.
  107536. */
  107537. reflectionReflectance0: number;
  107538. protected _reflectionReflectance90: number;
  107539. /**
  107540. * This specifies the weight of the reflection at a perpendicular point of view.
  107541. */
  107542. reflectionReflectance90: number;
  107543. /**
  107544. * Sets the reflection reflectance fresnel values according to the default standard
  107545. * empirically know to work well :-)
  107546. */
  107547. reflectionStandardFresnelWeight: number;
  107548. protected _useRGBColor: boolean;
  107549. /**
  107550. * Helps to directly use the maps channels instead of their level.
  107551. */
  107552. useRGBColor: boolean;
  107553. protected _enableNoise: boolean;
  107554. /**
  107555. * This helps reducing the banding effect that could occur on the background.
  107556. */
  107557. enableNoise: boolean;
  107558. /**
  107559. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  107560. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  107561. * Recommended to be keep at 1.0 except for special cases.
  107562. */
  107563. fovMultiplier: number;
  107564. private _fovMultiplier;
  107565. /**
  107566. * Enable the FOV adjustment feature controlled by fovMultiplier.
  107567. */
  107568. useEquirectangularFOV: boolean;
  107569. private _maxSimultaneousLights;
  107570. /**
  107571. * Number of Simultaneous lights allowed on the material.
  107572. */
  107573. maxSimultaneousLights: int;
  107574. /**
  107575. * Default configuration related to image processing available in the Background Material.
  107576. */
  107577. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107578. /**
  107579. * Keep track of the image processing observer to allow dispose and replace.
  107580. */
  107581. private _imageProcessingObserver;
  107582. /**
  107583. * Attaches a new image processing configuration to the PBR Material.
  107584. * @param configuration (if null the scene configuration will be use)
  107585. */
  107586. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107587. /**
  107588. * Gets the image processing configuration used either in this material.
  107589. */
  107590. /**
  107591. * Sets the Default image processing configuration used either in the this material.
  107592. *
  107593. * If sets to null, the scene one is in use.
  107594. */
  107595. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  107596. /**
  107597. * Gets wether the color curves effect is enabled.
  107598. */
  107599. /**
  107600. * Sets wether the color curves effect is enabled.
  107601. */
  107602. cameraColorCurvesEnabled: boolean;
  107603. /**
  107604. * Gets wether the color grading effect is enabled.
  107605. */
  107606. /**
  107607. * Gets wether the color grading effect is enabled.
  107608. */
  107609. cameraColorGradingEnabled: boolean;
  107610. /**
  107611. * Gets wether tonemapping is enabled or not.
  107612. */
  107613. /**
  107614. * Sets wether tonemapping is enabled or not
  107615. */
  107616. cameraToneMappingEnabled: boolean;
  107617. /**
  107618. * The camera exposure used on this material.
  107619. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107620. * This corresponds to a photographic exposure.
  107621. */
  107622. /**
  107623. * The camera exposure used on this material.
  107624. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107625. * This corresponds to a photographic exposure.
  107626. */
  107627. cameraExposure: float;
  107628. /**
  107629. * Gets The camera contrast used on this material.
  107630. */
  107631. /**
  107632. * Sets The camera contrast used on this material.
  107633. */
  107634. cameraContrast: float;
  107635. /**
  107636. * Gets the Color Grading 2D Lookup Texture.
  107637. */
  107638. /**
  107639. * Sets the Color Grading 2D Lookup Texture.
  107640. */
  107641. cameraColorGradingTexture: Nullable<BaseTexture>;
  107642. /**
  107643. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107644. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107645. * 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;
  107646. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107647. */
  107648. /**
  107649. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107650. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107651. * 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;
  107652. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107653. */
  107654. cameraColorCurves: Nullable<ColorCurves>;
  107655. /**
  107656. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  107657. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  107658. */
  107659. switchToBGR: boolean;
  107660. private _renderTargets;
  107661. private _reflectionControls;
  107662. private _white;
  107663. private _primaryShadowColor;
  107664. private _primaryHighlightColor;
  107665. /**
  107666. * Instantiates a Background Material in the given scene
  107667. * @param name The friendly name of the material
  107668. * @param scene The scene to add the material to
  107669. */
  107670. constructor(name: string, scene: Scene);
  107671. /**
  107672. * Gets a boolean indicating that current material needs to register RTT
  107673. */
  107674. readonly hasRenderTargetTextures: boolean;
  107675. /**
  107676. * The entire material has been created in order to prevent overdraw.
  107677. * @returns false
  107678. */
  107679. needAlphaTesting(): boolean;
  107680. /**
  107681. * The entire material has been created in order to prevent overdraw.
  107682. * @returns true if blending is enable
  107683. */
  107684. needAlphaBlending(): boolean;
  107685. /**
  107686. * Checks wether the material is ready to be rendered for a given mesh.
  107687. * @param mesh The mesh to render
  107688. * @param subMesh The submesh to check against
  107689. * @param useInstances Specify wether or not the material is used with instances
  107690. * @returns true if all the dependencies are ready (Textures, Effects...)
  107691. */
  107692. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107693. /**
  107694. * Compute the primary color according to the chosen perceptual color.
  107695. */
  107696. private _computePrimaryColorFromPerceptualColor;
  107697. /**
  107698. * Compute the highlights and shadow colors according to their chosen levels.
  107699. */
  107700. private _computePrimaryColors;
  107701. /**
  107702. * Build the uniform buffer used in the material.
  107703. */
  107704. buildUniformLayout(): void;
  107705. /**
  107706. * Unbind the material.
  107707. */
  107708. unbind(): void;
  107709. /**
  107710. * Bind only the world matrix to the material.
  107711. * @param world The world matrix to bind.
  107712. */
  107713. bindOnlyWorldMatrix(world: Matrix): void;
  107714. /**
  107715. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  107716. * @param world The world matrix to bind.
  107717. * @param subMesh The submesh to bind for.
  107718. */
  107719. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107720. /**
  107721. * Dispose the material.
  107722. * @param forceDisposeEffect Force disposal of the associated effect.
  107723. * @param forceDisposeTextures Force disposal of the associated textures.
  107724. */
  107725. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107726. /**
  107727. * Clones the material.
  107728. * @param name The cloned name.
  107729. * @returns The cloned material.
  107730. */
  107731. clone(name: string): BackgroundMaterial;
  107732. /**
  107733. * Serializes the current material to its JSON representation.
  107734. * @returns The JSON representation.
  107735. */
  107736. serialize(): any;
  107737. /**
  107738. * Gets the class name of the material
  107739. * @returns "BackgroundMaterial"
  107740. */
  107741. getClassName(): string;
  107742. /**
  107743. * Parse a JSON input to create back a background material.
  107744. * @param source The JSON data to parse
  107745. * @param scene The scene to create the parsed material in
  107746. * @param rootUrl The root url of the assets the material depends upon
  107747. * @returns the instantiated BackgroundMaterial.
  107748. */
  107749. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  107750. }
  107751. }
  107752. declare module BABYLON {
  107753. /**
  107754. * Represents the different options available during the creation of
  107755. * a Environment helper.
  107756. *
  107757. * This can control the default ground, skybox and image processing setup of your scene.
  107758. */
  107759. export interface IEnvironmentHelperOptions {
  107760. /**
  107761. * Specifies wether or not to create a ground.
  107762. * True by default.
  107763. */
  107764. createGround: boolean;
  107765. /**
  107766. * Specifies the ground size.
  107767. * 15 by default.
  107768. */
  107769. groundSize: number;
  107770. /**
  107771. * The texture used on the ground for the main color.
  107772. * Comes from the BabylonJS CDN by default.
  107773. *
  107774. * Remarks: Can be either a texture or a url.
  107775. */
  107776. groundTexture: string | BaseTexture;
  107777. /**
  107778. * The color mixed in the ground texture by default.
  107779. * BabylonJS clearColor by default.
  107780. */
  107781. groundColor: Color3;
  107782. /**
  107783. * Specifies the ground opacity.
  107784. * 1 by default.
  107785. */
  107786. groundOpacity: number;
  107787. /**
  107788. * Enables the ground to receive shadows.
  107789. * True by default.
  107790. */
  107791. enableGroundShadow: boolean;
  107792. /**
  107793. * Helps preventing the shadow to be fully black on the ground.
  107794. * 0.5 by default.
  107795. */
  107796. groundShadowLevel: number;
  107797. /**
  107798. * Creates a mirror texture attach to the ground.
  107799. * false by default.
  107800. */
  107801. enableGroundMirror: boolean;
  107802. /**
  107803. * Specifies the ground mirror size ratio.
  107804. * 0.3 by default as the default kernel is 64.
  107805. */
  107806. groundMirrorSizeRatio: number;
  107807. /**
  107808. * Specifies the ground mirror blur kernel size.
  107809. * 64 by default.
  107810. */
  107811. groundMirrorBlurKernel: number;
  107812. /**
  107813. * Specifies the ground mirror visibility amount.
  107814. * 1 by default
  107815. */
  107816. groundMirrorAmount: number;
  107817. /**
  107818. * Specifies the ground mirror reflectance weight.
  107819. * This uses the standard weight of the background material to setup the fresnel effect
  107820. * of the mirror.
  107821. * 1 by default.
  107822. */
  107823. groundMirrorFresnelWeight: number;
  107824. /**
  107825. * Specifies the ground mirror Falloff distance.
  107826. * This can helps reducing the size of the reflection.
  107827. * 0 by Default.
  107828. */
  107829. groundMirrorFallOffDistance: number;
  107830. /**
  107831. * Specifies the ground mirror texture type.
  107832. * Unsigned Int by Default.
  107833. */
  107834. groundMirrorTextureType: number;
  107835. /**
  107836. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  107837. * the shown objects.
  107838. */
  107839. groundYBias: number;
  107840. /**
  107841. * Specifies wether or not to create a skybox.
  107842. * True by default.
  107843. */
  107844. createSkybox: boolean;
  107845. /**
  107846. * Specifies the skybox size.
  107847. * 20 by default.
  107848. */
  107849. skyboxSize: number;
  107850. /**
  107851. * The texture used on the skybox for the main color.
  107852. * Comes from the BabylonJS CDN by default.
  107853. *
  107854. * Remarks: Can be either a texture or a url.
  107855. */
  107856. skyboxTexture: string | BaseTexture;
  107857. /**
  107858. * The color mixed in the skybox texture by default.
  107859. * BabylonJS clearColor by default.
  107860. */
  107861. skyboxColor: Color3;
  107862. /**
  107863. * The background rotation around the Y axis of the scene.
  107864. * This helps aligning the key lights of your scene with the background.
  107865. * 0 by default.
  107866. */
  107867. backgroundYRotation: number;
  107868. /**
  107869. * Compute automatically the size of the elements to best fit with the scene.
  107870. */
  107871. sizeAuto: boolean;
  107872. /**
  107873. * Default position of the rootMesh if autoSize is not true.
  107874. */
  107875. rootPosition: Vector3;
  107876. /**
  107877. * Sets up the image processing in the scene.
  107878. * true by default.
  107879. */
  107880. setupImageProcessing: boolean;
  107881. /**
  107882. * The texture used as your environment texture in the scene.
  107883. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  107884. *
  107885. * Remarks: Can be either a texture or a url.
  107886. */
  107887. environmentTexture: string | BaseTexture;
  107888. /**
  107889. * The value of the exposure to apply to the scene.
  107890. * 0.6 by default if setupImageProcessing is true.
  107891. */
  107892. cameraExposure: number;
  107893. /**
  107894. * The value of the contrast to apply to the scene.
  107895. * 1.6 by default if setupImageProcessing is true.
  107896. */
  107897. cameraContrast: number;
  107898. /**
  107899. * Specifies wether or not tonemapping should be enabled in the scene.
  107900. * true by default if setupImageProcessing is true.
  107901. */
  107902. toneMappingEnabled: boolean;
  107903. }
  107904. /**
  107905. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  107906. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  107907. * It also helps with the default setup of your imageProcessing configuration.
  107908. */
  107909. export class EnvironmentHelper {
  107910. /**
  107911. * Default ground texture URL.
  107912. */
  107913. private static _groundTextureCDNUrl;
  107914. /**
  107915. * Default skybox texture URL.
  107916. */
  107917. private static _skyboxTextureCDNUrl;
  107918. /**
  107919. * Default environment texture URL.
  107920. */
  107921. private static _environmentTextureCDNUrl;
  107922. /**
  107923. * Creates the default options for the helper.
  107924. */
  107925. private static _getDefaultOptions;
  107926. private _rootMesh;
  107927. /**
  107928. * Gets the root mesh created by the helper.
  107929. */
  107930. readonly rootMesh: Mesh;
  107931. private _skybox;
  107932. /**
  107933. * Gets the skybox created by the helper.
  107934. */
  107935. readonly skybox: Nullable<Mesh>;
  107936. private _skyboxTexture;
  107937. /**
  107938. * Gets the skybox texture created by the helper.
  107939. */
  107940. readonly skyboxTexture: Nullable<BaseTexture>;
  107941. private _skyboxMaterial;
  107942. /**
  107943. * Gets the skybox material created by the helper.
  107944. */
  107945. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  107946. private _ground;
  107947. /**
  107948. * Gets the ground mesh created by the helper.
  107949. */
  107950. readonly ground: Nullable<Mesh>;
  107951. private _groundTexture;
  107952. /**
  107953. * Gets the ground texture created by the helper.
  107954. */
  107955. readonly groundTexture: Nullable<BaseTexture>;
  107956. private _groundMirror;
  107957. /**
  107958. * Gets the ground mirror created by the helper.
  107959. */
  107960. readonly groundMirror: Nullable<MirrorTexture>;
  107961. /**
  107962. * Gets the ground mirror render list to helps pushing the meshes
  107963. * you wish in the ground reflection.
  107964. */
  107965. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  107966. private _groundMaterial;
  107967. /**
  107968. * Gets the ground material created by the helper.
  107969. */
  107970. readonly groundMaterial: Nullable<BackgroundMaterial>;
  107971. /**
  107972. * Stores the creation options.
  107973. */
  107974. private readonly _scene;
  107975. private _options;
  107976. /**
  107977. * This observable will be notified with any error during the creation of the environment,
  107978. * mainly texture creation errors.
  107979. */
  107980. onErrorObservable: Observable<{
  107981. message?: string;
  107982. exception?: any;
  107983. }>;
  107984. /**
  107985. * constructor
  107986. * @param options Defines the options we want to customize the helper
  107987. * @param scene The scene to add the material to
  107988. */
  107989. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  107990. /**
  107991. * Updates the background according to the new options
  107992. * @param options
  107993. */
  107994. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  107995. /**
  107996. * Sets the primary color of all the available elements.
  107997. * @param color the main color to affect to the ground and the background
  107998. */
  107999. setMainColor(color: Color3): void;
  108000. /**
  108001. * Setup the image processing according to the specified options.
  108002. */
  108003. private _setupImageProcessing;
  108004. /**
  108005. * Setup the environment texture according to the specified options.
  108006. */
  108007. private _setupEnvironmentTexture;
  108008. /**
  108009. * Setup the background according to the specified options.
  108010. */
  108011. private _setupBackground;
  108012. /**
  108013. * Get the scene sizes according to the setup.
  108014. */
  108015. private _getSceneSize;
  108016. /**
  108017. * Setup the ground according to the specified options.
  108018. */
  108019. private _setupGround;
  108020. /**
  108021. * Setup the ground material according to the specified options.
  108022. */
  108023. private _setupGroundMaterial;
  108024. /**
  108025. * Setup the ground diffuse texture according to the specified options.
  108026. */
  108027. private _setupGroundDiffuseTexture;
  108028. /**
  108029. * Setup the ground mirror texture according to the specified options.
  108030. */
  108031. private _setupGroundMirrorTexture;
  108032. /**
  108033. * Setup the ground to receive the mirror texture.
  108034. */
  108035. private _setupMirrorInGroundMaterial;
  108036. /**
  108037. * Setup the skybox according to the specified options.
  108038. */
  108039. private _setupSkybox;
  108040. /**
  108041. * Setup the skybox material according to the specified options.
  108042. */
  108043. private _setupSkyboxMaterial;
  108044. /**
  108045. * Setup the skybox reflection texture according to the specified options.
  108046. */
  108047. private _setupSkyboxReflectionTexture;
  108048. private _errorHandler;
  108049. /**
  108050. * Dispose all the elements created by the Helper.
  108051. */
  108052. dispose(): void;
  108053. }
  108054. }
  108055. declare module BABYLON {
  108056. /**
  108057. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  108058. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  108059. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  108060. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  108061. */
  108062. export class PhotoDome extends TransformNode {
  108063. /**
  108064. * Define the image as a Monoscopic panoramic 360 image.
  108065. */
  108066. static readonly MODE_MONOSCOPIC: number;
  108067. /**
  108068. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  108069. */
  108070. static readonly MODE_TOPBOTTOM: number;
  108071. /**
  108072. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  108073. */
  108074. static readonly MODE_SIDEBYSIDE: number;
  108075. private _useDirectMapping;
  108076. /**
  108077. * The texture being displayed on the sphere
  108078. */
  108079. protected _photoTexture: Texture;
  108080. /**
  108081. * Gets or sets the texture being displayed on the sphere
  108082. */
  108083. photoTexture: Texture;
  108084. /**
  108085. * Observable raised when an error occured while loading the 360 image
  108086. */
  108087. onLoadErrorObservable: Observable<string>;
  108088. /**
  108089. * The skybox material
  108090. */
  108091. protected _material: BackgroundMaterial;
  108092. /**
  108093. * The surface used for the skybox
  108094. */
  108095. protected _mesh: Mesh;
  108096. /**
  108097. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  108098. * Also see the options.resolution property.
  108099. */
  108100. fovMultiplier: number;
  108101. private _imageMode;
  108102. /**
  108103. * Gets or set the current video mode for the video. It can be:
  108104. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  108105. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  108106. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  108107. */
  108108. imageMode: number;
  108109. /**
  108110. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  108111. * @param name Element's name, child elements will append suffixes for their own names.
  108112. * @param urlsOfPhoto defines the url of the photo to display
  108113. * @param options defines an object containing optional or exposed sub element properties
  108114. * @param onError defines a callback called when an error occured while loading the texture
  108115. */
  108116. constructor(name: string, urlOfPhoto: string, options: {
  108117. resolution?: number;
  108118. size?: number;
  108119. useDirectMapping?: boolean;
  108120. faceForward?: boolean;
  108121. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  108122. private _onBeforeCameraRenderObserver;
  108123. private _changeImageMode;
  108124. /**
  108125. * Releases resources associated with this node.
  108126. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  108127. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  108128. */
  108129. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  108130. }
  108131. }
  108132. declare module BABYLON {
  108133. /** @hidden */
  108134. export var rgbdDecodePixelShader: {
  108135. name: string;
  108136. shader: string;
  108137. };
  108138. }
  108139. declare module BABYLON {
  108140. /**
  108141. * Class used to host texture specific utilities
  108142. */
  108143. export class BRDFTextureTools {
  108144. /**
  108145. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  108146. * @param texture the texture to expand.
  108147. */
  108148. private static _ExpandDefaultBRDFTexture;
  108149. /**
  108150. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  108151. * @param scene defines the hosting scene
  108152. * @returns the environment BRDF texture
  108153. */
  108154. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  108155. private static _environmentBRDFBase64Texture;
  108156. }
  108157. }
  108158. declare module BABYLON {
  108159. /**
  108160. * @hidden
  108161. */
  108162. export interface IMaterialClearCoatDefines {
  108163. CLEARCOAT: boolean;
  108164. CLEARCOAT_DEFAULTIOR: boolean;
  108165. CLEARCOAT_TEXTURE: boolean;
  108166. CLEARCOAT_TEXTUREDIRECTUV: number;
  108167. CLEARCOAT_BUMP: boolean;
  108168. CLEARCOAT_BUMPDIRECTUV: number;
  108169. CLEARCOAT_TINT: boolean;
  108170. CLEARCOAT_TINT_TEXTURE: boolean;
  108171. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  108172. /** @hidden */
  108173. _areTexturesDirty: boolean;
  108174. }
  108175. /**
  108176. * Define the code related to the clear coat parameters of the pbr material.
  108177. */
  108178. export class PBRClearCoatConfiguration {
  108179. /**
  108180. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  108181. * The default fits with a polyurethane material.
  108182. */
  108183. private static readonly _DefaultIndexOfRefraction;
  108184. private _isEnabled;
  108185. /**
  108186. * Defines if the clear coat is enabled in the material.
  108187. */
  108188. isEnabled: boolean;
  108189. /**
  108190. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  108191. */
  108192. intensity: number;
  108193. /**
  108194. * Defines the clear coat layer roughness.
  108195. */
  108196. roughness: number;
  108197. private _indexOfRefraction;
  108198. /**
  108199. * Defines the index of refraction of the clear coat.
  108200. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  108201. * The default fits with a polyurethane material.
  108202. * Changing the default value is more performance intensive.
  108203. */
  108204. indexOfRefraction: number;
  108205. private _texture;
  108206. /**
  108207. * Stores the clear coat values in a texture.
  108208. */
  108209. texture: Nullable<BaseTexture>;
  108210. private _bumpTexture;
  108211. /**
  108212. * Define the clear coat specific bump texture.
  108213. */
  108214. bumpTexture: Nullable<BaseTexture>;
  108215. private _isTintEnabled;
  108216. /**
  108217. * Defines if the clear coat tint is enabled in the material.
  108218. */
  108219. isTintEnabled: boolean;
  108220. /**
  108221. * Defines the clear coat tint of the material.
  108222. * This is only use if tint is enabled
  108223. */
  108224. tintColor: Color3;
  108225. /**
  108226. * Defines the distance at which the tint color should be found in the
  108227. * clear coat media.
  108228. * This is only use if tint is enabled
  108229. */
  108230. tintColorAtDistance: number;
  108231. /**
  108232. * Defines the clear coat layer thickness.
  108233. * This is only use if tint is enabled
  108234. */
  108235. tintThickness: number;
  108236. private _tintTexture;
  108237. /**
  108238. * Stores the clear tint values in a texture.
  108239. * rgb is tint
  108240. * a is a thickness factor
  108241. */
  108242. tintTexture: Nullable<BaseTexture>;
  108243. /** @hidden */
  108244. private _internalMarkAllSubMeshesAsTexturesDirty;
  108245. /** @hidden */
  108246. _markAllSubMeshesAsTexturesDirty(): void;
  108247. /**
  108248. * Instantiate a new istance of clear coat configuration.
  108249. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  108250. */
  108251. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  108252. /**
  108253. * Gets wehter the submesh is ready to be used or not.
  108254. * @param defines the list of "defines" to update.
  108255. * @param scene defines the scene the material belongs to.
  108256. * @param engine defines the engine the material belongs to.
  108257. * @param disableBumpMap defines wether the material disables bump or not.
  108258. * @returns - boolean indicating that the submesh is ready or not.
  108259. */
  108260. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  108261. /**
  108262. * Checks to see if a texture is used in the material.
  108263. * @param defines the list of "defines" to update.
  108264. * @param scene defines the scene to the material belongs to.
  108265. */
  108266. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  108267. /**
  108268. * Binds the material data.
  108269. * @param uniformBuffer defines the Uniform buffer to fill in.
  108270. * @param scene defines the scene the material belongs to.
  108271. * @param engine defines the engine the material belongs to.
  108272. * @param disableBumpMap defines wether the material disables bump or not.
  108273. * @param isFrozen defines wether the material is frozen or not.
  108274. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  108275. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  108276. */
  108277. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  108278. /**
  108279. * Checks to see if a texture is used in the material.
  108280. * @param texture - Base texture to use.
  108281. * @returns - Boolean specifying if a texture is used in the material.
  108282. */
  108283. hasTexture(texture: BaseTexture): boolean;
  108284. /**
  108285. * Returns an array of the actively used textures.
  108286. * @param activeTextures Array of BaseTextures
  108287. */
  108288. getActiveTextures(activeTextures: BaseTexture[]): void;
  108289. /**
  108290. * Returns the animatable textures.
  108291. * @param animatables Array of animatable textures.
  108292. */
  108293. getAnimatables(animatables: IAnimatable[]): void;
  108294. /**
  108295. * Disposes the resources of the material.
  108296. * @param forceDisposeTextures - Forces the disposal of all textures.
  108297. */
  108298. dispose(forceDisposeTextures?: boolean): void;
  108299. /**
  108300. * Get the current class name of the texture useful for serialization or dynamic coding.
  108301. * @returns "PBRClearCoatConfiguration"
  108302. */
  108303. getClassName(): string;
  108304. /**
  108305. * Add fallbacks to the effect fallbacks list.
  108306. * @param defines defines the Base texture to use.
  108307. * @param fallbacks defines the current fallback list.
  108308. * @param currentRank defines the current fallback rank.
  108309. * @returns the new fallback rank.
  108310. */
  108311. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  108312. /**
  108313. * Add the required uniforms to the current list.
  108314. * @param uniforms defines the current uniform list.
  108315. */
  108316. static AddUniforms(uniforms: string[]): void;
  108317. /**
  108318. * Add the required samplers to the current list.
  108319. * @param samplers defines the current sampler list.
  108320. */
  108321. static AddSamplers(samplers: string[]): void;
  108322. /**
  108323. * Add the required uniforms to the current buffer.
  108324. * @param uniformBuffer defines the current uniform buffer.
  108325. */
  108326. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  108327. /**
  108328. * Makes a duplicate of the current configuration into another one.
  108329. * @param clearCoatConfiguration define the config where to copy the info
  108330. */
  108331. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  108332. /**
  108333. * Serializes this clear coat configuration.
  108334. * @returns - An object with the serialized config.
  108335. */
  108336. serialize(): any;
  108337. /**
  108338. * Parses a anisotropy Configuration from a serialized object.
  108339. * @param source - Serialized object.
  108340. * @param scene Defines the scene we are parsing for
  108341. * @param rootUrl Defines the rootUrl to load from
  108342. */
  108343. parse(source: any, scene: Scene, rootUrl: string): void;
  108344. }
  108345. }
  108346. declare module BABYLON {
  108347. /**
  108348. * @hidden
  108349. */
  108350. export interface IMaterialAnisotropicDefines {
  108351. ANISOTROPIC: boolean;
  108352. ANISOTROPIC_TEXTURE: boolean;
  108353. ANISOTROPIC_TEXTUREDIRECTUV: number;
  108354. MAINUV1: boolean;
  108355. _areTexturesDirty: boolean;
  108356. _needUVs: boolean;
  108357. }
  108358. /**
  108359. * Define the code related to the anisotropic parameters of the pbr material.
  108360. */
  108361. export class PBRAnisotropicConfiguration {
  108362. private _isEnabled;
  108363. /**
  108364. * Defines if the anisotropy is enabled in the material.
  108365. */
  108366. isEnabled: boolean;
  108367. /**
  108368. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  108369. */
  108370. intensity: number;
  108371. /**
  108372. * Defines if the effect is along the tangents, bitangents or in between.
  108373. * By default, the effect is "strectching" the highlights along the tangents.
  108374. */
  108375. direction: Vector2;
  108376. private _texture;
  108377. /**
  108378. * Stores the anisotropy values in a texture.
  108379. * rg is direction (like normal from -1 to 1)
  108380. * b is a intensity
  108381. */
  108382. texture: Nullable<BaseTexture>;
  108383. /** @hidden */
  108384. private _internalMarkAllSubMeshesAsTexturesDirty;
  108385. /** @hidden */
  108386. _markAllSubMeshesAsTexturesDirty(): void;
  108387. /**
  108388. * Instantiate a new istance of anisotropy configuration.
  108389. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  108390. */
  108391. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  108392. /**
  108393. * Specifies that the submesh is ready to be used.
  108394. * @param defines the list of "defines" to update.
  108395. * @param scene defines the scene the material belongs to.
  108396. * @returns - boolean indicating that the submesh is ready or not.
  108397. */
  108398. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  108399. /**
  108400. * Checks to see if a texture is used in the material.
  108401. * @param defines the list of "defines" to update.
  108402. * @param mesh the mesh we are preparing the defines for.
  108403. * @param scene defines the scene the material belongs to.
  108404. */
  108405. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  108406. /**
  108407. * Binds the material data.
  108408. * @param uniformBuffer defines the Uniform buffer to fill in.
  108409. * @param scene defines the scene the material belongs to.
  108410. * @param isFrozen defines wether the material is frozen or not.
  108411. */
  108412. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  108413. /**
  108414. * Checks to see if a texture is used in the material.
  108415. * @param texture - Base texture to use.
  108416. * @returns - Boolean specifying if a texture is used in the material.
  108417. */
  108418. hasTexture(texture: BaseTexture): boolean;
  108419. /**
  108420. * Returns an array of the actively used textures.
  108421. * @param activeTextures Array of BaseTextures
  108422. */
  108423. getActiveTextures(activeTextures: BaseTexture[]): void;
  108424. /**
  108425. * Returns the animatable textures.
  108426. * @param animatables Array of animatable textures.
  108427. */
  108428. getAnimatables(animatables: IAnimatable[]): void;
  108429. /**
  108430. * Disposes the resources of the material.
  108431. * @param forceDisposeTextures - Forces the disposal of all textures.
  108432. */
  108433. dispose(forceDisposeTextures?: boolean): void;
  108434. /**
  108435. * Get the current class name of the texture useful for serialization or dynamic coding.
  108436. * @returns "PBRAnisotropicConfiguration"
  108437. */
  108438. getClassName(): string;
  108439. /**
  108440. * Add fallbacks to the effect fallbacks list.
  108441. * @param defines defines the Base texture to use.
  108442. * @param fallbacks defines the current fallback list.
  108443. * @param currentRank defines the current fallback rank.
  108444. * @returns the new fallback rank.
  108445. */
  108446. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  108447. /**
  108448. * Add the required uniforms to the current list.
  108449. * @param uniforms defines the current uniform list.
  108450. */
  108451. static AddUniforms(uniforms: string[]): void;
  108452. /**
  108453. * Add the required uniforms to the current buffer.
  108454. * @param uniformBuffer defines the current uniform buffer.
  108455. */
  108456. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  108457. /**
  108458. * Add the required samplers to the current list.
  108459. * @param samplers defines the current sampler list.
  108460. */
  108461. static AddSamplers(samplers: string[]): void;
  108462. /**
  108463. * Makes a duplicate of the current configuration into another one.
  108464. * @param anisotropicConfiguration define the config where to copy the info
  108465. */
  108466. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  108467. /**
  108468. * Serializes this anisotropy configuration.
  108469. * @returns - An object with the serialized config.
  108470. */
  108471. serialize(): any;
  108472. /**
  108473. * Parses a anisotropy Configuration from a serialized object.
  108474. * @param source - Serialized object.
  108475. * @param scene Defines the scene we are parsing for
  108476. * @param rootUrl Defines the rootUrl to load from
  108477. */
  108478. parse(source: any, scene: Scene, rootUrl: string): void;
  108479. }
  108480. }
  108481. declare module BABYLON {
  108482. /**
  108483. * @hidden
  108484. */
  108485. export interface IMaterialBRDFDefines {
  108486. BRDF_V_HEIGHT_CORRELATED: boolean;
  108487. MS_BRDF_ENERGY_CONSERVATION: boolean;
  108488. SPHERICAL_HARMONICS: boolean;
  108489. /** @hidden */
  108490. _areMiscDirty: boolean;
  108491. }
  108492. /**
  108493. * Define the code related to the BRDF parameters of the pbr material.
  108494. */
  108495. export class PBRBRDFConfiguration {
  108496. /**
  108497. * Default value used for the energy conservation.
  108498. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  108499. */
  108500. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  108501. /**
  108502. * Default value used for the Smith Visibility Height Correlated mode.
  108503. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  108504. */
  108505. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  108506. /**
  108507. * Default value used for the IBL diffuse part.
  108508. * This can help switching back to the polynomials mode globally which is a tiny bit
  108509. * less GPU intensive at the drawback of a lower quality.
  108510. */
  108511. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  108512. private _useEnergyConservation;
  108513. /**
  108514. * Defines if the material uses energy conservation.
  108515. */
  108516. useEnergyConservation: boolean;
  108517. private _useSmithVisibilityHeightCorrelated;
  108518. /**
  108519. * LEGACY Mode set to false
  108520. * Defines if the material uses height smith correlated visibility term.
  108521. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  108522. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  108523. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  108524. * Not relying on height correlated will also disable energy conservation.
  108525. */
  108526. useSmithVisibilityHeightCorrelated: boolean;
  108527. private _useSphericalHarmonics;
  108528. /**
  108529. * LEGACY Mode set to false
  108530. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  108531. * diffuse part of the IBL.
  108532. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  108533. * to the ground truth.
  108534. */
  108535. useSphericalHarmonics: boolean;
  108536. /** @hidden */
  108537. private _internalMarkAllSubMeshesAsMiscDirty;
  108538. /** @hidden */
  108539. _markAllSubMeshesAsMiscDirty(): void;
  108540. /**
  108541. * Instantiate a new istance of clear coat configuration.
  108542. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  108543. */
  108544. constructor(markAllSubMeshesAsMiscDirty: () => void);
  108545. /**
  108546. * Checks to see if a texture is used in the material.
  108547. * @param defines the list of "defines" to update.
  108548. */
  108549. prepareDefines(defines: IMaterialBRDFDefines): void;
  108550. /**
  108551. * Get the current class name of the texture useful for serialization or dynamic coding.
  108552. * @returns "PBRClearCoatConfiguration"
  108553. */
  108554. getClassName(): string;
  108555. /**
  108556. * Makes a duplicate of the current configuration into another one.
  108557. * @param brdfConfiguration define the config where to copy the info
  108558. */
  108559. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  108560. /**
  108561. * Serializes this BRDF configuration.
  108562. * @returns - An object with the serialized config.
  108563. */
  108564. serialize(): any;
  108565. /**
  108566. * Parses a anisotropy Configuration from a serialized object.
  108567. * @param source - Serialized object.
  108568. * @param scene Defines the scene we are parsing for
  108569. * @param rootUrl Defines the rootUrl to load from
  108570. */
  108571. parse(source: any, scene: Scene, rootUrl: string): void;
  108572. }
  108573. }
  108574. declare module BABYLON {
  108575. /**
  108576. * @hidden
  108577. */
  108578. export interface IMaterialSheenDefines {
  108579. SHEEN: boolean;
  108580. SHEEN_TEXTURE: boolean;
  108581. SHEEN_TEXTUREDIRECTUV: number;
  108582. SHEEN_LINKWITHALBEDO: boolean;
  108583. /** @hidden */
  108584. _areTexturesDirty: boolean;
  108585. }
  108586. /**
  108587. * Define the code related to the Sheen parameters of the pbr material.
  108588. */
  108589. export class PBRSheenConfiguration {
  108590. private _isEnabled;
  108591. /**
  108592. * Defines if the material uses sheen.
  108593. */
  108594. isEnabled: boolean;
  108595. private _linkSheenWithAlbedo;
  108596. /**
  108597. * Defines if the sheen is linked to the sheen color.
  108598. */
  108599. linkSheenWithAlbedo: boolean;
  108600. /**
  108601. * Defines the sheen intensity.
  108602. */
  108603. intensity: number;
  108604. /**
  108605. * Defines the sheen color.
  108606. */
  108607. color: Color3;
  108608. private _texture;
  108609. /**
  108610. * Stores the sheen tint values in a texture.
  108611. * rgb is tint
  108612. * a is a intensity
  108613. */
  108614. texture: Nullable<BaseTexture>;
  108615. /** @hidden */
  108616. private _internalMarkAllSubMeshesAsTexturesDirty;
  108617. /** @hidden */
  108618. _markAllSubMeshesAsTexturesDirty(): void;
  108619. /**
  108620. * Instantiate a new istance of clear coat configuration.
  108621. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  108622. */
  108623. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  108624. /**
  108625. * Specifies that the submesh is ready to be used.
  108626. * @param defines the list of "defines" to update.
  108627. * @param scene defines the scene the material belongs to.
  108628. * @returns - boolean indicating that the submesh is ready or not.
  108629. */
  108630. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  108631. /**
  108632. * Checks to see if a texture is used in the material.
  108633. * @param defines the list of "defines" to update.
  108634. * @param scene defines the scene the material belongs to.
  108635. */
  108636. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  108637. /**
  108638. * Binds the material data.
  108639. * @param uniformBuffer defines the Uniform buffer to fill in.
  108640. * @param scene defines the scene the material belongs to.
  108641. * @param isFrozen defines wether the material is frozen or not.
  108642. */
  108643. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  108644. /**
  108645. * Checks to see if a texture is used in the material.
  108646. * @param texture - Base texture to use.
  108647. * @returns - Boolean specifying if a texture is used in the material.
  108648. */
  108649. hasTexture(texture: BaseTexture): boolean;
  108650. /**
  108651. * Returns an array of the actively used textures.
  108652. * @param activeTextures Array of BaseTextures
  108653. */
  108654. getActiveTextures(activeTextures: BaseTexture[]): void;
  108655. /**
  108656. * Returns the animatable textures.
  108657. * @param animatables Array of animatable textures.
  108658. */
  108659. getAnimatables(animatables: IAnimatable[]): void;
  108660. /**
  108661. * Disposes the resources of the material.
  108662. * @param forceDisposeTextures - Forces the disposal of all textures.
  108663. */
  108664. dispose(forceDisposeTextures?: boolean): void;
  108665. /**
  108666. * Get the current class name of the texture useful for serialization or dynamic coding.
  108667. * @returns "PBRSheenConfiguration"
  108668. */
  108669. getClassName(): string;
  108670. /**
  108671. * Add fallbacks to the effect fallbacks list.
  108672. * @param defines defines the Base texture to use.
  108673. * @param fallbacks defines the current fallback list.
  108674. * @param currentRank defines the current fallback rank.
  108675. * @returns the new fallback rank.
  108676. */
  108677. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  108678. /**
  108679. * Add the required uniforms to the current list.
  108680. * @param uniforms defines the current uniform list.
  108681. */
  108682. static AddUniforms(uniforms: string[]): void;
  108683. /**
  108684. * Add the required uniforms to the current buffer.
  108685. * @param uniformBuffer defines the current uniform buffer.
  108686. */
  108687. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  108688. /**
  108689. * Add the required samplers to the current list.
  108690. * @param samplers defines the current sampler list.
  108691. */
  108692. static AddSamplers(samplers: string[]): void;
  108693. /**
  108694. * Makes a duplicate of the current configuration into another one.
  108695. * @param sheenConfiguration define the config where to copy the info
  108696. */
  108697. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  108698. /**
  108699. * Serializes this BRDF configuration.
  108700. * @returns - An object with the serialized config.
  108701. */
  108702. serialize(): any;
  108703. /**
  108704. * Parses a anisotropy Configuration from a serialized object.
  108705. * @param source - Serialized object.
  108706. * @param scene Defines the scene we are parsing for
  108707. * @param rootUrl Defines the rootUrl to load from
  108708. */
  108709. parse(source: any, scene: Scene, rootUrl: string): void;
  108710. }
  108711. }
  108712. declare module BABYLON {
  108713. /**
  108714. * @hidden
  108715. */
  108716. export interface IMaterialSubSurfaceDefines {
  108717. SUBSURFACE: boolean;
  108718. SS_REFRACTION: boolean;
  108719. SS_TRANSLUCENCY: boolean;
  108720. SS_SCATERRING: boolean;
  108721. SS_THICKNESSANDMASK_TEXTURE: boolean;
  108722. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  108723. SS_REFRACTIONMAP_3D: boolean;
  108724. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  108725. SS_LODINREFRACTIONALPHA: boolean;
  108726. SS_GAMMAREFRACTION: boolean;
  108727. SS_RGBDREFRACTION: boolean;
  108728. SS_LINEARSPECULARREFRACTION: boolean;
  108729. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  108730. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  108731. /** @hidden */
  108732. _areTexturesDirty: boolean;
  108733. }
  108734. /**
  108735. * Define the code related to the sub surface parameters of the pbr material.
  108736. */
  108737. export class PBRSubSurfaceConfiguration {
  108738. private _isRefractionEnabled;
  108739. /**
  108740. * Defines if the refraction is enabled in the material.
  108741. */
  108742. isRefractionEnabled: boolean;
  108743. private _isTranslucencyEnabled;
  108744. /**
  108745. * Defines if the translucency is enabled in the material.
  108746. */
  108747. isTranslucencyEnabled: boolean;
  108748. private _isScatteringEnabled;
  108749. /**
  108750. * Defines the refraction intensity of the material.
  108751. * The refraction when enabled replaces the Diffuse part of the material.
  108752. * The intensity helps transitionning between diffuse and refraction.
  108753. */
  108754. refractionIntensity: number;
  108755. /**
  108756. * Defines the translucency intensity of the material.
  108757. * When translucency has been enabled, this defines how much of the "translucency"
  108758. * is addded to the diffuse part of the material.
  108759. */
  108760. translucencyIntensity: number;
  108761. /**
  108762. * Defines the scattering intensity of the material.
  108763. * When scattering has been enabled, this defines how much of the "scattered light"
  108764. * is addded to the diffuse part of the material.
  108765. */
  108766. scatteringIntensity: number;
  108767. private _thicknessTexture;
  108768. /**
  108769. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  108770. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  108771. * 0 would mean minimumThickness
  108772. * 1 would mean maximumThickness
  108773. * The other channels might be use as a mask to vary the different effects intensity.
  108774. */
  108775. thicknessTexture: Nullable<BaseTexture>;
  108776. private _refractionTexture;
  108777. /**
  108778. * Defines the texture to use for refraction.
  108779. */
  108780. refractionTexture: Nullable<BaseTexture>;
  108781. private _indexOfRefraction;
  108782. /**
  108783. * Defines the index of refraction used in the material.
  108784. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  108785. */
  108786. indexOfRefraction: number;
  108787. private _invertRefractionY;
  108788. /**
  108789. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  108790. */
  108791. invertRefractionY: boolean;
  108792. private _linkRefractionWithTransparency;
  108793. /**
  108794. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  108795. * Materials half opaque for instance using refraction could benefit from this control.
  108796. */
  108797. linkRefractionWithTransparency: boolean;
  108798. /**
  108799. * Defines the minimum thickness stored in the thickness map.
  108800. * If no thickness map is defined, this value will be used to simulate thickness.
  108801. */
  108802. minimumThickness: number;
  108803. /**
  108804. * Defines the maximum thickness stored in the thickness map.
  108805. */
  108806. maximumThickness: number;
  108807. /**
  108808. * Defines the volume tint of the material.
  108809. * This is used for both translucency and scattering.
  108810. */
  108811. tintColor: Color3;
  108812. /**
  108813. * Defines the distance at which the tint color should be found in the media.
  108814. * This is used for refraction only.
  108815. */
  108816. tintColorAtDistance: number;
  108817. /**
  108818. * Defines how far each channel transmit through the media.
  108819. * It is defined as a color to simplify it selection.
  108820. */
  108821. diffusionDistance: Color3;
  108822. private _useMaskFromThicknessTexture;
  108823. /**
  108824. * Stores the intensity of the different subsurface effects in the thickness texture.
  108825. * * the green channel is the translucency intensity.
  108826. * * the blue channel is the scattering intensity.
  108827. * * the alpha channel is the refraction intensity.
  108828. */
  108829. useMaskFromThicknessTexture: boolean;
  108830. /** @hidden */
  108831. private _internalMarkAllSubMeshesAsTexturesDirty;
  108832. /** @hidden */
  108833. _markAllSubMeshesAsTexturesDirty(): void;
  108834. /**
  108835. * Instantiate a new istance of sub surface configuration.
  108836. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  108837. */
  108838. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  108839. /**
  108840. * Gets wehter the submesh is ready to be used or not.
  108841. * @param defines the list of "defines" to update.
  108842. * @param scene defines the scene the material belongs to.
  108843. * @returns - boolean indicating that the submesh is ready or not.
  108844. */
  108845. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  108846. /**
  108847. * Checks to see if a texture is used in the material.
  108848. * @param defines the list of "defines" to update.
  108849. * @param scene defines the scene to the material belongs to.
  108850. */
  108851. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  108852. /**
  108853. * Binds the material data.
  108854. * @param uniformBuffer defines the Uniform buffer to fill in.
  108855. * @param scene defines the scene the material belongs to.
  108856. * @param engine defines the engine the material belongs to.
  108857. * @param isFrozen defines wether the material is frozen or not.
  108858. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  108859. */
  108860. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  108861. /**
  108862. * Unbinds the material from the mesh.
  108863. * @param activeEffect defines the effect that should be unbound from.
  108864. * @returns true if unbound, otherwise false
  108865. */
  108866. unbind(activeEffect: Effect): boolean;
  108867. /**
  108868. * Returns the texture used for refraction or null if none is used.
  108869. * @param scene defines the scene the material belongs to.
  108870. * @returns - Refraction texture if present. If no refraction texture and refraction
  108871. * is linked with transparency, returns environment texture. Otherwise, returns null.
  108872. */
  108873. private _getRefractionTexture;
  108874. /**
  108875. * Returns true if alpha blending should be disabled.
  108876. */
  108877. readonly disableAlphaBlending: boolean;
  108878. /**
  108879. * Fills the list of render target textures.
  108880. * @param renderTargets the list of render targets to update
  108881. */
  108882. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  108883. /**
  108884. * Checks to see if a texture is used in the material.
  108885. * @param texture - Base texture to use.
  108886. * @returns - Boolean specifying if a texture is used in the material.
  108887. */
  108888. hasTexture(texture: BaseTexture): boolean;
  108889. /**
  108890. * Gets a boolean indicating that current material needs to register RTT
  108891. * @returns true if this uses a render target otherwise false.
  108892. */
  108893. hasRenderTargetTextures(): boolean;
  108894. /**
  108895. * Returns an array of the actively used textures.
  108896. * @param activeTextures Array of BaseTextures
  108897. */
  108898. getActiveTextures(activeTextures: BaseTexture[]): void;
  108899. /**
  108900. * Returns the animatable textures.
  108901. * @param animatables Array of animatable textures.
  108902. */
  108903. getAnimatables(animatables: IAnimatable[]): void;
  108904. /**
  108905. * Disposes the resources of the material.
  108906. * @param forceDisposeTextures - Forces the disposal of all textures.
  108907. */
  108908. dispose(forceDisposeTextures?: boolean): void;
  108909. /**
  108910. * Get the current class name of the texture useful for serialization or dynamic coding.
  108911. * @returns "PBRSubSurfaceConfiguration"
  108912. */
  108913. getClassName(): string;
  108914. /**
  108915. * Add fallbacks to the effect fallbacks list.
  108916. * @param defines defines the Base texture to use.
  108917. * @param fallbacks defines the current fallback list.
  108918. * @param currentRank defines the current fallback rank.
  108919. * @returns the new fallback rank.
  108920. */
  108921. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  108922. /**
  108923. * Add the required uniforms to the current list.
  108924. * @param uniforms defines the current uniform list.
  108925. */
  108926. static AddUniforms(uniforms: string[]): void;
  108927. /**
  108928. * Add the required samplers to the current list.
  108929. * @param samplers defines the current sampler list.
  108930. */
  108931. static AddSamplers(samplers: string[]): void;
  108932. /**
  108933. * Add the required uniforms to the current buffer.
  108934. * @param uniformBuffer defines the current uniform buffer.
  108935. */
  108936. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  108937. /**
  108938. * Makes a duplicate of the current configuration into another one.
  108939. * @param configuration define the config where to copy the info
  108940. */
  108941. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  108942. /**
  108943. * Serializes this Sub Surface configuration.
  108944. * @returns - An object with the serialized config.
  108945. */
  108946. serialize(): any;
  108947. /**
  108948. * Parses a anisotropy Configuration from a serialized object.
  108949. * @param source - Serialized object.
  108950. * @param scene Defines the scene we are parsing for
  108951. * @param rootUrl Defines the rootUrl to load from
  108952. */
  108953. parse(source: any, scene: Scene, rootUrl: string): void;
  108954. }
  108955. }
  108956. declare module BABYLON {
  108957. /** @hidden */
  108958. export var pbrFragmentDeclaration: {
  108959. name: string;
  108960. shader: string;
  108961. };
  108962. }
  108963. declare module BABYLON {
  108964. /** @hidden */
  108965. export var pbrUboDeclaration: {
  108966. name: string;
  108967. shader: string;
  108968. };
  108969. }
  108970. declare module BABYLON {
  108971. /** @hidden */
  108972. export var pbrFragmentExtraDeclaration: {
  108973. name: string;
  108974. shader: string;
  108975. };
  108976. }
  108977. declare module BABYLON {
  108978. /** @hidden */
  108979. export var pbrFragmentSamplersDeclaration: {
  108980. name: string;
  108981. shader: string;
  108982. };
  108983. }
  108984. declare module BABYLON {
  108985. /** @hidden */
  108986. export var pbrHelperFunctions: {
  108987. name: string;
  108988. shader: string;
  108989. };
  108990. }
  108991. declare module BABYLON {
  108992. /** @hidden */
  108993. export var harmonicsFunctions: {
  108994. name: string;
  108995. shader: string;
  108996. };
  108997. }
  108998. declare module BABYLON {
  108999. /** @hidden */
  109000. export var pbrDirectLightingSetupFunctions: {
  109001. name: string;
  109002. shader: string;
  109003. };
  109004. }
  109005. declare module BABYLON {
  109006. /** @hidden */
  109007. export var pbrDirectLightingFalloffFunctions: {
  109008. name: string;
  109009. shader: string;
  109010. };
  109011. }
  109012. declare module BABYLON {
  109013. /** @hidden */
  109014. export var pbrBRDFFunctions: {
  109015. name: string;
  109016. shader: string;
  109017. };
  109018. }
  109019. declare module BABYLON {
  109020. /** @hidden */
  109021. export var pbrDirectLightingFunctions: {
  109022. name: string;
  109023. shader: string;
  109024. };
  109025. }
  109026. declare module BABYLON {
  109027. /** @hidden */
  109028. export var pbrIBLFunctions: {
  109029. name: string;
  109030. shader: string;
  109031. };
  109032. }
  109033. declare module BABYLON {
  109034. /** @hidden */
  109035. export var pbrDebug: {
  109036. name: string;
  109037. shader: string;
  109038. };
  109039. }
  109040. declare module BABYLON {
  109041. /** @hidden */
  109042. export var pbrPixelShader: {
  109043. name: string;
  109044. shader: string;
  109045. };
  109046. }
  109047. declare module BABYLON {
  109048. /** @hidden */
  109049. export var pbrVertexDeclaration: {
  109050. name: string;
  109051. shader: string;
  109052. };
  109053. }
  109054. declare module BABYLON {
  109055. /** @hidden */
  109056. export var pbrVertexShader: {
  109057. name: string;
  109058. shader: string;
  109059. };
  109060. }
  109061. declare module BABYLON {
  109062. /**
  109063. * Manages the defines for the PBR Material.
  109064. * @hidden
  109065. */
  109066. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  109067. PBR: boolean;
  109068. MAINUV1: boolean;
  109069. MAINUV2: boolean;
  109070. UV1: boolean;
  109071. UV2: boolean;
  109072. ALBEDO: boolean;
  109073. ALBEDODIRECTUV: number;
  109074. VERTEXCOLOR: boolean;
  109075. AMBIENT: boolean;
  109076. AMBIENTDIRECTUV: number;
  109077. AMBIENTINGRAYSCALE: boolean;
  109078. OPACITY: boolean;
  109079. VERTEXALPHA: boolean;
  109080. OPACITYDIRECTUV: number;
  109081. OPACITYRGB: boolean;
  109082. ALPHATEST: boolean;
  109083. DEPTHPREPASS: boolean;
  109084. ALPHABLEND: boolean;
  109085. ALPHAFROMALBEDO: boolean;
  109086. ALPHATESTVALUE: string;
  109087. SPECULAROVERALPHA: boolean;
  109088. RADIANCEOVERALPHA: boolean;
  109089. ALPHAFRESNEL: boolean;
  109090. LINEARALPHAFRESNEL: boolean;
  109091. PREMULTIPLYALPHA: boolean;
  109092. EMISSIVE: boolean;
  109093. EMISSIVEDIRECTUV: number;
  109094. REFLECTIVITY: boolean;
  109095. REFLECTIVITYDIRECTUV: number;
  109096. SPECULARTERM: boolean;
  109097. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  109098. MICROSURFACEAUTOMATIC: boolean;
  109099. LODBASEDMICROSFURACE: boolean;
  109100. MICROSURFACEMAP: boolean;
  109101. MICROSURFACEMAPDIRECTUV: number;
  109102. METALLICWORKFLOW: boolean;
  109103. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  109104. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  109105. METALLNESSSTOREINMETALMAPBLUE: boolean;
  109106. AOSTOREINMETALMAPRED: boolean;
  109107. ENVIRONMENTBRDF: boolean;
  109108. ENVIRONMENTBRDF_RGBD: boolean;
  109109. NORMAL: boolean;
  109110. TANGENT: boolean;
  109111. BUMP: boolean;
  109112. BUMPDIRECTUV: number;
  109113. OBJECTSPACE_NORMALMAP: boolean;
  109114. PARALLAX: boolean;
  109115. PARALLAXOCCLUSION: boolean;
  109116. NORMALXYSCALE: boolean;
  109117. LIGHTMAP: boolean;
  109118. LIGHTMAPDIRECTUV: number;
  109119. USELIGHTMAPASSHADOWMAP: boolean;
  109120. GAMMALIGHTMAP: boolean;
  109121. REFLECTION: boolean;
  109122. REFLECTIONMAP_3D: boolean;
  109123. REFLECTIONMAP_SPHERICAL: boolean;
  109124. REFLECTIONMAP_PLANAR: boolean;
  109125. REFLECTIONMAP_CUBIC: boolean;
  109126. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  109127. REFLECTIONMAP_PROJECTION: boolean;
  109128. REFLECTIONMAP_SKYBOX: boolean;
  109129. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  109130. REFLECTIONMAP_EXPLICIT: boolean;
  109131. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  109132. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  109133. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  109134. INVERTCUBICMAP: boolean;
  109135. USESPHERICALFROMREFLECTIONMAP: boolean;
  109136. USEIRRADIANCEMAP: boolean;
  109137. SPHERICAL_HARMONICS: boolean;
  109138. USESPHERICALINVERTEX: boolean;
  109139. REFLECTIONMAP_OPPOSITEZ: boolean;
  109140. LODINREFLECTIONALPHA: boolean;
  109141. GAMMAREFLECTION: boolean;
  109142. RGBDREFLECTION: boolean;
  109143. LINEARSPECULARREFLECTION: boolean;
  109144. RADIANCEOCCLUSION: boolean;
  109145. HORIZONOCCLUSION: boolean;
  109146. INSTANCES: boolean;
  109147. NUM_BONE_INFLUENCERS: number;
  109148. BonesPerMesh: number;
  109149. BONETEXTURE: boolean;
  109150. NONUNIFORMSCALING: boolean;
  109151. MORPHTARGETS: boolean;
  109152. MORPHTARGETS_NORMAL: boolean;
  109153. MORPHTARGETS_TANGENT: boolean;
  109154. MORPHTARGETS_UV: boolean;
  109155. NUM_MORPH_INFLUENCERS: number;
  109156. IMAGEPROCESSING: boolean;
  109157. VIGNETTE: boolean;
  109158. VIGNETTEBLENDMODEMULTIPLY: boolean;
  109159. VIGNETTEBLENDMODEOPAQUE: boolean;
  109160. TONEMAPPING: boolean;
  109161. TONEMAPPING_ACES: boolean;
  109162. CONTRAST: boolean;
  109163. COLORCURVES: boolean;
  109164. COLORGRADING: boolean;
  109165. COLORGRADING3D: boolean;
  109166. SAMPLER3DGREENDEPTH: boolean;
  109167. SAMPLER3DBGRMAP: boolean;
  109168. IMAGEPROCESSINGPOSTPROCESS: boolean;
  109169. EXPOSURE: boolean;
  109170. MULTIVIEW: boolean;
  109171. USEPHYSICALLIGHTFALLOFF: boolean;
  109172. USEGLTFLIGHTFALLOFF: boolean;
  109173. TWOSIDEDLIGHTING: boolean;
  109174. SHADOWFLOAT: boolean;
  109175. CLIPPLANE: boolean;
  109176. CLIPPLANE2: boolean;
  109177. CLIPPLANE3: boolean;
  109178. CLIPPLANE4: boolean;
  109179. POINTSIZE: boolean;
  109180. FOG: boolean;
  109181. LOGARITHMICDEPTH: boolean;
  109182. FORCENORMALFORWARD: boolean;
  109183. SPECULARAA: boolean;
  109184. CLEARCOAT: boolean;
  109185. CLEARCOAT_DEFAULTIOR: boolean;
  109186. CLEARCOAT_TEXTURE: boolean;
  109187. CLEARCOAT_TEXTUREDIRECTUV: number;
  109188. CLEARCOAT_BUMP: boolean;
  109189. CLEARCOAT_BUMPDIRECTUV: number;
  109190. CLEARCOAT_TINT: boolean;
  109191. CLEARCOAT_TINT_TEXTURE: boolean;
  109192. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  109193. ANISOTROPIC: boolean;
  109194. ANISOTROPIC_TEXTURE: boolean;
  109195. ANISOTROPIC_TEXTUREDIRECTUV: number;
  109196. BRDF_V_HEIGHT_CORRELATED: boolean;
  109197. MS_BRDF_ENERGY_CONSERVATION: boolean;
  109198. SHEEN: boolean;
  109199. SHEEN_TEXTURE: boolean;
  109200. SHEEN_TEXTUREDIRECTUV: number;
  109201. SHEEN_LINKWITHALBEDO: boolean;
  109202. SUBSURFACE: boolean;
  109203. SS_REFRACTION: boolean;
  109204. SS_TRANSLUCENCY: boolean;
  109205. SS_SCATERRING: boolean;
  109206. SS_THICKNESSANDMASK_TEXTURE: boolean;
  109207. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  109208. SS_REFRACTIONMAP_3D: boolean;
  109209. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  109210. SS_LODINREFRACTIONALPHA: boolean;
  109211. SS_GAMMAREFRACTION: boolean;
  109212. SS_RGBDREFRACTION: boolean;
  109213. SS_LINEARSPECULARREFRACTION: boolean;
  109214. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  109215. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  109216. UNLIT: boolean;
  109217. DEBUGMODE: number;
  109218. /**
  109219. * Initializes the PBR Material defines.
  109220. */
  109221. constructor();
  109222. /**
  109223. * Resets the PBR Material defines.
  109224. */
  109225. reset(): void;
  109226. }
  109227. /**
  109228. * The Physically based material base class of BJS.
  109229. *
  109230. * This offers the main features of a standard PBR material.
  109231. * For more information, please refer to the documentation :
  109232. * https://doc.babylonjs.com/how_to/physically_based_rendering
  109233. */
  109234. export abstract class PBRBaseMaterial extends PushMaterial {
  109235. /**
  109236. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  109237. */
  109238. static readonly PBRMATERIAL_OPAQUE: number;
  109239. /**
  109240. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  109241. */
  109242. static readonly PBRMATERIAL_ALPHATEST: number;
  109243. /**
  109244. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109245. */
  109246. static readonly PBRMATERIAL_ALPHABLEND: number;
  109247. /**
  109248. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109249. * They are also discarded below the alpha cutoff threshold to improve performances.
  109250. */
  109251. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  109252. /**
  109253. * Defines the default value of how much AO map is occluding the analytical lights
  109254. * (point spot...).
  109255. */
  109256. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  109257. /**
  109258. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  109259. */
  109260. static readonly LIGHTFALLOFF_PHYSICAL: number;
  109261. /**
  109262. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  109263. * to enhance interoperability with other engines.
  109264. */
  109265. static readonly LIGHTFALLOFF_GLTF: number;
  109266. /**
  109267. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  109268. * to enhance interoperability with other materials.
  109269. */
  109270. static readonly LIGHTFALLOFF_STANDARD: number;
  109271. /**
  109272. * Intensity of the direct lights e.g. the four lights available in your scene.
  109273. * This impacts both the direct diffuse and specular highlights.
  109274. */
  109275. protected _directIntensity: number;
  109276. /**
  109277. * Intensity of the emissive part of the material.
  109278. * This helps controlling the emissive effect without modifying the emissive color.
  109279. */
  109280. protected _emissiveIntensity: number;
  109281. /**
  109282. * Intensity of the environment e.g. how much the environment will light the object
  109283. * either through harmonics for rough material or through the refelction for shiny ones.
  109284. */
  109285. protected _environmentIntensity: number;
  109286. /**
  109287. * This is a special control allowing the reduction of the specular highlights coming from the
  109288. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  109289. */
  109290. protected _specularIntensity: number;
  109291. /**
  109292. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  109293. */
  109294. private _lightingInfos;
  109295. /**
  109296. * Debug Control allowing disabling the bump map on this material.
  109297. */
  109298. protected _disableBumpMap: boolean;
  109299. /**
  109300. * AKA Diffuse Texture in standard nomenclature.
  109301. */
  109302. protected _albedoTexture: Nullable<BaseTexture>;
  109303. /**
  109304. * AKA Occlusion Texture in other nomenclature.
  109305. */
  109306. protected _ambientTexture: Nullable<BaseTexture>;
  109307. /**
  109308. * AKA Occlusion Texture Intensity in other nomenclature.
  109309. */
  109310. protected _ambientTextureStrength: number;
  109311. /**
  109312. * Defines how much the AO map is occluding the analytical lights (point spot...).
  109313. * 1 means it completely occludes it
  109314. * 0 mean it has no impact
  109315. */
  109316. protected _ambientTextureImpactOnAnalyticalLights: number;
  109317. /**
  109318. * Stores the alpha values in a texture.
  109319. */
  109320. protected _opacityTexture: Nullable<BaseTexture>;
  109321. /**
  109322. * Stores the reflection values in a texture.
  109323. */
  109324. protected _reflectionTexture: Nullable<BaseTexture>;
  109325. /**
  109326. * Stores the emissive values in a texture.
  109327. */
  109328. protected _emissiveTexture: Nullable<BaseTexture>;
  109329. /**
  109330. * AKA Specular texture in other nomenclature.
  109331. */
  109332. protected _reflectivityTexture: Nullable<BaseTexture>;
  109333. /**
  109334. * Used to switch from specular/glossiness to metallic/roughness workflow.
  109335. */
  109336. protected _metallicTexture: Nullable<BaseTexture>;
  109337. /**
  109338. * Specifies the metallic scalar of the metallic/roughness workflow.
  109339. * Can also be used to scale the metalness values of the metallic texture.
  109340. */
  109341. protected _metallic: Nullable<number>;
  109342. /**
  109343. * Specifies the roughness scalar of the metallic/roughness workflow.
  109344. * Can also be used to scale the roughness values of the metallic texture.
  109345. */
  109346. protected _roughness: Nullable<number>;
  109347. /**
  109348. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  109349. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  109350. */
  109351. protected _microSurfaceTexture: Nullable<BaseTexture>;
  109352. /**
  109353. * Stores surface normal data used to displace a mesh in a texture.
  109354. */
  109355. protected _bumpTexture: Nullable<BaseTexture>;
  109356. /**
  109357. * Stores the pre-calculated light information of a mesh in a texture.
  109358. */
  109359. protected _lightmapTexture: Nullable<BaseTexture>;
  109360. /**
  109361. * The color of a material in ambient lighting.
  109362. */
  109363. protected _ambientColor: Color3;
  109364. /**
  109365. * AKA Diffuse Color in other nomenclature.
  109366. */
  109367. protected _albedoColor: Color3;
  109368. /**
  109369. * AKA Specular Color in other nomenclature.
  109370. */
  109371. protected _reflectivityColor: Color3;
  109372. /**
  109373. * The color applied when light is reflected from a material.
  109374. */
  109375. protected _reflectionColor: Color3;
  109376. /**
  109377. * The color applied when light is emitted from a material.
  109378. */
  109379. protected _emissiveColor: Color3;
  109380. /**
  109381. * AKA Glossiness in other nomenclature.
  109382. */
  109383. protected _microSurface: number;
  109384. /**
  109385. * Specifies that the material will use the light map as a show map.
  109386. */
  109387. protected _useLightmapAsShadowmap: boolean;
  109388. /**
  109389. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  109390. * makes the reflect vector face the model (under horizon).
  109391. */
  109392. protected _useHorizonOcclusion: boolean;
  109393. /**
  109394. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  109395. * too much the area relying on ambient texture to define their ambient occlusion.
  109396. */
  109397. protected _useRadianceOcclusion: boolean;
  109398. /**
  109399. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  109400. */
  109401. protected _useAlphaFromAlbedoTexture: boolean;
  109402. /**
  109403. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  109404. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  109405. */
  109406. protected _useSpecularOverAlpha: boolean;
  109407. /**
  109408. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  109409. */
  109410. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  109411. /**
  109412. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  109413. */
  109414. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  109415. /**
  109416. * Specifies if the metallic texture contains the roughness information in its green channel.
  109417. */
  109418. protected _useRoughnessFromMetallicTextureGreen: boolean;
  109419. /**
  109420. * Specifies if the metallic texture contains the metallness information in its blue channel.
  109421. */
  109422. protected _useMetallnessFromMetallicTextureBlue: boolean;
  109423. /**
  109424. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  109425. */
  109426. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  109427. /**
  109428. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  109429. */
  109430. protected _useAmbientInGrayScale: boolean;
  109431. /**
  109432. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  109433. * The material will try to infer what glossiness each pixel should be.
  109434. */
  109435. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  109436. /**
  109437. * Defines the falloff type used in this material.
  109438. * It by default is Physical.
  109439. */
  109440. protected _lightFalloff: number;
  109441. /**
  109442. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  109443. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  109444. */
  109445. protected _useRadianceOverAlpha: boolean;
  109446. /**
  109447. * Allows using an object space normal map (instead of tangent space).
  109448. */
  109449. protected _useObjectSpaceNormalMap: boolean;
  109450. /**
  109451. * Allows using the bump map in parallax mode.
  109452. */
  109453. protected _useParallax: boolean;
  109454. /**
  109455. * Allows using the bump map in parallax occlusion mode.
  109456. */
  109457. protected _useParallaxOcclusion: boolean;
  109458. /**
  109459. * Controls the scale bias of the parallax mode.
  109460. */
  109461. protected _parallaxScaleBias: number;
  109462. /**
  109463. * If sets to true, disables all the lights affecting the material.
  109464. */
  109465. protected _disableLighting: boolean;
  109466. /**
  109467. * Number of Simultaneous lights allowed on the material.
  109468. */
  109469. protected _maxSimultaneousLights: number;
  109470. /**
  109471. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  109472. */
  109473. protected _invertNormalMapX: boolean;
  109474. /**
  109475. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  109476. */
  109477. protected _invertNormalMapY: boolean;
  109478. /**
  109479. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  109480. */
  109481. protected _twoSidedLighting: boolean;
  109482. /**
  109483. * Defines the alpha limits in alpha test mode.
  109484. */
  109485. protected _alphaCutOff: number;
  109486. /**
  109487. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  109488. */
  109489. protected _forceAlphaTest: boolean;
  109490. /**
  109491. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  109492. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  109493. */
  109494. protected _useAlphaFresnel: boolean;
  109495. /**
  109496. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  109497. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  109498. */
  109499. protected _useLinearAlphaFresnel: boolean;
  109500. /**
  109501. * The transparency mode of the material.
  109502. */
  109503. protected _transparencyMode: Nullable<number>;
  109504. /**
  109505. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  109506. * from cos thetav and roughness:
  109507. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  109508. */
  109509. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  109510. /**
  109511. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  109512. */
  109513. protected _forceIrradianceInFragment: boolean;
  109514. /**
  109515. * Force normal to face away from face.
  109516. */
  109517. protected _forceNormalForward: boolean;
  109518. /**
  109519. * Enables specular anti aliasing in the PBR shader.
  109520. * It will both interacts on the Geometry for analytical and IBL lighting.
  109521. * It also prefilter the roughness map based on the bump values.
  109522. */
  109523. protected _enableSpecularAntiAliasing: boolean;
  109524. /**
  109525. * Default configuration related to image processing available in the PBR Material.
  109526. */
  109527. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109528. /**
  109529. * Keep track of the image processing observer to allow dispose and replace.
  109530. */
  109531. private _imageProcessingObserver;
  109532. /**
  109533. * Attaches a new image processing configuration to the PBR Material.
  109534. * @param configuration
  109535. */
  109536. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  109537. /**
  109538. * Stores the available render targets.
  109539. */
  109540. private _renderTargets;
  109541. /**
  109542. * Sets the global ambient color for the material used in lighting calculations.
  109543. */
  109544. private _globalAmbientColor;
  109545. /**
  109546. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  109547. */
  109548. private _useLogarithmicDepth;
  109549. /**
  109550. * If set to true, no lighting calculations will be applied.
  109551. */
  109552. private _unlit;
  109553. private _debugMode;
  109554. /**
  109555. * @hidden
  109556. * This is reserved for the inspector.
  109557. * Defines the material debug mode.
  109558. * It helps seeing only some components of the material while troubleshooting.
  109559. */
  109560. debugMode: number;
  109561. /**
  109562. * @hidden
  109563. * This is reserved for the inspector.
  109564. * Specify from where on screen the debug mode should start.
  109565. * The value goes from -1 (full screen) to 1 (not visible)
  109566. * It helps with side by side comparison against the final render
  109567. * This defaults to -1
  109568. */
  109569. private debugLimit;
  109570. /**
  109571. * @hidden
  109572. * This is reserved for the inspector.
  109573. * As the default viewing range might not be enough (if the ambient is really small for instance)
  109574. * You can use the factor to better multiply the final value.
  109575. */
  109576. private debugFactor;
  109577. /**
  109578. * Defines the clear coat layer parameters for the material.
  109579. */
  109580. readonly clearCoat: PBRClearCoatConfiguration;
  109581. /**
  109582. * Defines the anisotropic parameters for the material.
  109583. */
  109584. readonly anisotropy: PBRAnisotropicConfiguration;
  109585. /**
  109586. * Defines the BRDF parameters for the material.
  109587. */
  109588. readonly brdf: PBRBRDFConfiguration;
  109589. /**
  109590. * Defines the Sheen parameters for the material.
  109591. */
  109592. readonly sheen: PBRSheenConfiguration;
  109593. /**
  109594. * Defines the SubSurface parameters for the material.
  109595. */
  109596. readonly subSurface: PBRSubSurfaceConfiguration;
  109597. /**
  109598. * Custom callback helping to override the default shader used in the material.
  109599. */
  109600. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  109601. /**
  109602. * Instantiates a new PBRMaterial instance.
  109603. *
  109604. * @param name The material name
  109605. * @param scene The scene the material will be use in.
  109606. */
  109607. constructor(name: string, scene: Scene);
  109608. /**
  109609. * Gets a boolean indicating that current material needs to register RTT
  109610. */
  109611. readonly hasRenderTargetTextures: boolean;
  109612. /**
  109613. * Gets the name of the material class.
  109614. */
  109615. getClassName(): string;
  109616. /**
  109617. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  109618. */
  109619. /**
  109620. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  109621. */
  109622. useLogarithmicDepth: boolean;
  109623. /**
  109624. * Gets the current transparency mode.
  109625. */
  109626. /**
  109627. * Sets the transparency mode of the material.
  109628. *
  109629. * | Value | Type | Description |
  109630. * | ----- | ----------------------------------- | ----------- |
  109631. * | 0 | OPAQUE | |
  109632. * | 1 | ALPHATEST | |
  109633. * | 2 | ALPHABLEND | |
  109634. * | 3 | ALPHATESTANDBLEND | |
  109635. *
  109636. */
  109637. transparencyMode: Nullable<number>;
  109638. /**
  109639. * Returns true if alpha blending should be disabled.
  109640. */
  109641. private readonly _disableAlphaBlending;
  109642. /**
  109643. * Specifies whether or not this material should be rendered in alpha blend mode.
  109644. */
  109645. needAlphaBlending(): boolean;
  109646. /**
  109647. * Specifies if the mesh will require alpha blending.
  109648. * @param mesh - BJS mesh.
  109649. */
  109650. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  109651. /**
  109652. * Specifies whether or not this material should be rendered in alpha test mode.
  109653. */
  109654. needAlphaTesting(): boolean;
  109655. /**
  109656. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  109657. */
  109658. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  109659. /**
  109660. * Gets the texture used for the alpha test.
  109661. */
  109662. getAlphaTestTexture(): Nullable<BaseTexture>;
  109663. /**
  109664. * Specifies that the submesh is ready to be used.
  109665. * @param mesh - BJS mesh.
  109666. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  109667. * @param useInstances - Specifies that instances should be used.
  109668. * @returns - boolean indicating that the submesh is ready or not.
  109669. */
  109670. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109671. /**
  109672. * Specifies if the material uses metallic roughness workflow.
  109673. * @returns boolean specifiying if the material uses metallic roughness workflow.
  109674. */
  109675. isMetallicWorkflow(): boolean;
  109676. private _prepareEffect;
  109677. private _prepareDefines;
  109678. /**
  109679. * Force shader compilation
  109680. */
  109681. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  109682. clipPlane: boolean;
  109683. }>): void;
  109684. /**
  109685. * Initializes the uniform buffer layout for the shader.
  109686. */
  109687. buildUniformLayout(): void;
  109688. /**
  109689. * Unbinds the material from the mesh
  109690. */
  109691. unbind(): void;
  109692. /**
  109693. * Binds the submesh data.
  109694. * @param world - The world matrix.
  109695. * @param mesh - The BJS mesh.
  109696. * @param subMesh - A submesh of the BJS mesh.
  109697. */
  109698. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109699. /**
  109700. * Returns the animatable textures.
  109701. * @returns - Array of animatable textures.
  109702. */
  109703. getAnimatables(): IAnimatable[];
  109704. /**
  109705. * Returns the texture used for reflections.
  109706. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  109707. */
  109708. private _getReflectionTexture;
  109709. /**
  109710. * Returns an array of the actively used textures.
  109711. * @returns - Array of BaseTextures
  109712. */
  109713. getActiveTextures(): BaseTexture[];
  109714. /**
  109715. * Checks to see if a texture is used in the material.
  109716. * @param texture - Base texture to use.
  109717. * @returns - Boolean specifying if a texture is used in the material.
  109718. */
  109719. hasTexture(texture: BaseTexture): boolean;
  109720. /**
  109721. * Disposes the resources of the material.
  109722. * @param forceDisposeEffect - Forces the disposal of effects.
  109723. * @param forceDisposeTextures - Forces the disposal of all textures.
  109724. */
  109725. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  109726. }
  109727. }
  109728. declare module BABYLON {
  109729. /**
  109730. * The Physically based material of BJS.
  109731. *
  109732. * This offers the main features of a standard PBR material.
  109733. * For more information, please refer to the documentation :
  109734. * https://doc.babylonjs.com/how_to/physically_based_rendering
  109735. */
  109736. export class PBRMaterial extends PBRBaseMaterial {
  109737. /**
  109738. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  109739. */
  109740. static readonly PBRMATERIAL_OPAQUE: number;
  109741. /**
  109742. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  109743. */
  109744. static readonly PBRMATERIAL_ALPHATEST: number;
  109745. /**
  109746. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109747. */
  109748. static readonly PBRMATERIAL_ALPHABLEND: number;
  109749. /**
  109750. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109751. * They are also discarded below the alpha cutoff threshold to improve performances.
  109752. */
  109753. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  109754. /**
  109755. * Defines the default value of how much AO map is occluding the analytical lights
  109756. * (point spot...).
  109757. */
  109758. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  109759. /**
  109760. * Intensity of the direct lights e.g. the four lights available in your scene.
  109761. * This impacts both the direct diffuse and specular highlights.
  109762. */
  109763. directIntensity: number;
  109764. /**
  109765. * Intensity of the emissive part of the material.
  109766. * This helps controlling the emissive effect without modifying the emissive color.
  109767. */
  109768. emissiveIntensity: number;
  109769. /**
  109770. * Intensity of the environment e.g. how much the environment will light the object
  109771. * either through harmonics for rough material or through the refelction for shiny ones.
  109772. */
  109773. environmentIntensity: number;
  109774. /**
  109775. * This is a special control allowing the reduction of the specular highlights coming from the
  109776. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  109777. */
  109778. specularIntensity: number;
  109779. /**
  109780. * Debug Control allowing disabling the bump map on this material.
  109781. */
  109782. disableBumpMap: boolean;
  109783. /**
  109784. * AKA Diffuse Texture in standard nomenclature.
  109785. */
  109786. albedoTexture: BaseTexture;
  109787. /**
  109788. * AKA Occlusion Texture in other nomenclature.
  109789. */
  109790. ambientTexture: BaseTexture;
  109791. /**
  109792. * AKA Occlusion Texture Intensity in other nomenclature.
  109793. */
  109794. ambientTextureStrength: number;
  109795. /**
  109796. * Defines how much the AO map is occluding the analytical lights (point spot...).
  109797. * 1 means it completely occludes it
  109798. * 0 mean it has no impact
  109799. */
  109800. ambientTextureImpactOnAnalyticalLights: number;
  109801. /**
  109802. * Stores the alpha values in a texture.
  109803. */
  109804. opacityTexture: BaseTexture;
  109805. /**
  109806. * Stores the reflection values in a texture.
  109807. */
  109808. reflectionTexture: Nullable<BaseTexture>;
  109809. /**
  109810. * Stores the emissive values in a texture.
  109811. */
  109812. emissiveTexture: BaseTexture;
  109813. /**
  109814. * AKA Specular texture in other nomenclature.
  109815. */
  109816. reflectivityTexture: BaseTexture;
  109817. /**
  109818. * Used to switch from specular/glossiness to metallic/roughness workflow.
  109819. */
  109820. metallicTexture: BaseTexture;
  109821. /**
  109822. * Specifies the metallic scalar of the metallic/roughness workflow.
  109823. * Can also be used to scale the metalness values of the metallic texture.
  109824. */
  109825. metallic: Nullable<number>;
  109826. /**
  109827. * Specifies the roughness scalar of the metallic/roughness workflow.
  109828. * Can also be used to scale the roughness values of the metallic texture.
  109829. */
  109830. roughness: Nullable<number>;
  109831. /**
  109832. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  109833. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  109834. */
  109835. microSurfaceTexture: BaseTexture;
  109836. /**
  109837. * Stores surface normal data used to displace a mesh in a texture.
  109838. */
  109839. bumpTexture: BaseTexture;
  109840. /**
  109841. * Stores the pre-calculated light information of a mesh in a texture.
  109842. */
  109843. lightmapTexture: BaseTexture;
  109844. /**
  109845. * Stores the refracted light information in a texture.
  109846. */
  109847. refractionTexture: Nullable<BaseTexture>;
  109848. /**
  109849. * The color of a material in ambient lighting.
  109850. */
  109851. ambientColor: Color3;
  109852. /**
  109853. * AKA Diffuse Color in other nomenclature.
  109854. */
  109855. albedoColor: Color3;
  109856. /**
  109857. * AKA Specular Color in other nomenclature.
  109858. */
  109859. reflectivityColor: Color3;
  109860. /**
  109861. * The color reflected from the material.
  109862. */
  109863. reflectionColor: Color3;
  109864. /**
  109865. * The color emitted from the material.
  109866. */
  109867. emissiveColor: Color3;
  109868. /**
  109869. * AKA Glossiness in other nomenclature.
  109870. */
  109871. microSurface: number;
  109872. /**
  109873. * source material index of refraction (IOR)' / 'destination material IOR.
  109874. */
  109875. indexOfRefraction: number;
  109876. /**
  109877. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  109878. */
  109879. invertRefractionY: boolean;
  109880. /**
  109881. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  109882. * Materials half opaque for instance using refraction could benefit from this control.
  109883. */
  109884. linkRefractionWithTransparency: boolean;
  109885. /**
  109886. * If true, the light map contains occlusion information instead of lighting info.
  109887. */
  109888. useLightmapAsShadowmap: boolean;
  109889. /**
  109890. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  109891. */
  109892. useAlphaFromAlbedoTexture: boolean;
  109893. /**
  109894. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  109895. */
  109896. forceAlphaTest: boolean;
  109897. /**
  109898. * Defines the alpha limits in alpha test mode.
  109899. */
  109900. alphaCutOff: number;
  109901. /**
  109902. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  109903. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  109904. */
  109905. useSpecularOverAlpha: boolean;
  109906. /**
  109907. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  109908. */
  109909. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  109910. /**
  109911. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  109912. */
  109913. useRoughnessFromMetallicTextureAlpha: boolean;
  109914. /**
  109915. * Specifies if the metallic texture contains the roughness information in its green channel.
  109916. */
  109917. useRoughnessFromMetallicTextureGreen: boolean;
  109918. /**
  109919. * Specifies if the metallic texture contains the metallness information in its blue channel.
  109920. */
  109921. useMetallnessFromMetallicTextureBlue: boolean;
  109922. /**
  109923. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  109924. */
  109925. useAmbientOcclusionFromMetallicTextureRed: boolean;
  109926. /**
  109927. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  109928. */
  109929. useAmbientInGrayScale: boolean;
  109930. /**
  109931. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  109932. * The material will try to infer what glossiness each pixel should be.
  109933. */
  109934. useAutoMicroSurfaceFromReflectivityMap: boolean;
  109935. /**
  109936. * BJS is using an harcoded light falloff based on a manually sets up range.
  109937. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  109938. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  109939. */
  109940. /**
  109941. * BJS is using an harcoded light falloff based on a manually sets up range.
  109942. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  109943. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  109944. */
  109945. usePhysicalLightFalloff: boolean;
  109946. /**
  109947. * In order to support the falloff compatibility with gltf, a special mode has been added
  109948. * to reproduce the gltf light falloff.
  109949. */
  109950. /**
  109951. * In order to support the falloff compatibility with gltf, a special mode has been added
  109952. * to reproduce the gltf light falloff.
  109953. */
  109954. useGLTFLightFalloff: boolean;
  109955. /**
  109956. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  109957. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  109958. */
  109959. useRadianceOverAlpha: boolean;
  109960. /**
  109961. * Allows using an object space normal map (instead of tangent space).
  109962. */
  109963. useObjectSpaceNormalMap: boolean;
  109964. /**
  109965. * Allows using the bump map in parallax mode.
  109966. */
  109967. useParallax: boolean;
  109968. /**
  109969. * Allows using the bump map in parallax occlusion mode.
  109970. */
  109971. useParallaxOcclusion: boolean;
  109972. /**
  109973. * Controls the scale bias of the parallax mode.
  109974. */
  109975. parallaxScaleBias: number;
  109976. /**
  109977. * If sets to true, disables all the lights affecting the material.
  109978. */
  109979. disableLighting: boolean;
  109980. /**
  109981. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  109982. */
  109983. forceIrradianceInFragment: boolean;
  109984. /**
  109985. * Number of Simultaneous lights allowed on the material.
  109986. */
  109987. maxSimultaneousLights: number;
  109988. /**
  109989. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  109990. */
  109991. invertNormalMapX: boolean;
  109992. /**
  109993. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  109994. */
  109995. invertNormalMapY: boolean;
  109996. /**
  109997. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  109998. */
  109999. twoSidedLighting: boolean;
  110000. /**
  110001. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  110002. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  110003. */
  110004. useAlphaFresnel: boolean;
  110005. /**
  110006. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  110007. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  110008. */
  110009. useLinearAlphaFresnel: boolean;
  110010. /**
  110011. * Let user defines the brdf lookup texture used for IBL.
  110012. * A default 8bit version is embedded but you could point at :
  110013. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  110014. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  110015. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  110016. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  110017. */
  110018. environmentBRDFTexture: Nullable<BaseTexture>;
  110019. /**
  110020. * Force normal to face away from face.
  110021. */
  110022. forceNormalForward: boolean;
  110023. /**
  110024. * Enables specular anti aliasing in the PBR shader.
  110025. * It will both interacts on the Geometry for analytical and IBL lighting.
  110026. * It also prefilter the roughness map based on the bump values.
  110027. */
  110028. enableSpecularAntiAliasing: boolean;
  110029. /**
  110030. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  110031. * makes the reflect vector face the model (under horizon).
  110032. */
  110033. useHorizonOcclusion: boolean;
  110034. /**
  110035. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  110036. * too much the area relying on ambient texture to define their ambient occlusion.
  110037. */
  110038. useRadianceOcclusion: boolean;
  110039. /**
  110040. * If set to true, no lighting calculations will be applied.
  110041. */
  110042. unlit: boolean;
  110043. /**
  110044. * Gets the image processing configuration used either in this material.
  110045. */
  110046. /**
  110047. * Sets the Default image processing configuration used either in the this material.
  110048. *
  110049. * If sets to null, the scene one is in use.
  110050. */
  110051. imageProcessingConfiguration: ImageProcessingConfiguration;
  110052. /**
  110053. * Gets wether the color curves effect is enabled.
  110054. */
  110055. /**
  110056. * Sets wether the color curves effect is enabled.
  110057. */
  110058. cameraColorCurvesEnabled: boolean;
  110059. /**
  110060. * Gets wether the color grading effect is enabled.
  110061. */
  110062. /**
  110063. * Gets wether the color grading effect is enabled.
  110064. */
  110065. cameraColorGradingEnabled: boolean;
  110066. /**
  110067. * Gets wether tonemapping is enabled or not.
  110068. */
  110069. /**
  110070. * Sets wether tonemapping is enabled or not
  110071. */
  110072. cameraToneMappingEnabled: boolean;
  110073. /**
  110074. * The camera exposure used on this material.
  110075. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  110076. * This corresponds to a photographic exposure.
  110077. */
  110078. /**
  110079. * The camera exposure used on this material.
  110080. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  110081. * This corresponds to a photographic exposure.
  110082. */
  110083. cameraExposure: number;
  110084. /**
  110085. * Gets The camera contrast used on this material.
  110086. */
  110087. /**
  110088. * Sets The camera contrast used on this material.
  110089. */
  110090. cameraContrast: number;
  110091. /**
  110092. * Gets the Color Grading 2D Lookup Texture.
  110093. */
  110094. /**
  110095. * Sets the Color Grading 2D Lookup Texture.
  110096. */
  110097. cameraColorGradingTexture: Nullable<BaseTexture>;
  110098. /**
  110099. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  110100. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  110101. * 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;
  110102. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  110103. */
  110104. /**
  110105. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  110106. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  110107. * 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;
  110108. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  110109. */
  110110. cameraColorCurves: Nullable<ColorCurves>;
  110111. /**
  110112. * Instantiates a new PBRMaterial instance.
  110113. *
  110114. * @param name The material name
  110115. * @param scene The scene the material will be use in.
  110116. */
  110117. constructor(name: string, scene: Scene);
  110118. /**
  110119. * Returns the name of this material class.
  110120. */
  110121. getClassName(): string;
  110122. /**
  110123. * Makes a duplicate of the current material.
  110124. * @param name - name to use for the new material.
  110125. */
  110126. clone(name: string): PBRMaterial;
  110127. /**
  110128. * Serializes this PBR Material.
  110129. * @returns - An object with the serialized material.
  110130. */
  110131. serialize(): any;
  110132. /**
  110133. * Parses a PBR Material from a serialized object.
  110134. * @param source - Serialized object.
  110135. * @param scene - BJS scene instance.
  110136. * @param rootUrl - url for the scene object
  110137. * @returns - PBRMaterial
  110138. */
  110139. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  110140. }
  110141. }
  110142. declare module BABYLON {
  110143. /**
  110144. * Direct draw surface info
  110145. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  110146. */
  110147. export interface DDSInfo {
  110148. /**
  110149. * Width of the texture
  110150. */
  110151. width: number;
  110152. /**
  110153. * Width of the texture
  110154. */
  110155. height: number;
  110156. /**
  110157. * Number of Mipmaps for the texture
  110158. * @see https://en.wikipedia.org/wiki/Mipmap
  110159. */
  110160. mipmapCount: number;
  110161. /**
  110162. * If the textures format is a known fourCC format
  110163. * @see https://www.fourcc.org/
  110164. */
  110165. isFourCC: boolean;
  110166. /**
  110167. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  110168. */
  110169. isRGB: boolean;
  110170. /**
  110171. * If the texture is a lumincance format
  110172. */
  110173. isLuminance: boolean;
  110174. /**
  110175. * If this is a cube texture
  110176. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  110177. */
  110178. isCube: boolean;
  110179. /**
  110180. * If the texture is a compressed format eg. FOURCC_DXT1
  110181. */
  110182. isCompressed: boolean;
  110183. /**
  110184. * The dxgiFormat of the texture
  110185. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  110186. */
  110187. dxgiFormat: number;
  110188. /**
  110189. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  110190. */
  110191. textureType: number;
  110192. /**
  110193. * Sphericle polynomial created for the dds texture
  110194. */
  110195. sphericalPolynomial?: SphericalPolynomial;
  110196. }
  110197. /**
  110198. * Class used to provide DDS decompression tools
  110199. */
  110200. export class DDSTools {
  110201. /**
  110202. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  110203. */
  110204. static StoreLODInAlphaChannel: boolean;
  110205. /**
  110206. * Gets DDS information from an array buffer
  110207. * @param arrayBuffer defines the array buffer to read data from
  110208. * @returns the DDS information
  110209. */
  110210. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  110211. private static _FloatView;
  110212. private static _Int32View;
  110213. private static _ToHalfFloat;
  110214. private static _FromHalfFloat;
  110215. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  110216. private static _GetHalfFloatRGBAArrayBuffer;
  110217. private static _GetFloatRGBAArrayBuffer;
  110218. private static _GetFloatAsUIntRGBAArrayBuffer;
  110219. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  110220. private static _GetRGBAArrayBuffer;
  110221. private static _ExtractLongWordOrder;
  110222. private static _GetRGBArrayBuffer;
  110223. private static _GetLuminanceArrayBuffer;
  110224. /**
  110225. * Uploads DDS Levels to a Babylon Texture
  110226. * @hidden
  110227. */
  110228. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  110229. }
  110230. interface Engine {
  110231. /**
  110232. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  110233. * @param rootUrl defines the url where the file to load is located
  110234. * @param scene defines the current scene
  110235. * @param lodScale defines scale to apply to the mip map selection
  110236. * @param lodOffset defines offset to apply to the mip map selection
  110237. * @param onLoad defines an optional callback raised when the texture is loaded
  110238. * @param onError defines an optional callback raised if there is an issue to load the texture
  110239. * @param format defines the format of the data
  110240. * @param forcedExtension defines the extension to use to pick the right loader
  110241. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  110242. * @returns the cube texture as an InternalTexture
  110243. */
  110244. 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;
  110245. }
  110246. }
  110247. declare module BABYLON {
  110248. /**
  110249. * Implementation of the DDS Texture Loader.
  110250. * @hidden
  110251. */
  110252. export class _DDSTextureLoader implements IInternalTextureLoader {
  110253. /**
  110254. * Defines wether the loader supports cascade loading the different faces.
  110255. */
  110256. readonly supportCascades: boolean;
  110257. /**
  110258. * This returns if the loader support the current file information.
  110259. * @param extension defines the file extension of the file being loaded
  110260. * @param textureFormatInUse defines the current compressed format in use iun the engine
  110261. * @param fallback defines the fallback internal texture if any
  110262. * @param isBase64 defines whether the texture is encoded as a base64
  110263. * @param isBuffer defines whether the texture data are stored as a buffer
  110264. * @returns true if the loader can load the specified file
  110265. */
  110266. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  110267. /**
  110268. * Transform the url before loading if required.
  110269. * @param rootUrl the url of the texture
  110270. * @param textureFormatInUse defines the current compressed format in use iun the engine
  110271. * @returns the transformed texture
  110272. */
  110273. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  110274. /**
  110275. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  110276. * @param rootUrl the url of the texture
  110277. * @param textureFormatInUse defines the current compressed format in use iun the engine
  110278. * @returns the fallback texture
  110279. */
  110280. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  110281. /**
  110282. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  110283. * @param data contains the texture data
  110284. * @param texture defines the BabylonJS internal texture
  110285. * @param createPolynomials will be true if polynomials have been requested
  110286. * @param onLoad defines the callback to trigger once the texture is ready
  110287. * @param onError defines the callback to trigger in case of error
  110288. */
  110289. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  110290. /**
  110291. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  110292. * @param data contains the texture data
  110293. * @param texture defines the BabylonJS internal texture
  110294. * @param callback defines the method to call once ready to upload
  110295. */
  110296. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  110297. }
  110298. }
  110299. declare module BABYLON {
  110300. /** @hidden */
  110301. export var rgbdEncodePixelShader: {
  110302. name: string;
  110303. shader: string;
  110304. };
  110305. }
  110306. declare module BABYLON {
  110307. /**
  110308. * Raw texture data and descriptor sufficient for WebGL texture upload
  110309. */
  110310. export interface EnvironmentTextureInfo {
  110311. /**
  110312. * Version of the environment map
  110313. */
  110314. version: number;
  110315. /**
  110316. * Width of image
  110317. */
  110318. width: number;
  110319. /**
  110320. * Irradiance information stored in the file.
  110321. */
  110322. irradiance: any;
  110323. /**
  110324. * Specular information stored in the file.
  110325. */
  110326. specular: any;
  110327. }
  110328. /**
  110329. * Sets of helpers addressing the serialization and deserialization of environment texture
  110330. * stored in a BabylonJS env file.
  110331. * Those files are usually stored as .env files.
  110332. */
  110333. export class EnvironmentTextureTools {
  110334. /**
  110335. * Magic number identifying the env file.
  110336. */
  110337. private static _MagicBytes;
  110338. /**
  110339. * Gets the environment info from an env file.
  110340. * @param data The array buffer containing the .env bytes.
  110341. * @returns the environment file info (the json header) if successfully parsed.
  110342. */
  110343. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  110344. /**
  110345. * Creates an environment texture from a loaded cube texture.
  110346. * @param texture defines the cube texture to convert in env file
  110347. * @return a promise containing the environment data if succesfull.
  110348. */
  110349. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  110350. /**
  110351. * Creates a JSON representation of the spherical data.
  110352. * @param texture defines the texture containing the polynomials
  110353. * @return the JSON representation of the spherical info
  110354. */
  110355. private static _CreateEnvTextureIrradiance;
  110356. /**
  110357. * Uploads the texture info contained in the env file to the GPU.
  110358. * @param texture defines the internal texture to upload to
  110359. * @param arrayBuffer defines the buffer cotaining the data to load
  110360. * @param info defines the texture info retrieved through the GetEnvInfo method
  110361. * @returns a promise
  110362. */
  110363. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  110364. /**
  110365. * Uploads the levels of image data to the GPU.
  110366. * @param texture defines the internal texture to upload to
  110367. * @param imageData defines the array buffer views of image data [mipmap][face]
  110368. * @returns a promise
  110369. */
  110370. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  110371. /**
  110372. * Uploads spherical polynomials information to the texture.
  110373. * @param texture defines the texture we are trying to upload the information to
  110374. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  110375. */
  110376. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  110377. /** @hidden */
  110378. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  110379. }
  110380. }
  110381. declare module BABYLON {
  110382. /**
  110383. * Implementation of the ENV Texture Loader.
  110384. * @hidden
  110385. */
  110386. export class _ENVTextureLoader implements IInternalTextureLoader {
  110387. /**
  110388. * Defines wether the loader supports cascade loading the different faces.
  110389. */
  110390. readonly supportCascades: boolean;
  110391. /**
  110392. * This returns if the loader support the current file information.
  110393. * @param extension defines the file extension of the file being loaded
  110394. * @param textureFormatInUse defines the current compressed format in use iun the engine
  110395. * @param fallback defines the fallback internal texture if any
  110396. * @param isBase64 defines whether the texture is encoded as a base64
  110397. * @param isBuffer defines whether the texture data are stored as a buffer
  110398. * @returns true if the loader can load the specified file
  110399. */
  110400. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  110401. /**
  110402. * Transform the url before loading if required.
  110403. * @param rootUrl the url of the texture
  110404. * @param textureFormatInUse defines the current compressed format in use iun the engine
  110405. * @returns the transformed texture
  110406. */
  110407. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  110408. /**
  110409. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  110410. * @param rootUrl the url of the texture
  110411. * @param textureFormatInUse defines the current compressed format in use iun the engine
  110412. * @returns the fallback texture
  110413. */
  110414. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  110415. /**
  110416. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  110417. * @param data contains the texture data
  110418. * @param texture defines the BabylonJS internal texture
  110419. * @param createPolynomials will be true if polynomials have been requested
  110420. * @param onLoad defines the callback to trigger once the texture is ready
  110421. * @param onError defines the callback to trigger in case of error
  110422. */
  110423. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  110424. /**
  110425. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  110426. * @param data contains the texture data
  110427. * @param texture defines the BabylonJS internal texture
  110428. * @param callback defines the method to call once ready to upload
  110429. */
  110430. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  110431. }
  110432. }
  110433. declare module BABYLON {
  110434. /**
  110435. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  110436. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  110437. */
  110438. export class KhronosTextureContainer {
  110439. /** contents of the KTX container file */
  110440. arrayBuffer: any;
  110441. private static HEADER_LEN;
  110442. private static COMPRESSED_2D;
  110443. private static COMPRESSED_3D;
  110444. private static TEX_2D;
  110445. private static TEX_3D;
  110446. /**
  110447. * Gets the openGL type
  110448. */
  110449. glType: number;
  110450. /**
  110451. * Gets the openGL type size
  110452. */
  110453. glTypeSize: number;
  110454. /**
  110455. * Gets the openGL format
  110456. */
  110457. glFormat: number;
  110458. /**
  110459. * Gets the openGL internal format
  110460. */
  110461. glInternalFormat: number;
  110462. /**
  110463. * Gets the base internal format
  110464. */
  110465. glBaseInternalFormat: number;
  110466. /**
  110467. * Gets image width in pixel
  110468. */
  110469. pixelWidth: number;
  110470. /**
  110471. * Gets image height in pixel
  110472. */
  110473. pixelHeight: number;
  110474. /**
  110475. * Gets image depth in pixels
  110476. */
  110477. pixelDepth: number;
  110478. /**
  110479. * Gets the number of array elements
  110480. */
  110481. numberOfArrayElements: number;
  110482. /**
  110483. * Gets the number of faces
  110484. */
  110485. numberOfFaces: number;
  110486. /**
  110487. * Gets the number of mipmap levels
  110488. */
  110489. numberOfMipmapLevels: number;
  110490. /**
  110491. * Gets the bytes of key value data
  110492. */
  110493. bytesOfKeyValueData: number;
  110494. /**
  110495. * Gets the load type
  110496. */
  110497. loadType: number;
  110498. /**
  110499. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  110500. */
  110501. isInvalid: boolean;
  110502. /**
  110503. * Creates a new KhronosTextureContainer
  110504. * @param arrayBuffer contents of the KTX container file
  110505. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  110506. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  110507. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  110508. */
  110509. constructor(
  110510. /** contents of the KTX container file */
  110511. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  110512. /**
  110513. * Uploads KTX content to a Babylon Texture.
  110514. * It is assumed that the texture has already been created & is currently bound
  110515. * @hidden
  110516. */
  110517. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  110518. private _upload2DCompressedLevels;
  110519. }
  110520. }
  110521. declare module BABYLON {
  110522. /**
  110523. * Implementation of the KTX Texture Loader.
  110524. * @hidden
  110525. */
  110526. export class _KTXTextureLoader implements IInternalTextureLoader {
  110527. /**
  110528. * Defines wether the loader supports cascade loading the different faces.
  110529. */
  110530. readonly supportCascades: boolean;
  110531. /**
  110532. * This returns if the loader support the current file information.
  110533. * @param extension defines the file extension of the file being loaded
  110534. * @param textureFormatInUse defines the current compressed format in use iun the engine
  110535. * @param fallback defines the fallback internal texture if any
  110536. * @param isBase64 defines whether the texture is encoded as a base64
  110537. * @param isBuffer defines whether the texture data are stored as a buffer
  110538. * @returns true if the loader can load the specified file
  110539. */
  110540. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  110541. /**
  110542. * Transform the url before loading if required.
  110543. * @param rootUrl the url of the texture
  110544. * @param textureFormatInUse defines the current compressed format in use iun the engine
  110545. * @returns the transformed texture
  110546. */
  110547. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  110548. /**
  110549. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  110550. * @param rootUrl the url of the texture
  110551. * @param textureFormatInUse defines the current compressed format in use iun the engine
  110552. * @returns the fallback texture
  110553. */
  110554. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  110555. /**
  110556. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  110557. * @param data contains the texture data
  110558. * @param texture defines the BabylonJS internal texture
  110559. * @param createPolynomials will be true if polynomials have been requested
  110560. * @param onLoad defines the callback to trigger once the texture is ready
  110561. * @param onError defines the callback to trigger in case of error
  110562. */
  110563. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  110564. /**
  110565. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  110566. * @param data contains the texture data
  110567. * @param texture defines the BabylonJS internal texture
  110568. * @param callback defines the method to call once ready to upload
  110569. */
  110570. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  110571. }
  110572. }
  110573. declare module BABYLON {
  110574. /**
  110575. * Options for the default xr helper
  110576. */
  110577. export class WebXRDefaultExperienceOptions {
  110578. /**
  110579. * Floor meshes that should be used for teleporting
  110580. */
  110581. floorMeshes: Array<AbstractMesh>;
  110582. }
  110583. /**
  110584. * Default experience which provides a similar setup to the previous webVRExperience
  110585. */
  110586. export class WebXRDefaultExperience {
  110587. /**
  110588. * Base experience
  110589. */
  110590. baseExperience: WebXRExperienceHelper;
  110591. /**
  110592. * Input experience extension
  110593. */
  110594. input: WebXRInput;
  110595. /**
  110596. * Loads the controller models
  110597. */
  110598. controllerModelLoader: WebXRControllerModelLoader;
  110599. /**
  110600. * Enables laser pointer and selection
  110601. */
  110602. pointerSelection: WebXRControllerPointerSelection;
  110603. /**
  110604. * Enables teleportation
  110605. */
  110606. teleportation: WebXRControllerTeleportation;
  110607. /**
  110608. * Enables ui for enetering/exiting xr
  110609. */
  110610. enterExitUI: WebXREnterExitUI;
  110611. /**
  110612. * Default output canvas xr should render to
  110613. */
  110614. outputCanvas: WebXRManagedOutputCanvas;
  110615. /**
  110616. * Creates the default xr experience
  110617. * @param scene scene
  110618. * @param options options for basic configuration
  110619. * @returns resulting WebXRDefaultExperience
  110620. */
  110621. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  110622. private constructor();
  110623. /**
  110624. * DIsposes of the experience helper
  110625. */
  110626. dispose(): void;
  110627. }
  110628. }
  110629. declare module BABYLON {
  110630. /** @hidden */
  110631. export var _forceSceneHelpersToBundle: boolean;
  110632. interface Scene {
  110633. /**
  110634. * Creates a default light for the scene.
  110635. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  110636. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  110637. */
  110638. createDefaultLight(replace?: boolean): void;
  110639. /**
  110640. * Creates a default camera for the scene.
  110641. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  110642. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  110643. * @param replace has default false, when true replaces the active camera in the scene
  110644. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  110645. */
  110646. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  110647. /**
  110648. * Creates a default camera and a default light.
  110649. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  110650. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  110651. * @param replace has the default false, when true replaces the active camera/light in the scene
  110652. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  110653. */
  110654. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  110655. /**
  110656. * Creates a new sky box
  110657. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  110658. * @param environmentTexture defines the texture to use as environment texture
  110659. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  110660. * @param scale defines the overall scale of the skybox
  110661. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  110662. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  110663. * @returns a new mesh holding the sky box
  110664. */
  110665. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  110666. /**
  110667. * Creates a new environment
  110668. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  110669. * @param options defines the options you can use to configure the environment
  110670. * @returns the new EnvironmentHelper
  110671. */
  110672. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  110673. /**
  110674. * Creates a new VREXperienceHelper
  110675. * @see http://doc.babylonjs.com/how_to/webvr_helper
  110676. * @param webVROptions defines the options used to create the new VREXperienceHelper
  110677. * @returns a new VREXperienceHelper
  110678. */
  110679. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  110680. /**
  110681. * Creates a new WebXRDefaultExperience
  110682. * @see http://doc.babylonjs.com/how_to/webxr
  110683. * @param options experience options
  110684. * @returns a promise for a new WebXRDefaultExperience
  110685. */
  110686. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  110687. }
  110688. }
  110689. declare module BABYLON {
  110690. /**
  110691. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  110692. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  110693. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  110694. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  110695. */
  110696. export class VideoDome extends TransformNode {
  110697. /**
  110698. * Define the video source as a Monoscopic panoramic 360 video.
  110699. */
  110700. static readonly MODE_MONOSCOPIC: number;
  110701. /**
  110702. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  110703. */
  110704. static readonly MODE_TOPBOTTOM: number;
  110705. /**
  110706. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  110707. */
  110708. static readonly MODE_SIDEBYSIDE: number;
  110709. private _useDirectMapping;
  110710. /**
  110711. * The video texture being displayed on the sphere
  110712. */
  110713. protected _videoTexture: VideoTexture;
  110714. /**
  110715. * Gets the video texture being displayed on the sphere
  110716. */
  110717. readonly videoTexture: VideoTexture;
  110718. /**
  110719. * The skybox material
  110720. */
  110721. protected _material: BackgroundMaterial;
  110722. /**
  110723. * The surface used for the skybox
  110724. */
  110725. protected _mesh: Mesh;
  110726. /**
  110727. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  110728. * Also see the options.resolution property.
  110729. */
  110730. fovMultiplier: number;
  110731. private _videoMode;
  110732. /**
  110733. * Gets or set the current video mode for the video. It can be:
  110734. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  110735. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  110736. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  110737. */
  110738. videoMode: number;
  110739. /**
  110740. * Oberserver used in Stereoscopic VR Mode.
  110741. */
  110742. private _onBeforeCameraRenderObserver;
  110743. /**
  110744. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  110745. * @param name Element's name, child elements will append suffixes for their own names.
  110746. * @param urlsOrVideo defines the url(s) or the video element to use
  110747. * @param options An object containing optional or exposed sub element properties
  110748. */
  110749. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  110750. resolution?: number;
  110751. clickToPlay?: boolean;
  110752. autoPlay?: boolean;
  110753. loop?: boolean;
  110754. size?: number;
  110755. poster?: string;
  110756. faceForward?: boolean;
  110757. useDirectMapping?: boolean;
  110758. }, scene: Scene);
  110759. private _changeVideoMode;
  110760. /**
  110761. * Releases resources associated with this node.
  110762. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  110763. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  110764. */
  110765. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  110766. }
  110767. }
  110768. declare module BABYLON {
  110769. /**
  110770. * This class can be used to get instrumentation data from a Babylon engine
  110771. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  110772. */
  110773. export class EngineInstrumentation implements IDisposable {
  110774. /**
  110775. * Define the instrumented engine.
  110776. */
  110777. engine: Engine;
  110778. private _captureGPUFrameTime;
  110779. private _gpuFrameTimeToken;
  110780. private _gpuFrameTime;
  110781. private _captureShaderCompilationTime;
  110782. private _shaderCompilationTime;
  110783. private _onBeginFrameObserver;
  110784. private _onEndFrameObserver;
  110785. private _onBeforeShaderCompilationObserver;
  110786. private _onAfterShaderCompilationObserver;
  110787. /**
  110788. * Gets the perf counter used for GPU frame time
  110789. */
  110790. readonly gpuFrameTimeCounter: PerfCounter;
  110791. /**
  110792. * Gets the GPU frame time capture status
  110793. */
  110794. /**
  110795. * Enable or disable the GPU frame time capture
  110796. */
  110797. captureGPUFrameTime: boolean;
  110798. /**
  110799. * Gets the perf counter used for shader compilation time
  110800. */
  110801. readonly shaderCompilationTimeCounter: PerfCounter;
  110802. /**
  110803. * Gets the shader compilation time capture status
  110804. */
  110805. /**
  110806. * Enable or disable the shader compilation time capture
  110807. */
  110808. captureShaderCompilationTime: boolean;
  110809. /**
  110810. * Instantiates a new engine instrumentation.
  110811. * This class can be used to get instrumentation data from a Babylon engine
  110812. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  110813. * @param engine Defines the engine to instrument
  110814. */
  110815. constructor(
  110816. /**
  110817. * Define the instrumented engine.
  110818. */
  110819. engine: Engine);
  110820. /**
  110821. * Dispose and release associated resources.
  110822. */
  110823. dispose(): void;
  110824. }
  110825. }
  110826. declare module BABYLON {
  110827. /**
  110828. * This class can be used to get instrumentation data from a Babylon engine
  110829. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  110830. */
  110831. export class SceneInstrumentation implements IDisposable {
  110832. /**
  110833. * Defines the scene to instrument
  110834. */
  110835. scene: Scene;
  110836. private _captureActiveMeshesEvaluationTime;
  110837. private _activeMeshesEvaluationTime;
  110838. private _captureRenderTargetsRenderTime;
  110839. private _renderTargetsRenderTime;
  110840. private _captureFrameTime;
  110841. private _frameTime;
  110842. private _captureRenderTime;
  110843. private _renderTime;
  110844. private _captureInterFrameTime;
  110845. private _interFrameTime;
  110846. private _captureParticlesRenderTime;
  110847. private _particlesRenderTime;
  110848. private _captureSpritesRenderTime;
  110849. private _spritesRenderTime;
  110850. private _capturePhysicsTime;
  110851. private _physicsTime;
  110852. private _captureAnimationsTime;
  110853. private _animationsTime;
  110854. private _captureCameraRenderTime;
  110855. private _cameraRenderTime;
  110856. private _onBeforeActiveMeshesEvaluationObserver;
  110857. private _onAfterActiveMeshesEvaluationObserver;
  110858. private _onBeforeRenderTargetsRenderObserver;
  110859. private _onAfterRenderTargetsRenderObserver;
  110860. private _onAfterRenderObserver;
  110861. private _onBeforeDrawPhaseObserver;
  110862. private _onAfterDrawPhaseObserver;
  110863. private _onBeforeAnimationsObserver;
  110864. private _onBeforeParticlesRenderingObserver;
  110865. private _onAfterParticlesRenderingObserver;
  110866. private _onBeforeSpritesRenderingObserver;
  110867. private _onAfterSpritesRenderingObserver;
  110868. private _onBeforePhysicsObserver;
  110869. private _onAfterPhysicsObserver;
  110870. private _onAfterAnimationsObserver;
  110871. private _onBeforeCameraRenderObserver;
  110872. private _onAfterCameraRenderObserver;
  110873. /**
  110874. * Gets the perf counter used for active meshes evaluation time
  110875. */
  110876. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  110877. /**
  110878. * Gets the active meshes evaluation time capture status
  110879. */
  110880. /**
  110881. * Enable or disable the active meshes evaluation time capture
  110882. */
  110883. captureActiveMeshesEvaluationTime: boolean;
  110884. /**
  110885. * Gets the perf counter used for render targets render time
  110886. */
  110887. readonly renderTargetsRenderTimeCounter: PerfCounter;
  110888. /**
  110889. * Gets the render targets render time capture status
  110890. */
  110891. /**
  110892. * Enable or disable the render targets render time capture
  110893. */
  110894. captureRenderTargetsRenderTime: boolean;
  110895. /**
  110896. * Gets the perf counter used for particles render time
  110897. */
  110898. readonly particlesRenderTimeCounter: PerfCounter;
  110899. /**
  110900. * Gets the particles render time capture status
  110901. */
  110902. /**
  110903. * Enable or disable the particles render time capture
  110904. */
  110905. captureParticlesRenderTime: boolean;
  110906. /**
  110907. * Gets the perf counter used for sprites render time
  110908. */
  110909. readonly spritesRenderTimeCounter: PerfCounter;
  110910. /**
  110911. * Gets the sprites render time capture status
  110912. */
  110913. /**
  110914. * Enable or disable the sprites render time capture
  110915. */
  110916. captureSpritesRenderTime: boolean;
  110917. /**
  110918. * Gets the perf counter used for physics time
  110919. */
  110920. readonly physicsTimeCounter: PerfCounter;
  110921. /**
  110922. * Gets the physics time capture status
  110923. */
  110924. /**
  110925. * Enable or disable the physics time capture
  110926. */
  110927. capturePhysicsTime: boolean;
  110928. /**
  110929. * Gets the perf counter used for animations time
  110930. */
  110931. readonly animationsTimeCounter: PerfCounter;
  110932. /**
  110933. * Gets the animations time capture status
  110934. */
  110935. /**
  110936. * Enable or disable the animations time capture
  110937. */
  110938. captureAnimationsTime: boolean;
  110939. /**
  110940. * Gets the perf counter used for frame time capture
  110941. */
  110942. readonly frameTimeCounter: PerfCounter;
  110943. /**
  110944. * Gets the frame time capture status
  110945. */
  110946. /**
  110947. * Enable or disable the frame time capture
  110948. */
  110949. captureFrameTime: boolean;
  110950. /**
  110951. * Gets the perf counter used for inter-frames time capture
  110952. */
  110953. readonly interFrameTimeCounter: PerfCounter;
  110954. /**
  110955. * Gets the inter-frames time capture status
  110956. */
  110957. /**
  110958. * Enable or disable the inter-frames time capture
  110959. */
  110960. captureInterFrameTime: boolean;
  110961. /**
  110962. * Gets the perf counter used for render time capture
  110963. */
  110964. readonly renderTimeCounter: PerfCounter;
  110965. /**
  110966. * Gets the render time capture status
  110967. */
  110968. /**
  110969. * Enable or disable the render time capture
  110970. */
  110971. captureRenderTime: boolean;
  110972. /**
  110973. * Gets the perf counter used for camera render time capture
  110974. */
  110975. readonly cameraRenderTimeCounter: PerfCounter;
  110976. /**
  110977. * Gets the camera render time capture status
  110978. */
  110979. /**
  110980. * Enable or disable the camera render time capture
  110981. */
  110982. captureCameraRenderTime: boolean;
  110983. /**
  110984. * Gets the perf counter used for draw calls
  110985. */
  110986. readonly drawCallsCounter: PerfCounter;
  110987. /**
  110988. * Instantiates a new scene instrumentation.
  110989. * This class can be used to get instrumentation data from a Babylon engine
  110990. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  110991. * @param scene Defines the scene to instrument
  110992. */
  110993. constructor(
  110994. /**
  110995. * Defines the scene to instrument
  110996. */
  110997. scene: Scene);
  110998. /**
  110999. * Dispose and release associated resources.
  111000. */
  111001. dispose(): void;
  111002. }
  111003. }
  111004. declare module BABYLON {
  111005. /** @hidden */
  111006. export var glowMapGenerationPixelShader: {
  111007. name: string;
  111008. shader: string;
  111009. };
  111010. }
  111011. declare module BABYLON {
  111012. /** @hidden */
  111013. export var glowMapGenerationVertexShader: {
  111014. name: string;
  111015. shader: string;
  111016. };
  111017. }
  111018. declare module BABYLON {
  111019. /**
  111020. * Effect layer options. This helps customizing the behaviour
  111021. * of the effect layer.
  111022. */
  111023. export interface IEffectLayerOptions {
  111024. /**
  111025. * Multiplication factor apply to the canvas size to compute the render target size
  111026. * used to generated the objects (the smaller the faster).
  111027. */
  111028. mainTextureRatio: number;
  111029. /**
  111030. * Enforces a fixed size texture to ensure effect stability across devices.
  111031. */
  111032. mainTextureFixedSize?: number;
  111033. /**
  111034. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  111035. */
  111036. alphaBlendingMode: number;
  111037. /**
  111038. * The camera attached to the layer.
  111039. */
  111040. camera: Nullable<Camera>;
  111041. /**
  111042. * The rendering group to draw the layer in.
  111043. */
  111044. renderingGroupId: number;
  111045. }
  111046. /**
  111047. * The effect layer Helps adding post process effect blended with the main pass.
  111048. *
  111049. * This can be for instance use to generate glow or higlight effects on the scene.
  111050. *
  111051. * The effect layer class can not be used directly and is intented to inherited from to be
  111052. * customized per effects.
  111053. */
  111054. export abstract class EffectLayer {
  111055. private _vertexBuffers;
  111056. private _indexBuffer;
  111057. private _cachedDefines;
  111058. private _effectLayerMapGenerationEffect;
  111059. private _effectLayerOptions;
  111060. private _mergeEffect;
  111061. protected _scene: Scene;
  111062. protected _engine: Engine;
  111063. protected _maxSize: number;
  111064. protected _mainTextureDesiredSize: ISize;
  111065. protected _mainTexture: RenderTargetTexture;
  111066. protected _shouldRender: boolean;
  111067. protected _postProcesses: PostProcess[];
  111068. protected _textures: BaseTexture[];
  111069. protected _emissiveTextureAndColor: {
  111070. texture: Nullable<BaseTexture>;
  111071. color: Color4;
  111072. };
  111073. /**
  111074. * The name of the layer
  111075. */
  111076. name: string;
  111077. /**
  111078. * The clear color of the texture used to generate the glow map.
  111079. */
  111080. neutralColor: Color4;
  111081. /**
  111082. * Specifies wether the highlight layer is enabled or not.
  111083. */
  111084. isEnabled: boolean;
  111085. /**
  111086. * Gets the camera attached to the layer.
  111087. */
  111088. readonly camera: Nullable<Camera>;
  111089. /**
  111090. * Gets the rendering group id the layer should render in.
  111091. */
  111092. renderingGroupId: number;
  111093. /**
  111094. * An event triggered when the effect layer has been disposed.
  111095. */
  111096. onDisposeObservable: Observable<EffectLayer>;
  111097. /**
  111098. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  111099. */
  111100. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  111101. /**
  111102. * An event triggered when the generated texture is being merged in the scene.
  111103. */
  111104. onBeforeComposeObservable: Observable<EffectLayer>;
  111105. /**
  111106. * An event triggered when the generated texture has been merged in the scene.
  111107. */
  111108. onAfterComposeObservable: Observable<EffectLayer>;
  111109. /**
  111110. * An event triggered when the efffect layer changes its size.
  111111. */
  111112. onSizeChangedObservable: Observable<EffectLayer>;
  111113. /** @hidden */
  111114. static _SceneComponentInitialization: (scene: Scene) => void;
  111115. /**
  111116. * Instantiates a new effect Layer and references it in the scene.
  111117. * @param name The name of the layer
  111118. * @param scene The scene to use the layer in
  111119. */
  111120. constructor(
  111121. /** The Friendly of the effect in the scene */
  111122. name: string, scene: Scene);
  111123. /**
  111124. * Get the effect name of the layer.
  111125. * @return The effect name
  111126. */
  111127. abstract getEffectName(): string;
  111128. /**
  111129. * Checks for the readiness of the element composing the layer.
  111130. * @param subMesh the mesh to check for
  111131. * @param useInstances specify wether or not to use instances to render the mesh
  111132. * @return true if ready otherwise, false
  111133. */
  111134. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  111135. /**
  111136. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  111137. * @returns true if the effect requires stencil during the main canvas render pass.
  111138. */
  111139. abstract needStencil(): boolean;
  111140. /**
  111141. * Create the merge effect. This is the shader use to blit the information back
  111142. * to the main canvas at the end of the scene rendering.
  111143. * @returns The effect containing the shader used to merge the effect on the main canvas
  111144. */
  111145. protected abstract _createMergeEffect(): Effect;
  111146. /**
  111147. * Creates the render target textures and post processes used in the effect layer.
  111148. */
  111149. protected abstract _createTextureAndPostProcesses(): void;
  111150. /**
  111151. * Implementation specific of rendering the generating effect on the main canvas.
  111152. * @param effect The effect used to render through
  111153. */
  111154. protected abstract _internalRender(effect: Effect): void;
  111155. /**
  111156. * Sets the required values for both the emissive texture and and the main color.
  111157. */
  111158. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  111159. /**
  111160. * Free any resources and references associated to a mesh.
  111161. * Internal use
  111162. * @param mesh The mesh to free.
  111163. */
  111164. abstract _disposeMesh(mesh: Mesh): void;
  111165. /**
  111166. * Serializes this layer (Glow or Highlight for example)
  111167. * @returns a serialized layer object
  111168. */
  111169. abstract serialize?(): any;
  111170. /**
  111171. * Initializes the effect layer with the required options.
  111172. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  111173. */
  111174. protected _init(options: Partial<IEffectLayerOptions>): void;
  111175. /**
  111176. * Generates the index buffer of the full screen quad blending to the main canvas.
  111177. */
  111178. private _generateIndexBuffer;
  111179. /**
  111180. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  111181. */
  111182. private _generateVertexBuffer;
  111183. /**
  111184. * Sets the main texture desired size which is the closest power of two
  111185. * of the engine canvas size.
  111186. */
  111187. private _setMainTextureSize;
  111188. /**
  111189. * Creates the main texture for the effect layer.
  111190. */
  111191. protected _createMainTexture(): void;
  111192. /**
  111193. * Adds specific effects defines.
  111194. * @param defines The defines to add specifics to.
  111195. */
  111196. protected _addCustomEffectDefines(defines: string[]): void;
  111197. /**
  111198. * Checks for the readiness of the element composing the layer.
  111199. * @param subMesh the mesh to check for
  111200. * @param useInstances specify wether or not to use instances to render the mesh
  111201. * @param emissiveTexture the associated emissive texture used to generate the glow
  111202. * @return true if ready otherwise, false
  111203. */
  111204. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  111205. /**
  111206. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  111207. */
  111208. render(): void;
  111209. /**
  111210. * Determine if a given mesh will be used in the current effect.
  111211. * @param mesh mesh to test
  111212. * @returns true if the mesh will be used
  111213. */
  111214. hasMesh(mesh: AbstractMesh): boolean;
  111215. /**
  111216. * Returns true if the layer contains information to display, otherwise false.
  111217. * @returns true if the glow layer should be rendered
  111218. */
  111219. shouldRender(): boolean;
  111220. /**
  111221. * Returns true if the mesh should render, otherwise false.
  111222. * @param mesh The mesh to render
  111223. * @returns true if it should render otherwise false
  111224. */
  111225. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  111226. /**
  111227. * Returns true if the mesh can be rendered, otherwise false.
  111228. * @param mesh The mesh to render
  111229. * @param material The material used on the mesh
  111230. * @returns true if it can be rendered otherwise false
  111231. */
  111232. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  111233. /**
  111234. * Returns true if the mesh should render, otherwise false.
  111235. * @param mesh The mesh to render
  111236. * @returns true if it should render otherwise false
  111237. */
  111238. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  111239. /**
  111240. * Renders the submesh passed in parameter to the generation map.
  111241. */
  111242. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  111243. /**
  111244. * Rebuild the required buffers.
  111245. * @hidden Internal use only.
  111246. */
  111247. _rebuild(): void;
  111248. /**
  111249. * Dispose only the render target textures and post process.
  111250. */
  111251. private _disposeTextureAndPostProcesses;
  111252. /**
  111253. * Dispose the highlight layer and free resources.
  111254. */
  111255. dispose(): void;
  111256. /**
  111257. * Gets the class name of the effect layer
  111258. * @returns the string with the class name of the effect layer
  111259. */
  111260. getClassName(): string;
  111261. /**
  111262. * Creates an effect layer from parsed effect layer data
  111263. * @param parsedEffectLayer defines effect layer data
  111264. * @param scene defines the current scene
  111265. * @param rootUrl defines the root URL containing the effect layer information
  111266. * @returns a parsed effect Layer
  111267. */
  111268. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  111269. }
  111270. }
  111271. declare module BABYLON {
  111272. interface AbstractScene {
  111273. /**
  111274. * The list of effect layers (highlights/glow) added to the scene
  111275. * @see http://doc.babylonjs.com/how_to/highlight_layer
  111276. * @see http://doc.babylonjs.com/how_to/glow_layer
  111277. */
  111278. effectLayers: Array<EffectLayer>;
  111279. /**
  111280. * Removes the given effect layer from this scene.
  111281. * @param toRemove defines the effect layer to remove
  111282. * @returns the index of the removed effect layer
  111283. */
  111284. removeEffectLayer(toRemove: EffectLayer): number;
  111285. /**
  111286. * Adds the given effect layer to this scene
  111287. * @param newEffectLayer defines the effect layer to add
  111288. */
  111289. addEffectLayer(newEffectLayer: EffectLayer): void;
  111290. }
  111291. /**
  111292. * Defines the layer scene component responsible to manage any effect layers
  111293. * in a given scene.
  111294. */
  111295. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  111296. /**
  111297. * The component name helpfull to identify the component in the list of scene components.
  111298. */
  111299. readonly name: string;
  111300. /**
  111301. * The scene the component belongs to.
  111302. */
  111303. scene: Scene;
  111304. private _engine;
  111305. private _renderEffects;
  111306. private _needStencil;
  111307. private _previousStencilState;
  111308. /**
  111309. * Creates a new instance of the component for the given scene
  111310. * @param scene Defines the scene to register the component in
  111311. */
  111312. constructor(scene: Scene);
  111313. /**
  111314. * Registers the component in a given scene
  111315. */
  111316. register(): void;
  111317. /**
  111318. * Rebuilds the elements related to this component in case of
  111319. * context lost for instance.
  111320. */
  111321. rebuild(): void;
  111322. /**
  111323. * Serializes the component data to the specified json object
  111324. * @param serializationObject The object to serialize to
  111325. */
  111326. serialize(serializationObject: any): void;
  111327. /**
  111328. * Adds all the elements from the container to the scene
  111329. * @param container the container holding the elements
  111330. */
  111331. addFromContainer(container: AbstractScene): void;
  111332. /**
  111333. * Removes all the elements in the container from the scene
  111334. * @param container contains the elements to remove
  111335. * @param dispose if the removed element should be disposed (default: false)
  111336. */
  111337. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111338. /**
  111339. * Disposes the component and the associated ressources.
  111340. */
  111341. dispose(): void;
  111342. private _isReadyForMesh;
  111343. private _renderMainTexture;
  111344. private _setStencil;
  111345. private _setStencilBack;
  111346. private _draw;
  111347. private _drawCamera;
  111348. private _drawRenderingGroup;
  111349. }
  111350. }
  111351. declare module BABYLON {
  111352. /** @hidden */
  111353. export var glowMapMergePixelShader: {
  111354. name: string;
  111355. shader: string;
  111356. };
  111357. }
  111358. declare module BABYLON {
  111359. /** @hidden */
  111360. export var glowMapMergeVertexShader: {
  111361. name: string;
  111362. shader: string;
  111363. };
  111364. }
  111365. declare module BABYLON {
  111366. interface AbstractScene {
  111367. /**
  111368. * Return a the first highlight layer of the scene with a given name.
  111369. * @param name The name of the highlight layer to look for.
  111370. * @return The highlight layer if found otherwise null.
  111371. */
  111372. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  111373. }
  111374. /**
  111375. * Glow layer options. This helps customizing the behaviour
  111376. * of the glow layer.
  111377. */
  111378. export interface IGlowLayerOptions {
  111379. /**
  111380. * Multiplication factor apply to the canvas size to compute the render target size
  111381. * used to generated the glowing objects (the smaller the faster).
  111382. */
  111383. mainTextureRatio: number;
  111384. /**
  111385. * Enforces a fixed size texture to ensure resize independant blur.
  111386. */
  111387. mainTextureFixedSize?: number;
  111388. /**
  111389. * How big is the kernel of the blur texture.
  111390. */
  111391. blurKernelSize: number;
  111392. /**
  111393. * The camera attached to the layer.
  111394. */
  111395. camera: Nullable<Camera>;
  111396. /**
  111397. * Enable MSAA by chosing the number of samples.
  111398. */
  111399. mainTextureSamples?: number;
  111400. /**
  111401. * The rendering group to draw the layer in.
  111402. */
  111403. renderingGroupId: number;
  111404. }
  111405. /**
  111406. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  111407. *
  111408. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  111409. * glowy meshes to your scene.
  111410. *
  111411. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  111412. */
  111413. export class GlowLayer extends EffectLayer {
  111414. /**
  111415. * Effect Name of the layer.
  111416. */
  111417. static readonly EffectName: string;
  111418. /**
  111419. * The default blur kernel size used for the glow.
  111420. */
  111421. static DefaultBlurKernelSize: number;
  111422. /**
  111423. * The default texture size ratio used for the glow.
  111424. */
  111425. static DefaultTextureRatio: number;
  111426. /**
  111427. * Sets the kernel size of the blur.
  111428. */
  111429. /**
  111430. * Gets the kernel size of the blur.
  111431. */
  111432. blurKernelSize: number;
  111433. /**
  111434. * Sets the glow intensity.
  111435. */
  111436. /**
  111437. * Gets the glow intensity.
  111438. */
  111439. intensity: number;
  111440. private _options;
  111441. private _intensity;
  111442. private _horizontalBlurPostprocess1;
  111443. private _verticalBlurPostprocess1;
  111444. private _horizontalBlurPostprocess2;
  111445. private _verticalBlurPostprocess2;
  111446. private _blurTexture1;
  111447. private _blurTexture2;
  111448. private _postProcesses1;
  111449. private _postProcesses2;
  111450. private _includedOnlyMeshes;
  111451. private _excludedMeshes;
  111452. /**
  111453. * Callback used to let the user override the color selection on a per mesh basis
  111454. */
  111455. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  111456. /**
  111457. * Callback used to let the user override the texture selection on a per mesh basis
  111458. */
  111459. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  111460. /**
  111461. * Instantiates a new glow Layer and references it to the scene.
  111462. * @param name The name of the layer
  111463. * @param scene The scene to use the layer in
  111464. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  111465. */
  111466. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  111467. /**
  111468. * Get the effect name of the layer.
  111469. * @return The effect name
  111470. */
  111471. getEffectName(): string;
  111472. /**
  111473. * Create the merge effect. This is the shader use to blit the information back
  111474. * to the main canvas at the end of the scene rendering.
  111475. */
  111476. protected _createMergeEffect(): Effect;
  111477. /**
  111478. * Creates the render target textures and post processes used in the glow layer.
  111479. */
  111480. protected _createTextureAndPostProcesses(): void;
  111481. /**
  111482. * Checks for the readiness of the element composing the layer.
  111483. * @param subMesh the mesh to check for
  111484. * @param useInstances specify wether or not to use instances to render the mesh
  111485. * @param emissiveTexture the associated emissive texture used to generate the glow
  111486. * @return true if ready otherwise, false
  111487. */
  111488. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  111489. /**
  111490. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  111491. */
  111492. needStencil(): boolean;
  111493. /**
  111494. * Returns true if the mesh can be rendered, otherwise false.
  111495. * @param mesh The mesh to render
  111496. * @param material The material used on the mesh
  111497. * @returns true if it can be rendered otherwise false
  111498. */
  111499. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  111500. /**
  111501. * Implementation specific of rendering the generating effect on the main canvas.
  111502. * @param effect The effect used to render through
  111503. */
  111504. protected _internalRender(effect: Effect): void;
  111505. /**
  111506. * Sets the required values for both the emissive texture and and the main color.
  111507. */
  111508. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  111509. /**
  111510. * Returns true if the mesh should render, otherwise false.
  111511. * @param mesh The mesh to render
  111512. * @returns true if it should render otherwise false
  111513. */
  111514. protected _shouldRenderMesh(mesh: Mesh): boolean;
  111515. /**
  111516. * Adds specific effects defines.
  111517. * @param defines The defines to add specifics to.
  111518. */
  111519. protected _addCustomEffectDefines(defines: string[]): void;
  111520. /**
  111521. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  111522. * @param mesh The mesh to exclude from the glow layer
  111523. */
  111524. addExcludedMesh(mesh: Mesh): void;
  111525. /**
  111526. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  111527. * @param mesh The mesh to remove
  111528. */
  111529. removeExcludedMesh(mesh: Mesh): void;
  111530. /**
  111531. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  111532. * @param mesh The mesh to include in the glow layer
  111533. */
  111534. addIncludedOnlyMesh(mesh: Mesh): void;
  111535. /**
  111536. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  111537. * @param mesh The mesh to remove
  111538. */
  111539. removeIncludedOnlyMesh(mesh: Mesh): void;
  111540. /**
  111541. * Determine if a given mesh will be used in the glow layer
  111542. * @param mesh The mesh to test
  111543. * @returns true if the mesh will be highlighted by the current glow layer
  111544. */
  111545. hasMesh(mesh: AbstractMesh): boolean;
  111546. /**
  111547. * Free any resources and references associated to a mesh.
  111548. * Internal use
  111549. * @param mesh The mesh to free.
  111550. * @hidden
  111551. */
  111552. _disposeMesh(mesh: Mesh): void;
  111553. /**
  111554. * Gets the class name of the effect layer
  111555. * @returns the string with the class name of the effect layer
  111556. */
  111557. getClassName(): string;
  111558. /**
  111559. * Serializes this glow layer
  111560. * @returns a serialized glow layer object
  111561. */
  111562. serialize(): any;
  111563. /**
  111564. * Creates a Glow Layer from parsed glow layer data
  111565. * @param parsedGlowLayer defines glow layer data
  111566. * @param scene defines the current scene
  111567. * @param rootUrl defines the root URL containing the glow layer information
  111568. * @returns a parsed Glow Layer
  111569. */
  111570. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  111571. }
  111572. }
  111573. declare module BABYLON {
  111574. /** @hidden */
  111575. export var glowBlurPostProcessPixelShader: {
  111576. name: string;
  111577. shader: string;
  111578. };
  111579. }
  111580. declare module BABYLON {
  111581. interface AbstractScene {
  111582. /**
  111583. * Return a the first highlight layer of the scene with a given name.
  111584. * @param name The name of the highlight layer to look for.
  111585. * @return The highlight layer if found otherwise null.
  111586. */
  111587. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  111588. }
  111589. /**
  111590. * Highlight layer options. This helps customizing the behaviour
  111591. * of the highlight layer.
  111592. */
  111593. export interface IHighlightLayerOptions {
  111594. /**
  111595. * Multiplication factor apply to the canvas size to compute the render target size
  111596. * used to generated the glowing objects (the smaller the faster).
  111597. */
  111598. mainTextureRatio: number;
  111599. /**
  111600. * Enforces a fixed size texture to ensure resize independant blur.
  111601. */
  111602. mainTextureFixedSize?: number;
  111603. /**
  111604. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  111605. * of the picture to blur (the smaller the faster).
  111606. */
  111607. blurTextureSizeRatio: number;
  111608. /**
  111609. * How big in texel of the blur texture is the vertical blur.
  111610. */
  111611. blurVerticalSize: number;
  111612. /**
  111613. * How big in texel of the blur texture is the horizontal blur.
  111614. */
  111615. blurHorizontalSize: number;
  111616. /**
  111617. * Alpha blending mode used to apply the blur. Default is combine.
  111618. */
  111619. alphaBlendingMode: number;
  111620. /**
  111621. * The camera attached to the layer.
  111622. */
  111623. camera: Nullable<Camera>;
  111624. /**
  111625. * Should we display highlight as a solid stroke?
  111626. */
  111627. isStroke?: boolean;
  111628. /**
  111629. * The rendering group to draw the layer in.
  111630. */
  111631. renderingGroupId: number;
  111632. }
  111633. /**
  111634. * The highlight layer Helps adding a glow effect around a mesh.
  111635. *
  111636. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  111637. * glowy meshes to your scene.
  111638. *
  111639. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  111640. */
  111641. export class HighlightLayer extends EffectLayer {
  111642. name: string;
  111643. /**
  111644. * Effect Name of the highlight layer.
  111645. */
  111646. static readonly EffectName: string;
  111647. /**
  111648. * The neutral color used during the preparation of the glow effect.
  111649. * This is black by default as the blend operation is a blend operation.
  111650. */
  111651. static NeutralColor: Color4;
  111652. /**
  111653. * Stencil value used for glowing meshes.
  111654. */
  111655. static GlowingMeshStencilReference: number;
  111656. /**
  111657. * Stencil value used for the other meshes in the scene.
  111658. */
  111659. static NormalMeshStencilReference: number;
  111660. /**
  111661. * Specifies whether or not the inner glow is ACTIVE in the layer.
  111662. */
  111663. innerGlow: boolean;
  111664. /**
  111665. * Specifies whether or not the outer glow is ACTIVE in the layer.
  111666. */
  111667. outerGlow: boolean;
  111668. /**
  111669. * Specifies the horizontal size of the blur.
  111670. */
  111671. /**
  111672. * Gets the horizontal size of the blur.
  111673. */
  111674. blurHorizontalSize: number;
  111675. /**
  111676. * Specifies the vertical size of the blur.
  111677. */
  111678. /**
  111679. * Gets the vertical size of the blur.
  111680. */
  111681. blurVerticalSize: number;
  111682. /**
  111683. * An event triggered when the highlight layer is being blurred.
  111684. */
  111685. onBeforeBlurObservable: Observable<HighlightLayer>;
  111686. /**
  111687. * An event triggered when the highlight layer has been blurred.
  111688. */
  111689. onAfterBlurObservable: Observable<HighlightLayer>;
  111690. private _instanceGlowingMeshStencilReference;
  111691. private _options;
  111692. private _downSamplePostprocess;
  111693. private _horizontalBlurPostprocess;
  111694. private _verticalBlurPostprocess;
  111695. private _blurTexture;
  111696. private _meshes;
  111697. private _excludedMeshes;
  111698. /**
  111699. * Instantiates a new highlight Layer and references it to the scene..
  111700. * @param name The name of the layer
  111701. * @param scene The scene to use the layer in
  111702. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  111703. */
  111704. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  111705. /**
  111706. * Get the effect name of the layer.
  111707. * @return The effect name
  111708. */
  111709. getEffectName(): string;
  111710. /**
  111711. * Create the merge effect. This is the shader use to blit the information back
  111712. * to the main canvas at the end of the scene rendering.
  111713. */
  111714. protected _createMergeEffect(): Effect;
  111715. /**
  111716. * Creates the render target textures and post processes used in the highlight layer.
  111717. */
  111718. protected _createTextureAndPostProcesses(): void;
  111719. /**
  111720. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  111721. */
  111722. needStencil(): boolean;
  111723. /**
  111724. * Checks for the readiness of the element composing the layer.
  111725. * @param subMesh the mesh to check for
  111726. * @param useInstances specify wether or not to use instances to render the mesh
  111727. * @param emissiveTexture the associated emissive texture used to generate the glow
  111728. * @return true if ready otherwise, false
  111729. */
  111730. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  111731. /**
  111732. * Implementation specific of rendering the generating effect on the main canvas.
  111733. * @param effect The effect used to render through
  111734. */
  111735. protected _internalRender(effect: Effect): void;
  111736. /**
  111737. * Returns true if the layer contains information to display, otherwise false.
  111738. */
  111739. shouldRender(): boolean;
  111740. /**
  111741. * Returns true if the mesh should render, otherwise false.
  111742. * @param mesh The mesh to render
  111743. * @returns true if it should render otherwise false
  111744. */
  111745. protected _shouldRenderMesh(mesh: Mesh): boolean;
  111746. /**
  111747. * Sets the required values for both the emissive texture and and the main color.
  111748. */
  111749. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  111750. /**
  111751. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  111752. * @param mesh The mesh to exclude from the highlight layer
  111753. */
  111754. addExcludedMesh(mesh: Mesh): void;
  111755. /**
  111756. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  111757. * @param mesh The mesh to highlight
  111758. */
  111759. removeExcludedMesh(mesh: Mesh): void;
  111760. /**
  111761. * Determine if a given mesh will be highlighted by the current HighlightLayer
  111762. * @param mesh mesh to test
  111763. * @returns true if the mesh will be highlighted by the current HighlightLayer
  111764. */
  111765. hasMesh(mesh: AbstractMesh): boolean;
  111766. /**
  111767. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  111768. * @param mesh The mesh to highlight
  111769. * @param color The color of the highlight
  111770. * @param glowEmissiveOnly Extract the glow from the emissive texture
  111771. */
  111772. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  111773. /**
  111774. * Remove a mesh from the highlight layer in order to make it stop glowing.
  111775. * @param mesh The mesh to highlight
  111776. */
  111777. removeMesh(mesh: Mesh): void;
  111778. /**
  111779. * Force the stencil to the normal expected value for none glowing parts
  111780. */
  111781. private _defaultStencilReference;
  111782. /**
  111783. * Free any resources and references associated to a mesh.
  111784. * Internal use
  111785. * @param mesh The mesh to free.
  111786. * @hidden
  111787. */
  111788. _disposeMesh(mesh: Mesh): void;
  111789. /**
  111790. * Dispose the highlight layer and free resources.
  111791. */
  111792. dispose(): void;
  111793. /**
  111794. * Gets the class name of the effect layer
  111795. * @returns the string with the class name of the effect layer
  111796. */
  111797. getClassName(): string;
  111798. /**
  111799. * Serializes this Highlight layer
  111800. * @returns a serialized Highlight layer object
  111801. */
  111802. serialize(): any;
  111803. /**
  111804. * Creates a Highlight layer from parsed Highlight layer data
  111805. * @param parsedHightlightLayer defines the Highlight layer data
  111806. * @param scene defines the current scene
  111807. * @param rootUrl defines the root URL containing the Highlight layer information
  111808. * @returns a parsed Highlight layer
  111809. */
  111810. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  111811. }
  111812. }
  111813. declare module BABYLON {
  111814. interface AbstractScene {
  111815. /**
  111816. * The list of layers (background and foreground) of the scene
  111817. */
  111818. layers: Array<Layer>;
  111819. }
  111820. /**
  111821. * Defines the layer scene component responsible to manage any layers
  111822. * in a given scene.
  111823. */
  111824. export class LayerSceneComponent implements ISceneComponent {
  111825. /**
  111826. * The component name helpfull to identify the component in the list of scene components.
  111827. */
  111828. readonly name: string;
  111829. /**
  111830. * The scene the component belongs to.
  111831. */
  111832. scene: Scene;
  111833. private _engine;
  111834. /**
  111835. * Creates a new instance of the component for the given scene
  111836. * @param scene Defines the scene to register the component in
  111837. */
  111838. constructor(scene: Scene);
  111839. /**
  111840. * Registers the component in a given scene
  111841. */
  111842. register(): void;
  111843. /**
  111844. * Rebuilds the elements related to this component in case of
  111845. * context lost for instance.
  111846. */
  111847. rebuild(): void;
  111848. /**
  111849. * Disposes the component and the associated ressources.
  111850. */
  111851. dispose(): void;
  111852. private _draw;
  111853. private _drawCameraPredicate;
  111854. private _drawCameraBackground;
  111855. private _drawCameraForeground;
  111856. private _drawRenderTargetPredicate;
  111857. private _drawRenderTargetBackground;
  111858. private _drawRenderTargetForeground;
  111859. /**
  111860. * Adds all the elements from the container to the scene
  111861. * @param container the container holding the elements
  111862. */
  111863. addFromContainer(container: AbstractScene): void;
  111864. /**
  111865. * Removes all the elements in the container from the scene
  111866. * @param container contains the elements to remove
  111867. * @param dispose if the removed element should be disposed (default: false)
  111868. */
  111869. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111870. }
  111871. }
  111872. declare module BABYLON {
  111873. /** @hidden */
  111874. export var layerPixelShader: {
  111875. name: string;
  111876. shader: string;
  111877. };
  111878. }
  111879. declare module BABYLON {
  111880. /** @hidden */
  111881. export var layerVertexShader: {
  111882. name: string;
  111883. shader: string;
  111884. };
  111885. }
  111886. declare module BABYLON {
  111887. /**
  111888. * This represents a full screen 2d layer.
  111889. * This can be useful to display a picture in the background of your scene for instance.
  111890. * @see https://www.babylonjs-playground.com/#08A2BS#1
  111891. */
  111892. export class Layer {
  111893. /**
  111894. * Define the name of the layer.
  111895. */
  111896. name: string;
  111897. /**
  111898. * Define the texture the layer should display.
  111899. */
  111900. texture: Nullable<Texture>;
  111901. /**
  111902. * Is the layer in background or foreground.
  111903. */
  111904. isBackground: boolean;
  111905. /**
  111906. * Define the color of the layer (instead of texture).
  111907. */
  111908. color: Color4;
  111909. /**
  111910. * Define the scale of the layer in order to zoom in out of the texture.
  111911. */
  111912. scale: Vector2;
  111913. /**
  111914. * Define an offset for the layer in order to shift the texture.
  111915. */
  111916. offset: Vector2;
  111917. /**
  111918. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  111919. */
  111920. alphaBlendingMode: number;
  111921. /**
  111922. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  111923. * Alpha test will not mix with the background color in case of transparency.
  111924. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  111925. */
  111926. alphaTest: boolean;
  111927. /**
  111928. * Define a mask to restrict the layer to only some of the scene cameras.
  111929. */
  111930. layerMask: number;
  111931. /**
  111932. * Define the list of render target the layer is visible into.
  111933. */
  111934. renderTargetTextures: RenderTargetTexture[];
  111935. /**
  111936. * Define if the layer is only used in renderTarget or if it also
  111937. * renders in the main frame buffer of the canvas.
  111938. */
  111939. renderOnlyInRenderTargetTextures: boolean;
  111940. private _scene;
  111941. private _vertexBuffers;
  111942. private _indexBuffer;
  111943. private _effect;
  111944. private _alphaTestEffect;
  111945. /**
  111946. * An event triggered when the layer is disposed.
  111947. */
  111948. onDisposeObservable: Observable<Layer>;
  111949. private _onDisposeObserver;
  111950. /**
  111951. * Back compatibility with callback before the onDisposeObservable existed.
  111952. * The set callback will be triggered when the layer has been disposed.
  111953. */
  111954. onDispose: () => void;
  111955. /**
  111956. * An event triggered before rendering the scene
  111957. */
  111958. onBeforeRenderObservable: Observable<Layer>;
  111959. private _onBeforeRenderObserver;
  111960. /**
  111961. * Back compatibility with callback before the onBeforeRenderObservable existed.
  111962. * The set callback will be triggered just before rendering the layer.
  111963. */
  111964. onBeforeRender: () => void;
  111965. /**
  111966. * An event triggered after rendering the scene
  111967. */
  111968. onAfterRenderObservable: Observable<Layer>;
  111969. private _onAfterRenderObserver;
  111970. /**
  111971. * Back compatibility with callback before the onAfterRenderObservable existed.
  111972. * The set callback will be triggered just after rendering the layer.
  111973. */
  111974. onAfterRender: () => void;
  111975. /**
  111976. * Instantiates a new layer.
  111977. * This represents a full screen 2d layer.
  111978. * This can be useful to display a picture in the background of your scene for instance.
  111979. * @see https://www.babylonjs-playground.com/#08A2BS#1
  111980. * @param name Define the name of the layer in the scene
  111981. * @param imgUrl Define the url of the texture to display in the layer
  111982. * @param scene Define the scene the layer belongs to
  111983. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  111984. * @param color Defines a color for the layer
  111985. */
  111986. constructor(
  111987. /**
  111988. * Define the name of the layer.
  111989. */
  111990. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  111991. private _createIndexBuffer;
  111992. /** @hidden */
  111993. _rebuild(): void;
  111994. /**
  111995. * Renders the layer in the scene.
  111996. */
  111997. render(): void;
  111998. /**
  111999. * Disposes and releases the associated ressources.
  112000. */
  112001. dispose(): void;
  112002. }
  112003. }
  112004. declare module BABYLON {
  112005. /** @hidden */
  112006. export var lensFlarePixelShader: {
  112007. name: string;
  112008. shader: string;
  112009. };
  112010. }
  112011. declare module BABYLON {
  112012. /** @hidden */
  112013. export var lensFlareVertexShader: {
  112014. name: string;
  112015. shader: string;
  112016. };
  112017. }
  112018. declare module BABYLON {
  112019. /**
  112020. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  112021. * It is usually composed of several `lensFlare`.
  112022. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112023. */
  112024. export class LensFlareSystem {
  112025. /**
  112026. * Define the name of the lens flare system
  112027. */
  112028. name: string;
  112029. /**
  112030. * List of lens flares used in this system.
  112031. */
  112032. lensFlares: LensFlare[];
  112033. /**
  112034. * Define a limit from the border the lens flare can be visible.
  112035. */
  112036. borderLimit: number;
  112037. /**
  112038. * Define a viewport border we do not want to see the lens flare in.
  112039. */
  112040. viewportBorder: number;
  112041. /**
  112042. * Define a predicate which could limit the list of meshes able to occlude the effect.
  112043. */
  112044. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  112045. /**
  112046. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  112047. */
  112048. layerMask: number;
  112049. /**
  112050. * Define the id of the lens flare system in the scene.
  112051. * (equal to name by default)
  112052. */
  112053. id: string;
  112054. private _scene;
  112055. private _emitter;
  112056. private _vertexBuffers;
  112057. private _indexBuffer;
  112058. private _effect;
  112059. private _positionX;
  112060. private _positionY;
  112061. private _isEnabled;
  112062. /** @hidden */
  112063. static _SceneComponentInitialization: (scene: Scene) => void;
  112064. /**
  112065. * Instantiates a lens flare system.
  112066. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  112067. * It is usually composed of several `lensFlare`.
  112068. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112069. * @param name Define the name of the lens flare system in the scene
  112070. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  112071. * @param scene Define the scene the lens flare system belongs to
  112072. */
  112073. constructor(
  112074. /**
  112075. * Define the name of the lens flare system
  112076. */
  112077. name: string, emitter: any, scene: Scene);
  112078. /**
  112079. * Define if the lens flare system is enabled.
  112080. */
  112081. isEnabled: boolean;
  112082. /**
  112083. * Get the scene the effects belongs to.
  112084. * @returns the scene holding the lens flare system
  112085. */
  112086. getScene(): Scene;
  112087. /**
  112088. * Get the emitter of the lens flare system.
  112089. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  112090. * @returns the emitter of the lens flare system
  112091. */
  112092. getEmitter(): any;
  112093. /**
  112094. * Set the emitter of the lens flare system.
  112095. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  112096. * @param newEmitter Define the new emitter of the system
  112097. */
  112098. setEmitter(newEmitter: any): void;
  112099. /**
  112100. * Get the lens flare system emitter position.
  112101. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  112102. * @returns the position
  112103. */
  112104. getEmitterPosition(): Vector3;
  112105. /**
  112106. * @hidden
  112107. */
  112108. computeEffectivePosition(globalViewport: Viewport): boolean;
  112109. /** @hidden */
  112110. _isVisible(): boolean;
  112111. /**
  112112. * @hidden
  112113. */
  112114. render(): boolean;
  112115. /**
  112116. * Dispose and release the lens flare with its associated resources.
  112117. */
  112118. dispose(): void;
  112119. /**
  112120. * Parse a lens flare system from a JSON repressentation
  112121. * @param parsedLensFlareSystem Define the JSON to parse
  112122. * @param scene Define the scene the parsed system should be instantiated in
  112123. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  112124. * @returns the parsed system
  112125. */
  112126. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  112127. /**
  112128. * Serialize the current Lens Flare System into a JSON representation.
  112129. * @returns the serialized JSON
  112130. */
  112131. serialize(): any;
  112132. }
  112133. }
  112134. declare module BABYLON {
  112135. /**
  112136. * This represents one of the lens effect in a `lensFlareSystem`.
  112137. * It controls one of the indiviual texture used in the effect.
  112138. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112139. */
  112140. export class LensFlare {
  112141. /**
  112142. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  112143. */
  112144. size: number;
  112145. /**
  112146. * 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.
  112147. */
  112148. position: number;
  112149. /**
  112150. * Define the lens color.
  112151. */
  112152. color: Color3;
  112153. /**
  112154. * Define the lens texture.
  112155. */
  112156. texture: Nullable<Texture>;
  112157. /**
  112158. * Define the alpha mode to render this particular lens.
  112159. */
  112160. alphaMode: number;
  112161. private _system;
  112162. /**
  112163. * Creates a new Lens Flare.
  112164. * This represents one of the lens effect in a `lensFlareSystem`.
  112165. * It controls one of the indiviual texture used in the effect.
  112166. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112167. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  112168. * @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.
  112169. * @param color Define the lens color
  112170. * @param imgUrl Define the lens texture url
  112171. * @param system Define the `lensFlareSystem` this flare is part of
  112172. * @returns The newly created Lens Flare
  112173. */
  112174. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  112175. /**
  112176. * Instantiates a new Lens Flare.
  112177. * This represents one of the lens effect in a `lensFlareSystem`.
  112178. * It controls one of the indiviual texture used in the effect.
  112179. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112180. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  112181. * @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.
  112182. * @param color Define the lens color
  112183. * @param imgUrl Define the lens texture url
  112184. * @param system Define the `lensFlareSystem` this flare is part of
  112185. */
  112186. constructor(
  112187. /**
  112188. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  112189. */
  112190. size: number,
  112191. /**
  112192. * 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.
  112193. */
  112194. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  112195. /**
  112196. * Dispose and release the lens flare with its associated resources.
  112197. */
  112198. dispose(): void;
  112199. }
  112200. }
  112201. declare module BABYLON {
  112202. interface AbstractScene {
  112203. /**
  112204. * The list of lens flare system added to the scene
  112205. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112206. */
  112207. lensFlareSystems: Array<LensFlareSystem>;
  112208. /**
  112209. * Removes the given lens flare system from this scene.
  112210. * @param toRemove The lens flare system to remove
  112211. * @returns The index of the removed lens flare system
  112212. */
  112213. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  112214. /**
  112215. * Adds the given lens flare system to this scene
  112216. * @param newLensFlareSystem The lens flare system to add
  112217. */
  112218. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  112219. /**
  112220. * Gets a lens flare system using its name
  112221. * @param name defines the name to look for
  112222. * @returns the lens flare system or null if not found
  112223. */
  112224. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  112225. /**
  112226. * Gets a lens flare system using its id
  112227. * @param id defines the id to look for
  112228. * @returns the lens flare system or null if not found
  112229. */
  112230. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  112231. }
  112232. /**
  112233. * Defines the lens flare scene component responsible to manage any lens flares
  112234. * in a given scene.
  112235. */
  112236. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  112237. /**
  112238. * The component name helpfull to identify the component in the list of scene components.
  112239. */
  112240. readonly name: string;
  112241. /**
  112242. * The scene the component belongs to.
  112243. */
  112244. scene: Scene;
  112245. /**
  112246. * Creates a new instance of the component for the given scene
  112247. * @param scene Defines the scene to register the component in
  112248. */
  112249. constructor(scene: Scene);
  112250. /**
  112251. * Registers the component in a given scene
  112252. */
  112253. register(): void;
  112254. /**
  112255. * Rebuilds the elements related to this component in case of
  112256. * context lost for instance.
  112257. */
  112258. rebuild(): void;
  112259. /**
  112260. * Adds all the elements from the container to the scene
  112261. * @param container the container holding the elements
  112262. */
  112263. addFromContainer(container: AbstractScene): void;
  112264. /**
  112265. * Removes all the elements in the container from the scene
  112266. * @param container contains the elements to remove
  112267. * @param dispose if the removed element should be disposed (default: false)
  112268. */
  112269. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  112270. /**
  112271. * Serializes the component data to the specified json object
  112272. * @param serializationObject The object to serialize to
  112273. */
  112274. serialize(serializationObject: any): void;
  112275. /**
  112276. * Disposes the component and the associated ressources.
  112277. */
  112278. dispose(): void;
  112279. private _draw;
  112280. }
  112281. }
  112282. declare module BABYLON {
  112283. /**
  112284. * Defines the shadow generator component responsible to manage any shadow generators
  112285. * in a given scene.
  112286. */
  112287. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  112288. /**
  112289. * The component name helpfull to identify the component in the list of scene components.
  112290. */
  112291. readonly name: string;
  112292. /**
  112293. * The scene the component belongs to.
  112294. */
  112295. scene: Scene;
  112296. /**
  112297. * Creates a new instance of the component for the given scene
  112298. * @param scene Defines the scene to register the component in
  112299. */
  112300. constructor(scene: Scene);
  112301. /**
  112302. * Registers the component in a given scene
  112303. */
  112304. register(): void;
  112305. /**
  112306. * Rebuilds the elements related to this component in case of
  112307. * context lost for instance.
  112308. */
  112309. rebuild(): void;
  112310. /**
  112311. * Serializes the component data to the specified json object
  112312. * @param serializationObject The object to serialize to
  112313. */
  112314. serialize(serializationObject: any): void;
  112315. /**
  112316. * Adds all the elements from the container to the scene
  112317. * @param container the container holding the elements
  112318. */
  112319. addFromContainer(container: AbstractScene): void;
  112320. /**
  112321. * Removes all the elements in the container from the scene
  112322. * @param container contains the elements to remove
  112323. * @param dispose if the removed element should be disposed (default: false)
  112324. */
  112325. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  112326. /**
  112327. * Rebuilds the elements related to this component in case of
  112328. * context lost for instance.
  112329. */
  112330. dispose(): void;
  112331. private _gatherRenderTargets;
  112332. }
  112333. }
  112334. declare module BABYLON {
  112335. /**
  112336. * A point light is a light defined by an unique point in world space.
  112337. * The light is emitted in every direction from this point.
  112338. * A good example of a point light is a standard light bulb.
  112339. * Documentation: https://doc.babylonjs.com/babylon101/lights
  112340. */
  112341. export class PointLight extends ShadowLight {
  112342. private _shadowAngle;
  112343. /**
  112344. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  112345. * This specifies what angle the shadow will use to be created.
  112346. *
  112347. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  112348. */
  112349. /**
  112350. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  112351. * This specifies what angle the shadow will use to be created.
  112352. *
  112353. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  112354. */
  112355. shadowAngle: number;
  112356. /**
  112357. * Gets the direction if it has been set.
  112358. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  112359. */
  112360. /**
  112361. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  112362. */
  112363. direction: Vector3;
  112364. /**
  112365. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  112366. * A PointLight emits the light in every direction.
  112367. * It can cast shadows.
  112368. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  112369. * ```javascript
  112370. * var pointLight = new PointLight("pl", camera.position, scene);
  112371. * ```
  112372. * Documentation : https://doc.babylonjs.com/babylon101/lights
  112373. * @param name The light friendly name
  112374. * @param position The position of the point light in the scene
  112375. * @param scene The scene the lights belongs to
  112376. */
  112377. constructor(name: string, position: Vector3, scene: Scene);
  112378. /**
  112379. * Returns the string "PointLight"
  112380. * @returns the class name
  112381. */
  112382. getClassName(): string;
  112383. /**
  112384. * Returns the integer 0.
  112385. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  112386. */
  112387. getTypeID(): number;
  112388. /**
  112389. * Specifies wether or not the shadowmap should be a cube texture.
  112390. * @returns true if the shadowmap needs to be a cube texture.
  112391. */
  112392. needCube(): boolean;
  112393. /**
  112394. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  112395. * @param faceIndex The index of the face we are computed the direction to generate shadow
  112396. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  112397. */
  112398. getShadowDirection(faceIndex?: number): Vector3;
  112399. /**
  112400. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  112401. * - fov = PI / 2
  112402. * - aspect ratio : 1.0
  112403. * - z-near and far equal to the active camera minZ and maxZ.
  112404. * Returns the PointLight.
  112405. */
  112406. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112407. protected _buildUniformLayout(): void;
  112408. /**
  112409. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  112410. * @param effect The effect to update
  112411. * @param lightIndex The index of the light in the effect to update
  112412. * @returns The point light
  112413. */
  112414. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  112415. /**
  112416. * Prepares the list of defines specific to the light type.
  112417. * @param defines the list of defines
  112418. * @param lightIndex defines the index of the light for the effect
  112419. */
  112420. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  112421. }
  112422. }
  112423. declare module BABYLON {
  112424. /**
  112425. * Header information of HDR texture files.
  112426. */
  112427. export interface HDRInfo {
  112428. /**
  112429. * The height of the texture in pixels.
  112430. */
  112431. height: number;
  112432. /**
  112433. * The width of the texture in pixels.
  112434. */
  112435. width: number;
  112436. /**
  112437. * The index of the beginning of the data in the binary file.
  112438. */
  112439. dataPosition: number;
  112440. }
  112441. /**
  112442. * This groups tools to convert HDR texture to native colors array.
  112443. */
  112444. export class HDRTools {
  112445. private static Ldexp;
  112446. private static Rgbe2float;
  112447. private static readStringLine;
  112448. /**
  112449. * Reads header information from an RGBE texture stored in a native array.
  112450. * More information on this format are available here:
  112451. * https://en.wikipedia.org/wiki/RGBE_image_format
  112452. *
  112453. * @param uint8array The binary file stored in native array.
  112454. * @return The header information.
  112455. */
  112456. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  112457. /**
  112458. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  112459. * This RGBE texture needs to store the information as a panorama.
  112460. *
  112461. * More information on this format are available here:
  112462. * https://en.wikipedia.org/wiki/RGBE_image_format
  112463. *
  112464. * @param buffer The binary file stored in an array buffer.
  112465. * @param size The expected size of the extracted cubemap.
  112466. * @return The Cube Map information.
  112467. */
  112468. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  112469. /**
  112470. * Returns the pixels data extracted from an RGBE texture.
  112471. * This pixels will be stored left to right up to down in the R G B order in one array.
  112472. *
  112473. * More information on this format are available here:
  112474. * https://en.wikipedia.org/wiki/RGBE_image_format
  112475. *
  112476. * @param uint8array The binary file stored in an array buffer.
  112477. * @param hdrInfo The header information of the file.
  112478. * @return The pixels data in RGB right to left up to down order.
  112479. */
  112480. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  112481. private static RGBE_ReadPixels_RLE;
  112482. }
  112483. }
  112484. declare module BABYLON {
  112485. /**
  112486. * This represents a texture coming from an HDR input.
  112487. *
  112488. * The only supported format is currently panorama picture stored in RGBE format.
  112489. * Example of such files can be found on HDRLib: http://hdrlib.com/
  112490. */
  112491. export class HDRCubeTexture extends BaseTexture {
  112492. private static _facesMapping;
  112493. private _generateHarmonics;
  112494. private _noMipmap;
  112495. private _textureMatrix;
  112496. private _size;
  112497. private _onLoad;
  112498. private _onError;
  112499. /**
  112500. * The texture URL.
  112501. */
  112502. url: string;
  112503. /**
  112504. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  112505. */
  112506. coordinatesMode: number;
  112507. protected _isBlocking: boolean;
  112508. /**
  112509. * Sets wether or not the texture is blocking during loading.
  112510. */
  112511. /**
  112512. * Gets wether or not the texture is blocking during loading.
  112513. */
  112514. isBlocking: boolean;
  112515. protected _rotationY: number;
  112516. /**
  112517. * Sets texture matrix rotation angle around Y axis in radians.
  112518. */
  112519. /**
  112520. * Gets texture matrix rotation angle around Y axis radians.
  112521. */
  112522. rotationY: number;
  112523. /**
  112524. * Gets or sets the center of the bounding box associated with the cube texture
  112525. * It must define where the camera used to render the texture was set
  112526. */
  112527. boundingBoxPosition: Vector3;
  112528. private _boundingBoxSize;
  112529. /**
  112530. * Gets or sets the size of the bounding box associated with the cube texture
  112531. * When defined, the cubemap will switch to local mode
  112532. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  112533. * @example https://www.babylonjs-playground.com/#RNASML
  112534. */
  112535. boundingBoxSize: Vector3;
  112536. /**
  112537. * Instantiates an HDRTexture from the following parameters.
  112538. *
  112539. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  112540. * @param scene The scene the texture will be used in
  112541. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  112542. * @param noMipmap Forces to not generate the mipmap if true
  112543. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  112544. * @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)
  112545. * @param reserved Reserved flag for internal use.
  112546. */
  112547. 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>);
  112548. /**
  112549. * Get the current class name of the texture useful for serialization or dynamic coding.
  112550. * @returns "HDRCubeTexture"
  112551. */
  112552. getClassName(): string;
  112553. /**
  112554. * Occurs when the file is raw .hdr file.
  112555. */
  112556. private loadTexture;
  112557. clone(): HDRCubeTexture;
  112558. delayLoad(): void;
  112559. /**
  112560. * Get the texture reflection matrix used to rotate/transform the reflection.
  112561. * @returns the reflection matrix
  112562. */
  112563. getReflectionTextureMatrix(): Matrix;
  112564. /**
  112565. * Set the texture reflection matrix used to rotate/transform the reflection.
  112566. * @param value Define the reflection matrix to set
  112567. */
  112568. setReflectionTextureMatrix(value: Matrix): void;
  112569. /**
  112570. * Parses a JSON representation of an HDR Texture in order to create the texture
  112571. * @param parsedTexture Define the JSON representation
  112572. * @param scene Define the scene the texture should be created in
  112573. * @param rootUrl Define the root url in case we need to load relative dependencies
  112574. * @returns the newly created texture after parsing
  112575. */
  112576. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  112577. serialize(): any;
  112578. }
  112579. }
  112580. declare module BABYLON {
  112581. /**
  112582. * Class used to control physics engine
  112583. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  112584. */
  112585. export class PhysicsEngine implements IPhysicsEngine {
  112586. private _physicsPlugin;
  112587. /**
  112588. * Global value used to control the smallest number supported by the simulation
  112589. */
  112590. static Epsilon: number;
  112591. private _impostors;
  112592. private _joints;
  112593. /**
  112594. * Gets the gravity vector used by the simulation
  112595. */
  112596. gravity: Vector3;
  112597. /**
  112598. * Factory used to create the default physics plugin.
  112599. * @returns The default physics plugin
  112600. */
  112601. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  112602. /**
  112603. * Creates a new Physics Engine
  112604. * @param gravity defines the gravity vector used by the simulation
  112605. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  112606. */
  112607. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  112608. /**
  112609. * Sets the gravity vector used by the simulation
  112610. * @param gravity defines the gravity vector to use
  112611. */
  112612. setGravity(gravity: Vector3): void;
  112613. /**
  112614. * Set the time step of the physics engine.
  112615. * Default is 1/60.
  112616. * To slow it down, enter 1/600 for example.
  112617. * To speed it up, 1/30
  112618. * @param newTimeStep defines the new timestep to apply to this world.
  112619. */
  112620. setTimeStep(newTimeStep?: number): void;
  112621. /**
  112622. * Get the time step of the physics engine.
  112623. * @returns the current time step
  112624. */
  112625. getTimeStep(): number;
  112626. /**
  112627. * Release all resources
  112628. */
  112629. dispose(): void;
  112630. /**
  112631. * Gets the name of the current physics plugin
  112632. * @returns the name of the plugin
  112633. */
  112634. getPhysicsPluginName(): string;
  112635. /**
  112636. * Adding a new impostor for the impostor tracking.
  112637. * This will be done by the impostor itself.
  112638. * @param impostor the impostor to add
  112639. */
  112640. addImpostor(impostor: PhysicsImpostor): void;
  112641. /**
  112642. * Remove an impostor from the engine.
  112643. * This impostor and its mesh will not longer be updated by the physics engine.
  112644. * @param impostor the impostor to remove
  112645. */
  112646. removeImpostor(impostor: PhysicsImpostor): void;
  112647. /**
  112648. * Add a joint to the physics engine
  112649. * @param mainImpostor defines the main impostor to which the joint is added.
  112650. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  112651. * @param joint defines the joint that will connect both impostors.
  112652. */
  112653. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  112654. /**
  112655. * Removes a joint from the simulation
  112656. * @param mainImpostor defines the impostor used with the joint
  112657. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  112658. * @param joint defines the joint to remove
  112659. */
  112660. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  112661. /**
  112662. * Called by the scene. No need to call it.
  112663. * @param delta defines the timespam between frames
  112664. */
  112665. _step(delta: number): void;
  112666. /**
  112667. * Gets the current plugin used to run the simulation
  112668. * @returns current plugin
  112669. */
  112670. getPhysicsPlugin(): IPhysicsEnginePlugin;
  112671. /**
  112672. * Gets the list of physic impostors
  112673. * @returns an array of PhysicsImpostor
  112674. */
  112675. getImpostors(): Array<PhysicsImpostor>;
  112676. /**
  112677. * Gets the impostor for a physics enabled object
  112678. * @param object defines the object impersonated by the impostor
  112679. * @returns the PhysicsImpostor or null if not found
  112680. */
  112681. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  112682. /**
  112683. * Gets the impostor for a physics body object
  112684. * @param body defines physics body used by the impostor
  112685. * @returns the PhysicsImpostor or null if not found
  112686. */
  112687. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  112688. /**
  112689. * Does a raycast in the physics world
  112690. * @param from when should the ray start?
  112691. * @param to when should the ray end?
  112692. * @returns PhysicsRaycastResult
  112693. */
  112694. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112695. }
  112696. }
  112697. declare module BABYLON {
  112698. /** @hidden */
  112699. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  112700. private _useDeltaForWorldStep;
  112701. world: any;
  112702. name: string;
  112703. private _physicsMaterials;
  112704. private _fixedTimeStep;
  112705. private _cannonRaycastResult;
  112706. private _raycastResult;
  112707. private _physicsBodysToRemoveAfterStep;
  112708. BJSCANNON: any;
  112709. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  112710. setGravity(gravity: Vector3): void;
  112711. setTimeStep(timeStep: number): void;
  112712. getTimeStep(): number;
  112713. executeStep(delta: number): void;
  112714. private _removeMarkedPhysicsBodiesFromWorld;
  112715. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112716. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112717. generatePhysicsBody(impostor: PhysicsImpostor): void;
  112718. private _processChildMeshes;
  112719. removePhysicsBody(impostor: PhysicsImpostor): void;
  112720. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  112721. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  112722. private _addMaterial;
  112723. private _checkWithEpsilon;
  112724. private _createShape;
  112725. private _createHeightmap;
  112726. private _minus90X;
  112727. private _plus90X;
  112728. private _tmpPosition;
  112729. private _tmpDeltaPosition;
  112730. private _tmpUnityRotation;
  112731. private _updatePhysicsBodyTransformation;
  112732. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  112733. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  112734. isSupported(): boolean;
  112735. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112736. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112737. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112738. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112739. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  112740. getBodyMass(impostor: PhysicsImpostor): number;
  112741. getBodyFriction(impostor: PhysicsImpostor): number;
  112742. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  112743. getBodyRestitution(impostor: PhysicsImpostor): number;
  112744. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  112745. sleepBody(impostor: PhysicsImpostor): void;
  112746. wakeUpBody(impostor: PhysicsImpostor): void;
  112747. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  112748. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  112749. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  112750. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112751. getRadius(impostor: PhysicsImpostor): number;
  112752. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112753. dispose(): void;
  112754. private _extendNamespace;
  112755. /**
  112756. * Does a raycast in the physics world
  112757. * @param from when should the ray start?
  112758. * @param to when should the ray end?
  112759. * @returns PhysicsRaycastResult
  112760. */
  112761. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112762. }
  112763. }
  112764. declare module BABYLON {
  112765. /** @hidden */
  112766. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  112767. world: any;
  112768. name: string;
  112769. BJSOIMO: any;
  112770. private _raycastResult;
  112771. constructor(iterations?: number, oimoInjection?: any);
  112772. setGravity(gravity: Vector3): void;
  112773. setTimeStep(timeStep: number): void;
  112774. getTimeStep(): number;
  112775. private _tmpImpostorsArray;
  112776. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  112777. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112778. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112779. generatePhysicsBody(impostor: PhysicsImpostor): void;
  112780. private _tmpPositionVector;
  112781. removePhysicsBody(impostor: PhysicsImpostor): void;
  112782. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  112783. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  112784. isSupported(): boolean;
  112785. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  112786. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  112787. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112788. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112789. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112790. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112791. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  112792. getBodyMass(impostor: PhysicsImpostor): number;
  112793. getBodyFriction(impostor: PhysicsImpostor): number;
  112794. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  112795. getBodyRestitution(impostor: PhysicsImpostor): number;
  112796. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  112797. sleepBody(impostor: PhysicsImpostor): void;
  112798. wakeUpBody(impostor: PhysicsImpostor): void;
  112799. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  112800. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  112801. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112802. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112803. getRadius(impostor: PhysicsImpostor): number;
  112804. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112805. dispose(): void;
  112806. /**
  112807. * Does a raycast in the physics world
  112808. * @param from when should the ray start?
  112809. * @param to when should the ray end?
  112810. * @returns PhysicsRaycastResult
  112811. */
  112812. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112813. }
  112814. }
  112815. declare module BABYLON {
  112816. /**
  112817. * Class containing static functions to help procedurally build meshes
  112818. */
  112819. export class RibbonBuilder {
  112820. /**
  112821. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  112822. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  112823. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  112824. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  112825. * * 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
  112826. * * 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
  112827. * * 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
  112828. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112829. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112830. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  112831. * * 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
  112832. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  112833. * * 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
  112834. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  112835. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112836. * @param name defines the name of the mesh
  112837. * @param options defines the options used to create the mesh
  112838. * @param scene defines the hosting scene
  112839. * @returns the ribbon mesh
  112840. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  112841. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  112842. */
  112843. static CreateRibbon(name: string, options: {
  112844. pathArray: Vector3[][];
  112845. closeArray?: boolean;
  112846. closePath?: boolean;
  112847. offset?: number;
  112848. updatable?: boolean;
  112849. sideOrientation?: number;
  112850. frontUVs?: Vector4;
  112851. backUVs?: Vector4;
  112852. instance?: Mesh;
  112853. invertUV?: boolean;
  112854. uvs?: Vector2[];
  112855. colors?: Color4[];
  112856. }, scene?: Nullable<Scene>): Mesh;
  112857. }
  112858. }
  112859. declare module BABYLON {
  112860. /**
  112861. * Class containing static functions to help procedurally build meshes
  112862. */
  112863. export class ShapeBuilder {
  112864. /**
  112865. * 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.
  112866. * * 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.
  112867. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  112868. * * 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.
  112869. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  112870. * * 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
  112871. * * 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
  112872. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  112873. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112874. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112875. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  112876. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112877. * @param name defines the name of the mesh
  112878. * @param options defines the options used to create the mesh
  112879. * @param scene defines the hosting scene
  112880. * @returns the extruded shape mesh
  112881. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  112882. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  112883. */
  112884. static ExtrudeShape(name: string, options: {
  112885. shape: Vector3[];
  112886. path: Vector3[];
  112887. scale?: number;
  112888. rotation?: number;
  112889. cap?: number;
  112890. updatable?: boolean;
  112891. sideOrientation?: number;
  112892. frontUVs?: Vector4;
  112893. backUVs?: Vector4;
  112894. instance?: Mesh;
  112895. invertUV?: boolean;
  112896. }, scene?: Nullable<Scene>): Mesh;
  112897. /**
  112898. * Creates an custom extruded shape mesh.
  112899. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  112900. * * 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.
  112901. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  112902. * * 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
  112903. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  112904. * * 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
  112905. * * It must returns a float value that will be the scale value applied to the shape on each path point
  112906. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  112907. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  112908. * * 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
  112909. * * 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
  112910. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  112911. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112912. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112913. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  112914. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112915. * @param name defines the name of the mesh
  112916. * @param options defines the options used to create the mesh
  112917. * @param scene defines the hosting scene
  112918. * @returns the custom extruded shape mesh
  112919. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  112920. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  112921. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  112922. */
  112923. static ExtrudeShapeCustom(name: string, options: {
  112924. shape: Vector3[];
  112925. path: Vector3[];
  112926. scaleFunction?: any;
  112927. rotationFunction?: any;
  112928. ribbonCloseArray?: boolean;
  112929. ribbonClosePath?: boolean;
  112930. cap?: number;
  112931. updatable?: boolean;
  112932. sideOrientation?: number;
  112933. frontUVs?: Vector4;
  112934. backUVs?: Vector4;
  112935. instance?: Mesh;
  112936. invertUV?: boolean;
  112937. }, scene?: Nullable<Scene>): Mesh;
  112938. private static _ExtrudeShapeGeneric;
  112939. }
  112940. }
  112941. declare module BABYLON {
  112942. /**
  112943. * AmmoJS Physics plugin
  112944. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112945. * @see https://github.com/kripken/ammo.js/
  112946. */
  112947. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  112948. private _useDeltaForWorldStep;
  112949. /**
  112950. * Reference to the Ammo library
  112951. */
  112952. bjsAMMO: any;
  112953. /**
  112954. * Created ammoJS world which physics bodies are added to
  112955. */
  112956. world: any;
  112957. /**
  112958. * Name of the plugin
  112959. */
  112960. name: string;
  112961. private _timeStep;
  112962. private _fixedTimeStep;
  112963. private _maxSteps;
  112964. private _tmpQuaternion;
  112965. private _tmpAmmoTransform;
  112966. private _tmpAmmoQuaternion;
  112967. private _tmpAmmoConcreteContactResultCallback;
  112968. private _collisionConfiguration;
  112969. private _dispatcher;
  112970. private _overlappingPairCache;
  112971. private _solver;
  112972. private _softBodySolver;
  112973. private _tmpAmmoVectorA;
  112974. private _tmpAmmoVectorB;
  112975. private _tmpAmmoVectorC;
  112976. private _tmpAmmoVectorD;
  112977. private _tmpContactCallbackResult;
  112978. private _tmpAmmoVectorRCA;
  112979. private _tmpAmmoVectorRCB;
  112980. private _raycastResult;
  112981. private static readonly DISABLE_COLLISION_FLAG;
  112982. private static readonly KINEMATIC_FLAG;
  112983. private static readonly DISABLE_DEACTIVATION_FLAG;
  112984. /**
  112985. * Initializes the ammoJS plugin
  112986. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  112987. * @param ammoInjection can be used to inject your own ammo reference
  112988. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  112989. */
  112990. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  112991. /**
  112992. * Sets the gravity of the physics world (m/(s^2))
  112993. * @param gravity Gravity to set
  112994. */
  112995. setGravity(gravity: Vector3): void;
  112996. /**
  112997. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  112998. * @param timeStep timestep to use in seconds
  112999. */
  113000. setTimeStep(timeStep: number): void;
  113001. /**
  113002. * 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)
  113003. * @param fixedTimeStep fixedTimeStep to use in seconds
  113004. */
  113005. setFixedTimeStep(fixedTimeStep: number): void;
  113006. /**
  113007. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  113008. * @param maxSteps the maximum number of steps by the physics engine per frame
  113009. */
  113010. setMaxSteps(maxSteps: number): void;
  113011. /**
  113012. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  113013. * @returns the current timestep in seconds
  113014. */
  113015. getTimeStep(): number;
  113016. private _isImpostorInContact;
  113017. private _isImpostorPairInContact;
  113018. private _stepSimulation;
  113019. /**
  113020. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  113021. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  113022. * After the step the babylon meshes are set to the position of the physics imposters
  113023. * @param delta amount of time to step forward
  113024. * @param impostors array of imposters to update before/after the step
  113025. */
  113026. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  113027. /**
  113028. * Update babylon mesh to match physics world object
  113029. * @param impostor imposter to match
  113030. */
  113031. private _afterSoftStep;
  113032. /**
  113033. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  113034. * @param impostor imposter to match
  113035. */
  113036. private _ropeStep;
  113037. /**
  113038. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  113039. * @param impostor imposter to match
  113040. */
  113041. private _softbodyOrClothStep;
  113042. private _tmpVector;
  113043. private _tmpMatrix;
  113044. /**
  113045. * Applies an impulse on the imposter
  113046. * @param impostor imposter to apply impulse to
  113047. * @param force amount of force to be applied to the imposter
  113048. * @param contactPoint the location to apply the impulse on the imposter
  113049. */
  113050. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113051. /**
  113052. * Applies a force on the imposter
  113053. * @param impostor imposter to apply force
  113054. * @param force amount of force to be applied to the imposter
  113055. * @param contactPoint the location to apply the force on the imposter
  113056. */
  113057. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113058. /**
  113059. * Creates a physics body using the plugin
  113060. * @param impostor the imposter to create the physics body on
  113061. */
  113062. generatePhysicsBody(impostor: PhysicsImpostor): void;
  113063. /**
  113064. * Removes the physics body from the imposter and disposes of the body's memory
  113065. * @param impostor imposter to remove the physics body from
  113066. */
  113067. removePhysicsBody(impostor: PhysicsImpostor): void;
  113068. /**
  113069. * Generates a joint
  113070. * @param impostorJoint the imposter joint to create the joint with
  113071. */
  113072. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  113073. /**
  113074. * Removes a joint
  113075. * @param impostorJoint the imposter joint to remove the joint from
  113076. */
  113077. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  113078. private _addMeshVerts;
  113079. /**
  113080. * Initialise the soft body vertices to match its object's (mesh) vertices
  113081. * Softbody vertices (nodes) are in world space and to match this
  113082. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  113083. * @param impostor to create the softbody for
  113084. */
  113085. private _softVertexData;
  113086. /**
  113087. * Create an impostor's soft body
  113088. * @param impostor to create the softbody for
  113089. */
  113090. private _createSoftbody;
  113091. /**
  113092. * Create cloth for an impostor
  113093. * @param impostor to create the softbody for
  113094. */
  113095. private _createCloth;
  113096. /**
  113097. * Create rope for an impostor
  113098. * @param impostor to create the softbody for
  113099. */
  113100. private _createRope;
  113101. private _addHullVerts;
  113102. private _createShape;
  113103. /**
  113104. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  113105. * @param impostor imposter containing the physics body and babylon object
  113106. */
  113107. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  113108. /**
  113109. * Sets the babylon object's position/rotation from the physics body's position/rotation
  113110. * @param impostor imposter containing the physics body and babylon object
  113111. * @param newPosition new position
  113112. * @param newRotation new rotation
  113113. */
  113114. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  113115. /**
  113116. * If this plugin is supported
  113117. * @returns true if its supported
  113118. */
  113119. isSupported(): boolean;
  113120. /**
  113121. * Sets the linear velocity of the physics body
  113122. * @param impostor imposter to set the velocity on
  113123. * @param velocity velocity to set
  113124. */
  113125. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  113126. /**
  113127. * Sets the angular velocity of the physics body
  113128. * @param impostor imposter to set the velocity on
  113129. * @param velocity velocity to set
  113130. */
  113131. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  113132. /**
  113133. * gets the linear velocity
  113134. * @param impostor imposter to get linear velocity from
  113135. * @returns linear velocity
  113136. */
  113137. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113138. /**
  113139. * gets the angular velocity
  113140. * @param impostor imposter to get angular velocity from
  113141. * @returns angular velocity
  113142. */
  113143. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113144. /**
  113145. * Sets the mass of physics body
  113146. * @param impostor imposter to set the mass on
  113147. * @param mass mass to set
  113148. */
  113149. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  113150. /**
  113151. * Gets the mass of the physics body
  113152. * @param impostor imposter to get the mass from
  113153. * @returns mass
  113154. */
  113155. getBodyMass(impostor: PhysicsImpostor): number;
  113156. /**
  113157. * Gets friction of the impostor
  113158. * @param impostor impostor to get friction from
  113159. * @returns friction value
  113160. */
  113161. getBodyFriction(impostor: PhysicsImpostor): number;
  113162. /**
  113163. * Sets friction of the impostor
  113164. * @param impostor impostor to set friction on
  113165. * @param friction friction value
  113166. */
  113167. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  113168. /**
  113169. * Gets restitution of the impostor
  113170. * @param impostor impostor to get restitution from
  113171. * @returns restitution value
  113172. */
  113173. getBodyRestitution(impostor: PhysicsImpostor): number;
  113174. /**
  113175. * Sets resitution of the impostor
  113176. * @param impostor impostor to set resitution on
  113177. * @param restitution resitution value
  113178. */
  113179. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  113180. /**
  113181. * Gets pressure inside the impostor
  113182. * @param impostor impostor to get pressure from
  113183. * @returns pressure value
  113184. */
  113185. getBodyPressure(impostor: PhysicsImpostor): number;
  113186. /**
  113187. * Sets pressure inside a soft body impostor
  113188. * Cloth and rope must remain 0 pressure
  113189. * @param impostor impostor to set pressure on
  113190. * @param pressure pressure value
  113191. */
  113192. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  113193. /**
  113194. * Gets stiffness of the impostor
  113195. * @param impostor impostor to get stiffness from
  113196. * @returns pressure value
  113197. */
  113198. getBodyStiffness(impostor: PhysicsImpostor): number;
  113199. /**
  113200. * Sets stiffness of the impostor
  113201. * @param impostor impostor to set stiffness on
  113202. * @param stiffness stiffness value from 0 to 1
  113203. */
  113204. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  113205. /**
  113206. * Gets velocityIterations of the impostor
  113207. * @param impostor impostor to get velocity iterations from
  113208. * @returns velocityIterations value
  113209. */
  113210. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  113211. /**
  113212. * Sets velocityIterations of the impostor
  113213. * @param impostor impostor to set velocity iterations on
  113214. * @param velocityIterations velocityIterations value
  113215. */
  113216. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  113217. /**
  113218. * Gets positionIterations of the impostor
  113219. * @param impostor impostor to get position iterations from
  113220. * @returns positionIterations value
  113221. */
  113222. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  113223. /**
  113224. * Sets positionIterations of the impostor
  113225. * @param impostor impostor to set position on
  113226. * @param positionIterations positionIterations value
  113227. */
  113228. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  113229. /**
  113230. * Append an anchor to a cloth object
  113231. * @param impostor is the cloth impostor to add anchor to
  113232. * @param otherImpostor is the rigid impostor to anchor to
  113233. * @param width ratio across width from 0 to 1
  113234. * @param height ratio up height from 0 to 1
  113235. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  113236. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  113237. */
  113238. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  113239. /**
  113240. * Append an hook to a rope object
  113241. * @param impostor is the rope impostor to add hook to
  113242. * @param otherImpostor is the rigid impostor to hook to
  113243. * @param length ratio along the rope from 0 to 1
  113244. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  113245. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  113246. */
  113247. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  113248. /**
  113249. * Sleeps the physics body and stops it from being active
  113250. * @param impostor impostor to sleep
  113251. */
  113252. sleepBody(impostor: PhysicsImpostor): void;
  113253. /**
  113254. * Activates the physics body
  113255. * @param impostor impostor to activate
  113256. */
  113257. wakeUpBody(impostor: PhysicsImpostor): void;
  113258. /**
  113259. * Updates the distance parameters of the joint
  113260. * @param joint joint to update
  113261. * @param maxDistance maximum distance of the joint
  113262. * @param minDistance minimum distance of the joint
  113263. */
  113264. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  113265. /**
  113266. * Sets a motor on the joint
  113267. * @param joint joint to set motor on
  113268. * @param speed speed of the motor
  113269. * @param maxForce maximum force of the motor
  113270. * @param motorIndex index of the motor
  113271. */
  113272. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  113273. /**
  113274. * Sets the motors limit
  113275. * @param joint joint to set limit on
  113276. * @param upperLimit upper limit
  113277. * @param lowerLimit lower limit
  113278. */
  113279. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  113280. /**
  113281. * Syncs the position and rotation of a mesh with the impostor
  113282. * @param mesh mesh to sync
  113283. * @param impostor impostor to update the mesh with
  113284. */
  113285. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  113286. /**
  113287. * Gets the radius of the impostor
  113288. * @param impostor impostor to get radius from
  113289. * @returns the radius
  113290. */
  113291. getRadius(impostor: PhysicsImpostor): number;
  113292. /**
  113293. * Gets the box size of the impostor
  113294. * @param impostor impostor to get box size from
  113295. * @param result the resulting box size
  113296. */
  113297. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  113298. /**
  113299. * Disposes of the impostor
  113300. */
  113301. dispose(): void;
  113302. /**
  113303. * Does a raycast in the physics world
  113304. * @param from when should the ray start?
  113305. * @param to when should the ray end?
  113306. * @returns PhysicsRaycastResult
  113307. */
  113308. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  113309. }
  113310. }
  113311. declare module BABYLON {
  113312. interface AbstractScene {
  113313. /**
  113314. * The list of reflection probes added to the scene
  113315. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  113316. */
  113317. reflectionProbes: Array<ReflectionProbe>;
  113318. /**
  113319. * Removes the given reflection probe from this scene.
  113320. * @param toRemove The reflection probe to remove
  113321. * @returns The index of the removed reflection probe
  113322. */
  113323. removeReflectionProbe(toRemove: ReflectionProbe): number;
  113324. /**
  113325. * Adds the given reflection probe to this scene.
  113326. * @param newReflectionProbe The reflection probe to add
  113327. */
  113328. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  113329. }
  113330. /**
  113331. * Class used to generate realtime reflection / refraction cube textures
  113332. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  113333. */
  113334. export class ReflectionProbe {
  113335. /** defines the name of the probe */
  113336. name: string;
  113337. private _scene;
  113338. private _renderTargetTexture;
  113339. private _projectionMatrix;
  113340. private _viewMatrix;
  113341. private _target;
  113342. private _add;
  113343. private _attachedMesh;
  113344. private _invertYAxis;
  113345. /** Gets or sets probe position (center of the cube map) */
  113346. position: Vector3;
  113347. /**
  113348. * Creates a new reflection probe
  113349. * @param name defines the name of the probe
  113350. * @param size defines the texture resolution (for each face)
  113351. * @param scene defines the hosting scene
  113352. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  113353. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  113354. */
  113355. constructor(
  113356. /** defines the name of the probe */
  113357. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  113358. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  113359. samples: number;
  113360. /** Gets or sets the refresh rate to use (on every frame by default) */
  113361. refreshRate: number;
  113362. /**
  113363. * Gets the hosting scene
  113364. * @returns a Scene
  113365. */
  113366. getScene(): Scene;
  113367. /** Gets the internal CubeTexture used to render to */
  113368. readonly cubeTexture: RenderTargetTexture;
  113369. /** Gets the list of meshes to render */
  113370. readonly renderList: Nullable<AbstractMesh[]>;
  113371. /**
  113372. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  113373. * @param mesh defines the mesh to attach to
  113374. */
  113375. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  113376. /**
  113377. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  113378. * @param renderingGroupId The rendering group id corresponding to its index
  113379. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  113380. */
  113381. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  113382. /**
  113383. * Clean all associated resources
  113384. */
  113385. dispose(): void;
  113386. /**
  113387. * Converts the reflection probe information to a readable string for debug purpose.
  113388. * @param fullDetails Supports for multiple levels of logging within scene loading
  113389. * @returns the human readable reflection probe info
  113390. */
  113391. toString(fullDetails?: boolean): string;
  113392. /**
  113393. * Get the class name of the relfection probe.
  113394. * @returns "ReflectionProbe"
  113395. */
  113396. getClassName(): string;
  113397. /**
  113398. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  113399. * @returns The JSON representation of the texture
  113400. */
  113401. serialize(): any;
  113402. /**
  113403. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  113404. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  113405. * @param scene Define the scene the parsed reflection probe should be instantiated in
  113406. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  113407. * @returns The parsed reflection probe if successful
  113408. */
  113409. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  113410. }
  113411. }
  113412. declare module BABYLON {
  113413. /** @hidden */
  113414. export var _BabylonLoaderRegistered: boolean;
  113415. }
  113416. declare module BABYLON {
  113417. /**
  113418. * The Physically based simple base material of BJS.
  113419. *
  113420. * This enables better naming and convention enforcements on top of the pbrMaterial.
  113421. * It is used as the base class for both the specGloss and metalRough conventions.
  113422. */
  113423. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  113424. /**
  113425. * Number of Simultaneous lights allowed on the material.
  113426. */
  113427. maxSimultaneousLights: number;
  113428. /**
  113429. * If sets to true, disables all the lights affecting the material.
  113430. */
  113431. disableLighting: boolean;
  113432. /**
  113433. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  113434. */
  113435. environmentTexture: BaseTexture;
  113436. /**
  113437. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  113438. */
  113439. invertNormalMapX: boolean;
  113440. /**
  113441. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  113442. */
  113443. invertNormalMapY: boolean;
  113444. /**
  113445. * Normal map used in the model.
  113446. */
  113447. normalTexture: BaseTexture;
  113448. /**
  113449. * Emissivie color used to self-illuminate the model.
  113450. */
  113451. emissiveColor: Color3;
  113452. /**
  113453. * Emissivie texture used to self-illuminate the model.
  113454. */
  113455. emissiveTexture: BaseTexture;
  113456. /**
  113457. * Occlusion Channel Strenght.
  113458. */
  113459. occlusionStrength: number;
  113460. /**
  113461. * Occlusion Texture of the material (adding extra occlusion effects).
  113462. */
  113463. occlusionTexture: BaseTexture;
  113464. /**
  113465. * Defines the alpha limits in alpha test mode.
  113466. */
  113467. alphaCutOff: number;
  113468. /**
  113469. * Gets the current double sided mode.
  113470. */
  113471. /**
  113472. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  113473. */
  113474. doubleSided: boolean;
  113475. /**
  113476. * Stores the pre-calculated light information of a mesh in a texture.
  113477. */
  113478. lightmapTexture: BaseTexture;
  113479. /**
  113480. * If true, the light map contains occlusion information instead of lighting info.
  113481. */
  113482. useLightmapAsShadowmap: boolean;
  113483. /**
  113484. * Instantiates a new PBRMaterial instance.
  113485. *
  113486. * @param name The material name
  113487. * @param scene The scene the material will be use in.
  113488. */
  113489. constructor(name: string, scene: Scene);
  113490. getClassName(): string;
  113491. }
  113492. }
  113493. declare module BABYLON {
  113494. /**
  113495. * The PBR material of BJS following the metal roughness convention.
  113496. *
  113497. * This fits to the PBR convention in the GLTF definition:
  113498. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  113499. */
  113500. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  113501. /**
  113502. * The base color has two different interpretations depending on the value of metalness.
  113503. * When the material is a metal, the base color is the specific measured reflectance value
  113504. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  113505. * of the material.
  113506. */
  113507. baseColor: Color3;
  113508. /**
  113509. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  113510. * well as opacity information in the alpha channel.
  113511. */
  113512. baseTexture: BaseTexture;
  113513. /**
  113514. * Specifies the metallic scalar value of the material.
  113515. * Can also be used to scale the metalness values of the metallic texture.
  113516. */
  113517. metallic: number;
  113518. /**
  113519. * Specifies the roughness scalar value of the material.
  113520. * Can also be used to scale the roughness values of the metallic texture.
  113521. */
  113522. roughness: number;
  113523. /**
  113524. * Texture containing both the metallic value in the B channel and the
  113525. * roughness value in the G channel to keep better precision.
  113526. */
  113527. metallicRoughnessTexture: BaseTexture;
  113528. /**
  113529. * Instantiates a new PBRMetalRoughnessMaterial instance.
  113530. *
  113531. * @param name The material name
  113532. * @param scene The scene the material will be use in.
  113533. */
  113534. constructor(name: string, scene: Scene);
  113535. /**
  113536. * Return the currrent class name of the material.
  113537. */
  113538. getClassName(): string;
  113539. /**
  113540. * Makes a duplicate of the current material.
  113541. * @param name - name to use for the new material.
  113542. */
  113543. clone(name: string): PBRMetallicRoughnessMaterial;
  113544. /**
  113545. * Serialize the material to a parsable JSON object.
  113546. */
  113547. serialize(): any;
  113548. /**
  113549. * Parses a JSON object correponding to the serialize function.
  113550. */
  113551. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  113552. }
  113553. }
  113554. declare module BABYLON {
  113555. /**
  113556. * The PBR material of BJS following the specular glossiness convention.
  113557. *
  113558. * This fits to the PBR convention in the GLTF definition:
  113559. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  113560. */
  113561. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  113562. /**
  113563. * Specifies the diffuse color of the material.
  113564. */
  113565. diffuseColor: Color3;
  113566. /**
  113567. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  113568. * channel.
  113569. */
  113570. diffuseTexture: BaseTexture;
  113571. /**
  113572. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  113573. */
  113574. specularColor: Color3;
  113575. /**
  113576. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  113577. */
  113578. glossiness: number;
  113579. /**
  113580. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  113581. */
  113582. specularGlossinessTexture: BaseTexture;
  113583. /**
  113584. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  113585. *
  113586. * @param name The material name
  113587. * @param scene The scene the material will be use in.
  113588. */
  113589. constructor(name: string, scene: Scene);
  113590. /**
  113591. * Return the currrent class name of the material.
  113592. */
  113593. getClassName(): string;
  113594. /**
  113595. * Makes a duplicate of the current material.
  113596. * @param name - name to use for the new material.
  113597. */
  113598. clone(name: string): PBRSpecularGlossinessMaterial;
  113599. /**
  113600. * Serialize the material to a parsable JSON object.
  113601. */
  113602. serialize(): any;
  113603. /**
  113604. * Parses a JSON object correponding to the serialize function.
  113605. */
  113606. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  113607. }
  113608. }
  113609. declare module BABYLON {
  113610. /**
  113611. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  113612. * It can help converting any input color in a desired output one. This can then be used to create effects
  113613. * from sepia, black and white to sixties or futuristic rendering...
  113614. *
  113615. * The only supported format is currently 3dl.
  113616. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  113617. */
  113618. export class ColorGradingTexture extends BaseTexture {
  113619. /**
  113620. * The current texture matrix. (will always be identity in color grading texture)
  113621. */
  113622. private _textureMatrix;
  113623. /**
  113624. * The texture URL.
  113625. */
  113626. url: string;
  113627. /**
  113628. * Empty line regex stored for GC.
  113629. */
  113630. private static _noneEmptyLineRegex;
  113631. private _engine;
  113632. /**
  113633. * Instantiates a ColorGradingTexture from the following parameters.
  113634. *
  113635. * @param url The location of the color gradind data (currently only supporting 3dl)
  113636. * @param scene The scene the texture will be used in
  113637. */
  113638. constructor(url: string, scene: Scene);
  113639. /**
  113640. * Returns the texture matrix used in most of the material.
  113641. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  113642. */
  113643. getTextureMatrix(): Matrix;
  113644. /**
  113645. * Occurs when the file being loaded is a .3dl LUT file.
  113646. */
  113647. private load3dlTexture;
  113648. /**
  113649. * Starts the loading process of the texture.
  113650. */
  113651. private loadTexture;
  113652. /**
  113653. * Clones the color gradind texture.
  113654. */
  113655. clone(): ColorGradingTexture;
  113656. /**
  113657. * Called during delayed load for textures.
  113658. */
  113659. delayLoad(): void;
  113660. /**
  113661. * Parses a color grading texture serialized by Babylon.
  113662. * @param parsedTexture The texture information being parsedTexture
  113663. * @param scene The scene to load the texture in
  113664. * @param rootUrl The root url of the data assets to load
  113665. * @return A color gradind texture
  113666. */
  113667. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  113668. /**
  113669. * Serializes the LUT texture to json format.
  113670. */
  113671. serialize(): any;
  113672. }
  113673. }
  113674. declare module BABYLON {
  113675. /**
  113676. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  113677. */
  113678. export class EquiRectangularCubeTexture extends BaseTexture {
  113679. /** The six faces of the cube. */
  113680. private static _FacesMapping;
  113681. private _noMipmap;
  113682. private _onLoad;
  113683. private _onError;
  113684. /** The size of the cubemap. */
  113685. private _size;
  113686. /** The buffer of the image. */
  113687. private _buffer;
  113688. /** The width of the input image. */
  113689. private _width;
  113690. /** The height of the input image. */
  113691. private _height;
  113692. /** The URL to the image. */
  113693. url: string;
  113694. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  113695. coordinatesMode: number;
  113696. /**
  113697. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  113698. * @param url The location of the image
  113699. * @param scene The scene the texture will be used in
  113700. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  113701. * @param noMipmap Forces to not generate the mipmap if true
  113702. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  113703. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  113704. * @param onLoad — defines a callback called when texture is loaded
  113705. * @param onError — defines a callback called if there is an error
  113706. */
  113707. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  113708. /**
  113709. * Load the image data, by putting the image on a canvas and extracting its buffer.
  113710. */
  113711. private loadImage;
  113712. /**
  113713. * Convert the image buffer into a cubemap and create a CubeTexture.
  113714. */
  113715. private loadTexture;
  113716. /**
  113717. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  113718. * @param buffer The ArrayBuffer that should be converted.
  113719. * @returns The buffer as Float32Array.
  113720. */
  113721. private getFloat32ArrayFromArrayBuffer;
  113722. /**
  113723. * Get the current class name of the texture useful for serialization or dynamic coding.
  113724. * @returns "EquiRectangularCubeTexture"
  113725. */
  113726. getClassName(): string;
  113727. /**
  113728. * Create a clone of the current EquiRectangularCubeTexture and return it.
  113729. * @returns A clone of the current EquiRectangularCubeTexture.
  113730. */
  113731. clone(): EquiRectangularCubeTexture;
  113732. }
  113733. }
  113734. declare module BABYLON {
  113735. /**
  113736. * Based on jsTGALoader - Javascript loader for TGA file
  113737. * By Vincent Thibault
  113738. * @see http://blog.robrowser.com/javascript-tga-loader.html
  113739. */
  113740. export class TGATools {
  113741. private static _TYPE_INDEXED;
  113742. private static _TYPE_RGB;
  113743. private static _TYPE_GREY;
  113744. private static _TYPE_RLE_INDEXED;
  113745. private static _TYPE_RLE_RGB;
  113746. private static _TYPE_RLE_GREY;
  113747. private static _ORIGIN_MASK;
  113748. private static _ORIGIN_SHIFT;
  113749. private static _ORIGIN_BL;
  113750. private static _ORIGIN_BR;
  113751. private static _ORIGIN_UL;
  113752. private static _ORIGIN_UR;
  113753. /**
  113754. * Gets the header of a TGA file
  113755. * @param data defines the TGA data
  113756. * @returns the header
  113757. */
  113758. static GetTGAHeader(data: Uint8Array): any;
  113759. /**
  113760. * Uploads TGA content to a Babylon Texture
  113761. * @hidden
  113762. */
  113763. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  113764. /** @hidden */
  113765. 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;
  113766. /** @hidden */
  113767. 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;
  113768. /** @hidden */
  113769. 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;
  113770. /** @hidden */
  113771. 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;
  113772. /** @hidden */
  113773. 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;
  113774. /** @hidden */
  113775. 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;
  113776. }
  113777. }
  113778. declare module BABYLON {
  113779. /**
  113780. * Implementation of the TGA Texture Loader.
  113781. * @hidden
  113782. */
  113783. export class _TGATextureLoader implements IInternalTextureLoader {
  113784. /**
  113785. * Defines wether the loader supports cascade loading the different faces.
  113786. */
  113787. readonly supportCascades: boolean;
  113788. /**
  113789. * This returns if the loader support the current file information.
  113790. * @param extension defines the file extension of the file being loaded
  113791. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113792. * @param fallback defines the fallback internal texture if any
  113793. * @param isBase64 defines whether the texture is encoded as a base64
  113794. * @param isBuffer defines whether the texture data are stored as a buffer
  113795. * @returns true if the loader can load the specified file
  113796. */
  113797. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113798. /**
  113799. * Transform the url before loading if required.
  113800. * @param rootUrl the url of the texture
  113801. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113802. * @returns the transformed texture
  113803. */
  113804. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113805. /**
  113806. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113807. * @param rootUrl the url of the texture
  113808. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113809. * @returns the fallback texture
  113810. */
  113811. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113812. /**
  113813. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  113814. * @param data contains the texture data
  113815. * @param texture defines the BabylonJS internal texture
  113816. * @param createPolynomials will be true if polynomials have been requested
  113817. * @param onLoad defines the callback to trigger once the texture is ready
  113818. * @param onError defines the callback to trigger in case of error
  113819. */
  113820. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113821. /**
  113822. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113823. * @param data contains the texture data
  113824. * @param texture defines the BabylonJS internal texture
  113825. * @param callback defines the method to call once ready to upload
  113826. */
  113827. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  113828. }
  113829. }
  113830. declare module BABYLON {
  113831. /**
  113832. * Info about the .basis files
  113833. */
  113834. class BasisFileInfo {
  113835. /**
  113836. * If the file has alpha
  113837. */
  113838. hasAlpha: boolean;
  113839. /**
  113840. * Info about each image of the basis file
  113841. */
  113842. images: Array<{
  113843. levels: Array<{
  113844. width: number;
  113845. height: number;
  113846. transcodedPixels: ArrayBufferView;
  113847. }>;
  113848. }>;
  113849. }
  113850. /**
  113851. * Result of transcoding a basis file
  113852. */
  113853. class TranscodeResult {
  113854. /**
  113855. * Info about the .basis file
  113856. */
  113857. fileInfo: BasisFileInfo;
  113858. /**
  113859. * Format to use when loading the file
  113860. */
  113861. format: number;
  113862. }
  113863. /**
  113864. * Configuration options for the Basis transcoder
  113865. */
  113866. export class BasisTranscodeConfiguration {
  113867. /**
  113868. * Supported compression formats used to determine the supported output format of the transcoder
  113869. */
  113870. supportedCompressionFormats?: {
  113871. /**
  113872. * etc1 compression format
  113873. */
  113874. etc1?: boolean;
  113875. /**
  113876. * s3tc compression format
  113877. */
  113878. s3tc?: boolean;
  113879. /**
  113880. * pvrtc compression format
  113881. */
  113882. pvrtc?: boolean;
  113883. /**
  113884. * etc2 compression format
  113885. */
  113886. etc2?: boolean;
  113887. };
  113888. /**
  113889. * If mipmap levels should be loaded for transcoded images (Default: true)
  113890. */
  113891. loadMipmapLevels?: boolean;
  113892. /**
  113893. * Index of a single image to load (Default: all images)
  113894. */
  113895. loadSingleImage?: number;
  113896. }
  113897. /**
  113898. * Used to load .Basis files
  113899. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  113900. */
  113901. export class BasisTools {
  113902. private static _IgnoreSupportedFormats;
  113903. /**
  113904. * URL to use when loading the basis transcoder
  113905. */
  113906. static JSModuleURL: string;
  113907. /**
  113908. * URL to use when loading the wasm module for the transcoder
  113909. */
  113910. static WasmModuleURL: string;
  113911. /**
  113912. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  113913. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  113914. * @returns internal format corresponding to the Basis format
  113915. */
  113916. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  113917. private static _WorkerPromise;
  113918. private static _Worker;
  113919. private static _actionId;
  113920. private static _CreateWorkerAsync;
  113921. /**
  113922. * Transcodes a loaded image file to compressed pixel data
  113923. * @param imageData image data to transcode
  113924. * @param config configuration options for the transcoding
  113925. * @returns a promise resulting in the transcoded image
  113926. */
  113927. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  113928. /**
  113929. * Loads a texture from the transcode result
  113930. * @param texture texture load to
  113931. * @param transcodeResult the result of transcoding the basis file to load from
  113932. */
  113933. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  113934. }
  113935. }
  113936. declare module BABYLON {
  113937. /**
  113938. * Loader for .basis file format
  113939. */
  113940. export class _BasisTextureLoader implements IInternalTextureLoader {
  113941. /**
  113942. * Defines whether the loader supports cascade loading the different faces.
  113943. */
  113944. readonly supportCascades: boolean;
  113945. /**
  113946. * This returns if the loader support the current file information.
  113947. * @param extension defines the file extension of the file being loaded
  113948. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113949. * @param fallback defines the fallback internal texture if any
  113950. * @param isBase64 defines whether the texture is encoded as a base64
  113951. * @param isBuffer defines whether the texture data are stored as a buffer
  113952. * @returns true if the loader can load the specified file
  113953. */
  113954. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113955. /**
  113956. * Transform the url before loading if required.
  113957. * @param rootUrl the url of the texture
  113958. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113959. * @returns the transformed texture
  113960. */
  113961. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113962. /**
  113963. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113964. * @param rootUrl the url of the texture
  113965. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113966. * @returns the fallback texture
  113967. */
  113968. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113969. /**
  113970. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  113971. * @param data contains the texture data
  113972. * @param texture defines the BabylonJS internal texture
  113973. * @param createPolynomials will be true if polynomials have been requested
  113974. * @param onLoad defines the callback to trigger once the texture is ready
  113975. * @param onError defines the callback to trigger in case of error
  113976. */
  113977. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113978. /**
  113979. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113980. * @param data contains the texture data
  113981. * @param texture defines the BabylonJS internal texture
  113982. * @param callback defines the method to call once ready to upload
  113983. */
  113984. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  113985. }
  113986. }
  113987. declare module BABYLON {
  113988. /**
  113989. * 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.
  113990. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  113991. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  113992. */
  113993. export class CustomProceduralTexture extends ProceduralTexture {
  113994. private _animate;
  113995. private _time;
  113996. private _config;
  113997. private _texturePath;
  113998. /**
  113999. * Instantiates a new Custom Procedural Texture.
  114000. * 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.
  114001. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  114002. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  114003. * @param name Define the name of the texture
  114004. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  114005. * @param size Define the size of the texture to create
  114006. * @param scene Define the scene the texture belongs to
  114007. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  114008. * @param generateMipMaps Define if the texture should creates mip maps or not
  114009. */
  114010. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  114011. private _loadJson;
  114012. /**
  114013. * Is the texture ready to be used ? (rendered at least once)
  114014. * @returns true if ready, otherwise, false.
  114015. */
  114016. isReady(): boolean;
  114017. /**
  114018. * Render the texture to its associated render target.
  114019. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  114020. */
  114021. render(useCameraPostProcess?: boolean): void;
  114022. /**
  114023. * Update the list of dependant textures samplers in the shader.
  114024. */
  114025. updateTextures(): void;
  114026. /**
  114027. * Update the uniform values of the procedural texture in the shader.
  114028. */
  114029. updateShaderUniforms(): void;
  114030. /**
  114031. * Define if the texture animates or not.
  114032. */
  114033. animate: boolean;
  114034. }
  114035. }
  114036. declare module BABYLON {
  114037. /** @hidden */
  114038. export var noisePixelShader: {
  114039. name: string;
  114040. shader: string;
  114041. };
  114042. }
  114043. declare module BABYLON {
  114044. /**
  114045. * Class used to generate noise procedural textures
  114046. */
  114047. export class NoiseProceduralTexture extends ProceduralTexture {
  114048. private _time;
  114049. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  114050. brightness: number;
  114051. /** Defines the number of octaves to process */
  114052. octaves: number;
  114053. /** Defines the level of persistence (0.8 by default) */
  114054. persistence: number;
  114055. /** Gets or sets animation speed factor (default is 1) */
  114056. animationSpeedFactor: number;
  114057. /**
  114058. * Creates a new NoiseProceduralTexture
  114059. * @param name defines the name fo the texture
  114060. * @param size defines the size of the texture (default is 256)
  114061. * @param scene defines the hosting scene
  114062. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  114063. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  114064. */
  114065. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  114066. private _updateShaderUniforms;
  114067. protected _getDefines(): string;
  114068. /** Generate the current state of the procedural texture */
  114069. render(useCameraPostProcess?: boolean): void;
  114070. /**
  114071. * Serializes this noise procedural texture
  114072. * @returns a serialized noise procedural texture object
  114073. */
  114074. serialize(): any;
  114075. /**
  114076. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  114077. * @param parsedTexture defines parsed texture data
  114078. * @param scene defines the current scene
  114079. * @param rootUrl defines the root URL containing noise procedural texture information
  114080. * @returns a parsed NoiseProceduralTexture
  114081. */
  114082. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  114083. }
  114084. }
  114085. declare module BABYLON {
  114086. /**
  114087. * Raw cube texture where the raw buffers are passed in
  114088. */
  114089. export class RawCubeTexture extends CubeTexture {
  114090. /**
  114091. * Creates a cube texture where the raw buffers are passed in.
  114092. * @param scene defines the scene the texture is attached to
  114093. * @param data defines the array of data to use to create each face
  114094. * @param size defines the size of the textures
  114095. * @param format defines the format of the data
  114096. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  114097. * @param generateMipMaps defines if the engine should generate the mip levels
  114098. * @param invertY defines if data must be stored with Y axis inverted
  114099. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  114100. * @param compression defines the compression used (null by default)
  114101. */
  114102. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  114103. /**
  114104. * Updates the raw cube texture.
  114105. * @param data defines the data to store
  114106. * @param format defines the data format
  114107. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  114108. * @param invertY defines if data must be stored with Y axis inverted
  114109. * @param compression defines the compression used (null by default)
  114110. * @param level defines which level of the texture to update
  114111. */
  114112. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  114113. /**
  114114. * Updates a raw cube texture with RGBD encoded data.
  114115. * @param data defines the array of data [mipmap][face] to use to create each face
  114116. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  114117. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  114118. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  114119. * @returns a promsie that resolves when the operation is complete
  114120. */
  114121. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  114122. /**
  114123. * Clones the raw cube texture.
  114124. * @return a new cube texture
  114125. */
  114126. clone(): CubeTexture;
  114127. /** @hidden */
  114128. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  114129. }
  114130. }
  114131. declare module BABYLON {
  114132. /**
  114133. * Class used to store 3D textures containing user data
  114134. */
  114135. export class RawTexture3D extends Texture {
  114136. /** Gets or sets the texture format to use */
  114137. format: number;
  114138. private _engine;
  114139. /**
  114140. * Create a new RawTexture3D
  114141. * @param data defines the data of the texture
  114142. * @param width defines the width of the texture
  114143. * @param height defines the height of the texture
  114144. * @param depth defines the depth of the texture
  114145. * @param format defines the texture format to use
  114146. * @param scene defines the hosting scene
  114147. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  114148. * @param invertY defines if texture must be stored with Y axis inverted
  114149. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  114150. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  114151. */
  114152. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  114153. /** Gets or sets the texture format to use */
  114154. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  114155. /**
  114156. * Update the texture with new data
  114157. * @param data defines the data to store in the texture
  114158. */
  114159. update(data: ArrayBufferView): void;
  114160. }
  114161. }
  114162. declare module BABYLON {
  114163. /**
  114164. * Creates a refraction texture used by refraction channel of the standard material.
  114165. * It is like a mirror but to see through a material.
  114166. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  114167. */
  114168. export class RefractionTexture extends RenderTargetTexture {
  114169. /**
  114170. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  114171. * 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.
  114172. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  114173. */
  114174. refractionPlane: Plane;
  114175. /**
  114176. * Define how deep under the surface we should see.
  114177. */
  114178. depth: number;
  114179. /**
  114180. * Creates a refraction texture used by refraction channel of the standard material.
  114181. * It is like a mirror but to see through a material.
  114182. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  114183. * @param name Define the texture name
  114184. * @param size Define the size of the underlying texture
  114185. * @param scene Define the scene the refraction belongs to
  114186. * @param generateMipMaps Define if we need to generate mips level for the refraction
  114187. */
  114188. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  114189. /**
  114190. * Clone the refraction texture.
  114191. * @returns the cloned texture
  114192. */
  114193. clone(): RefractionTexture;
  114194. /**
  114195. * Serialize the texture to a JSON representation you could use in Parse later on
  114196. * @returns the serialized JSON representation
  114197. */
  114198. serialize(): any;
  114199. }
  114200. }
  114201. declare module BABYLON {
  114202. /**
  114203. * Defines the options related to the creation of an HtmlElementTexture
  114204. */
  114205. export interface IHtmlElementTextureOptions {
  114206. /**
  114207. * Defines wether mip maps should be created or not.
  114208. */
  114209. generateMipMaps?: boolean;
  114210. /**
  114211. * Defines the sampling mode of the texture.
  114212. */
  114213. samplingMode?: number;
  114214. /**
  114215. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  114216. */
  114217. engine: Nullable<Engine>;
  114218. /**
  114219. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  114220. */
  114221. scene: Nullable<Scene>;
  114222. }
  114223. /**
  114224. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  114225. * To be as efficient as possible depending on your constraints nothing aside the first upload
  114226. * is automatically managed.
  114227. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  114228. * in your application.
  114229. *
  114230. * As the update is not automatic, you need to call them manually.
  114231. */
  114232. export class HtmlElementTexture extends BaseTexture {
  114233. /**
  114234. * The texture URL.
  114235. */
  114236. element: HTMLVideoElement | HTMLCanvasElement;
  114237. private static readonly DefaultOptions;
  114238. private _textureMatrix;
  114239. private _engine;
  114240. private _isVideo;
  114241. private _generateMipMaps;
  114242. private _samplingMode;
  114243. /**
  114244. * Instantiates a HtmlElementTexture from the following parameters.
  114245. *
  114246. * @param name Defines the name of the texture
  114247. * @param element Defines the video or canvas the texture is filled with
  114248. * @param options Defines the other none mandatory texture creation options
  114249. */
  114250. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  114251. private _createInternalTexture;
  114252. /**
  114253. * Returns the texture matrix used in most of the material.
  114254. */
  114255. getTextureMatrix(): Matrix;
  114256. /**
  114257. * Updates the content of the texture.
  114258. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  114259. */
  114260. update(invertY?: Nullable<boolean>): void;
  114261. }
  114262. }
  114263. declare module BABYLON {
  114264. /**
  114265. * Enum used to define the target of a block
  114266. */
  114267. export enum NodeMaterialBlockTargets {
  114268. /** Vertex shader */
  114269. Vertex = 1,
  114270. /** Fragment shader */
  114271. Fragment = 2,
  114272. /** Neutral */
  114273. Neutral = 4,
  114274. /** Vertex and Fragment */
  114275. VertexAndFragment = 3
  114276. }
  114277. }
  114278. declare module BABYLON {
  114279. /**
  114280. * Defines the kind of connection point for node based material
  114281. */
  114282. export enum NodeMaterialBlockConnectionPointTypes {
  114283. /** Float */
  114284. Float = 1,
  114285. /** Int */
  114286. Int = 2,
  114287. /** Vector2 */
  114288. Vector2 = 4,
  114289. /** Vector3 */
  114290. Vector3 = 8,
  114291. /** Vector4 */
  114292. Vector4 = 16,
  114293. /** Color3 */
  114294. Color3 = 32,
  114295. /** Color4 */
  114296. Color4 = 64,
  114297. /** Matrix */
  114298. Matrix = 128,
  114299. /** Vector3 or Color3 */
  114300. Vector3OrColor3 = 40,
  114301. /** Vector3 or Vector4 */
  114302. Vector3OrVector4 = 24,
  114303. /** Vector4 or Color4 */
  114304. Vector4OrColor4 = 80,
  114305. /** Color3 or Color4 */
  114306. Color3OrColor4 = 96,
  114307. /** Vector2 or Color3 or Color4 */
  114308. Vector2OrColor3OrColor4 = 100,
  114309. /** Vector3 or Color3 or Color4 or Vector4 */
  114310. Vector3OrColor3OrVector4OrColor4 = 120,
  114311. /** Vector2 or Vector3 or Color3 or Color4 or Vector4 */
  114312. Vector2OrVector3OrColor3OrVector4OrColor4 = 124,
  114313. /** Detect type based on connection */
  114314. AutoDetect = 1024,
  114315. /** Output type that will be defined by input type */
  114316. BasedOnInput = 2048
  114317. }
  114318. }
  114319. declare module BABYLON {
  114320. /**
  114321. * Root class for all node material optimizers
  114322. */
  114323. export class NodeMaterialOptimizer {
  114324. /**
  114325. * Function used to optimize a NodeMaterial graph
  114326. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  114327. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  114328. */
  114329. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  114330. }
  114331. }
  114332. declare module BABYLON {
  114333. /**
  114334. * Block used to transform a vector4 with a matrix
  114335. */
  114336. export class Vector4TransformBlock extends NodeMaterialBlock {
  114337. /**
  114338. * Defines the value to use to complement Vector3 to transform it to a Vector4
  114339. */
  114340. complementW: number;
  114341. /**
  114342. * Creates a new Vector4TransformBlock
  114343. * @param name defines the block name
  114344. */
  114345. constructor(name: string);
  114346. /**
  114347. * Gets the current class name
  114348. * @returns the class name
  114349. */
  114350. getClassName(): string;
  114351. /**
  114352. * Gets the vector input
  114353. */
  114354. readonly vector: NodeMaterialConnectionPoint;
  114355. /**
  114356. * Gets the output component
  114357. */
  114358. readonly output: NodeMaterialConnectionPoint;
  114359. /**
  114360. * Gets the matrix transform input
  114361. */
  114362. readonly transform: NodeMaterialConnectionPoint;
  114363. protected _buildBlock(state: NodeMaterialBuildState): this;
  114364. }
  114365. }
  114366. declare module BABYLON {
  114367. /**
  114368. * Block used to output the vertex position
  114369. */
  114370. export class VertexOutputBlock extends NodeMaterialBlock {
  114371. /**
  114372. * Creates a new VertexOutputBlock
  114373. * @param name defines the block name
  114374. */
  114375. constructor(name: string);
  114376. /**
  114377. * Gets the current class name
  114378. * @returns the class name
  114379. */
  114380. getClassName(): string;
  114381. /**
  114382. * Gets the vector input component
  114383. */
  114384. readonly vector: NodeMaterialConnectionPoint;
  114385. protected _buildBlock(state: NodeMaterialBuildState): this;
  114386. }
  114387. }
  114388. declare module BABYLON {
  114389. /**
  114390. * Block used to output the final color
  114391. */
  114392. export class FragmentOutputBlock extends NodeMaterialBlock {
  114393. /**
  114394. * Gets or sets a boolean indicating if this block will output an alpha value
  114395. */
  114396. alphaBlendingEnabled: boolean;
  114397. /**
  114398. * Create a new FragmentOutputBlock
  114399. * @param name defines the block name
  114400. */
  114401. constructor(name: string);
  114402. /**
  114403. * Gets the current class name
  114404. * @returns the class name
  114405. */
  114406. getClassName(): string;
  114407. /**
  114408. * Gets the color input component
  114409. */
  114410. readonly color: NodeMaterialConnectionPoint;
  114411. protected _buildBlock(state: NodeMaterialBuildState): this;
  114412. }
  114413. }
  114414. declare module BABYLON {
  114415. /**
  114416. * Interface used to configure the node material editor
  114417. */
  114418. export interface INodeMaterialEditorOptions {
  114419. /** Define the URl to load node editor script */
  114420. editorURL?: string;
  114421. }
  114422. /** @hidden */
  114423. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  114424. /** BONES */
  114425. NUM_BONE_INFLUENCERS: number;
  114426. BonesPerMesh: number;
  114427. BONETEXTURE: boolean;
  114428. /** MORPH TARGETS */
  114429. MORPHTARGETS: boolean;
  114430. MORPHTARGETS_NORMAL: boolean;
  114431. MORPHTARGETS_TANGENT: boolean;
  114432. MORPHTARGETS_UV: boolean;
  114433. NUM_MORPH_INFLUENCERS: number;
  114434. /** IMAGE PROCESSING */
  114435. IMAGEPROCESSING: boolean;
  114436. VIGNETTE: boolean;
  114437. VIGNETTEBLENDMODEMULTIPLY: boolean;
  114438. VIGNETTEBLENDMODEOPAQUE: boolean;
  114439. TONEMAPPING: boolean;
  114440. TONEMAPPING_ACES: boolean;
  114441. CONTRAST: boolean;
  114442. EXPOSURE: boolean;
  114443. COLORCURVES: boolean;
  114444. COLORGRADING: boolean;
  114445. COLORGRADING3D: boolean;
  114446. SAMPLER3DGREENDEPTH: boolean;
  114447. SAMPLER3DBGRMAP: boolean;
  114448. IMAGEPROCESSINGPOSTPROCESS: boolean;
  114449. constructor();
  114450. setValue(name: string, value: boolean): void;
  114451. }
  114452. /**
  114453. * Class used to configure NodeMaterial
  114454. */
  114455. export interface INodeMaterialOptions {
  114456. /**
  114457. * Defines if blocks should emit comments
  114458. */
  114459. emitComments: boolean;
  114460. }
  114461. /**
  114462. * Class used to create a node based material built by assembling shader blocks
  114463. */
  114464. export class NodeMaterial extends PushMaterial {
  114465. private _options;
  114466. private _vertexCompilationState;
  114467. private _fragmentCompilationState;
  114468. private _sharedData;
  114469. private _buildId;
  114470. private _buildWasSuccessful;
  114471. private _cachedWorldViewMatrix;
  114472. private _cachedWorldViewProjectionMatrix;
  114473. private _optimizers;
  114474. /** Define the URl to load node editor script */
  114475. static EditorURL: string;
  114476. private BJSNODEMATERIALEDITOR;
  114477. /** Get the inspector from bundle or global */
  114478. private _getGlobalNodeMaterialEditor;
  114479. /**
  114480. * Defines the maximum number of lights that can be used in the material
  114481. */
  114482. maxSimultaneousLights: number;
  114483. /**
  114484. * Observable raised when the material is built
  114485. */
  114486. onBuildObservable: Observable<NodeMaterial>;
  114487. /**
  114488. * Gets or sets the root nodes of the material vertex shader
  114489. */
  114490. _vertexOutputNodes: NodeMaterialBlock[];
  114491. /**
  114492. * Gets or sets the root nodes of the material fragment (pixel) shader
  114493. */
  114494. _fragmentOutputNodes: NodeMaterialBlock[];
  114495. /** Gets or sets options to control the node material overall behavior */
  114496. options: INodeMaterialOptions;
  114497. /**
  114498. * Default configuration related to image processing available in the standard Material.
  114499. */
  114500. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  114501. /**
  114502. * Gets the image processing configuration used either in this material.
  114503. */
  114504. /**
  114505. * Sets the Default image processing configuration used either in the this material.
  114506. *
  114507. * If sets to null, the scene one is in use.
  114508. */
  114509. imageProcessingConfiguration: ImageProcessingConfiguration;
  114510. /**
  114511. * Create a new node based material
  114512. * @param name defines the material name
  114513. * @param scene defines the hosting scene
  114514. * @param options defines creation option
  114515. */
  114516. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  114517. /**
  114518. * Gets the current class name of the material e.g. "NodeMaterial"
  114519. * @returns the class name
  114520. */
  114521. getClassName(): string;
  114522. /**
  114523. * Keep track of the image processing observer to allow dispose and replace.
  114524. */
  114525. private _imageProcessingObserver;
  114526. /**
  114527. * Attaches a new image processing configuration to the Standard Material.
  114528. * @param configuration
  114529. */
  114530. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  114531. /**
  114532. * Adds a new optimizer to the list of optimizers
  114533. * @param optimizer defines the optimizers to add
  114534. * @returns the current material
  114535. */
  114536. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  114537. /**
  114538. * Remove an optimizer from the list of optimizers
  114539. * @param optimizer defines the optimizers to remove
  114540. * @returns the current material
  114541. */
  114542. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  114543. /**
  114544. * Add a new block to the list of output nodes
  114545. * @param node defines the node to add
  114546. * @returns the current material
  114547. */
  114548. addOutputNode(node: NodeMaterialBlock): this;
  114549. /**
  114550. * Remove a block from the list of root nodes
  114551. * @param node defines the node to remove
  114552. * @returns the current material
  114553. */
  114554. removeOutputNode(node: NodeMaterialBlock): this;
  114555. private _addVertexOutputNode;
  114556. private _removeVertexOutputNode;
  114557. private _addFragmentOutputNode;
  114558. private _removeFragmentOutputNode;
  114559. /**
  114560. * Specifies if the material will require alpha blending
  114561. * @returns a boolean specifying if alpha blending is needed
  114562. */
  114563. needAlphaBlending(): boolean;
  114564. /**
  114565. * Specifies if this material should be rendered in alpha test mode
  114566. * @returns a boolean specifying if an alpha test is needed.
  114567. */
  114568. needAlphaTesting(): boolean;
  114569. private _initializeBlock;
  114570. private _resetDualBlocks;
  114571. /**
  114572. * Build the material and generates the inner effect
  114573. * @param verbose defines if the build should log activity
  114574. */
  114575. build(verbose?: boolean): void;
  114576. /**
  114577. * Runs an otpimization phase to try to improve the shader code
  114578. */
  114579. optimize(): void;
  114580. private _prepareDefinesForAttributes;
  114581. /**
  114582. * Get if the submesh is ready to be used and all its information available.
  114583. * Child classes can use it to update shaders
  114584. * @param mesh defines the mesh to check
  114585. * @param subMesh defines which submesh to check
  114586. * @param useInstances specifies that instances should be used
  114587. * @returns a boolean indicating that the submesh is ready or not
  114588. */
  114589. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  114590. /**
  114591. * Binds the world matrix to the material
  114592. * @param world defines the world transformation matrix
  114593. */
  114594. bindOnlyWorldMatrix(world: Matrix): void;
  114595. /**
  114596. * Binds the submesh to this material by preparing the effect and shader to draw
  114597. * @param world defines the world transformation matrix
  114598. * @param mesh defines the mesh containing the submesh
  114599. * @param subMesh defines the submesh to bind the material to
  114600. */
  114601. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  114602. /**
  114603. * Gets the active textures from the material
  114604. * @returns an array of textures
  114605. */
  114606. getActiveTextures(): BaseTexture[];
  114607. /**
  114608. * Specifies if the material uses a texture
  114609. * @param texture defines the texture to check against the material
  114610. * @returns a boolean specifying if the material uses the texture
  114611. */
  114612. hasTexture(texture: BaseTexture): boolean;
  114613. /**
  114614. * Disposes the material
  114615. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  114616. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  114617. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  114618. */
  114619. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  114620. /** Creates the node editor window. */
  114621. private _createNodeEditor;
  114622. /**
  114623. * Launch the node material editor
  114624. * @param config Define the configuration of the editor
  114625. * @return a promise fulfilled when the node editor is visible
  114626. */
  114627. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  114628. /**
  114629. * Clear the current material
  114630. */
  114631. clear(): void;
  114632. /**
  114633. * Clear the current material and set it to a default state
  114634. */
  114635. setToDefault(): void;
  114636. }
  114637. }
  114638. declare module BABYLON {
  114639. /**
  114640. * Block used to read a texture from a sampler
  114641. */
  114642. export class TextureBlock extends NodeMaterialBlock {
  114643. private _defineName;
  114644. private _samplerName;
  114645. private _transformedUVName;
  114646. private _textureTransformName;
  114647. private _textureInfoName;
  114648. private _mainUVName;
  114649. private _mainUVDefineName;
  114650. /**
  114651. * Gets or sets the texture associated with the node
  114652. */
  114653. texture: Nullable<BaseTexture>;
  114654. /**
  114655. * Create a new TextureBlock
  114656. * @param name defines the block name
  114657. */
  114658. constructor(name: string);
  114659. /**
  114660. * Gets the current class name
  114661. * @returns the class name
  114662. */
  114663. getClassName(): string;
  114664. /**
  114665. * Gets the uv input component
  114666. */
  114667. readonly uv: NodeMaterialConnectionPoint;
  114668. /**
  114669. * Gets the output component
  114670. */
  114671. readonly output: NodeMaterialConnectionPoint;
  114672. autoConfigure(): void;
  114673. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  114674. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114675. isReady(): boolean;
  114676. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114677. private _injectVertexCode;
  114678. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  114679. }
  114680. }
  114681. declare module BABYLON {
  114682. /**
  114683. * Class used to store shared data between 2 NodeMaterialBuildState
  114684. */
  114685. export class NodeMaterialBuildStateSharedData {
  114686. /**
  114687. * Gets the list of emitted varyings
  114688. */
  114689. varyings: string[];
  114690. /**
  114691. * Gets the varying declaration string
  114692. */
  114693. varyingDeclaration: string;
  114694. /**
  114695. * Input blocks
  114696. */
  114697. inputBlocks: InputBlock[];
  114698. /**
  114699. * Input blocks
  114700. */
  114701. textureBlocks: TextureBlock[];
  114702. /**
  114703. * Bindable blocks (Blocks that need to set data to the effect)
  114704. */
  114705. bindableBlocks: NodeMaterialBlock[];
  114706. /**
  114707. * List of blocks that can provide a compilation fallback
  114708. */
  114709. blocksWithFallbacks: NodeMaterialBlock[];
  114710. /**
  114711. * List of blocks that can provide a define update
  114712. */
  114713. blocksWithDefines: NodeMaterialBlock[];
  114714. /**
  114715. * List of blocks that can provide a repeatable content
  114716. */
  114717. repeatableContentBlocks: NodeMaterialBlock[];
  114718. /**
  114719. * List of blocks that can provide a dynamic list of uniforms
  114720. */
  114721. dynamicUniformBlocks: NodeMaterialBlock[];
  114722. /**
  114723. * List of blocks that can block the isReady function for the material
  114724. */
  114725. blockingBlocks: NodeMaterialBlock[];
  114726. /**
  114727. * Build Id used to avoid multiple recompilations
  114728. */
  114729. buildId: number;
  114730. /** List of emitted variables */
  114731. variableNames: {
  114732. [key: string]: number;
  114733. };
  114734. /** List of emitted defines */
  114735. defineNames: {
  114736. [key: string]: number;
  114737. };
  114738. /** Should emit comments? */
  114739. emitComments: boolean;
  114740. /** Emit build activity */
  114741. verbose: boolean;
  114742. /**
  114743. * Gets the compilation hints emitted at compilation time
  114744. */
  114745. hints: {
  114746. needWorldViewMatrix: boolean;
  114747. needWorldViewProjectionMatrix: boolean;
  114748. needAlphaBlending: boolean;
  114749. needAlphaTesting: boolean;
  114750. };
  114751. /**
  114752. * List of compilation checks
  114753. */
  114754. checks: {
  114755. emitVertex: boolean;
  114756. emitFragment: boolean;
  114757. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  114758. };
  114759. /** Creates a new shared data */
  114760. constructor();
  114761. /**
  114762. * Emits console errors and exceptions if there is a failing check
  114763. */
  114764. emitErrors(): void;
  114765. }
  114766. }
  114767. declare module BABYLON {
  114768. /**
  114769. * Class used to store node based material build state
  114770. */
  114771. export class NodeMaterialBuildState {
  114772. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  114773. supportUniformBuffers: boolean;
  114774. /**
  114775. * Gets the list of emitted attributes
  114776. */
  114777. attributes: string[];
  114778. /**
  114779. * Gets the list of emitted uniforms
  114780. */
  114781. uniforms: string[];
  114782. /**
  114783. * Gets the list of emitted uniform buffers
  114784. */
  114785. uniformBuffers: string[];
  114786. /**
  114787. * Gets the list of emitted samplers
  114788. */
  114789. samplers: string[];
  114790. /**
  114791. * Gets the list of emitted functions
  114792. */
  114793. functions: {
  114794. [key: string]: string;
  114795. };
  114796. /**
  114797. * Gets the target of the compilation state
  114798. */
  114799. target: NodeMaterialBlockTargets;
  114800. /**
  114801. * Gets the list of emitted counters
  114802. */
  114803. counters: {
  114804. [key: string]: number;
  114805. };
  114806. /**
  114807. * Shared data between multiple NodeMaterialBuildState instances
  114808. */
  114809. sharedData: NodeMaterialBuildStateSharedData;
  114810. /** @hidden */
  114811. _vertexState: NodeMaterialBuildState;
  114812. /** @hidden */
  114813. _attributeDeclaration: string;
  114814. /** @hidden */
  114815. _uniformDeclaration: string;
  114816. /** @hidden */
  114817. _samplerDeclaration: string;
  114818. /** @hidden */
  114819. _varyingTransfer: string;
  114820. private _repeatableContentAnchorIndex;
  114821. /** @hidden */
  114822. _builtCompilationString: string;
  114823. /**
  114824. * Gets the emitted compilation strings
  114825. */
  114826. compilationString: string;
  114827. /**
  114828. * Finalize the compilation strings
  114829. * @param state defines the current compilation state
  114830. */
  114831. finalize(state: NodeMaterialBuildState): void;
  114832. /** @hidden */
  114833. readonly _repeatableContentAnchor: string;
  114834. /** @hidden */
  114835. _getFreeVariableName(prefix: string): string;
  114836. /** @hidden */
  114837. _getFreeDefineName(prefix: string): string;
  114838. /** @hidden */
  114839. _excludeVariableName(name: string): void;
  114840. /** @hidden */
  114841. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  114842. /** @hidden */
  114843. _emitFunction(name: string, code: string, comments: string): void;
  114844. /** @hidden */
  114845. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  114846. replaceStrings?: {
  114847. search: RegExp;
  114848. replace: string;
  114849. }[];
  114850. repeatKey?: string;
  114851. }): string;
  114852. /** @hidden */
  114853. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  114854. repeatKey?: string;
  114855. removeAttributes?: boolean;
  114856. removeUniforms?: boolean;
  114857. removeVaryings?: boolean;
  114858. removeIfDef?: boolean;
  114859. replaceStrings?: {
  114860. search: RegExp;
  114861. replace: string;
  114862. }[];
  114863. }, storeKey?: string): void;
  114864. /** @hidden */
  114865. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  114866. /** @hidden */
  114867. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  114868. }
  114869. }
  114870. declare module BABYLON {
  114871. /**
  114872. * Defines a block that can be used inside a node based material
  114873. */
  114874. export class NodeMaterialBlock {
  114875. private _buildId;
  114876. private _buildTarget;
  114877. private _target;
  114878. private _isFinalMerger;
  114879. private _isInput;
  114880. /** @hidden */
  114881. _inputs: NodeMaterialConnectionPoint[];
  114882. /** @hidden */
  114883. _outputs: NodeMaterialConnectionPoint[];
  114884. /**
  114885. * Gets or sets the name of the block
  114886. */
  114887. name: string;
  114888. /**
  114889. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  114890. */
  114891. readonly isFinalMerger: boolean;
  114892. /**
  114893. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  114894. */
  114895. readonly isInput: boolean;
  114896. /**
  114897. * Gets or sets the build Id
  114898. */
  114899. buildId: number;
  114900. /**
  114901. * Gets or sets the target of the block
  114902. */
  114903. target: NodeMaterialBlockTargets;
  114904. /**
  114905. * Gets the list of input points
  114906. */
  114907. readonly inputs: NodeMaterialConnectionPoint[];
  114908. /** Gets the list of output points */
  114909. readonly outputs: NodeMaterialConnectionPoint[];
  114910. /**
  114911. * Find an input by its name
  114912. * @param name defines the name of the input to look for
  114913. * @returns the input or null if not found
  114914. */
  114915. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  114916. /**
  114917. * Find an output by its name
  114918. * @param name defines the name of the outputto look for
  114919. * @returns the output or null if not found
  114920. */
  114921. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  114922. /**
  114923. * Creates a new NodeMaterialBlock
  114924. * @param name defines the block name
  114925. * @param target defines the target of that block (Vertex by default)
  114926. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  114927. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  114928. */
  114929. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  114930. /**
  114931. * Initialize the block and prepare the context for build
  114932. * @param state defines the state that will be used for the build
  114933. */
  114934. initialize(state: NodeMaterialBuildState): void;
  114935. /**
  114936. * Bind data to effect. Will only be called for blocks with isBindable === true
  114937. * @param effect defines the effect to bind data to
  114938. * @param nodeMaterial defines the hosting NodeMaterial
  114939. * @param mesh defines the mesh that will be rendered
  114940. */
  114941. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114942. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  114943. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  114944. protected _writeFloat(value: number): string;
  114945. /**
  114946. * Gets the current class name e.g. "NodeMaterialBlock"
  114947. * @returns the class name
  114948. */
  114949. getClassName(): string;
  114950. /**
  114951. * Register a new input. Must be called inside a block constructor
  114952. * @param name defines the connection point name
  114953. * @param type defines the connection point type
  114954. * @param isOptional defines a boolean indicating that this input can be omitted
  114955. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  114956. * @returns the current block
  114957. */
  114958. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  114959. /**
  114960. * Register a new output. Must be called inside a block constructor
  114961. * @param name defines the connection point name
  114962. * @param type defines the connection point type
  114963. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  114964. * @returns the current block
  114965. */
  114966. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  114967. /**
  114968. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  114969. * @param forOutput defines an optional connection point to check compatibility with
  114970. * @returns the first available input or null
  114971. */
  114972. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  114973. /**
  114974. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  114975. * @param forBlock defines an optional block to check compatibility with
  114976. * @returns the first available input or null
  114977. */
  114978. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  114979. /**
  114980. * Connect current block with another block
  114981. * @param other defines the block to connect with
  114982. * @param options define the various options to help pick the right connections
  114983. * @returns the current block
  114984. */
  114985. connectTo(other: NodeMaterialBlock, options?: {
  114986. input?: string;
  114987. output?: string;
  114988. outputSwizzle?: string;
  114989. }): this | undefined;
  114990. protected _buildBlock(state: NodeMaterialBuildState): void;
  114991. /**
  114992. * Add uniforms, samplers and uniform buffers at compilation time
  114993. * @param state defines the state to update
  114994. * @param nodeMaterial defines the node material requesting the update
  114995. * @param defines defines the material defines to update
  114996. */
  114997. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114998. /**
  114999. * Add potential fallbacks if shader compilation fails
  115000. * @param mesh defines the mesh to be rendered
  115001. * @param fallbacks defines the current prioritized list of fallbacks
  115002. */
  115003. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  115004. /**
  115005. * Update defines for shader compilation
  115006. * @param mesh defines the mesh to be rendered
  115007. * @param nodeMaterial defines the node material requesting the update
  115008. * @param defines defines the material defines to update
  115009. * @param useInstances specifies that instances should be used
  115010. */
  115011. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  115012. /**
  115013. * Initialize defines for shader compilation
  115014. * @param mesh defines the mesh to be rendered
  115015. * @param nodeMaterial defines the node material requesting the update
  115016. * @param defines defines the material defines to be prepared
  115017. * @param useInstances specifies that instances should be used
  115018. */
  115019. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  115020. /**
  115021. * Lets the block try to connect some inputs automatically
  115022. */
  115023. autoConfigure(): void;
  115024. /**
  115025. * Function called when a block is declared as repeatable content generator
  115026. * @param vertexShaderState defines the current compilation state for the vertex shader
  115027. * @param fragmentShaderState defines the current compilation state for the fragment shader
  115028. * @param mesh defines the mesh to be rendered
  115029. * @param defines defines the material defines to update
  115030. */
  115031. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  115032. /**
  115033. * Checks if the block is ready
  115034. * @param mesh defines the mesh to be rendered
  115035. * @param nodeMaterial defines the node material requesting the update
  115036. * @param defines defines the material defines to update
  115037. * @param useInstances specifies that instances should be used
  115038. * @returns true if the block is ready
  115039. */
  115040. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  115041. private _processBuild;
  115042. /**
  115043. * Compile the current node and generate the shader code
  115044. * @param state defines the current compilation state (uniforms, samplers, current string)
  115045. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  115046. * @returns true if already built
  115047. */
  115048. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  115049. }
  115050. }
  115051. declare module BABYLON {
  115052. /**
  115053. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  115054. */
  115055. export enum NodeMaterialBlockConnectionPointMode {
  115056. /** Value is an uniform */
  115057. Uniform = 0,
  115058. /** Value is a mesh attribute */
  115059. Attribute = 1,
  115060. /** Value is a varying between vertex and fragment shaders */
  115061. Varying = 2,
  115062. /** Mode is undefined */
  115063. Undefined = 3
  115064. }
  115065. }
  115066. declare module BABYLON {
  115067. /**
  115068. * Enum used to define well known values e.g. values automatically provided by the system
  115069. */
  115070. export enum NodeMaterialWellKnownValues {
  115071. /** World */
  115072. World = 1,
  115073. /** View */
  115074. View = 2,
  115075. /** Projection */
  115076. Projection = 3,
  115077. /** ViewProjection */
  115078. ViewProjection = 4,
  115079. /** WorldView */
  115080. WorldView = 5,
  115081. /** WorldViewProjection */
  115082. WorldViewProjection = 6,
  115083. /** CameraPosition */
  115084. CameraPosition = 7,
  115085. /** Fog Color */
  115086. FogColor = 8
  115087. }
  115088. }
  115089. declare module BABYLON {
  115090. /**
  115091. * Block used to expose an input value
  115092. */
  115093. export class InputBlock extends NodeMaterialBlock {
  115094. private _mode;
  115095. private _associatedVariableName;
  115096. private _storedValue;
  115097. private _valueCallback;
  115098. private _type;
  115099. /** @hidden */
  115100. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  115101. /**
  115102. * Gets or sets the connection point type (default is float)
  115103. */
  115104. readonly type: NodeMaterialBlockConnectionPointTypes;
  115105. /**
  115106. * Creates a new InputBlock
  115107. * @param name defines the block name
  115108. * @param target defines the target of that block (Vertex by default)
  115109. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  115110. */
  115111. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  115112. /**
  115113. * Gets the output component
  115114. */
  115115. readonly output: NodeMaterialConnectionPoint;
  115116. /**
  115117. * Set the source of this connection point to a vertex attribute
  115118. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  115119. * @returns the current connection point
  115120. */
  115121. setAsAttribute(attributeName?: string): InputBlock;
  115122. /**
  115123. * Set the source of this connection point to a well known value
  115124. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  115125. * @returns the current connection point
  115126. */
  115127. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  115128. /**
  115129. * Gets or sets the value of that point.
  115130. * Please note that this value will be ignored if valueCallback is defined
  115131. */
  115132. value: any;
  115133. /**
  115134. * Gets or sets a callback used to get the value of that point.
  115135. * Please note that setting this value will force the connection point to ignore the value property
  115136. */
  115137. valueCallback: () => any;
  115138. /**
  115139. * Gets or sets the associated variable name in the shader
  115140. */
  115141. associatedVariableName: string;
  115142. /**
  115143. * Gets a boolean indicating that this connection point not defined yet
  115144. */
  115145. readonly isUndefined: boolean;
  115146. /**
  115147. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  115148. * In this case the connection point name must be the name of the uniform to use.
  115149. * Can only be set on inputs
  115150. */
  115151. isUniform: boolean;
  115152. /**
  115153. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  115154. * In this case the connection point name must be the name of the attribute to use
  115155. * Can only be set on inputs
  115156. */
  115157. isAttribute: boolean;
  115158. /**
  115159. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  115160. * Can only be set on exit points
  115161. */
  115162. isVarying: boolean;
  115163. /**
  115164. * Gets a boolean indicating that the current connection point is a well known value
  115165. */
  115166. readonly isWellKnownValue: boolean;
  115167. /**
  115168. * Gets or sets the current well known value or null if not defined as well know value
  115169. */
  115170. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  115171. /**
  115172. * Gets the current class name
  115173. * @returns the class name
  115174. */
  115175. getClassName(): string;
  115176. private _emitDefine;
  115177. /**
  115178. * Set the input block to its default value (based on its type)
  115179. */
  115180. setDefaultValue(): void;
  115181. private _emit;
  115182. /** @hidden */
  115183. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  115184. /** @hidden */
  115185. _transmit(effect: Effect, scene: Scene): void;
  115186. protected _buildBlock(state: NodeMaterialBuildState): void;
  115187. }
  115188. }
  115189. declare module BABYLON {
  115190. /**
  115191. * Defines a connection point for a block
  115192. */
  115193. export class NodeMaterialConnectionPoint {
  115194. /** @hidden */
  115195. _ownerBlock: NodeMaterialBlock;
  115196. /** @hidden */
  115197. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  115198. private _endpoints;
  115199. private _associatedVariableName;
  115200. /** @hidden */
  115201. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  115202. private _type;
  115203. /** @hidden */
  115204. _enforceAssociatedVariableName: boolean;
  115205. /**
  115206. * Gets or sets the associated variable name in the shader
  115207. */
  115208. associatedVariableName: string;
  115209. /**
  115210. * Gets or sets the connection point type (default is float)
  115211. */
  115212. type: NodeMaterialBlockConnectionPointTypes;
  115213. /**
  115214. * Gets or sets the connection point name
  115215. */
  115216. name: string;
  115217. /**
  115218. * Gets or sets the swizzle to apply to this connection point when reading or writing
  115219. */
  115220. swizzle: string;
  115221. /**
  115222. * Gets or sets a boolean indicating that this connection point can be omitted
  115223. */
  115224. isOptional: boolean;
  115225. /**
  115226. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  115227. */
  115228. define: string;
  115229. /** Gets or sets the target of that connection point */
  115230. target: NodeMaterialBlockTargets;
  115231. /**
  115232. * Gets a boolean indicating that the current point is connected
  115233. */
  115234. readonly isConnected: boolean;
  115235. /**
  115236. * Gets a boolean indicating that the current point is connected to an input block
  115237. */
  115238. readonly isConnectedToInput: boolean;
  115239. /**
  115240. * Gets a the connected input block (if any)
  115241. */
  115242. readonly connectInputBlock: Nullable<InputBlock>;
  115243. /** Get the other side of the connection (if any) */
  115244. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  115245. /** Get the block that owns this connection point */
  115246. readonly ownerBlock: NodeMaterialBlock;
  115247. /** Get the block connected on the other side of this connection (if any) */
  115248. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  115249. /** Get the block connected on the endpoints of this connection (if any) */
  115250. readonly connectedBlocks: Array<NodeMaterialBlock>;
  115251. /** Gets the list of connected endpoints */
  115252. readonly endpoints: NodeMaterialConnectionPoint[];
  115253. /**
  115254. * Creates a new connection point
  115255. * @param name defines the connection point name
  115256. * @param ownerBlock defines the block hosting this connection point
  115257. */
  115258. constructor(name: string, ownerBlock: NodeMaterialBlock);
  115259. /**
  115260. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  115261. * @returns the class name
  115262. */
  115263. getClassName(): string;
  115264. private _getTypeLength;
  115265. /**
  115266. * Gets an boolean indicating if the current point can be connected to another point
  115267. * @param connectionPoint defines the other connection point
  115268. * @returns true if the connection is possible
  115269. */
  115270. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  115271. /**
  115272. * Connect this point to another connection point
  115273. * @param connectionPoint defines the other connection point
  115274. * @returns the current connection point
  115275. */
  115276. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  115277. /**
  115278. * Disconnect this point from one of his endpoint
  115279. * @param endpoint defines the other connection point
  115280. * @returns the current connection point
  115281. */
  115282. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  115283. }
  115284. }
  115285. declare module BABYLON {
  115286. /**
  115287. * Block used to add support for vertex skinning (bones)
  115288. */
  115289. export class BonesBlock extends NodeMaterialBlock {
  115290. /**
  115291. * Creates a new BonesBlock
  115292. * @param name defines the block name
  115293. */
  115294. constructor(name: string);
  115295. /**
  115296. * Initialize the block and prepare the context for build
  115297. * @param state defines the state that will be used for the build
  115298. */
  115299. initialize(state: NodeMaterialBuildState): void;
  115300. /**
  115301. * Gets the current class name
  115302. * @returns the class name
  115303. */
  115304. getClassName(): string;
  115305. /**
  115306. * Gets the matrix indices input component
  115307. */
  115308. readonly matricesIndices: NodeMaterialConnectionPoint;
  115309. /**
  115310. * Gets the matrix weights input component
  115311. */
  115312. readonly matricesWeights: NodeMaterialConnectionPoint;
  115313. /**
  115314. * Gets the extra matrix indices input component
  115315. */
  115316. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  115317. /**
  115318. * Gets the extra matrix weights input component
  115319. */
  115320. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  115321. /**
  115322. * Gets the world input component
  115323. */
  115324. readonly world: NodeMaterialConnectionPoint;
  115325. /**
  115326. * Gets the output component
  115327. */
  115328. readonly output: NodeMaterialConnectionPoint;
  115329. autoConfigure(): void;
  115330. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  115331. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  115332. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  115333. protected _buildBlock(state: NodeMaterialBuildState): this;
  115334. }
  115335. }
  115336. declare module BABYLON {
  115337. /**
  115338. * Block used to add support for instances
  115339. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  115340. */
  115341. export class InstancesBlock extends NodeMaterialBlock {
  115342. /**
  115343. * Creates a new InstancesBlock
  115344. * @param name defines the block name
  115345. */
  115346. constructor(name: string);
  115347. /**
  115348. * Gets the current class name
  115349. * @returns the class name
  115350. */
  115351. getClassName(): string;
  115352. /**
  115353. * Gets the first world row input component
  115354. */
  115355. readonly world0: NodeMaterialConnectionPoint;
  115356. /**
  115357. * Gets the second world row input component
  115358. */
  115359. readonly world1: NodeMaterialConnectionPoint;
  115360. /**
  115361. * Gets the third world row input component
  115362. */
  115363. readonly world2: NodeMaterialConnectionPoint;
  115364. /**
  115365. * Gets the forth world row input component
  115366. */
  115367. readonly world3: NodeMaterialConnectionPoint;
  115368. /**
  115369. * Gets the world input component
  115370. */
  115371. readonly world: NodeMaterialConnectionPoint;
  115372. /**
  115373. * Gets the output component
  115374. */
  115375. readonly output: NodeMaterialConnectionPoint;
  115376. autoConfigure(): void;
  115377. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  115378. protected _buildBlock(state: NodeMaterialBuildState): this;
  115379. }
  115380. }
  115381. declare module BABYLON {
  115382. /**
  115383. * Block used to add morph targets support to vertex shader
  115384. */
  115385. export class MorphTargetsBlock extends NodeMaterialBlock {
  115386. private _repeatableContentAnchor;
  115387. private _repeatebleContentGenerated;
  115388. /**
  115389. * Create a new MorphTargetsBlock
  115390. * @param name defines the block name
  115391. */
  115392. constructor(name: string);
  115393. /**
  115394. * Gets the current class name
  115395. * @returns the class name
  115396. */
  115397. getClassName(): string;
  115398. /**
  115399. * Gets the position input component
  115400. */
  115401. readonly position: NodeMaterialConnectionPoint;
  115402. /**
  115403. * Gets the normal input component
  115404. */
  115405. readonly normal: NodeMaterialConnectionPoint;
  115406. /**
  115407. * Gets the tangent input component
  115408. */
  115409. readonly tangent: NodeMaterialConnectionPoint;
  115410. /**
  115411. * Gets the tangent input component
  115412. */
  115413. readonly uv: NodeMaterialConnectionPoint;
  115414. /**
  115415. * Gets the position output component
  115416. */
  115417. readonly positionOutput: NodeMaterialConnectionPoint;
  115418. /**
  115419. * Gets the normal output component
  115420. */
  115421. readonly normalOutput: NodeMaterialConnectionPoint;
  115422. /**
  115423. * Gets the tangent output component
  115424. */
  115425. readonly tangentOutput: NodeMaterialConnectionPoint;
  115426. /**
  115427. * Gets the tangent output component
  115428. */
  115429. readonly uvOutput: NodeMaterialConnectionPoint;
  115430. initialize(state: NodeMaterialBuildState): void;
  115431. autoConfigure(): void;
  115432. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  115433. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  115434. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  115435. protected _buildBlock(state: NodeMaterialBuildState): this;
  115436. }
  115437. }
  115438. declare module BABYLON {
  115439. /**
  115440. * Block used to add an alpha test in the fragment shader
  115441. */
  115442. export class AlphaTestBlock extends NodeMaterialBlock {
  115443. /**
  115444. * Gets or sets the alpha value where alpha testing happens
  115445. */
  115446. alphaCutOff: number;
  115447. /**
  115448. * Create a new AlphaTestBlock
  115449. * @param name defines the block name
  115450. */
  115451. constructor(name: string);
  115452. /**
  115453. * Gets the current class name
  115454. * @returns the class name
  115455. */
  115456. getClassName(): string;
  115457. /**
  115458. * Gets the color input component
  115459. */
  115460. readonly color: NodeMaterialConnectionPoint;
  115461. protected _buildBlock(state: NodeMaterialBuildState): this;
  115462. }
  115463. }
  115464. declare module BABYLON {
  115465. /**
  115466. * Block used to create a Color4 out of 4 inputs (one for each component)
  115467. */
  115468. export class RGBAMergerBlock extends NodeMaterialBlock {
  115469. /**
  115470. * Create a new RGBAMergerBlock
  115471. * @param name defines the block name
  115472. */
  115473. constructor(name: string);
  115474. /**
  115475. * Gets the current class name
  115476. * @returns the class name
  115477. */
  115478. getClassName(): string;
  115479. /**
  115480. * Gets the R input component
  115481. */
  115482. readonly r: NodeMaterialConnectionPoint;
  115483. /**
  115484. * Gets the G input component
  115485. */
  115486. readonly g: NodeMaterialConnectionPoint;
  115487. /**
  115488. * Gets the B input component
  115489. */
  115490. readonly b: NodeMaterialConnectionPoint;
  115491. /**
  115492. * Gets the RGB input component
  115493. */
  115494. readonly rgb: NodeMaterialConnectionPoint;
  115495. /**
  115496. * Gets the R input component
  115497. */
  115498. readonly a: NodeMaterialConnectionPoint;
  115499. /**
  115500. * Gets the output component
  115501. */
  115502. readonly output: NodeMaterialConnectionPoint;
  115503. protected _buildBlock(state: NodeMaterialBuildState): this;
  115504. }
  115505. }
  115506. declare module BABYLON {
  115507. /**
  115508. * Block used to create a Color3 out of 3 inputs (one for each component)
  115509. */
  115510. export class RGBMergerBlock extends NodeMaterialBlock {
  115511. /**
  115512. * Create a new RGBMergerBlock
  115513. * @param name defines the block name
  115514. */
  115515. constructor(name: string);
  115516. /**
  115517. * Gets the current class name
  115518. * @returns the class name
  115519. */
  115520. getClassName(): string;
  115521. /**
  115522. * Gets the R component input
  115523. */
  115524. readonly r: NodeMaterialConnectionPoint;
  115525. /**
  115526. * Gets the G component input
  115527. */
  115528. readonly g: NodeMaterialConnectionPoint;
  115529. /**
  115530. * Gets the B component input
  115531. */
  115532. readonly b: NodeMaterialConnectionPoint;
  115533. /**
  115534. * Gets the output component
  115535. */
  115536. readonly output: NodeMaterialConnectionPoint;
  115537. protected _buildBlock(state: NodeMaterialBuildState): this;
  115538. }
  115539. }
  115540. declare module BABYLON {
  115541. /**
  115542. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  115543. */
  115544. export class RGBASplitterBlock extends NodeMaterialBlock {
  115545. /**
  115546. * Create a new RGBASplitterBlock
  115547. * @param name defines the block name
  115548. */
  115549. constructor(name: string);
  115550. /**
  115551. * Gets the current class name
  115552. * @returns the class name
  115553. */
  115554. getClassName(): string;
  115555. /**
  115556. * Gets the input component
  115557. */
  115558. readonly input: NodeMaterialConnectionPoint;
  115559. protected _buildBlock(state: NodeMaterialBuildState): this;
  115560. }
  115561. }
  115562. declare module BABYLON {
  115563. /**
  115564. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  115565. */
  115566. export class RGBSplitterBlock extends NodeMaterialBlock {
  115567. /**
  115568. * Create a new RGBSplitterBlock
  115569. * @param name defines the block name
  115570. */
  115571. constructor(name: string);
  115572. /**
  115573. * Gets the current class name
  115574. * @returns the class name
  115575. */
  115576. getClassName(): string;
  115577. /**
  115578. * Gets the input component
  115579. */
  115580. readonly input: NodeMaterialConnectionPoint;
  115581. protected _buildBlock(state: NodeMaterialBuildState): this;
  115582. }
  115583. }
  115584. declare module BABYLON {
  115585. /**
  115586. * Block used to add image processing support to fragment shader
  115587. */
  115588. export class ImageProcessingBlock extends NodeMaterialBlock {
  115589. /**
  115590. * Create a new ImageProcessingBlock
  115591. * @param name defines the block name
  115592. */
  115593. constructor(name: string);
  115594. /**
  115595. * Gets the current class name
  115596. * @returns the class name
  115597. */
  115598. getClassName(): string;
  115599. /**
  115600. * Gets the color input component
  115601. */
  115602. readonly color: NodeMaterialConnectionPoint;
  115603. /**
  115604. * Gets the output component
  115605. */
  115606. readonly output: NodeMaterialConnectionPoint;
  115607. /**
  115608. * Initialize the block and prepare the context for build
  115609. * @param state defines the state that will be used for the build
  115610. */
  115611. initialize(state: NodeMaterialBuildState): void;
  115612. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  115613. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  115614. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  115615. protected _buildBlock(state: NodeMaterialBuildState): this;
  115616. }
  115617. }
  115618. declare module BABYLON {
  115619. /**
  115620. * Block used to add support for scene fog
  115621. */
  115622. export class FogBlock extends NodeMaterialBlock {
  115623. private _fogDistanceName;
  115624. private _fogParameters;
  115625. /**
  115626. * Create a new FogBlock
  115627. * @param name defines the block name
  115628. */
  115629. constructor(name: string);
  115630. /**
  115631. * Gets the current class name
  115632. * @returns the class name
  115633. */
  115634. getClassName(): string;
  115635. /**
  115636. * Gets the world position input component
  115637. */
  115638. readonly worldPosition: NodeMaterialConnectionPoint;
  115639. /**
  115640. * Gets the view input component
  115641. */
  115642. readonly view: NodeMaterialConnectionPoint;
  115643. /**
  115644. * Gets the color input component
  115645. */
  115646. readonly color: NodeMaterialConnectionPoint;
  115647. /**
  115648. * Gets the fog color input component
  115649. */
  115650. readonly fogColor: NodeMaterialConnectionPoint;
  115651. /**
  115652. * Gets the output component
  115653. */
  115654. readonly output: NodeMaterialConnectionPoint;
  115655. autoConfigure(): void;
  115656. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  115657. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  115658. protected _buildBlock(state: NodeMaterialBuildState): this;
  115659. }
  115660. }
  115661. declare module BABYLON {
  115662. /**
  115663. * Block used to add light in the fragment shader
  115664. */
  115665. export class LightBlock extends NodeMaterialBlock {
  115666. private _lightId;
  115667. /**
  115668. * Gets or sets the light associated with this block
  115669. */
  115670. light: Nullable<Light>;
  115671. /**
  115672. * Create a new LightBlock
  115673. * @param name defines the block name
  115674. */
  115675. constructor(name: string);
  115676. /**
  115677. * Gets the current class name
  115678. * @returns the class name
  115679. */
  115680. getClassName(): string;
  115681. /**
  115682. * Gets the world position input component
  115683. */
  115684. readonly worldPosition: NodeMaterialConnectionPoint;
  115685. /**
  115686. * Gets the world normal input component
  115687. */
  115688. readonly worldNormal: NodeMaterialConnectionPoint;
  115689. /**
  115690. * Gets the camera (or eye) position component
  115691. */
  115692. readonly cameraPosition: NodeMaterialConnectionPoint;
  115693. /**
  115694. * Gets the diffuse output component
  115695. */
  115696. readonly diffuseOutput: NodeMaterialConnectionPoint;
  115697. /**
  115698. * Gets the specular output component
  115699. */
  115700. readonly specularOutput: NodeMaterialConnectionPoint;
  115701. autoConfigure(): void;
  115702. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  115703. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  115704. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  115705. private _injectVertexCode;
  115706. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  115707. }
  115708. }
  115709. declare module BABYLON {
  115710. /**
  115711. * Block used to multiply 2 values
  115712. */
  115713. export class MultiplyBlock extends NodeMaterialBlock {
  115714. /**
  115715. * Creates a new MultiplyBlock
  115716. * @param name defines the block name
  115717. */
  115718. constructor(name: string);
  115719. /**
  115720. * Gets the current class name
  115721. * @returns the class name
  115722. */
  115723. getClassName(): string;
  115724. /**
  115725. * Gets the left operand input component
  115726. */
  115727. readonly left: NodeMaterialConnectionPoint;
  115728. /**
  115729. * Gets the right operand input component
  115730. */
  115731. readonly right: NodeMaterialConnectionPoint;
  115732. /**
  115733. * Gets the output component
  115734. */
  115735. readonly output: NodeMaterialConnectionPoint;
  115736. protected _buildBlock(state: NodeMaterialBuildState): this;
  115737. }
  115738. }
  115739. declare module BABYLON {
  115740. /**
  115741. * Block used to add 2 vector4
  115742. */
  115743. export class AddBlock extends NodeMaterialBlock {
  115744. /**
  115745. * Creates a new AddBlock
  115746. * @param name defines the block name
  115747. */
  115748. constructor(name: string);
  115749. /**
  115750. * Gets the current class name
  115751. * @returns the class name
  115752. */
  115753. getClassName(): string;
  115754. /**
  115755. * Gets the left operand input component
  115756. */
  115757. readonly left: NodeMaterialConnectionPoint;
  115758. /**
  115759. * Gets the right operand input component
  115760. */
  115761. readonly right: NodeMaterialConnectionPoint;
  115762. /**
  115763. * Gets the output component
  115764. */
  115765. readonly output: NodeMaterialConnectionPoint;
  115766. protected _buildBlock(state: NodeMaterialBuildState): this;
  115767. }
  115768. }
  115769. declare module BABYLON {
  115770. /**
  115771. * Block used to clamp a float
  115772. */
  115773. export class ClampBlock extends NodeMaterialBlock {
  115774. /** Gets or sets the minimum range */
  115775. minimum: number;
  115776. /** Gets or sets the maximum range */
  115777. maximum: number;
  115778. /**
  115779. * Creates a new ClampBlock
  115780. * @param name defines the block name
  115781. */
  115782. constructor(name: string);
  115783. /**
  115784. * Gets the current class name
  115785. * @returns the class name
  115786. */
  115787. getClassName(): string;
  115788. /**
  115789. * Gets the value input component
  115790. */
  115791. readonly value: NodeMaterialConnectionPoint;
  115792. /**
  115793. * Gets the output component
  115794. */
  115795. readonly output: NodeMaterialConnectionPoint;
  115796. protected _buildBlock(state: NodeMaterialBuildState): this;
  115797. }
  115798. }
  115799. declare module BABYLON {
  115800. /**
  115801. * Block used to transform a vector2 with a matrix
  115802. */
  115803. export class Vector2TransformBlock extends NodeMaterialBlock {
  115804. /**
  115805. * Defines the value to use to complement Vector2 to transform it to a Vector4
  115806. */
  115807. complementZ: number;
  115808. /**
  115809. * Defines the value to use to complement Vector2 to transform it to a Vector4
  115810. */
  115811. complementW: number;
  115812. /**
  115813. * Creates a new Vector2TransformBlock
  115814. * @param name defines the block name
  115815. */
  115816. constructor(name: string);
  115817. /**
  115818. * Gets the vector input
  115819. */
  115820. readonly vector: NodeMaterialConnectionPoint;
  115821. /**
  115822. * Gets the matrix transform input
  115823. */
  115824. readonly transform: NodeMaterialConnectionPoint;
  115825. /**
  115826. * Gets the output component
  115827. */
  115828. readonly output: NodeMaterialConnectionPoint;
  115829. /**
  115830. * Gets the current class name
  115831. * @returns the class name
  115832. */
  115833. getClassName(): string;
  115834. protected _buildBlock(state: NodeMaterialBuildState): this;
  115835. }
  115836. }
  115837. declare module BABYLON {
  115838. /**
  115839. * Block used to transform a vector3 with a matrix
  115840. */
  115841. export class Vector3TransformBlock extends NodeMaterialBlock {
  115842. /**
  115843. * Defines the value to use to complement Vector3 to transform it to a Vector4
  115844. */
  115845. complement: number;
  115846. /**
  115847. * Creates a new Vector3TransformBlock
  115848. * @param name defines the block name
  115849. */
  115850. constructor(name: string);
  115851. /**
  115852. * Gets the vector input
  115853. */
  115854. readonly vector: NodeMaterialConnectionPoint;
  115855. /**
  115856. * Gets the matrix transform input
  115857. */
  115858. readonly transform: NodeMaterialConnectionPoint;
  115859. /**
  115860. * Gets the output component
  115861. */
  115862. readonly output: NodeMaterialConnectionPoint;
  115863. /**
  115864. * Gets the current class name
  115865. * @returns the class name
  115866. */
  115867. getClassName(): string;
  115868. protected _buildBlock(state: NodeMaterialBuildState): this;
  115869. }
  115870. }
  115871. declare module BABYLON {
  115872. /**
  115873. * Helper class to render one or more effects
  115874. */
  115875. export class EffectRenderer {
  115876. private engine;
  115877. private static _Vertices;
  115878. private static _Indices;
  115879. private _vertexBuffers;
  115880. private _indexBuffer;
  115881. private _ringBufferIndex;
  115882. private _ringScreenBuffer;
  115883. private _getNextFrameBuffer;
  115884. /**
  115885. * Creates an effect renderer
  115886. * @param engine the engine to use for rendering
  115887. */
  115888. constructor(engine: Engine);
  115889. /**
  115890. * renders one or more effects to a specified texture
  115891. * @param effectWrappers list of effects to renderer
  115892. * @param outputTexture texture to draw to, if null it will render to the screen
  115893. */
  115894. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  115895. /**
  115896. * Disposes of the effect renderer
  115897. */
  115898. dispose(): void;
  115899. }
  115900. /**
  115901. * Options to create an EffectWrapper
  115902. */
  115903. interface EffectWrapperCreationOptions {
  115904. /**
  115905. * Engine to use to create the effect
  115906. */
  115907. engine: Engine;
  115908. /**
  115909. * Fragment shader for the effect
  115910. */
  115911. fragmentShader: string;
  115912. /**
  115913. * Attributes to use in the shader
  115914. */
  115915. attributeNames: Array<string>;
  115916. /**
  115917. * Uniforms to use in the shader
  115918. */
  115919. uniformNames: Array<string>;
  115920. /**
  115921. * Texture sampler names to use in the shader
  115922. */
  115923. samplerNames: Array<string>;
  115924. }
  115925. /**
  115926. * Wraps an effect to be used for rendering
  115927. */
  115928. export class EffectWrapper {
  115929. /**
  115930. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  115931. */
  115932. onApplyObservable: Observable<{}>;
  115933. /**
  115934. * The underlying effect
  115935. */
  115936. effect: Effect;
  115937. /**
  115938. * Creates an effect to be renderer
  115939. * @param creationOptions options to create the effect
  115940. */
  115941. constructor(creationOptions: EffectWrapperCreationOptions);
  115942. /**
  115943. * Disposes of the effect wrapper
  115944. */
  115945. dispose(): void;
  115946. }
  115947. }
  115948. declare module BABYLON {
  115949. /**
  115950. * Contains position and normal vectors for a vertex
  115951. */
  115952. export class PositionNormalVertex {
  115953. /** the position of the vertex (defaut: 0,0,0) */
  115954. position: Vector3;
  115955. /** the normal of the vertex (defaut: 0,1,0) */
  115956. normal: Vector3;
  115957. /**
  115958. * Creates a PositionNormalVertex
  115959. * @param position the position of the vertex (defaut: 0,0,0)
  115960. * @param normal the normal of the vertex (defaut: 0,1,0)
  115961. */
  115962. constructor(
  115963. /** the position of the vertex (defaut: 0,0,0) */
  115964. position?: Vector3,
  115965. /** the normal of the vertex (defaut: 0,1,0) */
  115966. normal?: Vector3);
  115967. /**
  115968. * Clones the PositionNormalVertex
  115969. * @returns the cloned PositionNormalVertex
  115970. */
  115971. clone(): PositionNormalVertex;
  115972. }
  115973. /**
  115974. * Contains position, normal and uv vectors for a vertex
  115975. */
  115976. export class PositionNormalTextureVertex {
  115977. /** the position of the vertex (defaut: 0,0,0) */
  115978. position: Vector3;
  115979. /** the normal of the vertex (defaut: 0,1,0) */
  115980. normal: Vector3;
  115981. /** the uv of the vertex (default: 0,0) */
  115982. uv: Vector2;
  115983. /**
  115984. * Creates a PositionNormalTextureVertex
  115985. * @param position the position of the vertex (defaut: 0,0,0)
  115986. * @param normal the normal of the vertex (defaut: 0,1,0)
  115987. * @param uv the uv of the vertex (default: 0,0)
  115988. */
  115989. constructor(
  115990. /** the position of the vertex (defaut: 0,0,0) */
  115991. position?: Vector3,
  115992. /** the normal of the vertex (defaut: 0,1,0) */
  115993. normal?: Vector3,
  115994. /** the uv of the vertex (default: 0,0) */
  115995. uv?: Vector2);
  115996. /**
  115997. * Clones the PositionNormalTextureVertex
  115998. * @returns the cloned PositionNormalTextureVertex
  115999. */
  116000. clone(): PositionNormalTextureVertex;
  116001. }
  116002. }
  116003. declare module BABYLON {
  116004. /**
  116005. * Helper class to push actions to a pool of workers.
  116006. */
  116007. export class WorkerPool implements IDisposable {
  116008. private _workerInfos;
  116009. private _pendingActions;
  116010. /**
  116011. * Constructor
  116012. * @param workers Array of workers to use for actions
  116013. */
  116014. constructor(workers: Array<Worker>);
  116015. /**
  116016. * Terminates all workers and clears any pending actions.
  116017. */
  116018. dispose(): void;
  116019. /**
  116020. * Pushes an action to the worker pool. If all the workers are active, the action will be
  116021. * pended until a worker has completed its action.
  116022. * @param action The action to perform. Call onComplete when the action is complete.
  116023. */
  116024. push(action: (worker: Worker, onComplete: () => void) => void): void;
  116025. private _execute;
  116026. }
  116027. }
  116028. declare module BABYLON {
  116029. /**
  116030. * Configuration for Draco compression
  116031. */
  116032. export interface IDracoCompressionConfiguration {
  116033. /**
  116034. * Configuration for the decoder.
  116035. */
  116036. decoder: {
  116037. /**
  116038. * The url to the WebAssembly module.
  116039. */
  116040. wasmUrl?: string;
  116041. /**
  116042. * The url to the WebAssembly binary.
  116043. */
  116044. wasmBinaryUrl?: string;
  116045. /**
  116046. * The url to the fallback JavaScript module.
  116047. */
  116048. fallbackUrl?: string;
  116049. };
  116050. }
  116051. /**
  116052. * Draco compression (https://google.github.io/draco/)
  116053. *
  116054. * This class wraps the Draco module.
  116055. *
  116056. * **Encoder**
  116057. *
  116058. * The encoder is not currently implemented.
  116059. *
  116060. * **Decoder**
  116061. *
  116062. * 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.
  116063. *
  116064. * To update the configuration, use the following code:
  116065. * ```javascript
  116066. * DracoCompression.Configuration = {
  116067. * decoder: {
  116068. * wasmUrl: "<url to the WebAssembly library>",
  116069. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  116070. * fallbackUrl: "<url to the fallback JavaScript library>",
  116071. * }
  116072. * };
  116073. * ```
  116074. *
  116075. * 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.
  116076. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  116077. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  116078. *
  116079. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  116080. * ```javascript
  116081. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  116082. * ```
  116083. *
  116084. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  116085. */
  116086. export class DracoCompression implements IDisposable {
  116087. private _workerPoolPromise?;
  116088. private _decoderModulePromise?;
  116089. /**
  116090. * The configuration. Defaults to the following urls:
  116091. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  116092. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  116093. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  116094. */
  116095. static Configuration: IDracoCompressionConfiguration;
  116096. /**
  116097. * Returns true if the decoder configuration is available.
  116098. */
  116099. static readonly DecoderAvailable: boolean;
  116100. /**
  116101. * Default number of workers to create when creating the draco compression object.
  116102. */
  116103. static DefaultNumWorkers: number;
  116104. private static GetDefaultNumWorkers;
  116105. private static _Default;
  116106. /**
  116107. * Default instance for the draco compression object.
  116108. */
  116109. static readonly Default: DracoCompression;
  116110. /**
  116111. * Constructor
  116112. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  116113. */
  116114. constructor(numWorkers?: number);
  116115. /**
  116116. * Stop all async operations and release resources.
  116117. */
  116118. dispose(): void;
  116119. /**
  116120. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  116121. * @returns a promise that resolves when ready
  116122. */
  116123. whenReadyAsync(): Promise<void>;
  116124. /**
  116125. * Decode Draco compressed mesh data to vertex data.
  116126. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  116127. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  116128. * @returns A promise that resolves with the decoded vertex data
  116129. */
  116130. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  116131. [kind: string]: number;
  116132. }): Promise<VertexData>;
  116133. }
  116134. }
  116135. declare module BABYLON {
  116136. /**
  116137. * Class for building Constructive Solid Geometry
  116138. */
  116139. export class CSG {
  116140. private polygons;
  116141. /**
  116142. * The world matrix
  116143. */
  116144. matrix: Matrix;
  116145. /**
  116146. * Stores the position
  116147. */
  116148. position: Vector3;
  116149. /**
  116150. * Stores the rotation
  116151. */
  116152. rotation: Vector3;
  116153. /**
  116154. * Stores the rotation quaternion
  116155. */
  116156. rotationQuaternion: Nullable<Quaternion>;
  116157. /**
  116158. * Stores the scaling vector
  116159. */
  116160. scaling: Vector3;
  116161. /**
  116162. * Convert the Mesh to CSG
  116163. * @param mesh The Mesh to convert to CSG
  116164. * @returns A new CSG from the Mesh
  116165. */
  116166. static FromMesh(mesh: Mesh): CSG;
  116167. /**
  116168. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  116169. * @param polygons Polygons used to construct a CSG solid
  116170. */
  116171. private static FromPolygons;
  116172. /**
  116173. * Clones, or makes a deep copy, of the CSG
  116174. * @returns A new CSG
  116175. */
  116176. clone(): CSG;
  116177. /**
  116178. * Unions this CSG with another CSG
  116179. * @param csg The CSG to union against this CSG
  116180. * @returns The unioned CSG
  116181. */
  116182. union(csg: CSG): CSG;
  116183. /**
  116184. * Unions this CSG with another CSG in place
  116185. * @param csg The CSG to union against this CSG
  116186. */
  116187. unionInPlace(csg: CSG): void;
  116188. /**
  116189. * Subtracts this CSG with another CSG
  116190. * @param csg The CSG to subtract against this CSG
  116191. * @returns A new CSG
  116192. */
  116193. subtract(csg: CSG): CSG;
  116194. /**
  116195. * Subtracts this CSG with another CSG in place
  116196. * @param csg The CSG to subtact against this CSG
  116197. */
  116198. subtractInPlace(csg: CSG): void;
  116199. /**
  116200. * Intersect this CSG with another CSG
  116201. * @param csg The CSG to intersect against this CSG
  116202. * @returns A new CSG
  116203. */
  116204. intersect(csg: CSG): CSG;
  116205. /**
  116206. * Intersects this CSG with another CSG in place
  116207. * @param csg The CSG to intersect against this CSG
  116208. */
  116209. intersectInPlace(csg: CSG): void;
  116210. /**
  116211. * Return a new CSG solid with solid and empty space switched. This solid is
  116212. * not modified.
  116213. * @returns A new CSG solid with solid and empty space switched
  116214. */
  116215. inverse(): CSG;
  116216. /**
  116217. * Inverses the CSG in place
  116218. */
  116219. inverseInPlace(): void;
  116220. /**
  116221. * This is used to keep meshes transformations so they can be restored
  116222. * when we build back a Babylon Mesh
  116223. * NB : All CSG operations are performed in world coordinates
  116224. * @param csg The CSG to copy the transform attributes from
  116225. * @returns This CSG
  116226. */
  116227. copyTransformAttributes(csg: CSG): CSG;
  116228. /**
  116229. * Build Raw mesh from CSG
  116230. * Coordinates here are in world space
  116231. * @param name The name of the mesh geometry
  116232. * @param scene The Scene
  116233. * @param keepSubMeshes Specifies if the submeshes should be kept
  116234. * @returns A new Mesh
  116235. */
  116236. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  116237. /**
  116238. * Build Mesh from CSG taking material and transforms into account
  116239. * @param name The name of the Mesh
  116240. * @param material The material of the Mesh
  116241. * @param scene The Scene
  116242. * @param keepSubMeshes Specifies if submeshes should be kept
  116243. * @returns The new Mesh
  116244. */
  116245. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  116246. }
  116247. }
  116248. declare module BABYLON {
  116249. /**
  116250. * Class used to create a trail following a mesh
  116251. */
  116252. export class TrailMesh extends Mesh {
  116253. private _generator;
  116254. private _autoStart;
  116255. private _running;
  116256. private _diameter;
  116257. private _length;
  116258. private _sectionPolygonPointsCount;
  116259. private _sectionVectors;
  116260. private _sectionNormalVectors;
  116261. private _beforeRenderObserver;
  116262. /**
  116263. * @constructor
  116264. * @param name The value used by scene.getMeshByName() to do a lookup.
  116265. * @param generator The mesh to generate a trail.
  116266. * @param scene The scene to add this mesh to.
  116267. * @param diameter Diameter of trailing mesh. Default is 1.
  116268. * @param length Length of trailing mesh. Default is 60.
  116269. * @param autoStart Automatically start trailing mesh. Default true.
  116270. */
  116271. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  116272. /**
  116273. * "TrailMesh"
  116274. * @returns "TrailMesh"
  116275. */
  116276. getClassName(): string;
  116277. private _createMesh;
  116278. /**
  116279. * Start trailing mesh.
  116280. */
  116281. start(): void;
  116282. /**
  116283. * Stop trailing mesh.
  116284. */
  116285. stop(): void;
  116286. /**
  116287. * Update trailing mesh geometry.
  116288. */
  116289. update(): void;
  116290. /**
  116291. * Returns a new TrailMesh object.
  116292. * @param name is a string, the name given to the new mesh
  116293. * @param newGenerator use new generator object for cloned trail mesh
  116294. * @returns a new mesh
  116295. */
  116296. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  116297. /**
  116298. * Serializes this trail mesh
  116299. * @param serializationObject object to write serialization to
  116300. */
  116301. serialize(serializationObject: any): void;
  116302. /**
  116303. * Parses a serialized trail mesh
  116304. * @param parsedMesh the serialized mesh
  116305. * @param scene the scene to create the trail mesh in
  116306. * @returns the created trail mesh
  116307. */
  116308. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  116309. }
  116310. }
  116311. declare module BABYLON {
  116312. /**
  116313. * Class containing static functions to help procedurally build meshes
  116314. */
  116315. export class TiledBoxBuilder {
  116316. /**
  116317. * Creates a box mesh
  116318. * 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)
  116319. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  116320. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116321. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116323. * @param name defines the name of the mesh
  116324. * @param options defines the options used to create the mesh
  116325. * @param scene defines the hosting scene
  116326. * @returns the box mesh
  116327. */
  116328. static CreateTiledBox(name: string, options: {
  116329. pattern?: number;
  116330. width?: number;
  116331. height?: number;
  116332. depth?: number;
  116333. tileSize?: number;
  116334. tileWidth?: number;
  116335. tileHeight?: number;
  116336. alignHorizontal?: number;
  116337. alignVertical?: number;
  116338. faceUV?: Vector4[];
  116339. faceColors?: Color4[];
  116340. sideOrientation?: number;
  116341. updatable?: boolean;
  116342. }, scene?: Nullable<Scene>): Mesh;
  116343. }
  116344. }
  116345. declare module BABYLON {
  116346. /**
  116347. * Class containing static functions to help procedurally build meshes
  116348. */
  116349. export class TorusKnotBuilder {
  116350. /**
  116351. * Creates a torus knot mesh
  116352. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  116353. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  116354. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  116355. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  116356. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116357. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116359. * @param name defines the name of the mesh
  116360. * @param options defines the options used to create the mesh
  116361. * @param scene defines the hosting scene
  116362. * @returns the torus knot mesh
  116363. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  116364. */
  116365. static CreateTorusKnot(name: string, options: {
  116366. radius?: number;
  116367. tube?: number;
  116368. radialSegments?: number;
  116369. tubularSegments?: number;
  116370. p?: number;
  116371. q?: number;
  116372. updatable?: boolean;
  116373. sideOrientation?: number;
  116374. frontUVs?: Vector4;
  116375. backUVs?: Vector4;
  116376. }, scene: any): Mesh;
  116377. }
  116378. }
  116379. declare module BABYLON {
  116380. /**
  116381. * Polygon
  116382. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  116383. */
  116384. export class Polygon {
  116385. /**
  116386. * Creates a rectangle
  116387. * @param xmin bottom X coord
  116388. * @param ymin bottom Y coord
  116389. * @param xmax top X coord
  116390. * @param ymax top Y coord
  116391. * @returns points that make the resulting rectation
  116392. */
  116393. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  116394. /**
  116395. * Creates a circle
  116396. * @param radius radius of circle
  116397. * @param cx scale in x
  116398. * @param cy scale in y
  116399. * @param numberOfSides number of sides that make up the circle
  116400. * @returns points that make the resulting circle
  116401. */
  116402. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  116403. /**
  116404. * Creates a polygon from input string
  116405. * @param input Input polygon data
  116406. * @returns the parsed points
  116407. */
  116408. static Parse(input: string): Vector2[];
  116409. /**
  116410. * Starts building a polygon from x and y coordinates
  116411. * @param x x coordinate
  116412. * @param y y coordinate
  116413. * @returns the started path2
  116414. */
  116415. static StartingAt(x: number, y: number): Path2;
  116416. }
  116417. /**
  116418. * Builds a polygon
  116419. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  116420. */
  116421. export class PolygonMeshBuilder {
  116422. private _points;
  116423. private _outlinepoints;
  116424. private _holes;
  116425. private _name;
  116426. private _scene;
  116427. private _epoints;
  116428. private _eholes;
  116429. private _addToepoint;
  116430. /**
  116431. * Babylon reference to the earcut plugin.
  116432. */
  116433. bjsEarcut: any;
  116434. /**
  116435. * Creates a PolygonMeshBuilder
  116436. * @param name name of the builder
  116437. * @param contours Path of the polygon
  116438. * @param scene scene to add to when creating the mesh
  116439. * @param earcutInjection can be used to inject your own earcut reference
  116440. */
  116441. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  116442. /**
  116443. * Adds a whole within the polygon
  116444. * @param hole Array of points defining the hole
  116445. * @returns this
  116446. */
  116447. addHole(hole: Vector2[]): PolygonMeshBuilder;
  116448. /**
  116449. * Creates the polygon
  116450. * @param updatable If the mesh should be updatable
  116451. * @param depth The depth of the mesh created
  116452. * @returns the created mesh
  116453. */
  116454. build(updatable?: boolean, depth?: number): Mesh;
  116455. /**
  116456. * Creates the polygon
  116457. * @param depth The depth of the mesh created
  116458. * @returns the created VertexData
  116459. */
  116460. buildVertexData(depth?: number): VertexData;
  116461. /**
  116462. * Adds a side to the polygon
  116463. * @param positions points that make the polygon
  116464. * @param normals normals of the polygon
  116465. * @param uvs uvs of the polygon
  116466. * @param indices indices of the polygon
  116467. * @param bounds bounds of the polygon
  116468. * @param points points of the polygon
  116469. * @param depth depth of the polygon
  116470. * @param flip flip of the polygon
  116471. */
  116472. private addSide;
  116473. }
  116474. }
  116475. declare module BABYLON {
  116476. /**
  116477. * Class containing static functions to help procedurally build meshes
  116478. */
  116479. export class PolygonBuilder {
  116480. /**
  116481. * Creates a polygon mesh
  116482. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  116483. * * 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
  116484. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  116485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116486. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  116487. * * Remember you can only change the shape positions, not their number when updating a polygon
  116488. * @param name defines the name of the mesh
  116489. * @param options defines the options used to create the mesh
  116490. * @param scene defines the hosting scene
  116491. * @param earcutInjection can be used to inject your own earcut reference
  116492. * @returns the polygon mesh
  116493. */
  116494. static CreatePolygon(name: string, options: {
  116495. shape: Vector3[];
  116496. holes?: Vector3[][];
  116497. depth?: number;
  116498. faceUV?: Vector4[];
  116499. faceColors?: Color4[];
  116500. updatable?: boolean;
  116501. sideOrientation?: number;
  116502. frontUVs?: Vector4;
  116503. backUVs?: Vector4;
  116504. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  116505. /**
  116506. * Creates an extruded polygon mesh, with depth in the Y direction.
  116507. * * 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)
  116508. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  116509. * @param name defines the name of the mesh
  116510. * @param options defines the options used to create the mesh
  116511. * @param scene defines the hosting scene
  116512. * @param earcutInjection can be used to inject your own earcut reference
  116513. * @returns the polygon mesh
  116514. */
  116515. static ExtrudePolygon(name: string, options: {
  116516. shape: Vector3[];
  116517. holes?: Vector3[][];
  116518. depth?: number;
  116519. faceUV?: Vector4[];
  116520. faceColors?: Color4[];
  116521. updatable?: boolean;
  116522. sideOrientation?: number;
  116523. frontUVs?: Vector4;
  116524. backUVs?: Vector4;
  116525. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  116526. }
  116527. }
  116528. declare module BABYLON {
  116529. /**
  116530. * Class containing static functions to help procedurally build meshes
  116531. */
  116532. export class LatheBuilder {
  116533. /**
  116534. * Creates lathe mesh.
  116535. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  116536. * * 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
  116537. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  116538. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  116539. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  116540. * * 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
  116541. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  116542. * * 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
  116543. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116544. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116545. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116547. * @param name defines the name of the mesh
  116548. * @param options defines the options used to create the mesh
  116549. * @param scene defines the hosting scene
  116550. * @returns the lathe mesh
  116551. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  116552. */
  116553. static CreateLathe(name: string, options: {
  116554. shape: Vector3[];
  116555. radius?: number;
  116556. tessellation?: number;
  116557. clip?: number;
  116558. arc?: number;
  116559. closed?: boolean;
  116560. updatable?: boolean;
  116561. sideOrientation?: number;
  116562. frontUVs?: Vector4;
  116563. backUVs?: Vector4;
  116564. cap?: number;
  116565. invertUV?: boolean;
  116566. }, scene?: Nullable<Scene>): Mesh;
  116567. }
  116568. }
  116569. declare module BABYLON {
  116570. /**
  116571. * Class containing static functions to help procedurally build meshes
  116572. */
  116573. export class TiledPlaneBuilder {
  116574. /**
  116575. * Creates a tiled plane mesh
  116576. * * The parameter `pattern` will, depending on value, do nothing or
  116577. * * * flip (reflect about central vertical) alternate tiles across and up
  116578. * * * flip every tile on alternate rows
  116579. * * * rotate (180 degs) alternate tiles across and up
  116580. * * * rotate every tile on alternate rows
  116581. * * * flip and rotate alternate tiles across and up
  116582. * * * flip and rotate every tile on alternate rows
  116583. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  116584. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  116585. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116586. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  116587. * * 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)
  116588. * * 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)
  116589. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  116590. * @param name defines the name of the mesh
  116591. * @param options defines the options used to create the mesh
  116592. * @param scene defines the hosting scene
  116593. * @returns the box mesh
  116594. */
  116595. static CreateTiledPlane(name: string, options: {
  116596. pattern?: number;
  116597. tileSize?: number;
  116598. tileWidth?: number;
  116599. tileHeight?: number;
  116600. size?: number;
  116601. width?: number;
  116602. height?: number;
  116603. alignHorizontal?: number;
  116604. alignVertical?: number;
  116605. sideOrientation?: number;
  116606. frontUVs?: Vector4;
  116607. backUVs?: Vector4;
  116608. updatable?: boolean;
  116609. }, scene?: Nullable<Scene>): Mesh;
  116610. }
  116611. }
  116612. declare module BABYLON {
  116613. /**
  116614. * Class containing static functions to help procedurally build meshes
  116615. */
  116616. export class TubeBuilder {
  116617. /**
  116618. * Creates a tube mesh.
  116619. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  116620. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  116621. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  116622. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  116623. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  116624. * * 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)
  116625. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  116626. * * 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
  116627. * * 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
  116628. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116629. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116630. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116632. * @param name defines the name of the mesh
  116633. * @param options defines the options used to create the mesh
  116634. * @param scene defines the hosting scene
  116635. * @returns the tube mesh
  116636. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116637. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  116638. */
  116639. static CreateTube(name: string, options: {
  116640. path: Vector3[];
  116641. radius?: number;
  116642. tessellation?: number;
  116643. radiusFunction?: {
  116644. (i: number, distance: number): number;
  116645. };
  116646. cap?: number;
  116647. arc?: number;
  116648. updatable?: boolean;
  116649. sideOrientation?: number;
  116650. frontUVs?: Vector4;
  116651. backUVs?: Vector4;
  116652. instance?: Mesh;
  116653. invertUV?: boolean;
  116654. }, scene?: Nullable<Scene>): Mesh;
  116655. }
  116656. }
  116657. declare module BABYLON {
  116658. /**
  116659. * Class containing static functions to help procedurally build meshes
  116660. */
  116661. export class IcoSphereBuilder {
  116662. /**
  116663. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  116664. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  116665. * * 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`)
  116666. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  116667. * * 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
  116668. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116669. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116671. * @param name defines the name of the mesh
  116672. * @param options defines the options used to create the mesh
  116673. * @param scene defines the hosting scene
  116674. * @returns the icosahedron mesh
  116675. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  116676. */
  116677. static CreateIcoSphere(name: string, options: {
  116678. radius?: number;
  116679. radiusX?: number;
  116680. radiusY?: number;
  116681. radiusZ?: number;
  116682. flat?: boolean;
  116683. subdivisions?: number;
  116684. sideOrientation?: number;
  116685. frontUVs?: Vector4;
  116686. backUVs?: Vector4;
  116687. updatable?: boolean;
  116688. }, scene?: Nullable<Scene>): Mesh;
  116689. }
  116690. }
  116691. declare module BABYLON {
  116692. /**
  116693. * Class containing static functions to help procedurally build meshes
  116694. */
  116695. export class DecalBuilder {
  116696. /**
  116697. * Creates a decal mesh.
  116698. * 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
  116699. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  116700. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  116701. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  116702. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  116703. * @param name defines the name of the mesh
  116704. * @param sourceMesh defines the mesh where the decal must be applied
  116705. * @param options defines the options used to create the mesh
  116706. * @param scene defines the hosting scene
  116707. * @returns the decal mesh
  116708. * @see https://doc.babylonjs.com/how_to/decals
  116709. */
  116710. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  116711. position?: Vector3;
  116712. normal?: Vector3;
  116713. size?: Vector3;
  116714. angle?: number;
  116715. }): Mesh;
  116716. }
  116717. }
  116718. declare module BABYLON {
  116719. /**
  116720. * Class containing static functions to help procedurally build meshes
  116721. */
  116722. export class MeshBuilder {
  116723. /**
  116724. * Creates a box mesh
  116725. * * The parameter `size` sets the size (float) of each box side (default 1)
  116726. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  116727. * * 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)
  116728. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  116729. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116730. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116731. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116732. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  116733. * @param name defines the name of the mesh
  116734. * @param options defines the options used to create the mesh
  116735. * @param scene defines the hosting scene
  116736. * @returns the box mesh
  116737. */
  116738. static CreateBox(name: string, options: {
  116739. size?: number;
  116740. width?: number;
  116741. height?: number;
  116742. depth?: number;
  116743. faceUV?: Vector4[];
  116744. faceColors?: Color4[];
  116745. sideOrientation?: number;
  116746. frontUVs?: Vector4;
  116747. backUVs?: Vector4;
  116748. updatable?: boolean;
  116749. }, scene?: Nullable<Scene>): Mesh;
  116750. /**
  116751. * Creates a tiled box mesh
  116752. * * faceTiles sets the pattern, tile size and number of tiles for a face
  116753. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116754. * @param name defines the name of the mesh
  116755. * @param options defines the options used to create the mesh
  116756. * @param scene defines the hosting scene
  116757. * @returns the tiled box mesh
  116758. */
  116759. static CreateTiledBox(name: string, options: {
  116760. pattern?: number;
  116761. size?: number;
  116762. width?: number;
  116763. height?: number;
  116764. depth: number;
  116765. tileSize?: number;
  116766. tileWidth?: number;
  116767. tileHeight?: number;
  116768. faceUV?: Vector4[];
  116769. faceColors?: Color4[];
  116770. alignHorizontal?: number;
  116771. alignVertical?: number;
  116772. sideOrientation?: number;
  116773. updatable?: boolean;
  116774. }, scene?: Nullable<Scene>): Mesh;
  116775. /**
  116776. * Creates a sphere mesh
  116777. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  116778. * * 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`)
  116779. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  116780. * * 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
  116781. * * 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)
  116782. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116783. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116784. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116785. * @param name defines the name of the mesh
  116786. * @param options defines the options used to create the mesh
  116787. * @param scene defines the hosting scene
  116788. * @returns the sphere mesh
  116789. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  116790. */
  116791. static CreateSphere(name: string, options: {
  116792. segments?: number;
  116793. diameter?: number;
  116794. diameterX?: number;
  116795. diameterY?: number;
  116796. diameterZ?: number;
  116797. arc?: number;
  116798. slice?: number;
  116799. sideOrientation?: number;
  116800. frontUVs?: Vector4;
  116801. backUVs?: Vector4;
  116802. updatable?: boolean;
  116803. }, scene?: Nullable<Scene>): Mesh;
  116804. /**
  116805. * Creates a plane polygonal mesh. By default, this is a disc
  116806. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  116807. * * 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
  116808. * * 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
  116809. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116810. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116811. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116812. * @param name defines the name of the mesh
  116813. * @param options defines the options used to create the mesh
  116814. * @param scene defines the hosting scene
  116815. * @returns the plane polygonal mesh
  116816. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  116817. */
  116818. static CreateDisc(name: string, options: {
  116819. radius?: number;
  116820. tessellation?: number;
  116821. arc?: number;
  116822. updatable?: boolean;
  116823. sideOrientation?: number;
  116824. frontUVs?: Vector4;
  116825. backUVs?: Vector4;
  116826. }, scene?: Nullable<Scene>): Mesh;
  116827. /**
  116828. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  116829. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  116830. * * 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`)
  116831. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  116832. * * 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
  116833. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116834. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116835. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116836. * @param name defines the name of the mesh
  116837. * @param options defines the options used to create the mesh
  116838. * @param scene defines the hosting scene
  116839. * @returns the icosahedron mesh
  116840. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  116841. */
  116842. static CreateIcoSphere(name: string, options: {
  116843. radius?: number;
  116844. radiusX?: number;
  116845. radiusY?: number;
  116846. radiusZ?: number;
  116847. flat?: boolean;
  116848. subdivisions?: number;
  116849. sideOrientation?: number;
  116850. frontUVs?: Vector4;
  116851. backUVs?: Vector4;
  116852. updatable?: boolean;
  116853. }, scene?: Nullable<Scene>): Mesh;
  116854. /**
  116855. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  116856. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  116857. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  116858. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  116859. * * 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
  116860. * * 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
  116861. * * 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
  116862. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116863. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116864. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116865. * * 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
  116866. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  116867. * * 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
  116868. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  116869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116870. * @param name defines the name of the mesh
  116871. * @param options defines the options used to create the mesh
  116872. * @param scene defines the hosting scene
  116873. * @returns the ribbon mesh
  116874. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  116875. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116876. */
  116877. static CreateRibbon(name: string, options: {
  116878. pathArray: Vector3[][];
  116879. closeArray?: boolean;
  116880. closePath?: boolean;
  116881. offset?: number;
  116882. updatable?: boolean;
  116883. sideOrientation?: number;
  116884. frontUVs?: Vector4;
  116885. backUVs?: Vector4;
  116886. instance?: Mesh;
  116887. invertUV?: boolean;
  116888. uvs?: Vector2[];
  116889. colors?: Color4[];
  116890. }, scene?: Nullable<Scene>): Mesh;
  116891. /**
  116892. * Creates a cylinder or a cone mesh
  116893. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  116894. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  116895. * * 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.
  116896. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  116897. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  116898. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  116899. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  116900. * * 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).
  116901. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  116902. * * 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).
  116903. * * 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
  116904. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  116905. * * 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
  116906. * * 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.
  116907. * * If `enclose` is false, a ring surface is one element.
  116908. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  116909. * * 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
  116910. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116911. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116912. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116913. * @param name defines the name of the mesh
  116914. * @param options defines the options used to create the mesh
  116915. * @param scene defines the hosting scene
  116916. * @returns the cylinder mesh
  116917. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  116918. */
  116919. static CreateCylinder(name: string, options: {
  116920. height?: number;
  116921. diameterTop?: number;
  116922. diameterBottom?: number;
  116923. diameter?: number;
  116924. tessellation?: number;
  116925. subdivisions?: number;
  116926. arc?: number;
  116927. faceColors?: Color4[];
  116928. faceUV?: Vector4[];
  116929. updatable?: boolean;
  116930. hasRings?: boolean;
  116931. enclose?: boolean;
  116932. cap?: number;
  116933. sideOrientation?: number;
  116934. frontUVs?: Vector4;
  116935. backUVs?: Vector4;
  116936. }, scene?: Nullable<Scene>): Mesh;
  116937. /**
  116938. * Creates a torus mesh
  116939. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  116940. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  116941. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  116942. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116943. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116945. * @param name defines the name of the mesh
  116946. * @param options defines the options used to create the mesh
  116947. * @param scene defines the hosting scene
  116948. * @returns the torus mesh
  116949. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  116950. */
  116951. static CreateTorus(name: string, options: {
  116952. diameter?: number;
  116953. thickness?: number;
  116954. tessellation?: number;
  116955. updatable?: boolean;
  116956. sideOrientation?: number;
  116957. frontUVs?: Vector4;
  116958. backUVs?: Vector4;
  116959. }, scene?: Nullable<Scene>): Mesh;
  116960. /**
  116961. * Creates a torus knot mesh
  116962. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  116963. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  116964. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  116965. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  116966. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116967. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116969. * @param name defines the name of the mesh
  116970. * @param options defines the options used to create the mesh
  116971. * @param scene defines the hosting scene
  116972. * @returns the torus knot mesh
  116973. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  116974. */
  116975. static CreateTorusKnot(name: string, options: {
  116976. radius?: number;
  116977. tube?: number;
  116978. radialSegments?: number;
  116979. tubularSegments?: number;
  116980. p?: number;
  116981. q?: number;
  116982. updatable?: boolean;
  116983. sideOrientation?: number;
  116984. frontUVs?: Vector4;
  116985. backUVs?: Vector4;
  116986. }, scene?: Nullable<Scene>): Mesh;
  116987. /**
  116988. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  116989. * * 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
  116990. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  116991. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  116992. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  116993. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  116994. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  116995. * * 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
  116996. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  116997. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116998. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  116999. * @param name defines the name of the new line system
  117000. * @param options defines the options used to create the line system
  117001. * @param scene defines the hosting scene
  117002. * @returns a new line system mesh
  117003. */
  117004. static CreateLineSystem(name: string, options: {
  117005. lines: Vector3[][];
  117006. updatable?: boolean;
  117007. instance?: Nullable<LinesMesh>;
  117008. colors?: Nullable<Color4[][]>;
  117009. useVertexAlpha?: boolean;
  117010. }, scene: Nullable<Scene>): LinesMesh;
  117011. /**
  117012. * Creates a line mesh
  117013. * 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
  117014. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  117015. * * The parameter `points` is an array successive Vector3
  117016. * * 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
  117017. * * The optional parameter `colors` is an array of successive Color4, one per line point
  117018. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  117019. * * When updating an instance, remember that only point positions can change, not the number of points
  117020. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117021. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  117022. * @param name defines the name of the new line system
  117023. * @param options defines the options used to create the line system
  117024. * @param scene defines the hosting scene
  117025. * @returns a new line mesh
  117026. */
  117027. static CreateLines(name: string, options: {
  117028. points: Vector3[];
  117029. updatable?: boolean;
  117030. instance?: Nullable<LinesMesh>;
  117031. colors?: Color4[];
  117032. useVertexAlpha?: boolean;
  117033. }, scene?: Nullable<Scene>): LinesMesh;
  117034. /**
  117035. * Creates a dashed line mesh
  117036. * * 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
  117037. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  117038. * * The parameter `points` is an array successive Vector3
  117039. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  117040. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  117041. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  117042. * * 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
  117043. * * When updating an instance, remember that only point positions can change, not the number of points
  117044. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117045. * @param name defines the name of the mesh
  117046. * @param options defines the options used to create the mesh
  117047. * @param scene defines the hosting scene
  117048. * @returns the dashed line mesh
  117049. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  117050. */
  117051. static CreateDashedLines(name: string, options: {
  117052. points: Vector3[];
  117053. dashSize?: number;
  117054. gapSize?: number;
  117055. dashNb?: number;
  117056. updatable?: boolean;
  117057. instance?: LinesMesh;
  117058. }, scene?: Nullable<Scene>): LinesMesh;
  117059. /**
  117060. * 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.
  117061. * * 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.
  117062. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  117063. * * 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.
  117064. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  117065. * * 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
  117066. * * 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
  117067. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  117068. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117069. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117070. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  117071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117072. * @param name defines the name of the mesh
  117073. * @param options defines the options used to create the mesh
  117074. * @param scene defines the hosting scene
  117075. * @returns the extruded shape mesh
  117076. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117077. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  117078. */
  117079. static ExtrudeShape(name: string, options: {
  117080. shape: Vector3[];
  117081. path: Vector3[];
  117082. scale?: number;
  117083. rotation?: number;
  117084. cap?: number;
  117085. updatable?: boolean;
  117086. sideOrientation?: number;
  117087. frontUVs?: Vector4;
  117088. backUVs?: Vector4;
  117089. instance?: Mesh;
  117090. invertUV?: boolean;
  117091. }, scene?: Nullable<Scene>): Mesh;
  117092. /**
  117093. * Creates an custom extruded shape mesh.
  117094. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  117095. * * 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.
  117096. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  117097. * * 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
  117098. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  117099. * * 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
  117100. * * It must returns a float value that will be the scale value applied to the shape on each path point
  117101. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  117102. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  117103. * * 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
  117104. * * 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
  117105. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  117106. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117107. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117108. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117110. * @param name defines the name of the mesh
  117111. * @param options defines the options used to create the mesh
  117112. * @param scene defines the hosting scene
  117113. * @returns the custom extruded shape mesh
  117114. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  117115. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117116. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  117117. */
  117118. static ExtrudeShapeCustom(name: string, options: {
  117119. shape: Vector3[];
  117120. path: Vector3[];
  117121. scaleFunction?: any;
  117122. rotationFunction?: any;
  117123. ribbonCloseArray?: boolean;
  117124. ribbonClosePath?: boolean;
  117125. cap?: number;
  117126. updatable?: boolean;
  117127. sideOrientation?: number;
  117128. frontUVs?: Vector4;
  117129. backUVs?: Vector4;
  117130. instance?: Mesh;
  117131. invertUV?: boolean;
  117132. }, scene?: Nullable<Scene>): Mesh;
  117133. /**
  117134. * Creates lathe mesh.
  117135. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  117136. * * 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
  117137. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  117138. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  117139. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  117140. * * 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
  117141. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  117142. * * 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
  117143. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117144. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117145. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117146. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117147. * @param name defines the name of the mesh
  117148. * @param options defines the options used to create the mesh
  117149. * @param scene defines the hosting scene
  117150. * @returns the lathe mesh
  117151. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  117152. */
  117153. static CreateLathe(name: string, options: {
  117154. shape: Vector3[];
  117155. radius?: number;
  117156. tessellation?: number;
  117157. clip?: number;
  117158. arc?: number;
  117159. closed?: boolean;
  117160. updatable?: boolean;
  117161. sideOrientation?: number;
  117162. frontUVs?: Vector4;
  117163. backUVs?: Vector4;
  117164. cap?: number;
  117165. invertUV?: boolean;
  117166. }, scene?: Nullable<Scene>): Mesh;
  117167. /**
  117168. * Creates a tiled plane mesh
  117169. * * You can set a limited pattern arrangement with the tiles
  117170. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117171. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117172. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117173. * @param name defines the name of the mesh
  117174. * @param options defines the options used to create the mesh
  117175. * @param scene defines the hosting scene
  117176. * @returns the plane mesh
  117177. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  117178. */
  117179. static CreateTiledPlane(name: string, options: {
  117180. pattern?: number;
  117181. tileSize?: number;
  117182. tileWidth?: number;
  117183. tileHeight?: number;
  117184. size?: number;
  117185. width?: number;
  117186. height?: number;
  117187. alignHorizontal?: number;
  117188. alignVertical?: number;
  117189. sideOrientation?: number;
  117190. frontUVs?: Vector4;
  117191. backUVs?: Vector4;
  117192. updatable?: boolean;
  117193. }, scene?: Nullable<Scene>): Mesh;
  117194. /**
  117195. * Creates a plane mesh
  117196. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  117197. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  117198. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  117199. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117200. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117201. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117202. * @param name defines the name of the mesh
  117203. * @param options defines the options used to create the mesh
  117204. * @param scene defines the hosting scene
  117205. * @returns the plane mesh
  117206. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  117207. */
  117208. static CreatePlane(name: string, options: {
  117209. size?: number;
  117210. width?: number;
  117211. height?: number;
  117212. sideOrientation?: number;
  117213. frontUVs?: Vector4;
  117214. backUVs?: Vector4;
  117215. updatable?: boolean;
  117216. sourcePlane?: Plane;
  117217. }, scene?: Nullable<Scene>): Mesh;
  117218. /**
  117219. * Creates a ground mesh
  117220. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  117221. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  117222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117223. * @param name defines the name of the mesh
  117224. * @param options defines the options used to create the mesh
  117225. * @param scene defines the hosting scene
  117226. * @returns the ground mesh
  117227. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  117228. */
  117229. static CreateGround(name: string, options: {
  117230. width?: number;
  117231. height?: number;
  117232. subdivisions?: number;
  117233. subdivisionsX?: number;
  117234. subdivisionsY?: number;
  117235. updatable?: boolean;
  117236. }, scene?: Nullable<Scene>): Mesh;
  117237. /**
  117238. * Creates a tiled ground mesh
  117239. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  117240. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  117241. * * 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
  117242. * * 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
  117243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117244. * @param name defines the name of the mesh
  117245. * @param options defines the options used to create the mesh
  117246. * @param scene defines the hosting scene
  117247. * @returns the tiled ground mesh
  117248. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  117249. */
  117250. static CreateTiledGround(name: string, options: {
  117251. xmin: number;
  117252. zmin: number;
  117253. xmax: number;
  117254. zmax: number;
  117255. subdivisions?: {
  117256. w: number;
  117257. h: number;
  117258. };
  117259. precision?: {
  117260. w: number;
  117261. h: number;
  117262. };
  117263. updatable?: boolean;
  117264. }, scene?: Nullable<Scene>): Mesh;
  117265. /**
  117266. * Creates a ground mesh from a height map
  117267. * * The parameter `url` sets the URL of the height map image resource.
  117268. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  117269. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  117270. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  117271. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  117272. * * 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.
  117273. * * 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).
  117274. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  117275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117276. * @param name defines the name of the mesh
  117277. * @param url defines the url to the height map
  117278. * @param options defines the options used to create the mesh
  117279. * @param scene defines the hosting scene
  117280. * @returns the ground mesh
  117281. * @see https://doc.babylonjs.com/babylon101/height_map
  117282. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  117283. */
  117284. static CreateGroundFromHeightMap(name: string, url: string, options: {
  117285. width?: number;
  117286. height?: number;
  117287. subdivisions?: number;
  117288. minHeight?: number;
  117289. maxHeight?: number;
  117290. colorFilter?: Color3;
  117291. alphaFilter?: number;
  117292. updatable?: boolean;
  117293. onReady?: (mesh: GroundMesh) => void;
  117294. }, scene?: Nullable<Scene>): GroundMesh;
  117295. /**
  117296. * Creates a polygon mesh
  117297. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  117298. * * 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
  117299. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  117300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117301. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  117302. * * Remember you can only change the shape positions, not their number when updating a polygon
  117303. * @param name defines the name of the mesh
  117304. * @param options defines the options used to create the mesh
  117305. * @param scene defines the hosting scene
  117306. * @param earcutInjection can be used to inject your own earcut reference
  117307. * @returns the polygon mesh
  117308. */
  117309. static CreatePolygon(name: string, options: {
  117310. shape: Vector3[];
  117311. holes?: Vector3[][];
  117312. depth?: number;
  117313. faceUV?: Vector4[];
  117314. faceColors?: Color4[];
  117315. updatable?: boolean;
  117316. sideOrientation?: number;
  117317. frontUVs?: Vector4;
  117318. backUVs?: Vector4;
  117319. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  117320. /**
  117321. * Creates an extruded polygon mesh, with depth in the Y direction.
  117322. * * 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)
  117323. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  117324. * @param name defines the name of the mesh
  117325. * @param options defines the options used to create the mesh
  117326. * @param scene defines the hosting scene
  117327. * @param earcutInjection can be used to inject your own earcut reference
  117328. * @returns the polygon mesh
  117329. */
  117330. static ExtrudePolygon(name: string, options: {
  117331. shape: Vector3[];
  117332. holes?: Vector3[][];
  117333. depth?: number;
  117334. faceUV?: Vector4[];
  117335. faceColors?: Color4[];
  117336. updatable?: boolean;
  117337. sideOrientation?: number;
  117338. frontUVs?: Vector4;
  117339. backUVs?: Vector4;
  117340. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  117341. /**
  117342. * Creates a tube mesh.
  117343. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  117344. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  117345. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  117346. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  117347. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  117348. * * 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)
  117349. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  117350. * * 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
  117351. * * 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
  117352. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117353. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117354. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117356. * @param name defines the name of the mesh
  117357. * @param options defines the options used to create the mesh
  117358. * @param scene defines the hosting scene
  117359. * @returns the tube mesh
  117360. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117361. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  117362. */
  117363. static CreateTube(name: string, options: {
  117364. path: Vector3[];
  117365. radius?: number;
  117366. tessellation?: number;
  117367. radiusFunction?: {
  117368. (i: number, distance: number): number;
  117369. };
  117370. cap?: number;
  117371. arc?: number;
  117372. updatable?: boolean;
  117373. sideOrientation?: number;
  117374. frontUVs?: Vector4;
  117375. backUVs?: Vector4;
  117376. instance?: Mesh;
  117377. invertUV?: boolean;
  117378. }, scene?: Nullable<Scene>): Mesh;
  117379. /**
  117380. * Creates a polyhedron mesh
  117381. * * 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
  117382. * * The parameter `size` (positive float, default 1) sets the polygon size
  117383. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  117384. * * 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`
  117385. * * 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
  117386. * * 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)`)
  117387. * * 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
  117388. * * 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
  117389. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117390. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117391. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117392. * @param name defines the name of the mesh
  117393. * @param options defines the options used to create the mesh
  117394. * @param scene defines the hosting scene
  117395. * @returns the polyhedron mesh
  117396. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  117397. */
  117398. static CreatePolyhedron(name: string, options: {
  117399. type?: number;
  117400. size?: number;
  117401. sizeX?: number;
  117402. sizeY?: number;
  117403. sizeZ?: number;
  117404. custom?: any;
  117405. faceUV?: Vector4[];
  117406. faceColors?: Color4[];
  117407. flat?: boolean;
  117408. updatable?: boolean;
  117409. sideOrientation?: number;
  117410. frontUVs?: Vector4;
  117411. backUVs?: Vector4;
  117412. }, scene?: Nullable<Scene>): Mesh;
  117413. /**
  117414. * Creates a decal mesh.
  117415. * 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
  117416. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  117417. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  117418. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  117419. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  117420. * @param name defines the name of the mesh
  117421. * @param sourceMesh defines the mesh where the decal must be applied
  117422. * @param options defines the options used to create the mesh
  117423. * @param scene defines the hosting scene
  117424. * @returns the decal mesh
  117425. * @see https://doc.babylonjs.com/how_to/decals
  117426. */
  117427. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  117428. position?: Vector3;
  117429. normal?: Vector3;
  117430. size?: Vector3;
  117431. angle?: number;
  117432. }): Mesh;
  117433. }
  117434. }
  117435. declare module BABYLON {
  117436. /**
  117437. * A simplifier interface for future simplification implementations
  117438. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  117439. */
  117440. export interface ISimplifier {
  117441. /**
  117442. * Simplification of a given mesh according to the given settings.
  117443. * Since this requires computation, it is assumed that the function runs async.
  117444. * @param settings The settings of the simplification, including quality and distance
  117445. * @param successCallback A callback that will be called after the mesh was simplified.
  117446. * @param errorCallback in case of an error, this callback will be called. optional.
  117447. */
  117448. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  117449. }
  117450. /**
  117451. * Expected simplification settings.
  117452. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  117453. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  117454. */
  117455. export interface ISimplificationSettings {
  117456. /**
  117457. * Gets or sets the expected quality
  117458. */
  117459. quality: number;
  117460. /**
  117461. * Gets or sets the distance when this optimized version should be used
  117462. */
  117463. distance: number;
  117464. /**
  117465. * Gets an already optimized mesh
  117466. */
  117467. optimizeMesh?: boolean;
  117468. }
  117469. /**
  117470. * Class used to specify simplification options
  117471. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  117472. */
  117473. export class SimplificationSettings implements ISimplificationSettings {
  117474. /** expected quality */
  117475. quality: number;
  117476. /** distance when this optimized version should be used */
  117477. distance: number;
  117478. /** already optimized mesh */
  117479. optimizeMesh?: boolean | undefined;
  117480. /**
  117481. * Creates a SimplificationSettings
  117482. * @param quality expected quality
  117483. * @param distance distance when this optimized version should be used
  117484. * @param optimizeMesh already optimized mesh
  117485. */
  117486. constructor(
  117487. /** expected quality */
  117488. quality: number,
  117489. /** distance when this optimized version should be used */
  117490. distance: number,
  117491. /** already optimized mesh */
  117492. optimizeMesh?: boolean | undefined);
  117493. }
  117494. /**
  117495. * Interface used to define a simplification task
  117496. */
  117497. export interface ISimplificationTask {
  117498. /**
  117499. * Array of settings
  117500. */
  117501. settings: Array<ISimplificationSettings>;
  117502. /**
  117503. * Simplification type
  117504. */
  117505. simplificationType: SimplificationType;
  117506. /**
  117507. * Mesh to simplify
  117508. */
  117509. mesh: Mesh;
  117510. /**
  117511. * Callback called on success
  117512. */
  117513. successCallback?: () => void;
  117514. /**
  117515. * Defines if parallel processing can be used
  117516. */
  117517. parallelProcessing: boolean;
  117518. }
  117519. /**
  117520. * Queue used to order the simplification tasks
  117521. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  117522. */
  117523. export class SimplificationQueue {
  117524. private _simplificationArray;
  117525. /**
  117526. * Gets a boolean indicating that the process is still running
  117527. */
  117528. running: boolean;
  117529. /**
  117530. * Creates a new queue
  117531. */
  117532. constructor();
  117533. /**
  117534. * Adds a new simplification task
  117535. * @param task defines a task to add
  117536. */
  117537. addTask(task: ISimplificationTask): void;
  117538. /**
  117539. * Execute next task
  117540. */
  117541. executeNext(): void;
  117542. /**
  117543. * Execute a simplification task
  117544. * @param task defines the task to run
  117545. */
  117546. runSimplification(task: ISimplificationTask): void;
  117547. private getSimplifier;
  117548. }
  117549. /**
  117550. * The implemented types of simplification
  117551. * At the moment only Quadratic Error Decimation is implemented
  117552. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  117553. */
  117554. export enum SimplificationType {
  117555. /** Quadratic error decimation */
  117556. QUADRATIC = 0
  117557. }
  117558. }
  117559. declare module BABYLON {
  117560. interface Scene {
  117561. /** @hidden (Backing field) */
  117562. _simplificationQueue: SimplificationQueue;
  117563. /**
  117564. * Gets or sets the simplification queue attached to the scene
  117565. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  117566. */
  117567. simplificationQueue: SimplificationQueue;
  117568. }
  117569. interface Mesh {
  117570. /**
  117571. * Simplify the mesh according to the given array of settings.
  117572. * Function will return immediately and will simplify async
  117573. * @param settings a collection of simplification settings
  117574. * @param parallelProcessing should all levels calculate parallel or one after the other
  117575. * @param simplificationType the type of simplification to run
  117576. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  117577. * @returns the current mesh
  117578. */
  117579. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  117580. }
  117581. /**
  117582. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  117583. * created in a scene
  117584. */
  117585. export class SimplicationQueueSceneComponent implements ISceneComponent {
  117586. /**
  117587. * The component name helpfull to identify the component in the list of scene components.
  117588. */
  117589. readonly name: string;
  117590. /**
  117591. * The scene the component belongs to.
  117592. */
  117593. scene: Scene;
  117594. /**
  117595. * Creates a new instance of the component for the given scene
  117596. * @param scene Defines the scene to register the component in
  117597. */
  117598. constructor(scene: Scene);
  117599. /**
  117600. * Registers the component in a given scene
  117601. */
  117602. register(): void;
  117603. /**
  117604. * Rebuilds the elements related to this component in case of
  117605. * context lost for instance.
  117606. */
  117607. rebuild(): void;
  117608. /**
  117609. * Disposes the component and the associated ressources
  117610. */
  117611. dispose(): void;
  117612. private _beforeCameraUpdate;
  117613. }
  117614. }
  117615. declare module BABYLON {
  117616. /**
  117617. * Class used to enable access to IndexedDB
  117618. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  117619. */
  117620. export class Database implements IOfflineProvider {
  117621. private _callbackManifestChecked;
  117622. private _currentSceneUrl;
  117623. private _db;
  117624. private _enableSceneOffline;
  117625. private _enableTexturesOffline;
  117626. private _manifestVersionFound;
  117627. private _mustUpdateRessources;
  117628. private _hasReachedQuota;
  117629. private _isSupported;
  117630. private _idbFactory;
  117631. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  117632. private static IsUASupportingBlobStorage;
  117633. /**
  117634. * Gets a boolean indicating if Database storate is enabled (off by default)
  117635. */
  117636. static IDBStorageEnabled: boolean;
  117637. /**
  117638. * Gets a boolean indicating if scene must be saved in the database
  117639. */
  117640. readonly enableSceneOffline: boolean;
  117641. /**
  117642. * Gets a boolean indicating if textures must be saved in the database
  117643. */
  117644. readonly enableTexturesOffline: boolean;
  117645. /**
  117646. * Creates a new Database
  117647. * @param urlToScene defines the url to load the scene
  117648. * @param callbackManifestChecked defines the callback to use when manifest is checked
  117649. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  117650. */
  117651. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  117652. private static _ParseURL;
  117653. private static _ReturnFullUrlLocation;
  117654. private _checkManifestFile;
  117655. /**
  117656. * Open the database and make it available
  117657. * @param successCallback defines the callback to call on success
  117658. * @param errorCallback defines the callback to call on error
  117659. */
  117660. open(successCallback: () => void, errorCallback: () => void): void;
  117661. /**
  117662. * Loads an image from the database
  117663. * @param url defines the url to load from
  117664. * @param image defines the target DOM image
  117665. */
  117666. loadImage(url: string, image: HTMLImageElement): void;
  117667. private _loadImageFromDBAsync;
  117668. private _saveImageIntoDBAsync;
  117669. private _checkVersionFromDB;
  117670. private _loadVersionFromDBAsync;
  117671. private _saveVersionIntoDBAsync;
  117672. /**
  117673. * Loads a file from database
  117674. * @param url defines the URL to load from
  117675. * @param sceneLoaded defines a callback to call on success
  117676. * @param progressCallBack defines a callback to call when progress changed
  117677. * @param errorCallback defines a callback to call on error
  117678. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  117679. */
  117680. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  117681. private _loadFileAsync;
  117682. private _saveFileAsync;
  117683. /**
  117684. * Validates if xhr data is correct
  117685. * @param xhr defines the request to validate
  117686. * @param dataType defines the expected data type
  117687. * @returns true if data is correct
  117688. */
  117689. private static _ValidateXHRData;
  117690. }
  117691. }
  117692. declare module BABYLON {
  117693. /** @hidden */
  117694. export var gpuUpdateParticlesPixelShader: {
  117695. name: string;
  117696. shader: string;
  117697. };
  117698. }
  117699. declare module BABYLON {
  117700. /** @hidden */
  117701. export var gpuUpdateParticlesVertexShader: {
  117702. name: string;
  117703. shader: string;
  117704. };
  117705. }
  117706. declare module BABYLON {
  117707. /** @hidden */
  117708. export var clipPlaneFragmentDeclaration2: {
  117709. name: string;
  117710. shader: string;
  117711. };
  117712. }
  117713. declare module BABYLON {
  117714. /** @hidden */
  117715. export var gpuRenderParticlesPixelShader: {
  117716. name: string;
  117717. shader: string;
  117718. };
  117719. }
  117720. declare module BABYLON {
  117721. /** @hidden */
  117722. export var clipPlaneVertexDeclaration2: {
  117723. name: string;
  117724. shader: string;
  117725. };
  117726. }
  117727. declare module BABYLON {
  117728. /** @hidden */
  117729. export var gpuRenderParticlesVertexShader: {
  117730. name: string;
  117731. shader: string;
  117732. };
  117733. }
  117734. declare module BABYLON {
  117735. /**
  117736. * This represents a GPU particle system in Babylon
  117737. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  117738. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  117739. */
  117740. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  117741. /**
  117742. * The layer mask we are rendering the particles through.
  117743. */
  117744. layerMask: number;
  117745. private _capacity;
  117746. private _activeCount;
  117747. private _currentActiveCount;
  117748. private _accumulatedCount;
  117749. private _renderEffect;
  117750. private _updateEffect;
  117751. private _buffer0;
  117752. private _buffer1;
  117753. private _spriteBuffer;
  117754. private _updateVAO;
  117755. private _renderVAO;
  117756. private _targetIndex;
  117757. private _sourceBuffer;
  117758. private _targetBuffer;
  117759. private _engine;
  117760. private _currentRenderId;
  117761. private _started;
  117762. private _stopped;
  117763. private _timeDelta;
  117764. private _randomTexture;
  117765. private _randomTexture2;
  117766. private _attributesStrideSize;
  117767. private _updateEffectOptions;
  117768. private _randomTextureSize;
  117769. private _actualFrame;
  117770. private readonly _rawTextureWidth;
  117771. /**
  117772. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  117773. */
  117774. static readonly IsSupported: boolean;
  117775. /**
  117776. * An event triggered when the system is disposed.
  117777. */
  117778. onDisposeObservable: Observable<GPUParticleSystem>;
  117779. /**
  117780. * Gets the maximum number of particles active at the same time.
  117781. * @returns The max number of active particles.
  117782. */
  117783. getCapacity(): number;
  117784. /**
  117785. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  117786. * to override the particles.
  117787. */
  117788. forceDepthWrite: boolean;
  117789. /**
  117790. * Gets or set the number of active particles
  117791. */
  117792. activeParticleCount: number;
  117793. private _preWarmDone;
  117794. /**
  117795. * Is this system ready to be used/rendered
  117796. * @return true if the system is ready
  117797. */
  117798. isReady(): boolean;
  117799. /**
  117800. * Gets if the system has been started. (Note: this will still be true after stop is called)
  117801. * @returns True if it has been started, otherwise false.
  117802. */
  117803. isStarted(): boolean;
  117804. /**
  117805. * Starts the particle system and begins to emit
  117806. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  117807. */
  117808. start(delay?: number): void;
  117809. /**
  117810. * Stops the particle system.
  117811. */
  117812. stop(): void;
  117813. /**
  117814. * Remove all active particles
  117815. */
  117816. reset(): void;
  117817. /**
  117818. * Returns the string "GPUParticleSystem"
  117819. * @returns a string containing the class name
  117820. */
  117821. getClassName(): string;
  117822. private _colorGradientsTexture;
  117823. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  117824. /**
  117825. * Adds a new color gradient
  117826. * @param gradient defines the gradient to use (between 0 and 1)
  117827. * @param color1 defines the color to affect to the specified gradient
  117828. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  117829. * @returns the current particle system
  117830. */
  117831. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  117832. /**
  117833. * Remove a specific color gradient
  117834. * @param gradient defines the gradient to remove
  117835. * @returns the current particle system
  117836. */
  117837. removeColorGradient(gradient: number): GPUParticleSystem;
  117838. private _angularSpeedGradientsTexture;
  117839. private _sizeGradientsTexture;
  117840. private _velocityGradientsTexture;
  117841. private _limitVelocityGradientsTexture;
  117842. private _dragGradientsTexture;
  117843. private _addFactorGradient;
  117844. /**
  117845. * Adds a new size gradient
  117846. * @param gradient defines the gradient to use (between 0 and 1)
  117847. * @param factor defines the size factor to affect to the specified gradient
  117848. * @returns the current particle system
  117849. */
  117850. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  117851. /**
  117852. * Remove a specific size gradient
  117853. * @param gradient defines the gradient to remove
  117854. * @returns the current particle system
  117855. */
  117856. removeSizeGradient(gradient: number): GPUParticleSystem;
  117857. /**
  117858. * Adds a new angular speed gradient
  117859. * @param gradient defines the gradient to use (between 0 and 1)
  117860. * @param factor defines the angular speed to affect to the specified gradient
  117861. * @returns the current particle system
  117862. */
  117863. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  117864. /**
  117865. * Remove a specific angular speed gradient
  117866. * @param gradient defines the gradient to remove
  117867. * @returns the current particle system
  117868. */
  117869. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  117870. /**
  117871. * Adds a new velocity gradient
  117872. * @param gradient defines the gradient to use (between 0 and 1)
  117873. * @param factor defines the velocity to affect to the specified gradient
  117874. * @returns the current particle system
  117875. */
  117876. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  117877. /**
  117878. * Remove a specific velocity gradient
  117879. * @param gradient defines the gradient to remove
  117880. * @returns the current particle system
  117881. */
  117882. removeVelocityGradient(gradient: number): GPUParticleSystem;
  117883. /**
  117884. * Adds a new limit velocity gradient
  117885. * @param gradient defines the gradient to use (between 0 and 1)
  117886. * @param factor defines the limit velocity value to affect to the specified gradient
  117887. * @returns the current particle system
  117888. */
  117889. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  117890. /**
  117891. * Remove a specific limit velocity gradient
  117892. * @param gradient defines the gradient to remove
  117893. * @returns the current particle system
  117894. */
  117895. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  117896. /**
  117897. * Adds a new drag gradient
  117898. * @param gradient defines the gradient to use (between 0 and 1)
  117899. * @param factor defines the drag value to affect to the specified gradient
  117900. * @returns the current particle system
  117901. */
  117902. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  117903. /**
  117904. * Remove a specific drag gradient
  117905. * @param gradient defines the gradient to remove
  117906. * @returns the current particle system
  117907. */
  117908. removeDragGradient(gradient: number): GPUParticleSystem;
  117909. /**
  117910. * Not supported by GPUParticleSystem
  117911. * @param gradient defines the gradient to use (between 0 and 1)
  117912. * @param factor defines the emit rate value to affect to the specified gradient
  117913. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  117914. * @returns the current particle system
  117915. */
  117916. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  117917. /**
  117918. * Not supported by GPUParticleSystem
  117919. * @param gradient defines the gradient to remove
  117920. * @returns the current particle system
  117921. */
  117922. removeEmitRateGradient(gradient: number): IParticleSystem;
  117923. /**
  117924. * Not supported by GPUParticleSystem
  117925. * @param gradient defines the gradient to use (between 0 and 1)
  117926. * @param factor defines the start size value to affect to the specified gradient
  117927. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  117928. * @returns the current particle system
  117929. */
  117930. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  117931. /**
  117932. * Not supported by GPUParticleSystem
  117933. * @param gradient defines the gradient to remove
  117934. * @returns the current particle system
  117935. */
  117936. removeStartSizeGradient(gradient: number): IParticleSystem;
  117937. /**
  117938. * Not supported by GPUParticleSystem
  117939. * @param gradient defines the gradient to use (between 0 and 1)
  117940. * @param min defines the color remap minimal range
  117941. * @param max defines the color remap maximal range
  117942. * @returns the current particle system
  117943. */
  117944. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  117945. /**
  117946. * Not supported by GPUParticleSystem
  117947. * @param gradient defines the gradient to remove
  117948. * @returns the current particle system
  117949. */
  117950. removeColorRemapGradient(): IParticleSystem;
  117951. /**
  117952. * Not supported by GPUParticleSystem
  117953. * @param gradient defines the gradient to use (between 0 and 1)
  117954. * @param min defines the alpha remap minimal range
  117955. * @param max defines the alpha remap maximal range
  117956. * @returns the current particle system
  117957. */
  117958. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  117959. /**
  117960. * Not supported by GPUParticleSystem
  117961. * @param gradient defines the gradient to remove
  117962. * @returns the current particle system
  117963. */
  117964. removeAlphaRemapGradient(): IParticleSystem;
  117965. /**
  117966. * Not supported by GPUParticleSystem
  117967. * @param gradient defines the gradient to use (between 0 and 1)
  117968. * @param color defines the color to affect to the specified gradient
  117969. * @returns the current particle system
  117970. */
  117971. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  117972. /**
  117973. * Not supported by GPUParticleSystem
  117974. * @param gradient defines the gradient to remove
  117975. * @returns the current particle system
  117976. */
  117977. removeRampGradient(): IParticleSystem;
  117978. /**
  117979. * Not supported by GPUParticleSystem
  117980. * @returns the list of ramp gradients
  117981. */
  117982. getRampGradients(): Nullable<Array<Color3Gradient>>;
  117983. /**
  117984. * Not supported by GPUParticleSystem
  117985. * Gets or sets a boolean indicating that ramp gradients must be used
  117986. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  117987. */
  117988. useRampGradients: boolean;
  117989. /**
  117990. * Not supported by GPUParticleSystem
  117991. * @param gradient defines the gradient to use (between 0 and 1)
  117992. * @param factor defines the life time factor to affect to the specified gradient
  117993. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  117994. * @returns the current particle system
  117995. */
  117996. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  117997. /**
  117998. * Not supported by GPUParticleSystem
  117999. * @param gradient defines the gradient to remove
  118000. * @returns the current particle system
  118001. */
  118002. removeLifeTimeGradient(gradient: number): IParticleSystem;
  118003. /**
  118004. * Instantiates a GPU particle system.
  118005. * 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.
  118006. * @param name The name of the particle system
  118007. * @param options The options used to create the system
  118008. * @param scene The scene the particle system belongs to
  118009. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  118010. */
  118011. constructor(name: string, options: Partial<{
  118012. capacity: number;
  118013. randomTextureSize: number;
  118014. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  118015. protected _reset(): void;
  118016. private _createUpdateVAO;
  118017. private _createRenderVAO;
  118018. private _initialize;
  118019. /** @hidden */
  118020. _recreateUpdateEffect(): void;
  118021. /** @hidden */
  118022. _recreateRenderEffect(): void;
  118023. /**
  118024. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  118025. * @param preWarm defines if we are in the pre-warmimg phase
  118026. */
  118027. animate(preWarm?: boolean): void;
  118028. private _createFactorGradientTexture;
  118029. private _createSizeGradientTexture;
  118030. private _createAngularSpeedGradientTexture;
  118031. private _createVelocityGradientTexture;
  118032. private _createLimitVelocityGradientTexture;
  118033. private _createDragGradientTexture;
  118034. private _createColorGradientTexture;
  118035. /**
  118036. * Renders the particle system in its current state
  118037. * @param preWarm defines if the system should only update the particles but not render them
  118038. * @returns the current number of particles
  118039. */
  118040. render(preWarm?: boolean): number;
  118041. /**
  118042. * Rebuilds the particle system
  118043. */
  118044. rebuild(): void;
  118045. private _releaseBuffers;
  118046. private _releaseVAOs;
  118047. /**
  118048. * Disposes the particle system and free the associated resources
  118049. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  118050. */
  118051. dispose(disposeTexture?: boolean): void;
  118052. /**
  118053. * Clones the particle system.
  118054. * @param name The name of the cloned object
  118055. * @param newEmitter The new emitter to use
  118056. * @returns the cloned particle system
  118057. */
  118058. clone(name: string, newEmitter: any): GPUParticleSystem;
  118059. /**
  118060. * Serializes the particle system to a JSON object.
  118061. * @returns the JSON object
  118062. */
  118063. serialize(): any;
  118064. /**
  118065. * Parses a JSON object to create a GPU particle system.
  118066. * @param parsedParticleSystem The JSON object to parse
  118067. * @param scene The scene to create the particle system in
  118068. * @param rootUrl The root url to use to load external dependencies like texture
  118069. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  118070. * @returns the parsed GPU particle system
  118071. */
  118072. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  118073. }
  118074. }
  118075. declare module BABYLON {
  118076. /**
  118077. * Represents a set of particle systems working together to create a specific effect
  118078. */
  118079. export class ParticleSystemSet implements IDisposable {
  118080. private _emitterCreationOptions;
  118081. private _emitterNode;
  118082. /**
  118083. * Gets the particle system list
  118084. */
  118085. systems: IParticleSystem[];
  118086. /**
  118087. * Gets the emitter node used with this set
  118088. */
  118089. readonly emitterNode: Nullable<TransformNode>;
  118090. /**
  118091. * Creates a new emitter mesh as a sphere
  118092. * @param options defines the options used to create the sphere
  118093. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  118094. * @param scene defines the hosting scene
  118095. */
  118096. setEmitterAsSphere(options: {
  118097. diameter: number;
  118098. segments: number;
  118099. color: Color3;
  118100. }, renderingGroupId: number, scene: Scene): void;
  118101. /**
  118102. * Starts all particle systems of the set
  118103. * @param emitter defines an optional mesh to use as emitter for the particle systems
  118104. */
  118105. start(emitter?: AbstractMesh): void;
  118106. /**
  118107. * Release all associated resources
  118108. */
  118109. dispose(): void;
  118110. /**
  118111. * Serialize the set into a JSON compatible object
  118112. * @returns a JSON compatible representation of the set
  118113. */
  118114. serialize(): any;
  118115. /**
  118116. * Parse a new ParticleSystemSet from a serialized source
  118117. * @param data defines a JSON compatible representation of the set
  118118. * @param scene defines the hosting scene
  118119. * @param gpu defines if we want GPU particles or CPU particles
  118120. * @returns a new ParticleSystemSet
  118121. */
  118122. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  118123. }
  118124. }
  118125. declare module BABYLON {
  118126. /**
  118127. * This class is made for on one-liner static method to help creating particle system set.
  118128. */
  118129. export class ParticleHelper {
  118130. /**
  118131. * Gets or sets base Assets URL
  118132. */
  118133. static BaseAssetsUrl: string;
  118134. /**
  118135. * Create a default particle system that you can tweak
  118136. * @param emitter defines the emitter to use
  118137. * @param capacity defines the system capacity (default is 500 particles)
  118138. * @param scene defines the hosting scene
  118139. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  118140. * @returns the new Particle system
  118141. */
  118142. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  118143. /**
  118144. * This is the main static method (one-liner) of this helper to create different particle systems
  118145. * @param type This string represents the type to the particle system to create
  118146. * @param scene The scene where the particle system should live
  118147. * @param gpu If the system will use gpu
  118148. * @returns the ParticleSystemSet created
  118149. */
  118150. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  118151. /**
  118152. * Static function used to export a particle system to a ParticleSystemSet variable.
  118153. * Please note that the emitter shape is not exported
  118154. * @param systems defines the particle systems to export
  118155. * @returns the created particle system set
  118156. */
  118157. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  118158. }
  118159. }
  118160. declare module BABYLON {
  118161. interface Engine {
  118162. /**
  118163. * Create an effect to use with particle systems.
  118164. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  118165. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  118166. * @param uniformsNames defines a list of attribute names
  118167. * @param samplers defines an array of string used to represent textures
  118168. * @param defines defines the string containing the defines to use to compile the shaders
  118169. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  118170. * @param onCompiled defines a function to call when the effect creation is successful
  118171. * @param onError defines a function to call when the effect creation has failed
  118172. * @returns the new Effect
  118173. */
  118174. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  118175. }
  118176. interface Mesh {
  118177. /**
  118178. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  118179. * @returns an array of IParticleSystem
  118180. */
  118181. getEmittedParticleSystems(): IParticleSystem[];
  118182. /**
  118183. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  118184. * @returns an array of IParticleSystem
  118185. */
  118186. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  118187. }
  118188. /**
  118189. * @hidden
  118190. */
  118191. export var _IDoNeedToBeInTheBuild: number;
  118192. }
  118193. declare module BABYLON {
  118194. interface Scene {
  118195. /** @hidden (Backing field) */
  118196. _physicsEngine: Nullable<IPhysicsEngine>;
  118197. /**
  118198. * Gets the current physics engine
  118199. * @returns a IPhysicsEngine or null if none attached
  118200. */
  118201. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  118202. /**
  118203. * Enables physics to the current scene
  118204. * @param gravity defines the scene's gravity for the physics engine
  118205. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  118206. * @return a boolean indicating if the physics engine was initialized
  118207. */
  118208. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  118209. /**
  118210. * Disables and disposes the physics engine associated with the scene
  118211. */
  118212. disablePhysicsEngine(): void;
  118213. /**
  118214. * Gets a boolean indicating if there is an active physics engine
  118215. * @returns a boolean indicating if there is an active physics engine
  118216. */
  118217. isPhysicsEnabled(): boolean;
  118218. /**
  118219. * Deletes a physics compound impostor
  118220. * @param compound defines the compound to delete
  118221. */
  118222. deleteCompoundImpostor(compound: any): void;
  118223. /**
  118224. * An event triggered when physic simulation is about to be run
  118225. */
  118226. onBeforePhysicsObservable: Observable<Scene>;
  118227. /**
  118228. * An event triggered when physic simulation has been done
  118229. */
  118230. onAfterPhysicsObservable: Observable<Scene>;
  118231. }
  118232. interface AbstractMesh {
  118233. /** @hidden */
  118234. _physicsImpostor: Nullable<PhysicsImpostor>;
  118235. /**
  118236. * Gets or sets impostor used for physic simulation
  118237. * @see http://doc.babylonjs.com/features/physics_engine
  118238. */
  118239. physicsImpostor: Nullable<PhysicsImpostor>;
  118240. /**
  118241. * Gets the current physics impostor
  118242. * @see http://doc.babylonjs.com/features/physics_engine
  118243. * @returns a physics impostor or null
  118244. */
  118245. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  118246. /** Apply a physic impulse to the mesh
  118247. * @param force defines the force to apply
  118248. * @param contactPoint defines where to apply the force
  118249. * @returns the current mesh
  118250. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  118251. */
  118252. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  118253. /**
  118254. * Creates a physic joint between two meshes
  118255. * @param otherMesh defines the other mesh to use
  118256. * @param pivot1 defines the pivot to use on this mesh
  118257. * @param pivot2 defines the pivot to use on the other mesh
  118258. * @param options defines additional options (can be plugin dependent)
  118259. * @returns the current mesh
  118260. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  118261. */
  118262. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  118263. /** @hidden */
  118264. _disposePhysicsObserver: Nullable<Observer<Node>>;
  118265. }
  118266. /**
  118267. * Defines the physics engine scene component responsible to manage a physics engine
  118268. */
  118269. export class PhysicsEngineSceneComponent implements ISceneComponent {
  118270. /**
  118271. * The component name helpful to identify the component in the list of scene components.
  118272. */
  118273. readonly name: string;
  118274. /**
  118275. * The scene the component belongs to.
  118276. */
  118277. scene: Scene;
  118278. /**
  118279. * Creates a new instance of the component for the given scene
  118280. * @param scene Defines the scene to register the component in
  118281. */
  118282. constructor(scene: Scene);
  118283. /**
  118284. * Registers the component in a given scene
  118285. */
  118286. register(): void;
  118287. /**
  118288. * Rebuilds the elements related to this component in case of
  118289. * context lost for instance.
  118290. */
  118291. rebuild(): void;
  118292. /**
  118293. * Disposes the component and the associated ressources
  118294. */
  118295. dispose(): void;
  118296. }
  118297. }
  118298. declare module BABYLON {
  118299. /**
  118300. * A helper for physics simulations
  118301. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  118302. */
  118303. export class PhysicsHelper {
  118304. private _scene;
  118305. private _physicsEngine;
  118306. /**
  118307. * Initializes the Physics helper
  118308. * @param scene Babylon.js scene
  118309. */
  118310. constructor(scene: Scene);
  118311. /**
  118312. * Applies a radial explosion impulse
  118313. * @param origin the origin of the explosion
  118314. * @param radiusOrEventOptions the radius or the options of radial explosion
  118315. * @param strength the explosion strength
  118316. * @param falloff possible options: Constant & Linear. Defaults to Constant
  118317. * @returns A physics radial explosion event, or null
  118318. */
  118319. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  118320. /**
  118321. * Applies a radial explosion force
  118322. * @param origin the origin of the explosion
  118323. * @param radiusOrEventOptions the radius or the options of radial explosion
  118324. * @param strength the explosion strength
  118325. * @param falloff possible options: Constant & Linear. Defaults to Constant
  118326. * @returns A physics radial explosion event, or null
  118327. */
  118328. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  118329. /**
  118330. * Creates a gravitational field
  118331. * @param origin the origin of the explosion
  118332. * @param radiusOrEventOptions the radius or the options of radial explosion
  118333. * @param strength the explosion strength
  118334. * @param falloff possible options: Constant & Linear. Defaults to Constant
  118335. * @returns A physics gravitational field event, or null
  118336. */
  118337. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  118338. /**
  118339. * Creates a physics updraft event
  118340. * @param origin the origin of the updraft
  118341. * @param radiusOrEventOptions the radius or the options of the updraft
  118342. * @param strength the strength of the updraft
  118343. * @param height the height of the updraft
  118344. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  118345. * @returns A physics updraft event, or null
  118346. */
  118347. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  118348. /**
  118349. * Creates a physics vortex event
  118350. * @param origin the of the vortex
  118351. * @param radiusOrEventOptions the radius or the options of the vortex
  118352. * @param strength the strength of the vortex
  118353. * @param height the height of the vortex
  118354. * @returns a Physics vortex event, or null
  118355. * A physics vortex event or null
  118356. */
  118357. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  118358. }
  118359. /**
  118360. * Represents a physics radial explosion event
  118361. */
  118362. class PhysicsRadialExplosionEvent {
  118363. private _scene;
  118364. private _options;
  118365. private _sphere;
  118366. private _dataFetched;
  118367. /**
  118368. * Initializes a radial explosioin event
  118369. * @param _scene BabylonJS scene
  118370. * @param _options The options for the vortex event
  118371. */
  118372. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  118373. /**
  118374. * Returns the data related to the radial explosion event (sphere).
  118375. * @returns The radial explosion event data
  118376. */
  118377. getData(): PhysicsRadialExplosionEventData;
  118378. /**
  118379. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  118380. * @param impostor A physics imposter
  118381. * @param origin the origin of the explosion
  118382. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  118383. */
  118384. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  118385. /**
  118386. * Triggers affecterd impostors callbacks
  118387. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  118388. */
  118389. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  118390. /**
  118391. * Disposes the sphere.
  118392. * @param force Specifies if the sphere should be disposed by force
  118393. */
  118394. dispose(force?: boolean): void;
  118395. /*** Helpers ***/
  118396. private _prepareSphere;
  118397. private _intersectsWithSphere;
  118398. }
  118399. /**
  118400. * Represents a gravitational field event
  118401. */
  118402. class PhysicsGravitationalFieldEvent {
  118403. private _physicsHelper;
  118404. private _scene;
  118405. private _origin;
  118406. private _options;
  118407. private _tickCallback;
  118408. private _sphere;
  118409. private _dataFetched;
  118410. /**
  118411. * Initializes the physics gravitational field event
  118412. * @param _physicsHelper A physics helper
  118413. * @param _scene BabylonJS scene
  118414. * @param _origin The origin position of the gravitational field event
  118415. * @param _options The options for the vortex event
  118416. */
  118417. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  118418. /**
  118419. * Returns the data related to the gravitational field event (sphere).
  118420. * @returns A gravitational field event
  118421. */
  118422. getData(): PhysicsGravitationalFieldEventData;
  118423. /**
  118424. * Enables the gravitational field.
  118425. */
  118426. enable(): void;
  118427. /**
  118428. * Disables the gravitational field.
  118429. */
  118430. disable(): void;
  118431. /**
  118432. * Disposes the sphere.
  118433. * @param force The force to dispose from the gravitational field event
  118434. */
  118435. dispose(force?: boolean): void;
  118436. private _tick;
  118437. }
  118438. /**
  118439. * Represents a physics updraft event
  118440. */
  118441. class PhysicsUpdraftEvent {
  118442. private _scene;
  118443. private _origin;
  118444. private _options;
  118445. private _physicsEngine;
  118446. private _originTop;
  118447. private _originDirection;
  118448. private _tickCallback;
  118449. private _cylinder;
  118450. private _cylinderPosition;
  118451. private _dataFetched;
  118452. /**
  118453. * Initializes the physics updraft event
  118454. * @param _scene BabylonJS scene
  118455. * @param _origin The origin position of the updraft
  118456. * @param _options The options for the updraft event
  118457. */
  118458. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  118459. /**
  118460. * Returns the data related to the updraft event (cylinder).
  118461. * @returns A physics updraft event
  118462. */
  118463. getData(): PhysicsUpdraftEventData;
  118464. /**
  118465. * Enables the updraft.
  118466. */
  118467. enable(): void;
  118468. /**
  118469. * Disables the updraft.
  118470. */
  118471. disable(): void;
  118472. /**
  118473. * Disposes the cylinder.
  118474. * @param force Specifies if the updraft should be disposed by force
  118475. */
  118476. dispose(force?: boolean): void;
  118477. private getImpostorHitData;
  118478. private _tick;
  118479. /*** Helpers ***/
  118480. private _prepareCylinder;
  118481. private _intersectsWithCylinder;
  118482. }
  118483. /**
  118484. * Represents a physics vortex event
  118485. */
  118486. class PhysicsVortexEvent {
  118487. private _scene;
  118488. private _origin;
  118489. private _options;
  118490. private _physicsEngine;
  118491. private _originTop;
  118492. private _tickCallback;
  118493. private _cylinder;
  118494. private _cylinderPosition;
  118495. private _dataFetched;
  118496. /**
  118497. * Initializes the physics vortex event
  118498. * @param _scene The BabylonJS scene
  118499. * @param _origin The origin position of the vortex
  118500. * @param _options The options for the vortex event
  118501. */
  118502. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  118503. /**
  118504. * Returns the data related to the vortex event (cylinder).
  118505. * @returns The physics vortex event data
  118506. */
  118507. getData(): PhysicsVortexEventData;
  118508. /**
  118509. * Enables the vortex.
  118510. */
  118511. enable(): void;
  118512. /**
  118513. * Disables the cortex.
  118514. */
  118515. disable(): void;
  118516. /**
  118517. * Disposes the sphere.
  118518. * @param force
  118519. */
  118520. dispose(force?: boolean): void;
  118521. private getImpostorHitData;
  118522. private _tick;
  118523. /*** Helpers ***/
  118524. private _prepareCylinder;
  118525. private _intersectsWithCylinder;
  118526. }
  118527. /**
  118528. * Options fot the radial explosion event
  118529. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  118530. */
  118531. export class PhysicsRadialExplosionEventOptions {
  118532. /**
  118533. * The radius of the sphere for the radial explosion.
  118534. */
  118535. radius: number;
  118536. /**
  118537. * The strenth of the explosion.
  118538. */
  118539. strength: number;
  118540. /**
  118541. * The strenght of the force in correspondence to the distance of the affected object
  118542. */
  118543. falloff: PhysicsRadialImpulseFalloff;
  118544. /**
  118545. * Sphere options for the radial explosion.
  118546. */
  118547. sphere: {
  118548. segments: number;
  118549. diameter: number;
  118550. };
  118551. /**
  118552. * Sphere options for the radial explosion.
  118553. */
  118554. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  118555. }
  118556. /**
  118557. * Options fot the updraft event
  118558. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  118559. */
  118560. export class PhysicsUpdraftEventOptions {
  118561. /**
  118562. * The radius of the cylinder for the vortex
  118563. */
  118564. radius: number;
  118565. /**
  118566. * The strenth of the updraft.
  118567. */
  118568. strength: number;
  118569. /**
  118570. * The height of the cylinder for the updraft.
  118571. */
  118572. height: number;
  118573. /**
  118574. * The mode for the the updraft.
  118575. */
  118576. updraftMode: PhysicsUpdraftMode;
  118577. }
  118578. /**
  118579. * Options fot the vortex event
  118580. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  118581. */
  118582. export class PhysicsVortexEventOptions {
  118583. /**
  118584. * The radius of the cylinder for the vortex
  118585. */
  118586. radius: number;
  118587. /**
  118588. * The strenth of the vortex.
  118589. */
  118590. strength: number;
  118591. /**
  118592. * The height of the cylinder for the vortex.
  118593. */
  118594. height: number;
  118595. /**
  118596. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  118597. */
  118598. centripetalForceThreshold: number;
  118599. /**
  118600. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  118601. */
  118602. centripetalForceMultiplier: number;
  118603. /**
  118604. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  118605. */
  118606. centrifugalForceMultiplier: number;
  118607. /**
  118608. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  118609. */
  118610. updraftForceMultiplier: number;
  118611. }
  118612. /**
  118613. * The strenght of the force in correspondence to the distance of the affected object
  118614. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  118615. */
  118616. export enum PhysicsRadialImpulseFalloff {
  118617. /** Defines that impulse is constant in strength across it's whole radius */
  118618. Constant = 0,
  118619. /** Defines that impulse gets weaker if it's further from the origin */
  118620. Linear = 1
  118621. }
  118622. /**
  118623. * The strength of the force in correspondence to the distance of the affected object
  118624. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  118625. */
  118626. export enum PhysicsUpdraftMode {
  118627. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  118628. Center = 0,
  118629. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  118630. Perpendicular = 1
  118631. }
  118632. /**
  118633. * Interface for a physics hit data
  118634. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  118635. */
  118636. export interface PhysicsHitData {
  118637. /**
  118638. * The force applied at the contact point
  118639. */
  118640. force: Vector3;
  118641. /**
  118642. * The contact point
  118643. */
  118644. contactPoint: Vector3;
  118645. /**
  118646. * The distance from the origin to the contact point
  118647. */
  118648. distanceFromOrigin: number;
  118649. }
  118650. /**
  118651. * Interface for radial explosion event data
  118652. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  118653. */
  118654. export interface PhysicsRadialExplosionEventData {
  118655. /**
  118656. * A sphere used for the radial explosion event
  118657. */
  118658. sphere: Mesh;
  118659. }
  118660. /**
  118661. * Interface for gravitational field event data
  118662. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  118663. */
  118664. export interface PhysicsGravitationalFieldEventData {
  118665. /**
  118666. * A sphere mesh used for the gravitational field event
  118667. */
  118668. sphere: Mesh;
  118669. }
  118670. /**
  118671. * Interface for updraft event data
  118672. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  118673. */
  118674. export interface PhysicsUpdraftEventData {
  118675. /**
  118676. * A cylinder used for the updraft event
  118677. */
  118678. cylinder: Mesh;
  118679. }
  118680. /**
  118681. * Interface for vortex event data
  118682. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  118683. */
  118684. export interface PhysicsVortexEventData {
  118685. /**
  118686. * A cylinder used for the vortex event
  118687. */
  118688. cylinder: Mesh;
  118689. }
  118690. /**
  118691. * Interface for an affected physics impostor
  118692. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  118693. */
  118694. export interface PhysicsAffectedImpostorWithData {
  118695. /**
  118696. * The impostor affected by the effect
  118697. */
  118698. impostor: PhysicsImpostor;
  118699. /**
  118700. * The data about the hit/horce from the explosion
  118701. */
  118702. hitData: PhysicsHitData;
  118703. }
  118704. }
  118705. declare module BABYLON {
  118706. /** @hidden */
  118707. export var blackAndWhitePixelShader: {
  118708. name: string;
  118709. shader: string;
  118710. };
  118711. }
  118712. declare module BABYLON {
  118713. /**
  118714. * Post process used to render in black and white
  118715. */
  118716. export class BlackAndWhitePostProcess extends PostProcess {
  118717. /**
  118718. * Linear about to convert he result to black and white (default: 1)
  118719. */
  118720. degree: number;
  118721. /**
  118722. * Creates a black and white post process
  118723. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  118724. * @param name The name of the effect.
  118725. * @param options The required width/height ratio to downsize to before computing the render pass.
  118726. * @param camera The camera to apply the render pass to.
  118727. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118728. * @param engine The engine which the post process will be applied. (default: current engine)
  118729. * @param reusable If the post process can be reused on the same frame. (default: false)
  118730. */
  118731. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118732. }
  118733. }
  118734. declare module BABYLON {
  118735. /**
  118736. * This represents a set of one or more post processes in Babylon.
  118737. * A post process can be used to apply a shader to a texture after it is rendered.
  118738. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118739. */
  118740. export class PostProcessRenderEffect {
  118741. private _postProcesses;
  118742. private _getPostProcesses;
  118743. private _singleInstance;
  118744. private _cameras;
  118745. private _indicesForCamera;
  118746. /**
  118747. * Name of the effect
  118748. * @hidden
  118749. */
  118750. _name: string;
  118751. /**
  118752. * Instantiates a post process render effect.
  118753. * A post process can be used to apply a shader to a texture after it is rendered.
  118754. * @param engine The engine the effect is tied to
  118755. * @param name The name of the effect
  118756. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  118757. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  118758. */
  118759. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  118760. /**
  118761. * Checks if all the post processes in the effect are supported.
  118762. */
  118763. readonly isSupported: boolean;
  118764. /**
  118765. * Updates the current state of the effect
  118766. * @hidden
  118767. */
  118768. _update(): void;
  118769. /**
  118770. * Attaches the effect on cameras
  118771. * @param cameras The camera to attach to.
  118772. * @hidden
  118773. */
  118774. _attachCameras(cameras: Camera): void;
  118775. /**
  118776. * Attaches the effect on cameras
  118777. * @param cameras The camera to attach to.
  118778. * @hidden
  118779. */
  118780. _attachCameras(cameras: Camera[]): void;
  118781. /**
  118782. * Detaches the effect on cameras
  118783. * @param cameras The camera to detatch from.
  118784. * @hidden
  118785. */
  118786. _detachCameras(cameras: Camera): void;
  118787. /**
  118788. * Detatches the effect on cameras
  118789. * @param cameras The camera to detatch from.
  118790. * @hidden
  118791. */
  118792. _detachCameras(cameras: Camera[]): void;
  118793. /**
  118794. * Enables the effect on given cameras
  118795. * @param cameras The camera to enable.
  118796. * @hidden
  118797. */
  118798. _enable(cameras: Camera): void;
  118799. /**
  118800. * Enables the effect on given cameras
  118801. * @param cameras The camera to enable.
  118802. * @hidden
  118803. */
  118804. _enable(cameras: Nullable<Camera[]>): void;
  118805. /**
  118806. * Disables the effect on the given cameras
  118807. * @param cameras The camera to disable.
  118808. * @hidden
  118809. */
  118810. _disable(cameras: Camera): void;
  118811. /**
  118812. * Disables the effect on the given cameras
  118813. * @param cameras The camera to disable.
  118814. * @hidden
  118815. */
  118816. _disable(cameras: Nullable<Camera[]>): void;
  118817. /**
  118818. * Gets a list of the post processes contained in the effect.
  118819. * @param camera The camera to get the post processes on.
  118820. * @returns The list of the post processes in the effect.
  118821. */
  118822. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  118823. }
  118824. }
  118825. declare module BABYLON {
  118826. /** @hidden */
  118827. export var extractHighlightsPixelShader: {
  118828. name: string;
  118829. shader: string;
  118830. };
  118831. }
  118832. declare module BABYLON {
  118833. /**
  118834. * 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.
  118835. */
  118836. export class ExtractHighlightsPostProcess extends PostProcess {
  118837. /**
  118838. * The luminance threshold, pixels below this value will be set to black.
  118839. */
  118840. threshold: number;
  118841. /** @hidden */
  118842. _exposure: number;
  118843. /**
  118844. * Post process which has the input texture to be used when performing highlight extraction
  118845. * @hidden
  118846. */
  118847. _inputPostProcess: Nullable<PostProcess>;
  118848. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118849. }
  118850. }
  118851. declare module BABYLON {
  118852. /** @hidden */
  118853. export var bloomMergePixelShader: {
  118854. name: string;
  118855. shader: string;
  118856. };
  118857. }
  118858. declare module BABYLON {
  118859. /**
  118860. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  118861. */
  118862. export class BloomMergePostProcess extends PostProcess {
  118863. /** Weight of the bloom to be added to the original input. */
  118864. weight: number;
  118865. /**
  118866. * Creates a new instance of @see BloomMergePostProcess
  118867. * @param name The name of the effect.
  118868. * @param originalFromInput Post process which's input will be used for the merge.
  118869. * @param blurred Blurred highlights post process which's output will be used.
  118870. * @param weight Weight of the bloom to be added to the original input.
  118871. * @param options The required width/height ratio to downsize to before computing the render pass.
  118872. * @param camera The camera to apply the render pass to.
  118873. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118874. * @param engine The engine which the post process will be applied. (default: current engine)
  118875. * @param reusable If the post process can be reused on the same frame. (default: false)
  118876. * @param textureType Type of textures used when performing the post process. (default: 0)
  118877. * @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)
  118878. */
  118879. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  118880. /** Weight of the bloom to be added to the original input. */
  118881. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118882. }
  118883. }
  118884. declare module BABYLON {
  118885. /**
  118886. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  118887. */
  118888. export class BloomEffect extends PostProcessRenderEffect {
  118889. private bloomScale;
  118890. /**
  118891. * @hidden Internal
  118892. */
  118893. _effects: Array<PostProcess>;
  118894. /**
  118895. * @hidden Internal
  118896. */
  118897. _downscale: ExtractHighlightsPostProcess;
  118898. private _blurX;
  118899. private _blurY;
  118900. private _merge;
  118901. /**
  118902. * The luminance threshold to find bright areas of the image to bloom.
  118903. */
  118904. threshold: number;
  118905. /**
  118906. * The strength of the bloom.
  118907. */
  118908. weight: number;
  118909. /**
  118910. * Specifies the size of the bloom blur kernel, relative to the final output size
  118911. */
  118912. kernel: number;
  118913. /**
  118914. * Creates a new instance of @see BloomEffect
  118915. * @param scene The scene the effect belongs to.
  118916. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  118917. * @param bloomKernel The size of the kernel to be used when applying the blur.
  118918. * @param bloomWeight The the strength of bloom.
  118919. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  118920. * @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)
  118921. */
  118922. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  118923. /**
  118924. * Disposes each of the internal effects for a given camera.
  118925. * @param camera The camera to dispose the effect on.
  118926. */
  118927. disposeEffects(camera: Camera): void;
  118928. /**
  118929. * @hidden Internal
  118930. */
  118931. _updateEffects(): void;
  118932. /**
  118933. * Internal
  118934. * @returns if all the contained post processes are ready.
  118935. * @hidden
  118936. */
  118937. _isReady(): boolean;
  118938. }
  118939. }
  118940. declare module BABYLON {
  118941. /** @hidden */
  118942. export var chromaticAberrationPixelShader: {
  118943. name: string;
  118944. shader: string;
  118945. };
  118946. }
  118947. declare module BABYLON {
  118948. /**
  118949. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  118950. */
  118951. export class ChromaticAberrationPostProcess extends PostProcess {
  118952. /**
  118953. * The amount of seperation of rgb channels (default: 30)
  118954. */
  118955. aberrationAmount: number;
  118956. /**
  118957. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  118958. */
  118959. radialIntensity: number;
  118960. /**
  118961. * 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))
  118962. */
  118963. direction: Vector2;
  118964. /**
  118965. * 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))
  118966. */
  118967. centerPosition: Vector2;
  118968. /**
  118969. * Creates a new instance ChromaticAberrationPostProcess
  118970. * @param name The name of the effect.
  118971. * @param screenWidth The width of the screen to apply the effect on.
  118972. * @param screenHeight The height of the screen to apply the effect on.
  118973. * @param options The required width/height ratio to downsize to before computing the render pass.
  118974. * @param camera The camera to apply the render pass to.
  118975. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118976. * @param engine The engine which the post process will be applied. (default: current engine)
  118977. * @param reusable If the post process can be reused on the same frame. (default: false)
  118978. * @param textureType Type of textures used when performing the post process. (default: 0)
  118979. * @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)
  118980. */
  118981. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118982. }
  118983. }
  118984. declare module BABYLON {
  118985. /** @hidden */
  118986. export var circleOfConfusionPixelShader: {
  118987. name: string;
  118988. shader: string;
  118989. };
  118990. }
  118991. declare module BABYLON {
  118992. /**
  118993. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  118994. */
  118995. export class CircleOfConfusionPostProcess extends PostProcess {
  118996. /**
  118997. * 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.
  118998. */
  118999. lensSize: number;
  119000. /**
  119001. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  119002. */
  119003. fStop: number;
  119004. /**
  119005. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  119006. */
  119007. focusDistance: number;
  119008. /**
  119009. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  119010. */
  119011. focalLength: number;
  119012. private _depthTexture;
  119013. /**
  119014. * Creates a new instance CircleOfConfusionPostProcess
  119015. * @param name The name of the effect.
  119016. * @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.
  119017. * @param options The required width/height ratio to downsize to before computing the render pass.
  119018. * @param camera The camera to apply the render pass to.
  119019. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119020. * @param engine The engine which the post process will be applied. (default: current engine)
  119021. * @param reusable If the post process can be reused on the same frame. (default: false)
  119022. * @param textureType Type of textures used when performing the post process. (default: 0)
  119023. * @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)
  119024. */
  119025. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  119026. /**
  119027. * 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.
  119028. */
  119029. depthTexture: RenderTargetTexture;
  119030. }
  119031. }
  119032. declare module BABYLON {
  119033. /** @hidden */
  119034. export var colorCorrectionPixelShader: {
  119035. name: string;
  119036. shader: string;
  119037. };
  119038. }
  119039. declare module BABYLON {
  119040. /**
  119041. *
  119042. * This post-process allows the modification of rendered colors by using
  119043. * a 'look-up table' (LUT). This effect is also called Color Grading.
  119044. *
  119045. * The object needs to be provided an url to a texture containing the color
  119046. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  119047. * Use an image editing software to tweak the LUT to match your needs.
  119048. *
  119049. * For an example of a color LUT, see here:
  119050. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  119051. * For explanations on color grading, see here:
  119052. * @see http://udn.epicgames.com/Three/ColorGrading.html
  119053. *
  119054. */
  119055. export class ColorCorrectionPostProcess extends PostProcess {
  119056. private _colorTableTexture;
  119057. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  119058. }
  119059. }
  119060. declare module BABYLON {
  119061. /** @hidden */
  119062. export var convolutionPixelShader: {
  119063. name: string;
  119064. shader: string;
  119065. };
  119066. }
  119067. declare module BABYLON {
  119068. /**
  119069. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  119070. * input texture to perform effects such as edge detection or sharpening
  119071. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  119072. */
  119073. export class ConvolutionPostProcess extends PostProcess {
  119074. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  119075. kernel: number[];
  119076. /**
  119077. * Creates a new instance ConvolutionPostProcess
  119078. * @param name The name of the effect.
  119079. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  119080. * @param options The required width/height ratio to downsize to before computing the render pass.
  119081. * @param camera The camera to apply the render pass to.
  119082. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119083. * @param engine The engine which the post process will be applied. (default: current engine)
  119084. * @param reusable If the post process can be reused on the same frame. (default: false)
  119085. * @param textureType Type of textures used when performing the post process. (default: 0)
  119086. */
  119087. constructor(name: string,
  119088. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  119089. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  119090. /**
  119091. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  119092. */
  119093. static EdgeDetect0Kernel: number[];
  119094. /**
  119095. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  119096. */
  119097. static EdgeDetect1Kernel: number[];
  119098. /**
  119099. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  119100. */
  119101. static EdgeDetect2Kernel: number[];
  119102. /**
  119103. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  119104. */
  119105. static SharpenKernel: number[];
  119106. /**
  119107. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  119108. */
  119109. static EmbossKernel: number[];
  119110. /**
  119111. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  119112. */
  119113. static GaussianKernel: number[];
  119114. }
  119115. }
  119116. declare module BABYLON {
  119117. /**
  119118. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  119119. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  119120. * based on samples that have a large difference in distance than the center pixel.
  119121. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  119122. */
  119123. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  119124. direction: Vector2;
  119125. /**
  119126. * Creates a new instance CircleOfConfusionPostProcess
  119127. * @param name The name of the effect.
  119128. * @param scene The scene the effect belongs to.
  119129. * @param direction The direction the blur should be applied.
  119130. * @param kernel The size of the kernel used to blur.
  119131. * @param options The required width/height ratio to downsize to before computing the render pass.
  119132. * @param camera The camera to apply the render pass to.
  119133. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  119134. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  119135. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119136. * @param engine The engine which the post process will be applied. (default: current engine)
  119137. * @param reusable If the post process can be reused on the same frame. (default: false)
  119138. * @param textureType Type of textures used when performing the post process. (default: 0)
  119139. * @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)
  119140. */
  119141. 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);
  119142. }
  119143. }
  119144. declare module BABYLON {
  119145. /** @hidden */
  119146. export var depthOfFieldMergePixelShader: {
  119147. name: string;
  119148. shader: string;
  119149. };
  119150. }
  119151. declare module BABYLON {
  119152. /**
  119153. * Options to be set when merging outputs from the default pipeline.
  119154. */
  119155. export class DepthOfFieldMergePostProcessOptions {
  119156. /**
  119157. * The original image to merge on top of
  119158. */
  119159. originalFromInput: PostProcess;
  119160. /**
  119161. * Parameters to perform the merge of the depth of field effect
  119162. */
  119163. depthOfField?: {
  119164. circleOfConfusion: PostProcess;
  119165. blurSteps: Array<PostProcess>;
  119166. };
  119167. /**
  119168. * Parameters to perform the merge of bloom effect
  119169. */
  119170. bloom?: {
  119171. blurred: PostProcess;
  119172. weight: number;
  119173. };
  119174. }
  119175. /**
  119176. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  119177. */
  119178. export class DepthOfFieldMergePostProcess extends PostProcess {
  119179. private blurSteps;
  119180. /**
  119181. * Creates a new instance of DepthOfFieldMergePostProcess
  119182. * @param name The name of the effect.
  119183. * @param originalFromInput Post process which's input will be used for the merge.
  119184. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  119185. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  119186. * @param options The required width/height ratio to downsize to before computing the render pass.
  119187. * @param camera The camera to apply the render pass to.
  119188. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119189. * @param engine The engine which the post process will be applied. (default: current engine)
  119190. * @param reusable If the post process can be reused on the same frame. (default: false)
  119191. * @param textureType Type of textures used when performing the post process. (default: 0)
  119192. * @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)
  119193. */
  119194. 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);
  119195. /**
  119196. * Updates the effect with the current post process compile time values and recompiles the shader.
  119197. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  119198. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  119199. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  119200. * @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
  119201. * @param onCompiled Called when the shader has been compiled.
  119202. * @param onError Called if there is an error when compiling a shader.
  119203. */
  119204. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  119205. }
  119206. }
  119207. declare module BABYLON {
  119208. /**
  119209. * Specifies the level of max blur that should be applied when using the depth of field effect
  119210. */
  119211. export enum DepthOfFieldEffectBlurLevel {
  119212. /**
  119213. * Subtle blur
  119214. */
  119215. Low = 0,
  119216. /**
  119217. * Medium blur
  119218. */
  119219. Medium = 1,
  119220. /**
  119221. * Large blur
  119222. */
  119223. High = 2
  119224. }
  119225. /**
  119226. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  119227. */
  119228. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  119229. private _circleOfConfusion;
  119230. /**
  119231. * @hidden Internal, blurs from high to low
  119232. */
  119233. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  119234. private _depthOfFieldBlurY;
  119235. private _dofMerge;
  119236. /**
  119237. * @hidden Internal post processes in depth of field effect
  119238. */
  119239. _effects: Array<PostProcess>;
  119240. /**
  119241. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  119242. */
  119243. focalLength: number;
  119244. /**
  119245. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  119246. */
  119247. fStop: number;
  119248. /**
  119249. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  119250. */
  119251. focusDistance: number;
  119252. /**
  119253. * 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.
  119254. */
  119255. lensSize: number;
  119256. /**
  119257. * Creates a new instance DepthOfFieldEffect
  119258. * @param scene The scene the effect belongs to.
  119259. * @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.
  119260. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  119261. * @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)
  119262. */
  119263. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  119264. /**
  119265. * Get the current class name of the current effet
  119266. * @returns "DepthOfFieldEffect"
  119267. */
  119268. getClassName(): string;
  119269. /**
  119270. * 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.
  119271. */
  119272. depthTexture: RenderTargetTexture;
  119273. /**
  119274. * Disposes each of the internal effects for a given camera.
  119275. * @param camera The camera to dispose the effect on.
  119276. */
  119277. disposeEffects(camera: Camera): void;
  119278. /**
  119279. * @hidden Internal
  119280. */
  119281. _updateEffects(): void;
  119282. /**
  119283. * Internal
  119284. * @returns if all the contained post processes are ready.
  119285. * @hidden
  119286. */
  119287. _isReady(): boolean;
  119288. }
  119289. }
  119290. declare module BABYLON {
  119291. /** @hidden */
  119292. export var displayPassPixelShader: {
  119293. name: string;
  119294. shader: string;
  119295. };
  119296. }
  119297. declare module BABYLON {
  119298. /**
  119299. * DisplayPassPostProcess which produces an output the same as it's input
  119300. */
  119301. export class DisplayPassPostProcess extends PostProcess {
  119302. /**
  119303. * Creates the DisplayPassPostProcess
  119304. * @param name The name of the effect.
  119305. * @param options The required width/height ratio to downsize to before computing the render pass.
  119306. * @param camera The camera to apply the render pass to.
  119307. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119308. * @param engine The engine which the post process will be applied. (default: current engine)
  119309. * @param reusable If the post process can be reused on the same frame. (default: false)
  119310. */
  119311. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  119312. }
  119313. }
  119314. declare module BABYLON {
  119315. /** @hidden */
  119316. export var filterPixelShader: {
  119317. name: string;
  119318. shader: string;
  119319. };
  119320. }
  119321. declare module BABYLON {
  119322. /**
  119323. * Applies a kernel filter to the image
  119324. */
  119325. export class FilterPostProcess extends PostProcess {
  119326. /** The matrix to be applied to the image */
  119327. kernelMatrix: Matrix;
  119328. /**
  119329. *
  119330. * @param name The name of the effect.
  119331. * @param kernelMatrix The matrix to be applied to the image
  119332. * @param options The required width/height ratio to downsize to before computing the render pass.
  119333. * @param camera The camera to apply the render pass to.
  119334. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119335. * @param engine The engine which the post process will be applied. (default: current engine)
  119336. * @param reusable If the post process can be reused on the same frame. (default: false)
  119337. */
  119338. constructor(name: string,
  119339. /** The matrix to be applied to the image */
  119340. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  119341. }
  119342. }
  119343. declare module BABYLON {
  119344. /** @hidden */
  119345. export var fxaaPixelShader: {
  119346. name: string;
  119347. shader: string;
  119348. };
  119349. }
  119350. declare module BABYLON {
  119351. /** @hidden */
  119352. export var fxaaVertexShader: {
  119353. name: string;
  119354. shader: string;
  119355. };
  119356. }
  119357. declare module BABYLON {
  119358. /**
  119359. * Fxaa post process
  119360. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  119361. */
  119362. export class FxaaPostProcess extends PostProcess {
  119363. /** @hidden */
  119364. texelWidth: number;
  119365. /** @hidden */
  119366. texelHeight: number;
  119367. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  119368. private _getDefines;
  119369. }
  119370. }
  119371. declare module BABYLON {
  119372. /** @hidden */
  119373. export var grainPixelShader: {
  119374. name: string;
  119375. shader: string;
  119376. };
  119377. }
  119378. declare module BABYLON {
  119379. /**
  119380. * The GrainPostProcess adds noise to the image at mid luminance levels
  119381. */
  119382. export class GrainPostProcess extends PostProcess {
  119383. /**
  119384. * The intensity of the grain added (default: 30)
  119385. */
  119386. intensity: number;
  119387. /**
  119388. * If the grain should be randomized on every frame
  119389. */
  119390. animated: boolean;
  119391. /**
  119392. * Creates a new instance of @see GrainPostProcess
  119393. * @param name The name of the effect.
  119394. * @param options The required width/height ratio to downsize to before computing the render pass.
  119395. * @param camera The camera to apply the render pass to.
  119396. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119397. * @param engine The engine which the post process will be applied. (default: current engine)
  119398. * @param reusable If the post process can be reused on the same frame. (default: false)
  119399. * @param textureType Type of textures used when performing the post process. (default: 0)
  119400. * @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)
  119401. */
  119402. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  119403. }
  119404. }
  119405. declare module BABYLON {
  119406. /** @hidden */
  119407. export var highlightsPixelShader: {
  119408. name: string;
  119409. shader: string;
  119410. };
  119411. }
  119412. declare module BABYLON {
  119413. /**
  119414. * Extracts highlights from the image
  119415. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  119416. */
  119417. export class HighlightsPostProcess extends PostProcess {
  119418. /**
  119419. * Extracts highlights from the image
  119420. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  119421. * @param name The name of the effect.
  119422. * @param options The required width/height ratio to downsize to before computing the render pass.
  119423. * @param camera The camera to apply the render pass to.
  119424. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119425. * @param engine The engine which the post process will be applied. (default: current engine)
  119426. * @param reusable If the post process can be reused on the same frame. (default: false)
  119427. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  119428. */
  119429. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  119430. }
  119431. }
  119432. declare module BABYLON {
  119433. /** @hidden */
  119434. export var mrtFragmentDeclaration: {
  119435. name: string;
  119436. shader: string;
  119437. };
  119438. }
  119439. declare module BABYLON {
  119440. /** @hidden */
  119441. export var geometryPixelShader: {
  119442. name: string;
  119443. shader: string;
  119444. };
  119445. }
  119446. declare module BABYLON {
  119447. /** @hidden */
  119448. export var geometryVertexShader: {
  119449. name: string;
  119450. shader: string;
  119451. };
  119452. }
  119453. declare module BABYLON {
  119454. /** @hidden */
  119455. interface ISavedTransformationMatrix {
  119456. world: Matrix;
  119457. viewProjection: Matrix;
  119458. }
  119459. /**
  119460. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  119461. */
  119462. export class GeometryBufferRenderer {
  119463. /**
  119464. * Constant used to retrieve the position texture index in the G-Buffer textures array
  119465. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  119466. */
  119467. static readonly POSITION_TEXTURE_TYPE: number;
  119468. /**
  119469. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  119470. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  119471. */
  119472. static readonly VELOCITY_TEXTURE_TYPE: number;
  119473. /**
  119474. * Dictionary used to store the previous transformation matrices of each rendered mesh
  119475. * in order to compute objects velocities when enableVelocity is set to "true"
  119476. * @hidden
  119477. */
  119478. _previousTransformationMatrices: {
  119479. [index: number]: ISavedTransformationMatrix;
  119480. };
  119481. /**
  119482. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  119483. * in order to compute objects velocities when enableVelocity is set to "true"
  119484. * @hidden
  119485. */
  119486. _previousBonesTransformationMatrices: {
  119487. [index: number]: Float32Array;
  119488. };
  119489. /**
  119490. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  119491. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  119492. */
  119493. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  119494. private _scene;
  119495. private _multiRenderTarget;
  119496. private _ratio;
  119497. private _enablePosition;
  119498. private _enableVelocity;
  119499. private _positionIndex;
  119500. private _velocityIndex;
  119501. protected _effect: Effect;
  119502. protected _cachedDefines: string;
  119503. /**
  119504. * Set the render list (meshes to be rendered) used in the G buffer.
  119505. */
  119506. renderList: Mesh[];
  119507. /**
  119508. * Gets wether or not G buffer are supported by the running hardware.
  119509. * This requires draw buffer supports
  119510. */
  119511. readonly isSupported: boolean;
  119512. /**
  119513. * Returns the index of the given texture type in the G-Buffer textures array
  119514. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  119515. * @returns the index of the given texture type in the G-Buffer textures array
  119516. */
  119517. getTextureIndex(textureType: number): number;
  119518. /**
  119519. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  119520. */
  119521. /**
  119522. * Sets whether or not objects positions are enabled for the G buffer.
  119523. */
  119524. enablePosition: boolean;
  119525. /**
  119526. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  119527. */
  119528. /**
  119529. * Sets wether or not objects velocities are enabled for the G buffer.
  119530. */
  119531. enableVelocity: boolean;
  119532. /**
  119533. * Gets the scene associated with the buffer.
  119534. */
  119535. readonly scene: Scene;
  119536. /**
  119537. * Gets the ratio used by the buffer during its creation.
  119538. * How big is the buffer related to the main canvas.
  119539. */
  119540. readonly ratio: number;
  119541. /** @hidden */
  119542. static _SceneComponentInitialization: (scene: Scene) => void;
  119543. /**
  119544. * Creates a new G Buffer for the scene
  119545. * @param scene The scene the buffer belongs to
  119546. * @param ratio How big is the buffer related to the main canvas.
  119547. */
  119548. constructor(scene: Scene, ratio?: number);
  119549. /**
  119550. * Checks wether everything is ready to render a submesh to the G buffer.
  119551. * @param subMesh the submesh to check readiness for
  119552. * @param useInstances is the mesh drawn using instance or not
  119553. * @returns true if ready otherwise false
  119554. */
  119555. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  119556. /**
  119557. * Gets the current underlying G Buffer.
  119558. * @returns the buffer
  119559. */
  119560. getGBuffer(): MultiRenderTarget;
  119561. /**
  119562. * Gets the number of samples used to render the buffer (anti aliasing).
  119563. */
  119564. /**
  119565. * Sets the number of samples used to render the buffer (anti aliasing).
  119566. */
  119567. samples: number;
  119568. /**
  119569. * Disposes the renderer and frees up associated resources.
  119570. */
  119571. dispose(): void;
  119572. protected _createRenderTargets(): void;
  119573. private _copyBonesTransformationMatrices;
  119574. }
  119575. }
  119576. declare module BABYLON {
  119577. interface Scene {
  119578. /** @hidden (Backing field) */
  119579. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  119580. /**
  119581. * Gets or Sets the current geometry buffer associated to the scene.
  119582. */
  119583. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  119584. /**
  119585. * Enables a GeometryBufferRender and associates it with the scene
  119586. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  119587. * @returns the GeometryBufferRenderer
  119588. */
  119589. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  119590. /**
  119591. * Disables the GeometryBufferRender associated with the scene
  119592. */
  119593. disableGeometryBufferRenderer(): void;
  119594. }
  119595. /**
  119596. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  119597. * in several rendering techniques.
  119598. */
  119599. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  119600. /**
  119601. * The component name helpful to identify the component in the list of scene components.
  119602. */
  119603. readonly name: string;
  119604. /**
  119605. * The scene the component belongs to.
  119606. */
  119607. scene: Scene;
  119608. /**
  119609. * Creates a new instance of the component for the given scene
  119610. * @param scene Defines the scene to register the component in
  119611. */
  119612. constructor(scene: Scene);
  119613. /**
  119614. * Registers the component in a given scene
  119615. */
  119616. register(): void;
  119617. /**
  119618. * Rebuilds the elements related to this component in case of
  119619. * context lost for instance.
  119620. */
  119621. rebuild(): void;
  119622. /**
  119623. * Disposes the component and the associated ressources
  119624. */
  119625. dispose(): void;
  119626. private _gatherRenderTargets;
  119627. }
  119628. }
  119629. declare module BABYLON {
  119630. /** @hidden */
  119631. export var motionBlurPixelShader: {
  119632. name: string;
  119633. shader: string;
  119634. };
  119635. }
  119636. declare module BABYLON {
  119637. /**
  119638. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  119639. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  119640. * As an example, all you have to do is to create the post-process:
  119641. * var mb = new BABYLON.MotionBlurPostProcess(
  119642. * 'mb', // The name of the effect.
  119643. * scene, // The scene containing the objects to blur according to their velocity.
  119644. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  119645. * camera // The camera to apply the render pass to.
  119646. * );
  119647. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  119648. */
  119649. export class MotionBlurPostProcess extends PostProcess {
  119650. /**
  119651. * Defines how much the image is blurred by the movement. Default value is equal to 1
  119652. */
  119653. motionStrength: number;
  119654. /**
  119655. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  119656. */
  119657. /**
  119658. * Sets the number of iterations to be used for motion blur quality
  119659. */
  119660. motionBlurSamples: number;
  119661. private _motionBlurSamples;
  119662. private _geometryBufferRenderer;
  119663. /**
  119664. * Creates a new instance MotionBlurPostProcess
  119665. * @param name The name of the effect.
  119666. * @param scene The scene containing the objects to blur according to their velocity.
  119667. * @param options The required width/height ratio to downsize to before computing the render pass.
  119668. * @param camera The camera to apply the render pass to.
  119669. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119670. * @param engine The engine which the post process will be applied. (default: current engine)
  119671. * @param reusable If the post process can be reused on the same frame. (default: false)
  119672. * @param textureType Type of textures used when performing the post process. (default: 0)
  119673. * @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)
  119674. */
  119675. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  119676. /**
  119677. * Excludes the given skinned mesh from computing bones velocities.
  119678. * 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.
  119679. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  119680. */
  119681. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  119682. /**
  119683. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  119684. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  119685. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  119686. */
  119687. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  119688. /**
  119689. * Disposes the post process.
  119690. * @param camera The camera to dispose the post process on.
  119691. */
  119692. dispose(camera?: Camera): void;
  119693. }
  119694. }
  119695. declare module BABYLON {
  119696. /** @hidden */
  119697. export var refractionPixelShader: {
  119698. name: string;
  119699. shader: string;
  119700. };
  119701. }
  119702. declare module BABYLON {
  119703. /**
  119704. * Post process which applies a refractin texture
  119705. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  119706. */
  119707. export class RefractionPostProcess extends PostProcess {
  119708. /** the base color of the refraction (used to taint the rendering) */
  119709. color: Color3;
  119710. /** simulated refraction depth */
  119711. depth: number;
  119712. /** the coefficient of the base color (0 to remove base color tainting) */
  119713. colorLevel: number;
  119714. private _refTexture;
  119715. private _ownRefractionTexture;
  119716. /**
  119717. * Gets or sets the refraction texture
  119718. * Please note that you are responsible for disposing the texture if you set it manually
  119719. */
  119720. refractionTexture: Texture;
  119721. /**
  119722. * Initializes the RefractionPostProcess
  119723. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  119724. * @param name The name of the effect.
  119725. * @param refractionTextureUrl Url of the refraction texture to use
  119726. * @param color the base color of the refraction (used to taint the rendering)
  119727. * @param depth simulated refraction depth
  119728. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  119729. * @param camera The camera to apply the render pass to.
  119730. * @param options The required width/height ratio to downsize to before computing the render pass.
  119731. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119732. * @param engine The engine which the post process will be applied. (default: current engine)
  119733. * @param reusable If the post process can be reused on the same frame. (default: false)
  119734. */
  119735. constructor(name: string, refractionTextureUrl: string,
  119736. /** the base color of the refraction (used to taint the rendering) */
  119737. color: Color3,
  119738. /** simulated refraction depth */
  119739. depth: number,
  119740. /** the coefficient of the base color (0 to remove base color tainting) */
  119741. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  119742. /**
  119743. * Disposes of the post process
  119744. * @param camera Camera to dispose post process on
  119745. */
  119746. dispose(camera: Camera): void;
  119747. }
  119748. }
  119749. declare module BABYLON {
  119750. /** @hidden */
  119751. export var sharpenPixelShader: {
  119752. name: string;
  119753. shader: string;
  119754. };
  119755. }
  119756. declare module BABYLON {
  119757. /**
  119758. * The SharpenPostProcess applies a sharpen kernel to every pixel
  119759. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  119760. */
  119761. export class SharpenPostProcess extends PostProcess {
  119762. /**
  119763. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  119764. */
  119765. colorAmount: number;
  119766. /**
  119767. * How much sharpness should be applied (default: 0.3)
  119768. */
  119769. edgeAmount: number;
  119770. /**
  119771. * Creates a new instance ConvolutionPostProcess
  119772. * @param name The name of the effect.
  119773. * @param options The required width/height ratio to downsize to before computing the render pass.
  119774. * @param camera The camera to apply the render pass to.
  119775. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119776. * @param engine The engine which the post process will be applied. (default: current engine)
  119777. * @param reusable If the post process can be reused on the same frame. (default: false)
  119778. * @param textureType Type of textures used when performing the post process. (default: 0)
  119779. * @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)
  119780. */
  119781. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  119782. }
  119783. }
  119784. declare module BABYLON {
  119785. /**
  119786. * PostProcessRenderPipeline
  119787. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  119788. */
  119789. export class PostProcessRenderPipeline {
  119790. private engine;
  119791. private _renderEffects;
  119792. private _renderEffectsForIsolatedPass;
  119793. /**
  119794. * List of inspectable custom properties (used by the Inspector)
  119795. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  119796. */
  119797. inspectableCustomProperties: IInspectable[];
  119798. /**
  119799. * @hidden
  119800. */
  119801. protected _cameras: Camera[];
  119802. /** @hidden */
  119803. _name: string;
  119804. /**
  119805. * Gets pipeline name
  119806. */
  119807. readonly name: string;
  119808. /**
  119809. * Initializes a PostProcessRenderPipeline
  119810. * @param engine engine to add the pipeline to
  119811. * @param name name of the pipeline
  119812. */
  119813. constructor(engine: Engine, name: string);
  119814. /**
  119815. * Gets the class name
  119816. * @returns "PostProcessRenderPipeline"
  119817. */
  119818. getClassName(): string;
  119819. /**
  119820. * If all the render effects in the pipeline are supported
  119821. */
  119822. readonly isSupported: boolean;
  119823. /**
  119824. * Adds an effect to the pipeline
  119825. * @param renderEffect the effect to add
  119826. */
  119827. addEffect(renderEffect: PostProcessRenderEffect): void;
  119828. /** @hidden */
  119829. _rebuild(): void;
  119830. /** @hidden */
  119831. _enableEffect(renderEffectName: string, cameras: Camera): void;
  119832. /** @hidden */
  119833. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  119834. /** @hidden */
  119835. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  119836. /** @hidden */
  119837. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  119838. /** @hidden */
  119839. _attachCameras(cameras: Camera, unique: boolean): void;
  119840. /** @hidden */
  119841. _attachCameras(cameras: Camera[], unique: boolean): void;
  119842. /** @hidden */
  119843. _detachCameras(cameras: Camera): void;
  119844. /** @hidden */
  119845. _detachCameras(cameras: Nullable<Camera[]>): void;
  119846. /** @hidden */
  119847. _update(): void;
  119848. /** @hidden */
  119849. _reset(): void;
  119850. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  119851. /**
  119852. * Disposes of the pipeline
  119853. */
  119854. dispose(): void;
  119855. }
  119856. }
  119857. declare module BABYLON {
  119858. /**
  119859. * PostProcessRenderPipelineManager class
  119860. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  119861. */
  119862. export class PostProcessRenderPipelineManager {
  119863. private _renderPipelines;
  119864. /**
  119865. * Initializes a PostProcessRenderPipelineManager
  119866. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  119867. */
  119868. constructor();
  119869. /**
  119870. * Gets the list of supported render pipelines
  119871. */
  119872. readonly supportedPipelines: PostProcessRenderPipeline[];
  119873. /**
  119874. * Adds a pipeline to the manager
  119875. * @param renderPipeline The pipeline to add
  119876. */
  119877. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  119878. /**
  119879. * Attaches a camera to the pipeline
  119880. * @param renderPipelineName The name of the pipeline to attach to
  119881. * @param cameras the camera to attach
  119882. * @param unique if the camera can be attached multiple times to the pipeline
  119883. */
  119884. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  119885. /**
  119886. * Detaches a camera from the pipeline
  119887. * @param renderPipelineName The name of the pipeline to detach from
  119888. * @param cameras the camera to detach
  119889. */
  119890. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  119891. /**
  119892. * Enables an effect by name on a pipeline
  119893. * @param renderPipelineName the name of the pipeline to enable the effect in
  119894. * @param renderEffectName the name of the effect to enable
  119895. * @param cameras the cameras that the effect should be enabled on
  119896. */
  119897. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  119898. /**
  119899. * Disables an effect by name on a pipeline
  119900. * @param renderPipelineName the name of the pipeline to disable the effect in
  119901. * @param renderEffectName the name of the effect to disable
  119902. * @param cameras the cameras that the effect should be disabled on
  119903. */
  119904. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  119905. /**
  119906. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  119907. */
  119908. update(): void;
  119909. /** @hidden */
  119910. _rebuild(): void;
  119911. /**
  119912. * Disposes of the manager and pipelines
  119913. */
  119914. dispose(): void;
  119915. }
  119916. }
  119917. declare module BABYLON {
  119918. interface Scene {
  119919. /** @hidden (Backing field) */
  119920. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  119921. /**
  119922. * Gets the postprocess render pipeline manager
  119923. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  119924. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  119925. */
  119926. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  119927. }
  119928. /**
  119929. * Defines the Render Pipeline scene component responsible to rendering pipelines
  119930. */
  119931. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  119932. /**
  119933. * The component name helpfull to identify the component in the list of scene components.
  119934. */
  119935. readonly name: string;
  119936. /**
  119937. * The scene the component belongs to.
  119938. */
  119939. scene: Scene;
  119940. /**
  119941. * Creates a new instance of the component for the given scene
  119942. * @param scene Defines the scene to register the component in
  119943. */
  119944. constructor(scene: Scene);
  119945. /**
  119946. * Registers the component in a given scene
  119947. */
  119948. register(): void;
  119949. /**
  119950. * Rebuilds the elements related to this component in case of
  119951. * context lost for instance.
  119952. */
  119953. rebuild(): void;
  119954. /**
  119955. * Disposes the component and the associated ressources
  119956. */
  119957. dispose(): void;
  119958. private _gatherRenderTargets;
  119959. }
  119960. }
  119961. declare module BABYLON {
  119962. /**
  119963. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  119964. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  119965. */
  119966. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  119967. private _scene;
  119968. private _camerasToBeAttached;
  119969. /**
  119970. * ID of the sharpen post process,
  119971. */
  119972. private readonly SharpenPostProcessId;
  119973. /**
  119974. * @ignore
  119975. * ID of the image processing post process;
  119976. */
  119977. readonly ImageProcessingPostProcessId: string;
  119978. /**
  119979. * @ignore
  119980. * ID of the Fast Approximate Anti-Aliasing post process;
  119981. */
  119982. readonly FxaaPostProcessId: string;
  119983. /**
  119984. * ID of the chromatic aberration post process,
  119985. */
  119986. private readonly ChromaticAberrationPostProcessId;
  119987. /**
  119988. * ID of the grain post process
  119989. */
  119990. private readonly GrainPostProcessId;
  119991. /**
  119992. * Sharpen post process which will apply a sharpen convolution to enhance edges
  119993. */
  119994. sharpen: SharpenPostProcess;
  119995. private _sharpenEffect;
  119996. private bloom;
  119997. /**
  119998. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  119999. */
  120000. depthOfField: DepthOfFieldEffect;
  120001. /**
  120002. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  120003. */
  120004. fxaa: FxaaPostProcess;
  120005. /**
  120006. * Image post processing pass used to perform operations such as tone mapping or color grading.
  120007. */
  120008. imageProcessing: ImageProcessingPostProcess;
  120009. /**
  120010. * Chromatic aberration post process which will shift rgb colors in the image
  120011. */
  120012. chromaticAberration: ChromaticAberrationPostProcess;
  120013. private _chromaticAberrationEffect;
  120014. /**
  120015. * Grain post process which add noise to the image
  120016. */
  120017. grain: GrainPostProcess;
  120018. private _grainEffect;
  120019. /**
  120020. * Glow post process which adds a glow to emissive areas of the image
  120021. */
  120022. private _glowLayer;
  120023. /**
  120024. * Animations which can be used to tweak settings over a period of time
  120025. */
  120026. animations: Animation[];
  120027. private _imageProcessingConfigurationObserver;
  120028. private _sharpenEnabled;
  120029. private _bloomEnabled;
  120030. private _depthOfFieldEnabled;
  120031. private _depthOfFieldBlurLevel;
  120032. private _fxaaEnabled;
  120033. private _imageProcessingEnabled;
  120034. private _defaultPipelineTextureType;
  120035. private _bloomScale;
  120036. private _chromaticAberrationEnabled;
  120037. private _grainEnabled;
  120038. private _buildAllowed;
  120039. /**
  120040. * Gets active scene
  120041. */
  120042. readonly scene: Scene;
  120043. /**
  120044. * Enable or disable the sharpen process from the pipeline
  120045. */
  120046. sharpenEnabled: boolean;
  120047. private _resizeObserver;
  120048. private _hardwareScaleLevel;
  120049. private _bloomKernel;
  120050. /**
  120051. * Specifies the size of the bloom blur kernel, relative to the final output size
  120052. */
  120053. bloomKernel: number;
  120054. /**
  120055. * Specifies the weight of the bloom in the final rendering
  120056. */
  120057. private _bloomWeight;
  120058. /**
  120059. * Specifies the luma threshold for the area that will be blurred by the bloom
  120060. */
  120061. private _bloomThreshold;
  120062. private _hdr;
  120063. /**
  120064. * The strength of the bloom.
  120065. */
  120066. bloomWeight: number;
  120067. /**
  120068. * The strength of the bloom.
  120069. */
  120070. bloomThreshold: number;
  120071. /**
  120072. * The scale of the bloom, lower value will provide better performance.
  120073. */
  120074. bloomScale: number;
  120075. /**
  120076. * Enable or disable the bloom from the pipeline
  120077. */
  120078. bloomEnabled: boolean;
  120079. private _rebuildBloom;
  120080. /**
  120081. * If the depth of field is enabled.
  120082. */
  120083. depthOfFieldEnabled: boolean;
  120084. /**
  120085. * Blur level of the depth of field effect. (Higher blur will effect performance)
  120086. */
  120087. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  120088. /**
  120089. * If the anti aliasing is enabled.
  120090. */
  120091. fxaaEnabled: boolean;
  120092. private _samples;
  120093. /**
  120094. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  120095. */
  120096. samples: number;
  120097. /**
  120098. * If image processing is enabled.
  120099. */
  120100. imageProcessingEnabled: boolean;
  120101. /**
  120102. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  120103. */
  120104. glowLayerEnabled: boolean;
  120105. /**
  120106. * Gets the glow layer (or null if not defined)
  120107. */
  120108. readonly glowLayer: Nullable<GlowLayer>;
  120109. /**
  120110. * Enable or disable the chromaticAberration process from the pipeline
  120111. */
  120112. chromaticAberrationEnabled: boolean;
  120113. /**
  120114. * Enable or disable the grain process from the pipeline
  120115. */
  120116. grainEnabled: boolean;
  120117. /**
  120118. * @constructor
  120119. * @param name - The rendering pipeline name (default: "")
  120120. * @param hdr - If high dynamic range textures should be used (default: true)
  120121. * @param scene - The scene linked to this pipeline (default: the last created scene)
  120122. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  120123. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  120124. */
  120125. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  120126. /**
  120127. * Get the class name
  120128. * @returns "DefaultRenderingPipeline"
  120129. */
  120130. getClassName(): string;
  120131. /**
  120132. * Force the compilation of the entire pipeline.
  120133. */
  120134. prepare(): void;
  120135. private _hasCleared;
  120136. private _prevPostProcess;
  120137. private _prevPrevPostProcess;
  120138. private _setAutoClearAndTextureSharing;
  120139. private _depthOfFieldSceneObserver;
  120140. private _buildPipeline;
  120141. private _disposePostProcesses;
  120142. /**
  120143. * Adds a camera to the pipeline
  120144. * @param camera the camera to be added
  120145. */
  120146. addCamera(camera: Camera): void;
  120147. /**
  120148. * Removes a camera from the pipeline
  120149. * @param camera the camera to remove
  120150. */
  120151. removeCamera(camera: Camera): void;
  120152. /**
  120153. * Dispose of the pipeline and stop all post processes
  120154. */
  120155. dispose(): void;
  120156. /**
  120157. * Serialize the rendering pipeline (Used when exporting)
  120158. * @returns the serialized object
  120159. */
  120160. serialize(): any;
  120161. /**
  120162. * Parse the serialized pipeline
  120163. * @param source Source pipeline.
  120164. * @param scene The scene to load the pipeline to.
  120165. * @param rootUrl The URL of the serialized pipeline.
  120166. * @returns An instantiated pipeline from the serialized object.
  120167. */
  120168. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  120169. }
  120170. }
  120171. declare module BABYLON {
  120172. /** @hidden */
  120173. export var lensHighlightsPixelShader: {
  120174. name: string;
  120175. shader: string;
  120176. };
  120177. }
  120178. declare module BABYLON {
  120179. /** @hidden */
  120180. export var depthOfFieldPixelShader: {
  120181. name: string;
  120182. shader: string;
  120183. };
  120184. }
  120185. declare module BABYLON {
  120186. /**
  120187. * BABYLON.JS Chromatic Aberration GLSL Shader
  120188. * Author: Olivier Guyot
  120189. * Separates very slightly R, G and B colors on the edges of the screen
  120190. * Inspired by Francois Tarlier & Martins Upitis
  120191. */
  120192. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  120193. /**
  120194. * @ignore
  120195. * The chromatic aberration PostProcess id in the pipeline
  120196. */
  120197. LensChromaticAberrationEffect: string;
  120198. /**
  120199. * @ignore
  120200. * The highlights enhancing PostProcess id in the pipeline
  120201. */
  120202. HighlightsEnhancingEffect: string;
  120203. /**
  120204. * @ignore
  120205. * The depth-of-field PostProcess id in the pipeline
  120206. */
  120207. LensDepthOfFieldEffect: string;
  120208. private _scene;
  120209. private _depthTexture;
  120210. private _grainTexture;
  120211. private _chromaticAberrationPostProcess;
  120212. private _highlightsPostProcess;
  120213. private _depthOfFieldPostProcess;
  120214. private _edgeBlur;
  120215. private _grainAmount;
  120216. private _chromaticAberration;
  120217. private _distortion;
  120218. private _highlightsGain;
  120219. private _highlightsThreshold;
  120220. private _dofDistance;
  120221. private _dofAperture;
  120222. private _dofDarken;
  120223. private _dofPentagon;
  120224. private _blurNoise;
  120225. /**
  120226. * @constructor
  120227. *
  120228. * Effect parameters are as follow:
  120229. * {
  120230. * chromatic_aberration: number; // from 0 to x (1 for realism)
  120231. * edge_blur: number; // from 0 to x (1 for realism)
  120232. * distortion: number; // from 0 to x (1 for realism)
  120233. * grain_amount: number; // from 0 to 1
  120234. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  120235. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  120236. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  120237. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  120238. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  120239. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  120240. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  120241. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  120242. * }
  120243. * Note: if an effect parameter is unset, effect is disabled
  120244. *
  120245. * @param name The rendering pipeline name
  120246. * @param parameters - An object containing all parameters (see above)
  120247. * @param scene The scene linked to this pipeline
  120248. * @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)
  120249. * @param cameras The array of cameras that the rendering pipeline will be attached to
  120250. */
  120251. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  120252. /**
  120253. * Get the class name
  120254. * @returns "LensRenderingPipeline"
  120255. */
  120256. getClassName(): string;
  120257. /**
  120258. * Gets associated scene
  120259. */
  120260. readonly scene: Scene;
  120261. /**
  120262. * Gets or sets the edge blur
  120263. */
  120264. edgeBlur: number;
  120265. /**
  120266. * Gets or sets the grain amount
  120267. */
  120268. grainAmount: number;
  120269. /**
  120270. * Gets or sets the chromatic aberration amount
  120271. */
  120272. chromaticAberration: number;
  120273. /**
  120274. * Gets or sets the depth of field aperture
  120275. */
  120276. dofAperture: number;
  120277. /**
  120278. * Gets or sets the edge distortion
  120279. */
  120280. edgeDistortion: number;
  120281. /**
  120282. * Gets or sets the depth of field distortion
  120283. */
  120284. dofDistortion: number;
  120285. /**
  120286. * Gets or sets the darken out of focus amount
  120287. */
  120288. darkenOutOfFocus: number;
  120289. /**
  120290. * Gets or sets a boolean indicating if blur noise is enabled
  120291. */
  120292. blurNoise: boolean;
  120293. /**
  120294. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  120295. */
  120296. pentagonBokeh: boolean;
  120297. /**
  120298. * Gets or sets the highlight grain amount
  120299. */
  120300. highlightsGain: number;
  120301. /**
  120302. * Gets or sets the highlight threshold
  120303. */
  120304. highlightsThreshold: number;
  120305. /**
  120306. * Sets the amount of blur at the edges
  120307. * @param amount blur amount
  120308. */
  120309. setEdgeBlur(amount: number): void;
  120310. /**
  120311. * Sets edge blur to 0
  120312. */
  120313. disableEdgeBlur(): void;
  120314. /**
  120315. * Sets the amout of grain
  120316. * @param amount Amount of grain
  120317. */
  120318. setGrainAmount(amount: number): void;
  120319. /**
  120320. * Set grain amount to 0
  120321. */
  120322. disableGrain(): void;
  120323. /**
  120324. * Sets the chromatic aberration amount
  120325. * @param amount amount of chromatic aberration
  120326. */
  120327. setChromaticAberration(amount: number): void;
  120328. /**
  120329. * Sets chromatic aberration amount to 0
  120330. */
  120331. disableChromaticAberration(): void;
  120332. /**
  120333. * Sets the EdgeDistortion amount
  120334. * @param amount amount of EdgeDistortion
  120335. */
  120336. setEdgeDistortion(amount: number): void;
  120337. /**
  120338. * Sets edge distortion to 0
  120339. */
  120340. disableEdgeDistortion(): void;
  120341. /**
  120342. * Sets the FocusDistance amount
  120343. * @param amount amount of FocusDistance
  120344. */
  120345. setFocusDistance(amount: number): void;
  120346. /**
  120347. * Disables depth of field
  120348. */
  120349. disableDepthOfField(): void;
  120350. /**
  120351. * Sets the Aperture amount
  120352. * @param amount amount of Aperture
  120353. */
  120354. setAperture(amount: number): void;
  120355. /**
  120356. * Sets the DarkenOutOfFocus amount
  120357. * @param amount amount of DarkenOutOfFocus
  120358. */
  120359. setDarkenOutOfFocus(amount: number): void;
  120360. private _pentagonBokehIsEnabled;
  120361. /**
  120362. * Creates a pentagon bokeh effect
  120363. */
  120364. enablePentagonBokeh(): void;
  120365. /**
  120366. * Disables the pentagon bokeh effect
  120367. */
  120368. disablePentagonBokeh(): void;
  120369. /**
  120370. * Enables noise blur
  120371. */
  120372. enableNoiseBlur(): void;
  120373. /**
  120374. * Disables noise blur
  120375. */
  120376. disableNoiseBlur(): void;
  120377. /**
  120378. * Sets the HighlightsGain amount
  120379. * @param amount amount of HighlightsGain
  120380. */
  120381. setHighlightsGain(amount: number): void;
  120382. /**
  120383. * Sets the HighlightsThreshold amount
  120384. * @param amount amount of HighlightsThreshold
  120385. */
  120386. setHighlightsThreshold(amount: number): void;
  120387. /**
  120388. * Disables highlights
  120389. */
  120390. disableHighlights(): void;
  120391. /**
  120392. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  120393. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  120394. */
  120395. dispose(disableDepthRender?: boolean): void;
  120396. private _createChromaticAberrationPostProcess;
  120397. private _createHighlightsPostProcess;
  120398. private _createDepthOfFieldPostProcess;
  120399. private _createGrainTexture;
  120400. }
  120401. }
  120402. declare module BABYLON {
  120403. /** @hidden */
  120404. export var ssao2PixelShader: {
  120405. name: string;
  120406. shader: string;
  120407. };
  120408. }
  120409. declare module BABYLON {
  120410. /** @hidden */
  120411. export var ssaoCombinePixelShader: {
  120412. name: string;
  120413. shader: string;
  120414. };
  120415. }
  120416. declare module BABYLON {
  120417. /**
  120418. * Render pipeline to produce ssao effect
  120419. */
  120420. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  120421. /**
  120422. * @ignore
  120423. * The PassPostProcess id in the pipeline that contains the original scene color
  120424. */
  120425. SSAOOriginalSceneColorEffect: string;
  120426. /**
  120427. * @ignore
  120428. * The SSAO PostProcess id in the pipeline
  120429. */
  120430. SSAORenderEffect: string;
  120431. /**
  120432. * @ignore
  120433. * The horizontal blur PostProcess id in the pipeline
  120434. */
  120435. SSAOBlurHRenderEffect: string;
  120436. /**
  120437. * @ignore
  120438. * The vertical blur PostProcess id in the pipeline
  120439. */
  120440. SSAOBlurVRenderEffect: string;
  120441. /**
  120442. * @ignore
  120443. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  120444. */
  120445. SSAOCombineRenderEffect: string;
  120446. /**
  120447. * The output strength of the SSAO post-process. Default value is 1.0.
  120448. */
  120449. totalStrength: number;
  120450. /**
  120451. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  120452. */
  120453. maxZ: number;
  120454. /**
  120455. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  120456. */
  120457. minZAspect: number;
  120458. private _samples;
  120459. /**
  120460. * Number of samples used for the SSAO calculations. Default value is 8
  120461. */
  120462. samples: number;
  120463. private _textureSamples;
  120464. /**
  120465. * Number of samples to use for antialiasing
  120466. */
  120467. textureSamples: number;
  120468. /**
  120469. * Ratio object used for SSAO ratio and blur ratio
  120470. */
  120471. private _ratio;
  120472. /**
  120473. * Dynamically generated sphere sampler.
  120474. */
  120475. private _sampleSphere;
  120476. /**
  120477. * Blur filter offsets
  120478. */
  120479. private _samplerOffsets;
  120480. private _expensiveBlur;
  120481. /**
  120482. * If bilateral blur should be used
  120483. */
  120484. expensiveBlur: boolean;
  120485. /**
  120486. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  120487. */
  120488. radius: number;
  120489. /**
  120490. * The base color of the SSAO post-process
  120491. * The final result is "base + ssao" between [0, 1]
  120492. */
  120493. base: number;
  120494. /**
  120495. * Support test.
  120496. */
  120497. static readonly IsSupported: boolean;
  120498. private _scene;
  120499. private _depthTexture;
  120500. private _normalTexture;
  120501. private _randomTexture;
  120502. private _originalColorPostProcess;
  120503. private _ssaoPostProcess;
  120504. private _blurHPostProcess;
  120505. private _blurVPostProcess;
  120506. private _ssaoCombinePostProcess;
  120507. private _firstUpdate;
  120508. /**
  120509. * Gets active scene
  120510. */
  120511. readonly scene: Scene;
  120512. /**
  120513. * @constructor
  120514. * @param name The rendering pipeline name
  120515. * @param scene The scene linked to this pipeline
  120516. * @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 }
  120517. * @param cameras The array of cameras that the rendering pipeline will be attached to
  120518. */
  120519. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  120520. /**
  120521. * Get the class name
  120522. * @returns "SSAO2RenderingPipeline"
  120523. */
  120524. getClassName(): string;
  120525. /**
  120526. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  120527. */
  120528. dispose(disableGeometryBufferRenderer?: boolean): void;
  120529. private _createBlurPostProcess;
  120530. /** @hidden */
  120531. _rebuild(): void;
  120532. private _bits;
  120533. private _radicalInverse_VdC;
  120534. private _hammersley;
  120535. private _hemisphereSample_uniform;
  120536. private _generateHemisphere;
  120537. private _createSSAOPostProcess;
  120538. private _createSSAOCombinePostProcess;
  120539. private _createRandomTexture;
  120540. /**
  120541. * Serialize the rendering pipeline (Used when exporting)
  120542. * @returns the serialized object
  120543. */
  120544. serialize(): any;
  120545. /**
  120546. * Parse the serialized pipeline
  120547. * @param source Source pipeline.
  120548. * @param scene The scene to load the pipeline to.
  120549. * @param rootUrl The URL of the serialized pipeline.
  120550. * @returns An instantiated pipeline from the serialized object.
  120551. */
  120552. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  120553. }
  120554. }
  120555. declare module BABYLON {
  120556. /** @hidden */
  120557. export var ssaoPixelShader: {
  120558. name: string;
  120559. shader: string;
  120560. };
  120561. }
  120562. declare module BABYLON {
  120563. /**
  120564. * Render pipeline to produce ssao effect
  120565. */
  120566. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  120567. /**
  120568. * @ignore
  120569. * The PassPostProcess id in the pipeline that contains the original scene color
  120570. */
  120571. SSAOOriginalSceneColorEffect: string;
  120572. /**
  120573. * @ignore
  120574. * The SSAO PostProcess id in the pipeline
  120575. */
  120576. SSAORenderEffect: string;
  120577. /**
  120578. * @ignore
  120579. * The horizontal blur PostProcess id in the pipeline
  120580. */
  120581. SSAOBlurHRenderEffect: string;
  120582. /**
  120583. * @ignore
  120584. * The vertical blur PostProcess id in the pipeline
  120585. */
  120586. SSAOBlurVRenderEffect: string;
  120587. /**
  120588. * @ignore
  120589. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  120590. */
  120591. SSAOCombineRenderEffect: string;
  120592. /**
  120593. * The output strength of the SSAO post-process. Default value is 1.0.
  120594. */
  120595. totalStrength: number;
  120596. /**
  120597. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  120598. */
  120599. radius: number;
  120600. /**
  120601. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  120602. * Must not be equal to fallOff and superior to fallOff.
  120603. * Default value is 0.0075
  120604. */
  120605. area: number;
  120606. /**
  120607. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  120608. * Must not be equal to area and inferior to area.
  120609. * Default value is 0.000001
  120610. */
  120611. fallOff: number;
  120612. /**
  120613. * The base color of the SSAO post-process
  120614. * The final result is "base + ssao" between [0, 1]
  120615. */
  120616. base: number;
  120617. private _scene;
  120618. private _depthTexture;
  120619. private _randomTexture;
  120620. private _originalColorPostProcess;
  120621. private _ssaoPostProcess;
  120622. private _blurHPostProcess;
  120623. private _blurVPostProcess;
  120624. private _ssaoCombinePostProcess;
  120625. private _firstUpdate;
  120626. /**
  120627. * Gets active scene
  120628. */
  120629. readonly scene: Scene;
  120630. /**
  120631. * @constructor
  120632. * @param name - The rendering pipeline name
  120633. * @param scene - The scene linked to this pipeline
  120634. * @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 }
  120635. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  120636. */
  120637. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  120638. /**
  120639. * Get the class name
  120640. * @returns "SSAORenderingPipeline"
  120641. */
  120642. getClassName(): string;
  120643. /**
  120644. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  120645. */
  120646. dispose(disableDepthRender?: boolean): void;
  120647. private _createBlurPostProcess;
  120648. /** @hidden */
  120649. _rebuild(): void;
  120650. private _createSSAOPostProcess;
  120651. private _createSSAOCombinePostProcess;
  120652. private _createRandomTexture;
  120653. }
  120654. }
  120655. declare module BABYLON {
  120656. /** @hidden */
  120657. export var standardPixelShader: {
  120658. name: string;
  120659. shader: string;
  120660. };
  120661. }
  120662. declare module BABYLON {
  120663. /**
  120664. * Standard rendering pipeline
  120665. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  120666. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  120667. */
  120668. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  120669. /**
  120670. * Public members
  120671. */
  120672. /**
  120673. * Post-process which contains the original scene color before the pipeline applies all the effects
  120674. */
  120675. originalPostProcess: Nullable<PostProcess>;
  120676. /**
  120677. * Post-process used to down scale an image x4
  120678. */
  120679. downSampleX4PostProcess: Nullable<PostProcess>;
  120680. /**
  120681. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  120682. */
  120683. brightPassPostProcess: Nullable<PostProcess>;
  120684. /**
  120685. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  120686. */
  120687. blurHPostProcesses: PostProcess[];
  120688. /**
  120689. * Post-process array storing all the vertical blur post-processes used by the pipeline
  120690. */
  120691. blurVPostProcesses: PostProcess[];
  120692. /**
  120693. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  120694. */
  120695. textureAdderPostProcess: Nullable<PostProcess>;
  120696. /**
  120697. * Post-process used to create volumetric lighting effect
  120698. */
  120699. volumetricLightPostProcess: Nullable<PostProcess>;
  120700. /**
  120701. * Post-process used to smooth the previous volumetric light post-process on the X axis
  120702. */
  120703. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  120704. /**
  120705. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  120706. */
  120707. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  120708. /**
  120709. * Post-process used to merge the volumetric light effect and the real scene color
  120710. */
  120711. volumetricLightMergePostProces: Nullable<PostProcess>;
  120712. /**
  120713. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  120714. */
  120715. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  120716. /**
  120717. * Base post-process used to calculate the average luminance of the final image for HDR
  120718. */
  120719. luminancePostProcess: Nullable<PostProcess>;
  120720. /**
  120721. * Post-processes used to create down sample post-processes in order to get
  120722. * the average luminance of the final image for HDR
  120723. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  120724. */
  120725. luminanceDownSamplePostProcesses: PostProcess[];
  120726. /**
  120727. * Post-process used to create a HDR effect (light adaptation)
  120728. */
  120729. hdrPostProcess: Nullable<PostProcess>;
  120730. /**
  120731. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  120732. */
  120733. textureAdderFinalPostProcess: Nullable<PostProcess>;
  120734. /**
  120735. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  120736. */
  120737. lensFlareFinalPostProcess: Nullable<PostProcess>;
  120738. /**
  120739. * Post-process used to merge the final HDR post-process and the real scene color
  120740. */
  120741. hdrFinalPostProcess: Nullable<PostProcess>;
  120742. /**
  120743. * Post-process used to create a lens flare effect
  120744. */
  120745. lensFlarePostProcess: Nullable<PostProcess>;
  120746. /**
  120747. * Post-process that merges the result of the lens flare post-process and the real scene color
  120748. */
  120749. lensFlareComposePostProcess: Nullable<PostProcess>;
  120750. /**
  120751. * Post-process used to create a motion blur effect
  120752. */
  120753. motionBlurPostProcess: Nullable<PostProcess>;
  120754. /**
  120755. * Post-process used to create a depth of field effect
  120756. */
  120757. depthOfFieldPostProcess: Nullable<PostProcess>;
  120758. /**
  120759. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  120760. */
  120761. fxaaPostProcess: Nullable<FxaaPostProcess>;
  120762. /**
  120763. * Represents the brightness threshold in order to configure the illuminated surfaces
  120764. */
  120765. brightThreshold: number;
  120766. /**
  120767. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  120768. */
  120769. blurWidth: number;
  120770. /**
  120771. * Sets if the blur for highlighted surfaces must be only horizontal
  120772. */
  120773. horizontalBlur: boolean;
  120774. /**
  120775. * Gets the overall exposure used by the pipeline
  120776. */
  120777. /**
  120778. * Sets the overall exposure used by the pipeline
  120779. */
  120780. exposure: number;
  120781. /**
  120782. * Texture used typically to simulate "dirty" on camera lens
  120783. */
  120784. lensTexture: Nullable<Texture>;
  120785. /**
  120786. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  120787. */
  120788. volumetricLightCoefficient: number;
  120789. /**
  120790. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  120791. */
  120792. volumetricLightPower: number;
  120793. /**
  120794. * Used the set the blur intensity to smooth the volumetric lights
  120795. */
  120796. volumetricLightBlurScale: number;
  120797. /**
  120798. * Light (spot or directional) used to generate the volumetric lights rays
  120799. * The source light must have a shadow generate so the pipeline can get its
  120800. * depth map
  120801. */
  120802. sourceLight: Nullable<SpotLight | DirectionalLight>;
  120803. /**
  120804. * For eye adaptation, represents the minimum luminance the eye can see
  120805. */
  120806. hdrMinimumLuminance: number;
  120807. /**
  120808. * For eye adaptation, represents the decrease luminance speed
  120809. */
  120810. hdrDecreaseRate: number;
  120811. /**
  120812. * For eye adaptation, represents the increase luminance speed
  120813. */
  120814. hdrIncreaseRate: number;
  120815. /**
  120816. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  120817. */
  120818. /**
  120819. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  120820. */
  120821. hdrAutoExposure: boolean;
  120822. /**
  120823. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  120824. */
  120825. lensColorTexture: Nullable<Texture>;
  120826. /**
  120827. * The overall strengh for the lens flare effect
  120828. */
  120829. lensFlareStrength: number;
  120830. /**
  120831. * Dispersion coefficient for lens flare ghosts
  120832. */
  120833. lensFlareGhostDispersal: number;
  120834. /**
  120835. * Main lens flare halo width
  120836. */
  120837. lensFlareHaloWidth: number;
  120838. /**
  120839. * Based on the lens distortion effect, defines how much the lens flare result
  120840. * is distorted
  120841. */
  120842. lensFlareDistortionStrength: number;
  120843. /**
  120844. * Lens star texture must be used to simulate rays on the flares and is available
  120845. * in the documentation
  120846. */
  120847. lensStarTexture: Nullable<Texture>;
  120848. /**
  120849. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  120850. * flare effect by taking account of the dirt texture
  120851. */
  120852. lensFlareDirtTexture: Nullable<Texture>;
  120853. /**
  120854. * Represents the focal length for the depth of field effect
  120855. */
  120856. depthOfFieldDistance: number;
  120857. /**
  120858. * Represents the blur intensity for the blurred part of the depth of field effect
  120859. */
  120860. depthOfFieldBlurWidth: number;
  120861. /**
  120862. * Gets how much the image is blurred by the movement while using the motion blur post-process
  120863. */
  120864. /**
  120865. * Sets how much the image is blurred by the movement while using the motion blur post-process
  120866. */
  120867. motionStrength: number;
  120868. /**
  120869. * Gets wether or not the motion blur post-process is object based or screen based.
  120870. */
  120871. /**
  120872. * Sets wether or not the motion blur post-process should be object based or screen based
  120873. */
  120874. objectBasedMotionBlur: boolean;
  120875. /**
  120876. * List of animations for the pipeline (IAnimatable implementation)
  120877. */
  120878. animations: Animation[];
  120879. /**
  120880. * Private members
  120881. */
  120882. private _scene;
  120883. private _currentDepthOfFieldSource;
  120884. private _basePostProcess;
  120885. private _fixedExposure;
  120886. private _currentExposure;
  120887. private _hdrAutoExposure;
  120888. private _hdrCurrentLuminance;
  120889. private _motionStrength;
  120890. private _isObjectBasedMotionBlur;
  120891. private _floatTextureType;
  120892. private _ratio;
  120893. private _bloomEnabled;
  120894. private _depthOfFieldEnabled;
  120895. private _vlsEnabled;
  120896. private _lensFlareEnabled;
  120897. private _hdrEnabled;
  120898. private _motionBlurEnabled;
  120899. private _fxaaEnabled;
  120900. private _motionBlurSamples;
  120901. private _volumetricLightStepsCount;
  120902. private _samples;
  120903. /**
  120904. * @ignore
  120905. * Specifies if the bloom pipeline is enabled
  120906. */
  120907. BloomEnabled: boolean;
  120908. /**
  120909. * @ignore
  120910. * Specifies if the depth of field pipeline is enabed
  120911. */
  120912. DepthOfFieldEnabled: boolean;
  120913. /**
  120914. * @ignore
  120915. * Specifies if the lens flare pipeline is enabed
  120916. */
  120917. LensFlareEnabled: boolean;
  120918. /**
  120919. * @ignore
  120920. * Specifies if the HDR pipeline is enabled
  120921. */
  120922. HDREnabled: boolean;
  120923. /**
  120924. * @ignore
  120925. * Specifies if the volumetric lights scattering effect is enabled
  120926. */
  120927. VLSEnabled: boolean;
  120928. /**
  120929. * @ignore
  120930. * Specifies if the motion blur effect is enabled
  120931. */
  120932. MotionBlurEnabled: boolean;
  120933. /**
  120934. * Specifies if anti-aliasing is enabled
  120935. */
  120936. fxaaEnabled: boolean;
  120937. /**
  120938. * Specifies the number of steps used to calculate the volumetric lights
  120939. * Typically in interval [50, 200]
  120940. */
  120941. volumetricLightStepsCount: number;
  120942. /**
  120943. * Specifies the number of samples used for the motion blur effect
  120944. * Typically in interval [16, 64]
  120945. */
  120946. motionBlurSamples: number;
  120947. /**
  120948. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  120949. */
  120950. samples: number;
  120951. /**
  120952. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  120953. * @constructor
  120954. * @param name The rendering pipeline name
  120955. * @param scene The scene linked to this pipeline
  120956. * @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)
  120957. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  120958. * @param cameras The array of cameras that the rendering pipeline will be attached to
  120959. */
  120960. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  120961. private _buildPipeline;
  120962. private _createDownSampleX4PostProcess;
  120963. private _createBrightPassPostProcess;
  120964. private _createBlurPostProcesses;
  120965. private _createTextureAdderPostProcess;
  120966. private _createVolumetricLightPostProcess;
  120967. private _createLuminancePostProcesses;
  120968. private _createHdrPostProcess;
  120969. private _createLensFlarePostProcess;
  120970. private _createDepthOfFieldPostProcess;
  120971. private _createMotionBlurPostProcess;
  120972. private _getDepthTexture;
  120973. private _disposePostProcesses;
  120974. /**
  120975. * Dispose of the pipeline and stop all post processes
  120976. */
  120977. dispose(): void;
  120978. /**
  120979. * Serialize the rendering pipeline (Used when exporting)
  120980. * @returns the serialized object
  120981. */
  120982. serialize(): any;
  120983. /**
  120984. * Parse the serialized pipeline
  120985. * @param source Source pipeline.
  120986. * @param scene The scene to load the pipeline to.
  120987. * @param rootUrl The URL of the serialized pipeline.
  120988. * @returns An instantiated pipeline from the serialized object.
  120989. */
  120990. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  120991. /**
  120992. * Luminance steps
  120993. */
  120994. static LuminanceSteps: number;
  120995. }
  120996. }
  120997. declare module BABYLON {
  120998. /** @hidden */
  120999. export var tonemapPixelShader: {
  121000. name: string;
  121001. shader: string;
  121002. };
  121003. }
  121004. declare module BABYLON {
  121005. /** Defines operator used for tonemapping */
  121006. export enum TonemappingOperator {
  121007. /** Hable */
  121008. Hable = 0,
  121009. /** Reinhard */
  121010. Reinhard = 1,
  121011. /** HejiDawson */
  121012. HejiDawson = 2,
  121013. /** Photographic */
  121014. Photographic = 3
  121015. }
  121016. /**
  121017. * Defines a post process to apply tone mapping
  121018. */
  121019. export class TonemapPostProcess extends PostProcess {
  121020. private _operator;
  121021. /** Defines the required exposure adjustement */
  121022. exposureAdjustment: number;
  121023. /**
  121024. * Creates a new TonemapPostProcess
  121025. * @param name defines the name of the postprocess
  121026. * @param _operator defines the operator to use
  121027. * @param exposureAdjustment defines the required exposure adjustement
  121028. * @param camera defines the camera to use (can be null)
  121029. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  121030. * @param engine defines the hosting engine (can be ignore if camera is set)
  121031. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  121032. */
  121033. constructor(name: string, _operator: TonemappingOperator,
  121034. /** Defines the required exposure adjustement */
  121035. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  121036. }
  121037. }
  121038. declare module BABYLON {
  121039. /** @hidden */
  121040. export var depthVertexShader: {
  121041. name: string;
  121042. shader: string;
  121043. };
  121044. }
  121045. declare module BABYLON {
  121046. /** @hidden */
  121047. export var volumetricLightScatteringPixelShader: {
  121048. name: string;
  121049. shader: string;
  121050. };
  121051. }
  121052. declare module BABYLON {
  121053. /** @hidden */
  121054. export var volumetricLightScatteringPassPixelShader: {
  121055. name: string;
  121056. shader: string;
  121057. };
  121058. }
  121059. declare module BABYLON {
  121060. /**
  121061. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  121062. */
  121063. export class VolumetricLightScatteringPostProcess extends PostProcess {
  121064. private _volumetricLightScatteringPass;
  121065. private _volumetricLightScatteringRTT;
  121066. private _viewPort;
  121067. private _screenCoordinates;
  121068. private _cachedDefines;
  121069. /**
  121070. * If not undefined, the mesh position is computed from the attached node position
  121071. */
  121072. attachedNode: {
  121073. position: Vector3;
  121074. };
  121075. /**
  121076. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  121077. */
  121078. customMeshPosition: Vector3;
  121079. /**
  121080. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  121081. */
  121082. useCustomMeshPosition: boolean;
  121083. /**
  121084. * If the post-process should inverse the light scattering direction
  121085. */
  121086. invert: boolean;
  121087. /**
  121088. * The internal mesh used by the post-process
  121089. */
  121090. mesh: Mesh;
  121091. /**
  121092. * @hidden
  121093. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  121094. */
  121095. useDiffuseColor: boolean;
  121096. /**
  121097. * Array containing the excluded meshes not rendered in the internal pass
  121098. */
  121099. excludedMeshes: AbstractMesh[];
  121100. /**
  121101. * Controls the overall intensity of the post-process
  121102. */
  121103. exposure: number;
  121104. /**
  121105. * Dissipates each sample's contribution in range [0, 1]
  121106. */
  121107. decay: number;
  121108. /**
  121109. * Controls the overall intensity of each sample
  121110. */
  121111. weight: number;
  121112. /**
  121113. * Controls the density of each sample
  121114. */
  121115. density: number;
  121116. /**
  121117. * @constructor
  121118. * @param name The post-process name
  121119. * @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)
  121120. * @param camera The camera that the post-process will be attached to
  121121. * @param mesh The mesh used to create the light scattering
  121122. * @param samples The post-process quality, default 100
  121123. * @param samplingModeThe post-process filtering mode
  121124. * @param engine The babylon engine
  121125. * @param reusable If the post-process is reusable
  121126. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  121127. */
  121128. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  121129. /**
  121130. * Returns the string "VolumetricLightScatteringPostProcess"
  121131. * @returns "VolumetricLightScatteringPostProcess"
  121132. */
  121133. getClassName(): string;
  121134. private _isReady;
  121135. /**
  121136. * Sets the new light position for light scattering effect
  121137. * @param position The new custom light position
  121138. */
  121139. setCustomMeshPosition(position: Vector3): void;
  121140. /**
  121141. * Returns the light position for light scattering effect
  121142. * @return Vector3 The custom light position
  121143. */
  121144. getCustomMeshPosition(): Vector3;
  121145. /**
  121146. * Disposes the internal assets and detaches the post-process from the camera
  121147. */
  121148. dispose(camera: Camera): void;
  121149. /**
  121150. * Returns the render target texture used by the post-process
  121151. * @return the render target texture used by the post-process
  121152. */
  121153. getPass(): RenderTargetTexture;
  121154. private _meshExcluded;
  121155. private _createPass;
  121156. private _updateMeshScreenCoordinates;
  121157. /**
  121158. * Creates a default mesh for the Volumeric Light Scattering post-process
  121159. * @param name The mesh name
  121160. * @param scene The scene where to create the mesh
  121161. * @return the default mesh
  121162. */
  121163. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  121164. }
  121165. }
  121166. declare module BABYLON {
  121167. interface Scene {
  121168. /** @hidden (Backing field) */
  121169. _boundingBoxRenderer: BoundingBoxRenderer;
  121170. /** @hidden (Backing field) */
  121171. _forceShowBoundingBoxes: boolean;
  121172. /**
  121173. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  121174. */
  121175. forceShowBoundingBoxes: boolean;
  121176. /**
  121177. * Gets the bounding box renderer associated with the scene
  121178. * @returns a BoundingBoxRenderer
  121179. */
  121180. getBoundingBoxRenderer(): BoundingBoxRenderer;
  121181. }
  121182. interface AbstractMesh {
  121183. /** @hidden (Backing field) */
  121184. _showBoundingBox: boolean;
  121185. /**
  121186. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  121187. */
  121188. showBoundingBox: boolean;
  121189. }
  121190. /**
  121191. * Component responsible of rendering the bounding box of the meshes in a scene.
  121192. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  121193. */
  121194. export class BoundingBoxRenderer implements ISceneComponent {
  121195. /**
  121196. * The component name helpfull to identify the component in the list of scene components.
  121197. */
  121198. readonly name: string;
  121199. /**
  121200. * The scene the component belongs to.
  121201. */
  121202. scene: Scene;
  121203. /**
  121204. * Color of the bounding box lines placed in front of an object
  121205. */
  121206. frontColor: Color3;
  121207. /**
  121208. * Color of the bounding box lines placed behind an object
  121209. */
  121210. backColor: Color3;
  121211. /**
  121212. * Defines if the renderer should show the back lines or not
  121213. */
  121214. showBackLines: boolean;
  121215. /**
  121216. * @hidden
  121217. */
  121218. renderList: SmartArray<BoundingBox>;
  121219. private _colorShader;
  121220. private _vertexBuffers;
  121221. private _indexBuffer;
  121222. private _fillIndexBuffer;
  121223. private _fillIndexData;
  121224. /**
  121225. * Instantiates a new bounding box renderer in a scene.
  121226. * @param scene the scene the renderer renders in
  121227. */
  121228. constructor(scene: Scene);
  121229. /**
  121230. * Registers the component in a given scene
  121231. */
  121232. register(): void;
  121233. private _evaluateSubMesh;
  121234. private _activeMesh;
  121235. private _prepareRessources;
  121236. private _createIndexBuffer;
  121237. /**
  121238. * Rebuilds the elements related to this component in case of
  121239. * context lost for instance.
  121240. */
  121241. rebuild(): void;
  121242. /**
  121243. * @hidden
  121244. */
  121245. reset(): void;
  121246. /**
  121247. * Render the bounding boxes of a specific rendering group
  121248. * @param renderingGroupId defines the rendering group to render
  121249. */
  121250. render(renderingGroupId: number): void;
  121251. /**
  121252. * In case of occlusion queries, we can render the occlusion bounding box through this method
  121253. * @param mesh Define the mesh to render the occlusion bounding box for
  121254. */
  121255. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  121256. /**
  121257. * Dispose and release the resources attached to this renderer.
  121258. */
  121259. dispose(): void;
  121260. }
  121261. }
  121262. declare module BABYLON {
  121263. /** @hidden */
  121264. export var depthPixelShader: {
  121265. name: string;
  121266. shader: string;
  121267. };
  121268. }
  121269. declare module BABYLON {
  121270. /**
  121271. * This represents a depth renderer in Babylon.
  121272. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  121273. */
  121274. export class DepthRenderer {
  121275. private _scene;
  121276. private _depthMap;
  121277. private _effect;
  121278. private readonly _storeNonLinearDepth;
  121279. private readonly _clearColor;
  121280. /** Get if the depth renderer is using packed depth or not */
  121281. readonly isPacked: boolean;
  121282. private _cachedDefines;
  121283. private _camera;
  121284. /**
  121285. * Specifiess that the depth renderer will only be used within
  121286. * the camera it is created for.
  121287. * This can help forcing its rendering during the camera processing.
  121288. */
  121289. useOnlyInActiveCamera: boolean;
  121290. /** @hidden */
  121291. static _SceneComponentInitialization: (scene: Scene) => void;
  121292. /**
  121293. * Instantiates a depth renderer
  121294. * @param scene The scene the renderer belongs to
  121295. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  121296. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  121297. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  121298. */
  121299. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  121300. /**
  121301. * Creates the depth rendering effect and checks if the effect is ready.
  121302. * @param subMesh The submesh to be used to render the depth map of
  121303. * @param useInstances If multiple world instances should be used
  121304. * @returns if the depth renderer is ready to render the depth map
  121305. */
  121306. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  121307. /**
  121308. * Gets the texture which the depth map will be written to.
  121309. * @returns The depth map texture
  121310. */
  121311. getDepthMap(): RenderTargetTexture;
  121312. /**
  121313. * Disposes of the depth renderer.
  121314. */
  121315. dispose(): void;
  121316. }
  121317. }
  121318. declare module BABYLON {
  121319. interface Scene {
  121320. /** @hidden (Backing field) */
  121321. _depthRenderer: {
  121322. [id: string]: DepthRenderer;
  121323. };
  121324. /**
  121325. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  121326. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  121327. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  121328. * @returns the created depth renderer
  121329. */
  121330. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  121331. /**
  121332. * Disables a depth renderer for a given camera
  121333. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  121334. */
  121335. disableDepthRenderer(camera?: Nullable<Camera>): void;
  121336. }
  121337. /**
  121338. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  121339. * in several rendering techniques.
  121340. */
  121341. export class DepthRendererSceneComponent implements ISceneComponent {
  121342. /**
  121343. * The component name helpfull to identify the component in the list of scene components.
  121344. */
  121345. readonly name: string;
  121346. /**
  121347. * The scene the component belongs to.
  121348. */
  121349. scene: Scene;
  121350. /**
  121351. * Creates a new instance of the component for the given scene
  121352. * @param scene Defines the scene to register the component in
  121353. */
  121354. constructor(scene: Scene);
  121355. /**
  121356. * Registers the component in a given scene
  121357. */
  121358. register(): void;
  121359. /**
  121360. * Rebuilds the elements related to this component in case of
  121361. * context lost for instance.
  121362. */
  121363. rebuild(): void;
  121364. /**
  121365. * Disposes the component and the associated ressources
  121366. */
  121367. dispose(): void;
  121368. private _gatherRenderTargets;
  121369. private _gatherActiveCameraRenderTargets;
  121370. }
  121371. }
  121372. declare module BABYLON {
  121373. /** @hidden */
  121374. export var outlinePixelShader: {
  121375. name: string;
  121376. shader: string;
  121377. };
  121378. }
  121379. declare module BABYLON {
  121380. /** @hidden */
  121381. export var outlineVertexShader: {
  121382. name: string;
  121383. shader: string;
  121384. };
  121385. }
  121386. declare module BABYLON {
  121387. interface Scene {
  121388. /** @hidden */
  121389. _outlineRenderer: OutlineRenderer;
  121390. /**
  121391. * Gets the outline renderer associated with the scene
  121392. * @returns a OutlineRenderer
  121393. */
  121394. getOutlineRenderer(): OutlineRenderer;
  121395. }
  121396. interface AbstractMesh {
  121397. /** @hidden (Backing field) */
  121398. _renderOutline: boolean;
  121399. /**
  121400. * Gets or sets a boolean indicating if the outline must be rendered as well
  121401. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  121402. */
  121403. renderOutline: boolean;
  121404. /** @hidden (Backing field) */
  121405. _renderOverlay: boolean;
  121406. /**
  121407. * Gets or sets a boolean indicating if the overlay must be rendered as well
  121408. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  121409. */
  121410. renderOverlay: boolean;
  121411. }
  121412. /**
  121413. * This class is responsible to draw bothe outline/overlay of meshes.
  121414. * It should not be used directly but through the available method on mesh.
  121415. */
  121416. export class OutlineRenderer implements ISceneComponent {
  121417. /**
  121418. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  121419. */
  121420. private static _StencilReference;
  121421. /**
  121422. * The name of the component. Each component must have a unique name.
  121423. */
  121424. name: string;
  121425. /**
  121426. * The scene the component belongs to.
  121427. */
  121428. scene: Scene;
  121429. /**
  121430. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  121431. */
  121432. zOffset: number;
  121433. private _engine;
  121434. private _effect;
  121435. private _cachedDefines;
  121436. private _savedDepthWrite;
  121437. /**
  121438. * Instantiates a new outline renderer. (There could be only one per scene).
  121439. * @param scene Defines the scene it belongs to
  121440. */
  121441. constructor(scene: Scene);
  121442. /**
  121443. * Register the component to one instance of a scene.
  121444. */
  121445. register(): void;
  121446. /**
  121447. * Rebuilds the elements related to this component in case of
  121448. * context lost for instance.
  121449. */
  121450. rebuild(): void;
  121451. /**
  121452. * Disposes the component and the associated ressources.
  121453. */
  121454. dispose(): void;
  121455. /**
  121456. * Renders the outline in the canvas.
  121457. * @param subMesh Defines the sumesh to render
  121458. * @param batch Defines the batch of meshes in case of instances
  121459. * @param useOverlay Defines if the rendering is for the overlay or the outline
  121460. */
  121461. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  121462. /**
  121463. * Returns whether or not the outline renderer is ready for a given submesh.
  121464. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  121465. * @param subMesh Defines the submesh to check readyness for
  121466. * @param useInstances Defines wheter wee are trying to render instances or not
  121467. * @returns true if ready otherwise false
  121468. */
  121469. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  121470. private _beforeRenderingMesh;
  121471. private _afterRenderingMesh;
  121472. }
  121473. }
  121474. declare module BABYLON {
  121475. /**
  121476. * Defines the list of states available for a task inside a AssetsManager
  121477. */
  121478. export enum AssetTaskState {
  121479. /**
  121480. * Initialization
  121481. */
  121482. INIT = 0,
  121483. /**
  121484. * Running
  121485. */
  121486. RUNNING = 1,
  121487. /**
  121488. * Done
  121489. */
  121490. DONE = 2,
  121491. /**
  121492. * Error
  121493. */
  121494. ERROR = 3
  121495. }
  121496. /**
  121497. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  121498. */
  121499. export abstract class AbstractAssetTask {
  121500. /**
  121501. * Task name
  121502. */ name: string;
  121503. /**
  121504. * Callback called when the task is successful
  121505. */
  121506. onSuccess: (task: any) => void;
  121507. /**
  121508. * Callback called when the task is not successful
  121509. */
  121510. onError: (task: any, message?: string, exception?: any) => void;
  121511. /**
  121512. * Creates a new AssetsManager
  121513. * @param name defines the name of the task
  121514. */
  121515. constructor(
  121516. /**
  121517. * Task name
  121518. */ name: string);
  121519. private _isCompleted;
  121520. private _taskState;
  121521. private _errorObject;
  121522. /**
  121523. * Get if the task is completed
  121524. */
  121525. readonly isCompleted: boolean;
  121526. /**
  121527. * Gets the current state of the task
  121528. */
  121529. readonly taskState: AssetTaskState;
  121530. /**
  121531. * Gets the current error object (if task is in error)
  121532. */
  121533. readonly errorObject: {
  121534. message?: string;
  121535. exception?: any;
  121536. };
  121537. /**
  121538. * Internal only
  121539. * @hidden
  121540. */
  121541. _setErrorObject(message?: string, exception?: any): void;
  121542. /**
  121543. * Execute the current task
  121544. * @param scene defines the scene where you want your assets to be loaded
  121545. * @param onSuccess is a callback called when the task is successfully executed
  121546. * @param onError is a callback called if an error occurs
  121547. */
  121548. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121549. /**
  121550. * Execute the current task
  121551. * @param scene defines the scene where you want your assets to be loaded
  121552. * @param onSuccess is a callback called when the task is successfully executed
  121553. * @param onError is a callback called if an error occurs
  121554. */
  121555. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121556. /**
  121557. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  121558. * This can be used with failed tasks that have the reason for failure fixed.
  121559. */
  121560. reset(): void;
  121561. private onErrorCallback;
  121562. private onDoneCallback;
  121563. }
  121564. /**
  121565. * Define the interface used by progress events raised during assets loading
  121566. */
  121567. export interface IAssetsProgressEvent {
  121568. /**
  121569. * Defines the number of remaining tasks to process
  121570. */
  121571. remainingCount: number;
  121572. /**
  121573. * Defines the total number of tasks
  121574. */
  121575. totalCount: number;
  121576. /**
  121577. * Defines the task that was just processed
  121578. */
  121579. task: AbstractAssetTask;
  121580. }
  121581. /**
  121582. * Class used to share progress information about assets loading
  121583. */
  121584. export class AssetsProgressEvent implements IAssetsProgressEvent {
  121585. /**
  121586. * Defines the number of remaining tasks to process
  121587. */
  121588. remainingCount: number;
  121589. /**
  121590. * Defines the total number of tasks
  121591. */
  121592. totalCount: number;
  121593. /**
  121594. * Defines the task that was just processed
  121595. */
  121596. task: AbstractAssetTask;
  121597. /**
  121598. * Creates a AssetsProgressEvent
  121599. * @param remainingCount defines the number of remaining tasks to process
  121600. * @param totalCount defines the total number of tasks
  121601. * @param task defines the task that was just processed
  121602. */
  121603. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  121604. }
  121605. /**
  121606. * Define a task used by AssetsManager to load meshes
  121607. */
  121608. export class MeshAssetTask extends AbstractAssetTask {
  121609. /**
  121610. * Defines the name of the task
  121611. */
  121612. name: string;
  121613. /**
  121614. * Defines the list of mesh's names you want to load
  121615. */
  121616. meshesNames: any;
  121617. /**
  121618. * Defines the root url to use as a base to load your meshes and associated resources
  121619. */
  121620. rootUrl: string;
  121621. /**
  121622. * Defines the filename of the scene to load from
  121623. */
  121624. sceneFilename: string;
  121625. /**
  121626. * Gets the list of loaded meshes
  121627. */
  121628. loadedMeshes: Array<AbstractMesh>;
  121629. /**
  121630. * Gets the list of loaded particle systems
  121631. */
  121632. loadedParticleSystems: Array<IParticleSystem>;
  121633. /**
  121634. * Gets the list of loaded skeletons
  121635. */
  121636. loadedSkeletons: Array<Skeleton>;
  121637. /**
  121638. * Gets the list of loaded animation groups
  121639. */
  121640. loadedAnimationGroups: Array<AnimationGroup>;
  121641. /**
  121642. * Callback called when the task is successful
  121643. */
  121644. onSuccess: (task: MeshAssetTask) => void;
  121645. /**
  121646. * Callback called when the task is successful
  121647. */
  121648. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  121649. /**
  121650. * Creates a new MeshAssetTask
  121651. * @param name defines the name of the task
  121652. * @param meshesNames defines the list of mesh's names you want to load
  121653. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  121654. * @param sceneFilename defines the filename of the scene to load from
  121655. */
  121656. constructor(
  121657. /**
  121658. * Defines the name of the task
  121659. */
  121660. name: string,
  121661. /**
  121662. * Defines the list of mesh's names you want to load
  121663. */
  121664. meshesNames: any,
  121665. /**
  121666. * Defines the root url to use as a base to load your meshes and associated resources
  121667. */
  121668. rootUrl: string,
  121669. /**
  121670. * Defines the filename of the scene to load from
  121671. */
  121672. sceneFilename: string);
  121673. /**
  121674. * Execute the current task
  121675. * @param scene defines the scene where you want your assets to be loaded
  121676. * @param onSuccess is a callback called when the task is successfully executed
  121677. * @param onError is a callback called if an error occurs
  121678. */
  121679. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121680. }
  121681. /**
  121682. * Define a task used by AssetsManager to load text content
  121683. */
  121684. export class TextFileAssetTask extends AbstractAssetTask {
  121685. /**
  121686. * Defines the name of the task
  121687. */
  121688. name: string;
  121689. /**
  121690. * Defines the location of the file to load
  121691. */
  121692. url: string;
  121693. /**
  121694. * Gets the loaded text string
  121695. */
  121696. text: string;
  121697. /**
  121698. * Callback called when the task is successful
  121699. */
  121700. onSuccess: (task: TextFileAssetTask) => void;
  121701. /**
  121702. * Callback called when the task is successful
  121703. */
  121704. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  121705. /**
  121706. * Creates a new TextFileAssetTask object
  121707. * @param name defines the name of the task
  121708. * @param url defines the location of the file to load
  121709. */
  121710. constructor(
  121711. /**
  121712. * Defines the name of the task
  121713. */
  121714. name: string,
  121715. /**
  121716. * Defines the location of the file to load
  121717. */
  121718. url: string);
  121719. /**
  121720. * Execute the current task
  121721. * @param scene defines the scene where you want your assets to be loaded
  121722. * @param onSuccess is a callback called when the task is successfully executed
  121723. * @param onError is a callback called if an error occurs
  121724. */
  121725. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121726. }
  121727. /**
  121728. * Define a task used by AssetsManager to load binary data
  121729. */
  121730. export class BinaryFileAssetTask extends AbstractAssetTask {
  121731. /**
  121732. * Defines the name of the task
  121733. */
  121734. name: string;
  121735. /**
  121736. * Defines the location of the file to load
  121737. */
  121738. url: string;
  121739. /**
  121740. * Gets the lodaded data (as an array buffer)
  121741. */
  121742. data: ArrayBuffer;
  121743. /**
  121744. * Callback called when the task is successful
  121745. */
  121746. onSuccess: (task: BinaryFileAssetTask) => void;
  121747. /**
  121748. * Callback called when the task is successful
  121749. */
  121750. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  121751. /**
  121752. * Creates a new BinaryFileAssetTask object
  121753. * @param name defines the name of the new task
  121754. * @param url defines the location of the file to load
  121755. */
  121756. constructor(
  121757. /**
  121758. * Defines the name of the task
  121759. */
  121760. name: string,
  121761. /**
  121762. * Defines the location of the file to load
  121763. */
  121764. url: string);
  121765. /**
  121766. * Execute the current task
  121767. * @param scene defines the scene where you want your assets to be loaded
  121768. * @param onSuccess is a callback called when the task is successfully executed
  121769. * @param onError is a callback called if an error occurs
  121770. */
  121771. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121772. }
  121773. /**
  121774. * Define a task used by AssetsManager to load images
  121775. */
  121776. export class ImageAssetTask extends AbstractAssetTask {
  121777. /**
  121778. * Defines the name of the task
  121779. */
  121780. name: string;
  121781. /**
  121782. * Defines the location of the image to load
  121783. */
  121784. url: string;
  121785. /**
  121786. * Gets the loaded images
  121787. */
  121788. image: HTMLImageElement;
  121789. /**
  121790. * Callback called when the task is successful
  121791. */
  121792. onSuccess: (task: ImageAssetTask) => void;
  121793. /**
  121794. * Callback called when the task is successful
  121795. */
  121796. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  121797. /**
  121798. * Creates a new ImageAssetTask
  121799. * @param name defines the name of the task
  121800. * @param url defines the location of the image to load
  121801. */
  121802. constructor(
  121803. /**
  121804. * Defines the name of the task
  121805. */
  121806. name: string,
  121807. /**
  121808. * Defines the location of the image to load
  121809. */
  121810. url: string);
  121811. /**
  121812. * Execute the current task
  121813. * @param scene defines the scene where you want your assets to be loaded
  121814. * @param onSuccess is a callback called when the task is successfully executed
  121815. * @param onError is a callback called if an error occurs
  121816. */
  121817. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121818. }
  121819. /**
  121820. * Defines the interface used by texture loading tasks
  121821. */
  121822. export interface ITextureAssetTask<TEX extends BaseTexture> {
  121823. /**
  121824. * Gets the loaded texture
  121825. */
  121826. texture: TEX;
  121827. }
  121828. /**
  121829. * Define a task used by AssetsManager to load 2D textures
  121830. */
  121831. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  121832. /**
  121833. * Defines the name of the task
  121834. */
  121835. name: string;
  121836. /**
  121837. * Defines the location of the file to load
  121838. */
  121839. url: string;
  121840. /**
  121841. * Defines if mipmap should not be generated (default is false)
  121842. */
  121843. noMipmap?: boolean | undefined;
  121844. /**
  121845. * Defines if texture must be inverted on Y axis (default is false)
  121846. */
  121847. invertY?: boolean | undefined;
  121848. /**
  121849. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  121850. */
  121851. samplingMode: number;
  121852. /**
  121853. * Gets the loaded texture
  121854. */
  121855. texture: Texture;
  121856. /**
  121857. * Callback called when the task is successful
  121858. */
  121859. onSuccess: (task: TextureAssetTask) => void;
  121860. /**
  121861. * Callback called when the task is successful
  121862. */
  121863. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  121864. /**
  121865. * Creates a new TextureAssetTask object
  121866. * @param name defines the name of the task
  121867. * @param url defines the location of the file to load
  121868. * @param noMipmap defines if mipmap should not be generated (default is false)
  121869. * @param invertY defines if texture must be inverted on Y axis (default is false)
  121870. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  121871. */
  121872. constructor(
  121873. /**
  121874. * Defines the name of the task
  121875. */
  121876. name: string,
  121877. /**
  121878. * Defines the location of the file to load
  121879. */
  121880. url: string,
  121881. /**
  121882. * Defines if mipmap should not be generated (default is false)
  121883. */
  121884. noMipmap?: boolean | undefined,
  121885. /**
  121886. * Defines if texture must be inverted on Y axis (default is false)
  121887. */
  121888. invertY?: boolean | undefined,
  121889. /**
  121890. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  121891. */
  121892. samplingMode?: number);
  121893. /**
  121894. * Execute the current task
  121895. * @param scene defines the scene where you want your assets to be loaded
  121896. * @param onSuccess is a callback called when the task is successfully executed
  121897. * @param onError is a callback called if an error occurs
  121898. */
  121899. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121900. }
  121901. /**
  121902. * Define a task used by AssetsManager to load cube textures
  121903. */
  121904. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  121905. /**
  121906. * Defines the name of the task
  121907. */
  121908. name: string;
  121909. /**
  121910. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  121911. */
  121912. url: string;
  121913. /**
  121914. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  121915. */
  121916. extensions?: string[] | undefined;
  121917. /**
  121918. * Defines if mipmaps should not be generated (default is false)
  121919. */
  121920. noMipmap?: boolean | undefined;
  121921. /**
  121922. * Defines the explicit list of files (undefined by default)
  121923. */
  121924. files?: string[] | undefined;
  121925. /**
  121926. * Gets the loaded texture
  121927. */
  121928. texture: CubeTexture;
  121929. /**
  121930. * Callback called when the task is successful
  121931. */
  121932. onSuccess: (task: CubeTextureAssetTask) => void;
  121933. /**
  121934. * Callback called when the task is successful
  121935. */
  121936. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  121937. /**
  121938. * Creates a new CubeTextureAssetTask
  121939. * @param name defines the name of the task
  121940. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  121941. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  121942. * @param noMipmap defines if mipmaps should not be generated (default is false)
  121943. * @param files defines the explicit list of files (undefined by default)
  121944. */
  121945. constructor(
  121946. /**
  121947. * Defines the name of the task
  121948. */
  121949. name: string,
  121950. /**
  121951. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  121952. */
  121953. url: string,
  121954. /**
  121955. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  121956. */
  121957. extensions?: string[] | undefined,
  121958. /**
  121959. * Defines if mipmaps should not be generated (default is false)
  121960. */
  121961. noMipmap?: boolean | undefined,
  121962. /**
  121963. * Defines the explicit list of files (undefined by default)
  121964. */
  121965. files?: string[] | undefined);
  121966. /**
  121967. * Execute the current task
  121968. * @param scene defines the scene where you want your assets to be loaded
  121969. * @param onSuccess is a callback called when the task is successfully executed
  121970. * @param onError is a callback called if an error occurs
  121971. */
  121972. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121973. }
  121974. /**
  121975. * Define a task used by AssetsManager to load HDR cube textures
  121976. */
  121977. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  121978. /**
  121979. * Defines the name of the task
  121980. */
  121981. name: string;
  121982. /**
  121983. * Defines the location of the file to load
  121984. */
  121985. url: string;
  121986. /**
  121987. * Defines the desired size (the more it increases the longer the generation will be)
  121988. */
  121989. size: number;
  121990. /**
  121991. * Defines if mipmaps should not be generated (default is false)
  121992. */
  121993. noMipmap: boolean;
  121994. /**
  121995. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  121996. */
  121997. generateHarmonics: boolean;
  121998. /**
  121999. * 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)
  122000. */
  122001. gammaSpace: boolean;
  122002. /**
  122003. * Internal Use Only
  122004. */
  122005. reserved: boolean;
  122006. /**
  122007. * Gets the loaded texture
  122008. */
  122009. texture: HDRCubeTexture;
  122010. /**
  122011. * Callback called when the task is successful
  122012. */
  122013. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  122014. /**
  122015. * Callback called when the task is successful
  122016. */
  122017. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  122018. /**
  122019. * Creates a new HDRCubeTextureAssetTask object
  122020. * @param name defines the name of the task
  122021. * @param url defines the location of the file to load
  122022. * @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.
  122023. * @param noMipmap defines if mipmaps should not be generated (default is false)
  122024. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  122025. * @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)
  122026. * @param reserved Internal use only
  122027. */
  122028. constructor(
  122029. /**
  122030. * Defines the name of the task
  122031. */
  122032. name: string,
  122033. /**
  122034. * Defines the location of the file to load
  122035. */
  122036. url: string,
  122037. /**
  122038. * Defines the desired size (the more it increases the longer the generation will be)
  122039. */
  122040. size: number,
  122041. /**
  122042. * Defines if mipmaps should not be generated (default is false)
  122043. */
  122044. noMipmap?: boolean,
  122045. /**
  122046. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  122047. */
  122048. generateHarmonics?: boolean,
  122049. /**
  122050. * 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)
  122051. */
  122052. gammaSpace?: boolean,
  122053. /**
  122054. * Internal Use Only
  122055. */
  122056. reserved?: boolean);
  122057. /**
  122058. * Execute the current task
  122059. * @param scene defines the scene where you want your assets to be loaded
  122060. * @param onSuccess is a callback called when the task is successfully executed
  122061. * @param onError is a callback called if an error occurs
  122062. */
  122063. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  122064. }
  122065. /**
  122066. * Define a task used by AssetsManager to load Equirectangular cube textures
  122067. */
  122068. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  122069. /**
  122070. * Defines the name of the task
  122071. */
  122072. name: string;
  122073. /**
  122074. * Defines the location of the file to load
  122075. */
  122076. url: string;
  122077. /**
  122078. * Defines the desired size (the more it increases the longer the generation will be)
  122079. */
  122080. size: number;
  122081. /**
  122082. * Defines if mipmaps should not be generated (default is false)
  122083. */
  122084. noMipmap: boolean;
  122085. /**
  122086. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  122087. * but the standard material would require them in Gamma space) (default is true)
  122088. */
  122089. gammaSpace: boolean;
  122090. /**
  122091. * Gets the loaded texture
  122092. */
  122093. texture: EquiRectangularCubeTexture;
  122094. /**
  122095. * Callback called when the task is successful
  122096. */
  122097. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  122098. /**
  122099. * Callback called when the task is successful
  122100. */
  122101. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  122102. /**
  122103. * Creates a new EquiRectangularCubeTextureAssetTask object
  122104. * @param name defines the name of the task
  122105. * @param url defines the location of the file to load
  122106. * @param size defines the desired size (the more it increases the longer the generation will be)
  122107. * If the size is omitted this implies you are using a preprocessed cubemap.
  122108. * @param noMipmap defines if mipmaps should not be generated (default is false)
  122109. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  122110. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  122111. * (default is true)
  122112. */
  122113. constructor(
  122114. /**
  122115. * Defines the name of the task
  122116. */
  122117. name: string,
  122118. /**
  122119. * Defines the location of the file to load
  122120. */
  122121. url: string,
  122122. /**
  122123. * Defines the desired size (the more it increases the longer the generation will be)
  122124. */
  122125. size: number,
  122126. /**
  122127. * Defines if mipmaps should not be generated (default is false)
  122128. */
  122129. noMipmap?: boolean,
  122130. /**
  122131. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  122132. * but the standard material would require them in Gamma space) (default is true)
  122133. */
  122134. gammaSpace?: boolean);
  122135. /**
  122136. * Execute the current task
  122137. * @param scene defines the scene where you want your assets to be loaded
  122138. * @param onSuccess is a callback called when the task is successfully executed
  122139. * @param onError is a callback called if an error occurs
  122140. */
  122141. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  122142. }
  122143. /**
  122144. * This class can be used to easily import assets into a scene
  122145. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  122146. */
  122147. export class AssetsManager {
  122148. private _scene;
  122149. private _isLoading;
  122150. protected _tasks: AbstractAssetTask[];
  122151. protected _waitingTasksCount: number;
  122152. protected _totalTasksCount: number;
  122153. /**
  122154. * Callback called when all tasks are processed
  122155. */
  122156. onFinish: (tasks: AbstractAssetTask[]) => void;
  122157. /**
  122158. * Callback called when a task is successful
  122159. */
  122160. onTaskSuccess: (task: AbstractAssetTask) => void;
  122161. /**
  122162. * Callback called when a task had an error
  122163. */
  122164. onTaskError: (task: AbstractAssetTask) => void;
  122165. /**
  122166. * Callback called when a task is done (whatever the result is)
  122167. */
  122168. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  122169. /**
  122170. * Observable called when all tasks are processed
  122171. */
  122172. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  122173. /**
  122174. * Observable called when a task had an error
  122175. */
  122176. onTaskErrorObservable: Observable<AbstractAssetTask>;
  122177. /**
  122178. * Observable called when all tasks were executed
  122179. */
  122180. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  122181. /**
  122182. * Observable called when a task is done (whatever the result is)
  122183. */
  122184. onProgressObservable: Observable<IAssetsProgressEvent>;
  122185. /**
  122186. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  122187. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  122188. */
  122189. useDefaultLoadingScreen: boolean;
  122190. /**
  122191. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  122192. * when all assets have been downloaded.
  122193. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  122194. */
  122195. autoHideLoadingUI: boolean;
  122196. /**
  122197. * Creates a new AssetsManager
  122198. * @param scene defines the scene to work on
  122199. */
  122200. constructor(scene: Scene);
  122201. /**
  122202. * Add a MeshAssetTask to the list of active tasks
  122203. * @param taskName defines the name of the new task
  122204. * @param meshesNames defines the name of meshes to load
  122205. * @param rootUrl defines the root url to use to locate files
  122206. * @param sceneFilename defines the filename of the scene file
  122207. * @returns a new MeshAssetTask object
  122208. */
  122209. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  122210. /**
  122211. * Add a TextFileAssetTask to the list of active tasks
  122212. * @param taskName defines the name of the new task
  122213. * @param url defines the url of the file to load
  122214. * @returns a new TextFileAssetTask object
  122215. */
  122216. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  122217. /**
  122218. * Add a BinaryFileAssetTask to the list of active tasks
  122219. * @param taskName defines the name of the new task
  122220. * @param url defines the url of the file to load
  122221. * @returns a new BinaryFileAssetTask object
  122222. */
  122223. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  122224. /**
  122225. * Add a ImageAssetTask to the list of active tasks
  122226. * @param taskName defines the name of the new task
  122227. * @param url defines the url of the file to load
  122228. * @returns a new ImageAssetTask object
  122229. */
  122230. addImageTask(taskName: string, url: string): ImageAssetTask;
  122231. /**
  122232. * Add a TextureAssetTask to the list of active tasks
  122233. * @param taskName defines the name of the new task
  122234. * @param url defines the url of the file to load
  122235. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  122236. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  122237. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  122238. * @returns a new TextureAssetTask object
  122239. */
  122240. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  122241. /**
  122242. * Add a CubeTextureAssetTask to the list of active tasks
  122243. * @param taskName defines the name of the new task
  122244. * @param url defines the url of the file to load
  122245. * @param extensions defines the extension to use to load the cube map (can be null)
  122246. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  122247. * @param files defines the list of files to load (can be null)
  122248. * @returns a new CubeTextureAssetTask object
  122249. */
  122250. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  122251. /**
  122252. *
  122253. * Add a HDRCubeTextureAssetTask to the list of active tasks
  122254. * @param taskName defines the name of the new task
  122255. * @param url defines the url of the file to load
  122256. * @param size defines the size you want for the cubemap (can be null)
  122257. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  122258. * @param generateHarmonics defines if you want to automatically generate (true by default)
  122259. * @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)
  122260. * @param reserved Internal use only
  122261. * @returns a new HDRCubeTextureAssetTask object
  122262. */
  122263. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  122264. /**
  122265. *
  122266. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  122267. * @param taskName defines the name of the new task
  122268. * @param url defines the url of the file to load
  122269. * @param size defines the size you want for the cubemap (can be null)
  122270. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  122271. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  122272. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  122273. * @returns a new EquiRectangularCubeTextureAssetTask object
  122274. */
  122275. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  122276. /**
  122277. * Remove a task from the assets manager.
  122278. * @param task the task to remove
  122279. */
  122280. removeTask(task: AbstractAssetTask): void;
  122281. private _decreaseWaitingTasksCount;
  122282. private _runTask;
  122283. /**
  122284. * Reset the AssetsManager and remove all tasks
  122285. * @return the current instance of the AssetsManager
  122286. */
  122287. reset(): AssetsManager;
  122288. /**
  122289. * Start the loading process
  122290. * @return the current instance of the AssetsManager
  122291. */
  122292. load(): AssetsManager;
  122293. /**
  122294. * Start the loading process as an async operation
  122295. * @return a promise returning the list of failed tasks
  122296. */
  122297. loadAsync(): Promise<void>;
  122298. }
  122299. }
  122300. declare module BABYLON {
  122301. /**
  122302. * Wrapper class for promise with external resolve and reject.
  122303. */
  122304. export class Deferred<T> {
  122305. /**
  122306. * The promise associated with this deferred object.
  122307. */
  122308. readonly promise: Promise<T>;
  122309. private _resolve;
  122310. private _reject;
  122311. /**
  122312. * The resolve method of the promise associated with this deferred object.
  122313. */
  122314. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  122315. /**
  122316. * The reject method of the promise associated with this deferred object.
  122317. */
  122318. readonly reject: (reason?: any) => void;
  122319. /**
  122320. * Constructor for this deferred object.
  122321. */
  122322. constructor();
  122323. }
  122324. }
  122325. declare module BABYLON {
  122326. /**
  122327. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  122328. */
  122329. export class MeshExploder {
  122330. private _centerMesh;
  122331. private _meshes;
  122332. private _meshesOrigins;
  122333. private _toCenterVectors;
  122334. private _scaledDirection;
  122335. private _newPosition;
  122336. private _centerPosition;
  122337. /**
  122338. * Explodes meshes from a center mesh.
  122339. * @param meshes The meshes to explode.
  122340. * @param centerMesh The mesh to be center of explosion.
  122341. */
  122342. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  122343. private _setCenterMesh;
  122344. /**
  122345. * Get class name
  122346. * @returns "MeshExploder"
  122347. */
  122348. getClassName(): string;
  122349. /**
  122350. * "Exploded meshes"
  122351. * @returns Array of meshes with the centerMesh at index 0.
  122352. */
  122353. getMeshes(): Array<Mesh>;
  122354. /**
  122355. * Explodes meshes giving a specific direction
  122356. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  122357. */
  122358. explode(direction?: number): void;
  122359. }
  122360. }
  122361. declare module BABYLON {
  122362. /**
  122363. * Class used to help managing file picking and drag'n'drop
  122364. */
  122365. export class FilesInput {
  122366. /**
  122367. * List of files ready to be loaded
  122368. */
  122369. static readonly FilesToLoad: {
  122370. [key: string]: File;
  122371. };
  122372. /**
  122373. * Callback called when a file is processed
  122374. */
  122375. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  122376. private _engine;
  122377. private _currentScene;
  122378. private _sceneLoadedCallback;
  122379. private _progressCallback;
  122380. private _additionalRenderLoopLogicCallback;
  122381. private _textureLoadingCallback;
  122382. private _startingProcessingFilesCallback;
  122383. private _onReloadCallback;
  122384. private _errorCallback;
  122385. private _elementToMonitor;
  122386. private _sceneFileToLoad;
  122387. private _filesToLoad;
  122388. /**
  122389. * Creates a new FilesInput
  122390. * @param engine defines the rendering engine
  122391. * @param scene defines the hosting scene
  122392. * @param sceneLoadedCallback callback called when scene is loaded
  122393. * @param progressCallback callback called to track progress
  122394. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  122395. * @param textureLoadingCallback callback called when a texture is loading
  122396. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  122397. * @param onReloadCallback callback called when a reload is requested
  122398. * @param errorCallback callback call if an error occurs
  122399. */
  122400. 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);
  122401. private _dragEnterHandler;
  122402. private _dragOverHandler;
  122403. private _dropHandler;
  122404. /**
  122405. * Calls this function to listen to drag'n'drop events on a specific DOM element
  122406. * @param elementToMonitor defines the DOM element to track
  122407. */
  122408. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  122409. /**
  122410. * Release all associated resources
  122411. */
  122412. dispose(): void;
  122413. private renderFunction;
  122414. private drag;
  122415. private drop;
  122416. private _traverseFolder;
  122417. private _processFiles;
  122418. /**
  122419. * Load files from a drop event
  122420. * @param event defines the drop event to use as source
  122421. */
  122422. loadFiles(event: any): void;
  122423. private _processReload;
  122424. /**
  122425. * Reload the current scene from the loaded files
  122426. */
  122427. reload(): void;
  122428. }
  122429. }
  122430. declare module BABYLON {
  122431. /**
  122432. * Defines the root class used to create scene optimization to use with SceneOptimizer
  122433. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  122434. */
  122435. export class SceneOptimization {
  122436. /**
  122437. * Defines the priority of this optimization (0 by default which means first in the list)
  122438. */
  122439. priority: number;
  122440. /**
  122441. * Gets a string describing the action executed by the current optimization
  122442. * @returns description string
  122443. */
  122444. getDescription(): string;
  122445. /**
  122446. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  122447. * @param scene defines the current scene where to apply this optimization
  122448. * @param optimizer defines the current optimizer
  122449. * @returns true if everything that can be done was applied
  122450. */
  122451. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  122452. /**
  122453. * Creates the SceneOptimization object
  122454. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  122455. * @param desc defines the description associated with the optimization
  122456. */
  122457. constructor(
  122458. /**
  122459. * Defines the priority of this optimization (0 by default which means first in the list)
  122460. */
  122461. priority?: number);
  122462. }
  122463. /**
  122464. * Defines an optimization used to reduce the size of render target textures
  122465. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  122466. */
  122467. export class TextureOptimization extends SceneOptimization {
  122468. /**
  122469. * Defines the priority of this optimization (0 by default which means first in the list)
  122470. */
  122471. priority: number;
  122472. /**
  122473. * 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
  122474. */
  122475. maximumSize: number;
  122476. /**
  122477. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  122478. */
  122479. step: number;
  122480. /**
  122481. * Gets a string describing the action executed by the current optimization
  122482. * @returns description string
  122483. */
  122484. getDescription(): string;
  122485. /**
  122486. * Creates the TextureOptimization object
  122487. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  122488. * @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
  122489. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  122490. */
  122491. constructor(
  122492. /**
  122493. * Defines the priority of this optimization (0 by default which means first in the list)
  122494. */
  122495. priority?: number,
  122496. /**
  122497. * 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
  122498. */
  122499. maximumSize?: number,
  122500. /**
  122501. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  122502. */
  122503. step?: number);
  122504. /**
  122505. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  122506. * @param scene defines the current scene where to apply this optimization
  122507. * @param optimizer defines the current optimizer
  122508. * @returns true if everything that can be done was applied
  122509. */
  122510. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  122511. }
  122512. /**
  122513. * Defines an optimization used to increase or decrease the rendering resolution
  122514. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  122515. */
  122516. export class HardwareScalingOptimization extends SceneOptimization {
  122517. /**
  122518. * Defines the priority of this optimization (0 by default which means first in the list)
  122519. */
  122520. priority: number;
  122521. /**
  122522. * Defines the maximum scale to use (2 by default)
  122523. */
  122524. maximumScale: number;
  122525. /**
  122526. * Defines the step to use between two passes (0.5 by default)
  122527. */
  122528. step: number;
  122529. private _currentScale;
  122530. private _directionOffset;
  122531. /**
  122532. * Gets a string describing the action executed by the current optimization
  122533. * @return description string
  122534. */
  122535. getDescription(): string;
  122536. /**
  122537. * Creates the HardwareScalingOptimization object
  122538. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  122539. * @param maximumScale defines the maximum scale to use (2 by default)
  122540. * @param step defines the step to use between two passes (0.5 by default)
  122541. */
  122542. constructor(
  122543. /**
  122544. * Defines the priority of this optimization (0 by default which means first in the list)
  122545. */
  122546. priority?: number,
  122547. /**
  122548. * Defines the maximum scale to use (2 by default)
  122549. */
  122550. maximumScale?: number,
  122551. /**
  122552. * Defines the step to use between two passes (0.5 by default)
  122553. */
  122554. step?: number);
  122555. /**
  122556. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  122557. * @param scene defines the current scene where to apply this optimization
  122558. * @param optimizer defines the current optimizer
  122559. * @returns true if everything that can be done was applied
  122560. */
  122561. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  122562. }
  122563. /**
  122564. * Defines an optimization used to remove shadows
  122565. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  122566. */
  122567. export class ShadowsOptimization extends SceneOptimization {
  122568. /**
  122569. * Gets a string describing the action executed by the current optimization
  122570. * @return description string
  122571. */
  122572. getDescription(): string;
  122573. /**
  122574. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  122575. * @param scene defines the current scene where to apply this optimization
  122576. * @param optimizer defines the current optimizer
  122577. * @returns true if everything that can be done was applied
  122578. */
  122579. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  122580. }
  122581. /**
  122582. * Defines an optimization used to turn post-processes off
  122583. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  122584. */
  122585. export class PostProcessesOptimization extends SceneOptimization {
  122586. /**
  122587. * Gets a string describing the action executed by the current optimization
  122588. * @return description string
  122589. */
  122590. getDescription(): string;
  122591. /**
  122592. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  122593. * @param scene defines the current scene where to apply this optimization
  122594. * @param optimizer defines the current optimizer
  122595. * @returns true if everything that can be done was applied
  122596. */
  122597. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  122598. }
  122599. /**
  122600. * Defines an optimization used to turn lens flares off
  122601. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  122602. */
  122603. export class LensFlaresOptimization extends SceneOptimization {
  122604. /**
  122605. * Gets a string describing the action executed by the current optimization
  122606. * @return description string
  122607. */
  122608. getDescription(): string;
  122609. /**
  122610. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  122611. * @param scene defines the current scene where to apply this optimization
  122612. * @param optimizer defines the current optimizer
  122613. * @returns true if everything that can be done was applied
  122614. */
  122615. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  122616. }
  122617. /**
  122618. * Defines an optimization based on user defined callback.
  122619. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  122620. */
  122621. export class CustomOptimization extends SceneOptimization {
  122622. /**
  122623. * Callback called to apply the custom optimization.
  122624. */
  122625. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  122626. /**
  122627. * Callback called to get custom description
  122628. */
  122629. onGetDescription: () => string;
  122630. /**
  122631. * Gets a string describing the action executed by the current optimization
  122632. * @returns description string
  122633. */
  122634. getDescription(): string;
  122635. /**
  122636. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  122637. * @param scene defines the current scene where to apply this optimization
  122638. * @param optimizer defines the current optimizer
  122639. * @returns true if everything that can be done was applied
  122640. */
  122641. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  122642. }
  122643. /**
  122644. * Defines an optimization used to turn particles off
  122645. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  122646. */
  122647. export class ParticlesOptimization extends SceneOptimization {
  122648. /**
  122649. * Gets a string describing the action executed by the current optimization
  122650. * @return description string
  122651. */
  122652. getDescription(): string;
  122653. /**
  122654. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  122655. * @param scene defines the current scene where to apply this optimization
  122656. * @param optimizer defines the current optimizer
  122657. * @returns true if everything that can be done was applied
  122658. */
  122659. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  122660. }
  122661. /**
  122662. * Defines an optimization used to turn render targets off
  122663. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  122664. */
  122665. export class RenderTargetsOptimization extends SceneOptimization {
  122666. /**
  122667. * Gets a string describing the action executed by the current optimization
  122668. * @return description string
  122669. */
  122670. getDescription(): string;
  122671. /**
  122672. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  122673. * @param scene defines the current scene where to apply this optimization
  122674. * @param optimizer defines the current optimizer
  122675. * @returns true if everything that can be done was applied
  122676. */
  122677. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  122678. }
  122679. /**
  122680. * Defines an optimization used to merge meshes with compatible materials
  122681. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  122682. */
  122683. export class MergeMeshesOptimization extends SceneOptimization {
  122684. private static _UpdateSelectionTree;
  122685. /**
  122686. * Gets or sets a boolean which defines if optimization octree has to be updated
  122687. */
  122688. /**
  122689. * Gets or sets a boolean which defines if optimization octree has to be updated
  122690. */
  122691. static UpdateSelectionTree: boolean;
  122692. /**
  122693. * Gets a string describing the action executed by the current optimization
  122694. * @return description string
  122695. */
  122696. getDescription(): string;
  122697. private _canBeMerged;
  122698. /**
  122699. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  122700. * @param scene defines the current scene where to apply this optimization
  122701. * @param optimizer defines the current optimizer
  122702. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  122703. * @returns true if everything that can be done was applied
  122704. */
  122705. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  122706. }
  122707. /**
  122708. * Defines a list of options used by SceneOptimizer
  122709. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  122710. */
  122711. export class SceneOptimizerOptions {
  122712. /**
  122713. * Defines the target frame rate to reach (60 by default)
  122714. */
  122715. targetFrameRate: number;
  122716. /**
  122717. * Defines the interval between two checkes (2000ms by default)
  122718. */
  122719. trackerDuration: number;
  122720. /**
  122721. * Gets the list of optimizations to apply
  122722. */
  122723. optimizations: SceneOptimization[];
  122724. /**
  122725. * Creates a new list of options used by SceneOptimizer
  122726. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  122727. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  122728. */
  122729. constructor(
  122730. /**
  122731. * Defines the target frame rate to reach (60 by default)
  122732. */
  122733. targetFrameRate?: number,
  122734. /**
  122735. * Defines the interval between two checkes (2000ms by default)
  122736. */
  122737. trackerDuration?: number);
  122738. /**
  122739. * Add a new optimization
  122740. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  122741. * @returns the current SceneOptimizerOptions
  122742. */
  122743. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  122744. /**
  122745. * Add a new custom optimization
  122746. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  122747. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  122748. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  122749. * @returns the current SceneOptimizerOptions
  122750. */
  122751. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  122752. /**
  122753. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  122754. * @param targetFrameRate defines the target frame rate (60 by default)
  122755. * @returns a SceneOptimizerOptions object
  122756. */
  122757. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  122758. /**
  122759. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  122760. * @param targetFrameRate defines the target frame rate (60 by default)
  122761. * @returns a SceneOptimizerOptions object
  122762. */
  122763. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  122764. /**
  122765. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  122766. * @param targetFrameRate defines the target frame rate (60 by default)
  122767. * @returns a SceneOptimizerOptions object
  122768. */
  122769. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  122770. }
  122771. /**
  122772. * Class used to run optimizations in order to reach a target frame rate
  122773. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  122774. */
  122775. export class SceneOptimizer implements IDisposable {
  122776. private _isRunning;
  122777. private _options;
  122778. private _scene;
  122779. private _currentPriorityLevel;
  122780. private _targetFrameRate;
  122781. private _trackerDuration;
  122782. private _currentFrameRate;
  122783. private _sceneDisposeObserver;
  122784. private _improvementMode;
  122785. /**
  122786. * Defines an observable called when the optimizer reaches the target frame rate
  122787. */
  122788. onSuccessObservable: Observable<SceneOptimizer>;
  122789. /**
  122790. * Defines an observable called when the optimizer enables an optimization
  122791. */
  122792. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  122793. /**
  122794. * Defines an observable called when the optimizer is not able to reach the target frame rate
  122795. */
  122796. onFailureObservable: Observable<SceneOptimizer>;
  122797. /**
  122798. * Gets a boolean indicating if the optimizer is in improvement mode
  122799. */
  122800. readonly isInImprovementMode: boolean;
  122801. /**
  122802. * Gets the current priority level (0 at start)
  122803. */
  122804. readonly currentPriorityLevel: number;
  122805. /**
  122806. * Gets the current frame rate checked by the SceneOptimizer
  122807. */
  122808. readonly currentFrameRate: number;
  122809. /**
  122810. * Gets or sets the current target frame rate (60 by default)
  122811. */
  122812. /**
  122813. * Gets or sets the current target frame rate (60 by default)
  122814. */
  122815. targetFrameRate: number;
  122816. /**
  122817. * Gets or sets the current interval between two checks (every 2000ms by default)
  122818. */
  122819. /**
  122820. * Gets or sets the current interval between two checks (every 2000ms by default)
  122821. */
  122822. trackerDuration: number;
  122823. /**
  122824. * Gets the list of active optimizations
  122825. */
  122826. readonly optimizations: SceneOptimization[];
  122827. /**
  122828. * Creates a new SceneOptimizer
  122829. * @param scene defines the scene to work on
  122830. * @param options defines the options to use with the SceneOptimizer
  122831. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  122832. * @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)
  122833. */
  122834. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  122835. /**
  122836. * Stops the current optimizer
  122837. */
  122838. stop(): void;
  122839. /**
  122840. * Reset the optimizer to initial step (current priority level = 0)
  122841. */
  122842. reset(): void;
  122843. /**
  122844. * Start the optimizer. By default it will try to reach a specific framerate
  122845. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  122846. */
  122847. start(): void;
  122848. private _checkCurrentState;
  122849. /**
  122850. * Release all resources
  122851. */
  122852. dispose(): void;
  122853. /**
  122854. * Helper function to create a SceneOptimizer with one single line of code
  122855. * @param scene defines the scene to work on
  122856. * @param options defines the options to use with the SceneOptimizer
  122857. * @param onSuccess defines a callback to call on success
  122858. * @param onFailure defines a callback to call on failure
  122859. * @returns the new SceneOptimizer object
  122860. */
  122861. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  122862. }
  122863. }
  122864. declare module BABYLON {
  122865. /**
  122866. * Class used to serialize a scene into a string
  122867. */
  122868. export class SceneSerializer {
  122869. /**
  122870. * Clear cache used by a previous serialization
  122871. */
  122872. static ClearCache(): void;
  122873. /**
  122874. * Serialize a scene into a JSON compatible object
  122875. * @param scene defines the scene to serialize
  122876. * @returns a JSON compatible object
  122877. */
  122878. static Serialize(scene: Scene): any;
  122879. /**
  122880. * Serialize a mesh into a JSON compatible object
  122881. * @param toSerialize defines the mesh to serialize
  122882. * @param withParents defines if parents must be serialized as well
  122883. * @param withChildren defines if children must be serialized as well
  122884. * @returns a JSON compatible object
  122885. */
  122886. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  122887. }
  122888. }
  122889. declare module BABYLON {
  122890. /**
  122891. * Class used to host texture specific utilities
  122892. */
  122893. export class TextureTools {
  122894. /**
  122895. * Uses the GPU to create a copy texture rescaled at a given size
  122896. * @param texture Texture to copy from
  122897. * @param width defines the desired width
  122898. * @param height defines the desired height
  122899. * @param useBilinearMode defines if bilinear mode has to be used
  122900. * @return the generated texture
  122901. */
  122902. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  122903. }
  122904. }
  122905. declare module BABYLON {
  122906. /**
  122907. * This represents the different options available for the video capture.
  122908. */
  122909. export interface VideoRecorderOptions {
  122910. /** Defines the mime type of the video. */
  122911. mimeType: string;
  122912. /** Defines the FPS the video should be recorded at. */
  122913. fps: number;
  122914. /** Defines the chunk size for the recording data. */
  122915. recordChunckSize: number;
  122916. /** The audio tracks to attach to the recording. */
  122917. audioTracks?: MediaStreamTrack[];
  122918. }
  122919. /**
  122920. * This can help with recording videos from BabylonJS.
  122921. * This is based on the available WebRTC functionalities of the browser.
  122922. *
  122923. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  122924. */
  122925. export class VideoRecorder {
  122926. private static readonly _defaultOptions;
  122927. /**
  122928. * Returns whether or not the VideoRecorder is available in your browser.
  122929. * @param engine Defines the Babylon Engine.
  122930. * @returns true if supported otherwise false.
  122931. */
  122932. static IsSupported(engine: Engine): boolean;
  122933. private readonly _options;
  122934. private _canvas;
  122935. private _mediaRecorder;
  122936. private _recordedChunks;
  122937. private _fileName;
  122938. private _resolve;
  122939. private _reject;
  122940. /**
  122941. * True when a recording is already in progress.
  122942. */
  122943. readonly isRecording: boolean;
  122944. /**
  122945. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  122946. * @param engine Defines the BabylonJS Engine you wish to record.
  122947. * @param options Defines options that can be used to customize the capture.
  122948. */
  122949. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  122950. /**
  122951. * Stops the current recording before the default capture timeout passed in the startRecording function.
  122952. */
  122953. stopRecording(): void;
  122954. /**
  122955. * Starts recording the canvas for a max duration specified in parameters.
  122956. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  122957. * If null no automatic download will start and you can rely on the promise to get the data back.
  122958. * @param maxDuration Defines the maximum recording time in seconds.
  122959. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  122960. * @return A promise callback at the end of the recording with the video data in Blob.
  122961. */
  122962. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  122963. /**
  122964. * Releases internal resources used during the recording.
  122965. */
  122966. dispose(): void;
  122967. private _handleDataAvailable;
  122968. private _handleError;
  122969. private _handleStop;
  122970. }
  122971. }
  122972. declare module BABYLON {
  122973. /**
  122974. * Class containing a set of static utilities functions for screenshots
  122975. */
  122976. export class ScreenshotTools {
  122977. /**
  122978. * Captures a screenshot of the current rendering
  122979. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  122980. * @param engine defines the rendering engine
  122981. * @param camera defines the source camera
  122982. * @param size This parameter can be set to a single number or to an object with the
  122983. * following (optional) properties: precision, width, height. If a single number is passed,
  122984. * it will be used for both width and height. If an object is passed, the screenshot size
  122985. * will be derived from the parameters. The precision property is a multiplier allowing
  122986. * rendering at a higher or lower resolution
  122987. * @param successCallback defines the callback receives a single parameter which contains the
  122988. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  122989. * src parameter of an <img> to display it
  122990. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  122991. * Check your browser for supported MIME types
  122992. */
  122993. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  122994. /**
  122995. * Generates an image screenshot from the specified camera.
  122996. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  122997. * @param engine The engine to use for rendering
  122998. * @param camera The camera to use for rendering
  122999. * @param size This parameter can be set to a single number or to an object with the
  123000. * following (optional) properties: precision, width, height. If a single number is passed,
  123001. * it will be used for both width and height. If an object is passed, the screenshot size
  123002. * will be derived from the parameters. The precision property is a multiplier allowing
  123003. * rendering at a higher or lower resolution
  123004. * @param successCallback The callback receives a single parameter which contains the
  123005. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  123006. * src parameter of an <img> to display it
  123007. * @param mimeType The MIME type of the screenshot image (default: image/png).
  123008. * Check your browser for supported MIME types
  123009. * @param samples Texture samples (default: 1)
  123010. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  123011. * @param fileName A name for for the downloaded file.
  123012. */
  123013. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  123014. }
  123015. }
  123016. declare module BABYLON {
  123017. /**
  123018. * A cursor which tracks a point on a path
  123019. */
  123020. export class PathCursor {
  123021. private path;
  123022. /**
  123023. * Stores path cursor callbacks for when an onchange event is triggered
  123024. */
  123025. private _onchange;
  123026. /**
  123027. * The value of the path cursor
  123028. */
  123029. value: number;
  123030. /**
  123031. * The animation array of the path cursor
  123032. */
  123033. animations: Animation[];
  123034. /**
  123035. * Initializes the path cursor
  123036. * @param path The path to track
  123037. */
  123038. constructor(path: Path2);
  123039. /**
  123040. * Gets the cursor point on the path
  123041. * @returns A point on the path cursor at the cursor location
  123042. */
  123043. getPoint(): Vector3;
  123044. /**
  123045. * Moves the cursor ahead by the step amount
  123046. * @param step The amount to move the cursor forward
  123047. * @returns This path cursor
  123048. */
  123049. moveAhead(step?: number): PathCursor;
  123050. /**
  123051. * Moves the cursor behind by the step amount
  123052. * @param step The amount to move the cursor back
  123053. * @returns This path cursor
  123054. */
  123055. moveBack(step?: number): PathCursor;
  123056. /**
  123057. * Moves the cursor by the step amount
  123058. * If the step amount is greater than one, an exception is thrown
  123059. * @param step The amount to move the cursor
  123060. * @returns This path cursor
  123061. */
  123062. move(step: number): PathCursor;
  123063. /**
  123064. * Ensures that the value is limited between zero and one
  123065. * @returns This path cursor
  123066. */
  123067. private ensureLimits;
  123068. /**
  123069. * Runs onchange callbacks on change (used by the animation engine)
  123070. * @returns This path cursor
  123071. */
  123072. private raiseOnChange;
  123073. /**
  123074. * Executes a function on change
  123075. * @param f A path cursor onchange callback
  123076. * @returns This path cursor
  123077. */
  123078. onchange(f: (cursor: PathCursor) => void): PathCursor;
  123079. }
  123080. }
  123081. declare module BABYLON {
  123082. /** @hidden */
  123083. export var blurPixelShader: {
  123084. name: string;
  123085. shader: string;
  123086. };
  123087. }
  123088. declare module BABYLON {
  123089. /** @hidden */
  123090. export var pointCloudVertexDeclaration: {
  123091. name: string;
  123092. shader: string;
  123093. };
  123094. }
  123095. // Mixins
  123096. interface Window {
  123097. mozIndexedDB: IDBFactory;
  123098. webkitIndexedDB: IDBFactory;
  123099. msIndexedDB: IDBFactory;
  123100. webkitURL: typeof URL;
  123101. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  123102. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  123103. WebGLRenderingContext: WebGLRenderingContext;
  123104. MSGesture: MSGesture;
  123105. CANNON: any;
  123106. AudioContext: AudioContext;
  123107. webkitAudioContext: AudioContext;
  123108. PointerEvent: any;
  123109. Math: Math;
  123110. Uint8Array: Uint8ArrayConstructor;
  123111. Float32Array: Float32ArrayConstructor;
  123112. mozURL: typeof URL;
  123113. msURL: typeof URL;
  123114. VRFrameData: any; // WebVR, from specs 1.1
  123115. DracoDecoderModule: any;
  123116. setImmediate(handler: (...args: any[]) => void): number;
  123117. }
  123118. interface HTMLCanvasElement {
  123119. requestPointerLock(): void;
  123120. msRequestPointerLock?(): void;
  123121. mozRequestPointerLock?(): void;
  123122. webkitRequestPointerLock?(): void;
  123123. /** Track wether a record is in progress */
  123124. isRecording: boolean;
  123125. /** Capture Stream method defined by some browsers */
  123126. captureStream(fps?: number): MediaStream;
  123127. }
  123128. interface CanvasRenderingContext2D {
  123129. msImageSmoothingEnabled: boolean;
  123130. }
  123131. interface MouseEvent {
  123132. mozMovementX: number;
  123133. mozMovementY: number;
  123134. webkitMovementX: number;
  123135. webkitMovementY: number;
  123136. msMovementX: number;
  123137. msMovementY: number;
  123138. }
  123139. interface Navigator {
  123140. mozGetVRDevices: (any: any) => any;
  123141. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  123142. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  123143. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  123144. webkitGetGamepads(): Gamepad[];
  123145. msGetGamepads(): Gamepad[];
  123146. webkitGamepads(): Gamepad[];
  123147. }
  123148. interface HTMLVideoElement {
  123149. mozSrcObject: any;
  123150. }
  123151. interface Math {
  123152. fround(x: number): number;
  123153. imul(a: number, b: number): number;
  123154. }
  123155. interface WebGLRenderingContext {
  123156. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  123157. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  123158. vertexAttribDivisor(index: number, divisor: number): void;
  123159. createVertexArray(): any;
  123160. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  123161. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  123162. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  123163. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  123164. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  123165. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  123166. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  123167. // Queries
  123168. createQuery(): WebGLQuery;
  123169. deleteQuery(query: WebGLQuery): void;
  123170. beginQuery(target: number, query: WebGLQuery): void;
  123171. endQuery(target: number): void;
  123172. getQueryParameter(query: WebGLQuery, pname: number): any;
  123173. getQuery(target: number, pname: number): any;
  123174. MAX_SAMPLES: number;
  123175. RGBA8: number;
  123176. READ_FRAMEBUFFER: number;
  123177. DRAW_FRAMEBUFFER: number;
  123178. UNIFORM_BUFFER: number;
  123179. HALF_FLOAT_OES: number;
  123180. RGBA16F: number;
  123181. RGBA32F: number;
  123182. R32F: number;
  123183. RG32F: number;
  123184. RGB32F: number;
  123185. R16F: number;
  123186. RG16F: number;
  123187. RGB16F: number;
  123188. RED: number;
  123189. RG: number;
  123190. R8: number;
  123191. RG8: number;
  123192. UNSIGNED_INT_24_8: number;
  123193. DEPTH24_STENCIL8: number;
  123194. /* Multiple Render Targets */
  123195. drawBuffers(buffers: number[]): void;
  123196. readBuffer(src: number): void;
  123197. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  123198. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  123199. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  123200. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  123201. // Occlusion Query
  123202. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  123203. ANY_SAMPLES_PASSED: number;
  123204. QUERY_RESULT_AVAILABLE: number;
  123205. QUERY_RESULT: number;
  123206. }
  123207. interface WebGLProgram {
  123208. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  123209. }
  123210. interface EXT_disjoint_timer_query {
  123211. QUERY_COUNTER_BITS_EXT: number;
  123212. TIME_ELAPSED_EXT: number;
  123213. TIMESTAMP_EXT: number;
  123214. GPU_DISJOINT_EXT: number;
  123215. QUERY_RESULT_EXT: number;
  123216. QUERY_RESULT_AVAILABLE_EXT: number;
  123217. queryCounterEXT(query: WebGLQuery, target: number): void;
  123218. createQueryEXT(): WebGLQuery;
  123219. beginQueryEXT(target: number, query: WebGLQuery): void;
  123220. endQueryEXT(target: number): void;
  123221. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  123222. deleteQueryEXT(query: WebGLQuery): void;
  123223. }
  123224. interface WebGLUniformLocation {
  123225. _currentState: any;
  123226. }
  123227. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  123228. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  123229. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  123230. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  123231. interface WebGLRenderingContext {
  123232. readonly RASTERIZER_DISCARD: number;
  123233. readonly DEPTH_COMPONENT24: number;
  123234. readonly TEXTURE_3D: number;
  123235. readonly TEXTURE_2D_ARRAY: number;
  123236. readonly TEXTURE_COMPARE_FUNC: number;
  123237. readonly TEXTURE_COMPARE_MODE: number;
  123238. readonly COMPARE_REF_TO_TEXTURE: number;
  123239. readonly TEXTURE_WRAP_R: number;
  123240. readonly HALF_FLOAT: number;
  123241. readonly RGB8: number;
  123242. readonly RED_INTEGER: number;
  123243. readonly RG_INTEGER: number;
  123244. readonly RGB_INTEGER: number;
  123245. readonly RGBA_INTEGER: number;
  123246. readonly R8_SNORM: number;
  123247. readonly RG8_SNORM: number;
  123248. readonly RGB8_SNORM: number;
  123249. readonly RGBA8_SNORM: number;
  123250. readonly R8I: number;
  123251. readonly RG8I: number;
  123252. readonly RGB8I: number;
  123253. readonly RGBA8I: number;
  123254. readonly R8UI: number;
  123255. readonly RG8UI: number;
  123256. readonly RGB8UI: number;
  123257. readonly RGBA8UI: number;
  123258. readonly R16I: number;
  123259. readonly RG16I: number;
  123260. readonly RGB16I: number;
  123261. readonly RGBA16I: number;
  123262. readonly R16UI: number;
  123263. readonly RG16UI: number;
  123264. readonly RGB16UI: number;
  123265. readonly RGBA16UI: number;
  123266. readonly R32I: number;
  123267. readonly RG32I: number;
  123268. readonly RGB32I: number;
  123269. readonly RGBA32I: number;
  123270. readonly R32UI: number;
  123271. readonly RG32UI: number;
  123272. readonly RGB32UI: number;
  123273. readonly RGBA32UI: number;
  123274. readonly RGB10_A2UI: number;
  123275. readonly R11F_G11F_B10F: number;
  123276. readonly RGB9_E5: number;
  123277. readonly RGB10_A2: number;
  123278. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  123279. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  123280. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  123281. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  123282. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  123283. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  123284. 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;
  123285. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  123286. readonly TRANSFORM_FEEDBACK: number;
  123287. readonly INTERLEAVED_ATTRIBS: number;
  123288. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  123289. createTransformFeedback(): WebGLTransformFeedback;
  123290. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  123291. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  123292. beginTransformFeedback(primitiveMode: number): void;
  123293. endTransformFeedback(): void;
  123294. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  123295. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  123296. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  123297. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  123298. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  123299. }
  123300. interface ImageBitmap {
  123301. readonly width: number;
  123302. readonly height: number;
  123303. close(): void;
  123304. }
  123305. interface WebGLQuery extends WebGLObject {
  123306. }
  123307. declare var WebGLQuery: {
  123308. prototype: WebGLQuery;
  123309. new(): WebGLQuery;
  123310. };
  123311. interface WebGLSampler extends WebGLObject {
  123312. }
  123313. declare var WebGLSampler: {
  123314. prototype: WebGLSampler;
  123315. new(): WebGLSampler;
  123316. };
  123317. interface WebGLSync extends WebGLObject {
  123318. }
  123319. declare var WebGLSync: {
  123320. prototype: WebGLSync;
  123321. new(): WebGLSync;
  123322. };
  123323. interface WebGLTransformFeedback extends WebGLObject {
  123324. }
  123325. declare var WebGLTransformFeedback: {
  123326. prototype: WebGLTransformFeedback;
  123327. new(): WebGLTransformFeedback;
  123328. };
  123329. interface WebGLVertexArrayObject extends WebGLObject {
  123330. }
  123331. declare var WebGLVertexArrayObject: {
  123332. prototype: WebGLVertexArrayObject;
  123333. new(): WebGLVertexArrayObject;
  123334. };
  123335. // Type definitions for WebVR API
  123336. // Project: https://w3c.github.io/webvr/
  123337. // Definitions by: six a <https://github.com/lostfictions>
  123338. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  123339. interface VRDisplay extends EventTarget {
  123340. /**
  123341. * Dictionary of capabilities describing the VRDisplay.
  123342. */
  123343. readonly capabilities: VRDisplayCapabilities;
  123344. /**
  123345. * z-depth defining the far plane of the eye view frustum
  123346. * enables mapping of values in the render target depth
  123347. * attachment to scene coordinates. Initially set to 10000.0.
  123348. */
  123349. depthFar: number;
  123350. /**
  123351. * z-depth defining the near plane of the eye view frustum
  123352. * enables mapping of values in the render target depth
  123353. * attachment to scene coordinates. Initially set to 0.01.
  123354. */
  123355. depthNear: number;
  123356. /**
  123357. * An identifier for this distinct VRDisplay. Used as an
  123358. * association point in the Gamepad API.
  123359. */
  123360. readonly displayId: number;
  123361. /**
  123362. * A display name, a user-readable name identifying it.
  123363. */
  123364. readonly displayName: string;
  123365. readonly isConnected: boolean;
  123366. readonly isPresenting: boolean;
  123367. /**
  123368. * If this VRDisplay supports room-scale experiences, the optional
  123369. * stage attribute contains details on the room-scale parameters.
  123370. */
  123371. readonly stageParameters: VRStageParameters | null;
  123372. /**
  123373. * Passing the value returned by `requestAnimationFrame` to
  123374. * `cancelAnimationFrame` will unregister the callback.
  123375. * @param handle Define the hanle of the request to cancel
  123376. */
  123377. cancelAnimationFrame(handle: number): void;
  123378. /**
  123379. * Stops presenting to the VRDisplay.
  123380. * @returns a promise to know when it stopped
  123381. */
  123382. exitPresent(): Promise<void>;
  123383. /**
  123384. * Return the current VREyeParameters for the given eye.
  123385. * @param whichEye Define the eye we want the parameter for
  123386. * @returns the eye parameters
  123387. */
  123388. getEyeParameters(whichEye: string): VREyeParameters;
  123389. /**
  123390. * Populates the passed VRFrameData with the information required to render
  123391. * the current frame.
  123392. * @param frameData Define the data structure to populate
  123393. * @returns true if ok otherwise false
  123394. */
  123395. getFrameData(frameData: VRFrameData): boolean;
  123396. /**
  123397. * Get the layers currently being presented.
  123398. * @returns the list of VR layers
  123399. */
  123400. getLayers(): VRLayer[];
  123401. /**
  123402. * Return a VRPose containing the future predicted pose of the VRDisplay
  123403. * when the current frame will be presented. The value returned will not
  123404. * change until JavaScript has returned control to the browser.
  123405. *
  123406. * The VRPose will contain the position, orientation, velocity,
  123407. * and acceleration of each of these properties.
  123408. * @returns the pose object
  123409. */
  123410. getPose(): VRPose;
  123411. /**
  123412. * Return the current instantaneous pose of the VRDisplay, with no
  123413. * prediction applied.
  123414. * @returns the current instantaneous pose
  123415. */
  123416. getImmediatePose(): VRPose;
  123417. /**
  123418. * The callback passed to `requestAnimationFrame` will be called
  123419. * any time a new frame should be rendered. When the VRDisplay is
  123420. * presenting the callback will be called at the native refresh
  123421. * rate of the HMD. When not presenting this function acts
  123422. * identically to how window.requestAnimationFrame acts. Content should
  123423. * make no assumptions of frame rate or vsync behavior as the HMD runs
  123424. * asynchronously from other displays and at differing refresh rates.
  123425. * @param callback Define the eaction to run next frame
  123426. * @returns the request handle it
  123427. */
  123428. requestAnimationFrame(callback: FrameRequestCallback): number;
  123429. /**
  123430. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  123431. * Repeat calls while already presenting will update the VRLayers being displayed.
  123432. * @param layers Define the list of layer to present
  123433. * @returns a promise to know when the request has been fulfilled
  123434. */
  123435. requestPresent(layers: VRLayer[]): Promise<void>;
  123436. /**
  123437. * Reset the pose for this display, treating its current position and
  123438. * orientation as the "origin/zero" values. VRPose.position,
  123439. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  123440. * updated when calling resetPose(). This should be called in only
  123441. * sitting-space experiences.
  123442. */
  123443. resetPose(): void;
  123444. /**
  123445. * The VRLayer provided to the VRDisplay will be captured and presented
  123446. * in the HMD. Calling this function has the same effect on the source
  123447. * canvas as any other operation that uses its source image, and canvases
  123448. * created without preserveDrawingBuffer set to true will be cleared.
  123449. * @param pose Define the pose to submit
  123450. */
  123451. submitFrame(pose?: VRPose): void;
  123452. }
  123453. declare var VRDisplay: {
  123454. prototype: VRDisplay;
  123455. new(): VRDisplay;
  123456. };
  123457. interface VRLayer {
  123458. leftBounds?: number[] | Float32Array | null;
  123459. rightBounds?: number[] | Float32Array | null;
  123460. source?: HTMLCanvasElement | null;
  123461. }
  123462. interface VRDisplayCapabilities {
  123463. readonly canPresent: boolean;
  123464. readonly hasExternalDisplay: boolean;
  123465. readonly hasOrientation: boolean;
  123466. readonly hasPosition: boolean;
  123467. readonly maxLayers: number;
  123468. }
  123469. interface VREyeParameters {
  123470. /** @deprecated */
  123471. readonly fieldOfView: VRFieldOfView;
  123472. readonly offset: Float32Array;
  123473. readonly renderHeight: number;
  123474. readonly renderWidth: number;
  123475. }
  123476. interface VRFieldOfView {
  123477. readonly downDegrees: number;
  123478. readonly leftDegrees: number;
  123479. readonly rightDegrees: number;
  123480. readonly upDegrees: number;
  123481. }
  123482. interface VRFrameData {
  123483. readonly leftProjectionMatrix: Float32Array;
  123484. readonly leftViewMatrix: Float32Array;
  123485. readonly pose: VRPose;
  123486. readonly rightProjectionMatrix: Float32Array;
  123487. readonly rightViewMatrix: Float32Array;
  123488. readonly timestamp: number;
  123489. }
  123490. interface VRPose {
  123491. readonly angularAcceleration: Float32Array | null;
  123492. readonly angularVelocity: Float32Array | null;
  123493. readonly linearAcceleration: Float32Array | null;
  123494. readonly linearVelocity: Float32Array | null;
  123495. readonly orientation: Float32Array | null;
  123496. readonly position: Float32Array | null;
  123497. readonly timestamp: number;
  123498. }
  123499. interface VRStageParameters {
  123500. sittingToStandingTransform?: Float32Array;
  123501. sizeX?: number;
  123502. sizeY?: number;
  123503. }
  123504. interface Navigator {
  123505. getVRDisplays(): Promise<VRDisplay[]>;
  123506. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  123507. }
  123508. interface Window {
  123509. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  123510. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  123511. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  123512. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  123513. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  123514. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  123515. }
  123516. interface Gamepad {
  123517. readonly displayId: number;
  123518. }
  123519. type XRSessionMode =
  123520. | "inline"
  123521. | "immersive-vr"
  123522. | "immersive-ar";
  123523. type XRReferenceSpaceType =
  123524. | "viewer"
  123525. | "local"
  123526. | "local-floor"
  123527. | "bounded-floor"
  123528. | "unbounded";
  123529. type XREnvironmentBlendMode =
  123530. | "opaque"
  123531. | "additive"
  123532. | "alpha-blend";
  123533. type XRVisibilityState =
  123534. | "visible"
  123535. | "visible-blurred"
  123536. | "hidden";
  123537. type XRHandedness =
  123538. | "none"
  123539. | "left"
  123540. | "right";
  123541. type XRTargetRayMode =
  123542. | "gaze"
  123543. | "tracked-pointer"
  123544. | "screen";
  123545. type XREye =
  123546. | "none"
  123547. | "left"
  123548. | "right";
  123549. interface XRSpace extends EventTarget {
  123550. }
  123551. interface XRRenderState {
  123552. depthNear?: number;
  123553. depthFar?: number;
  123554. inlineVerticalFieldOfView?: number;
  123555. baseLayer?: XRWebGLLayer;
  123556. }
  123557. interface XRInputSource {
  123558. handedness: XRHandedness;
  123559. targetRayMode: XRTargetRayMode;
  123560. targetRaySpace: XRSpace;
  123561. gripSpace: XRSpace | undefined;
  123562. gamepad: Gamepad | undefined;
  123563. profiles: Array<string>;
  123564. }
  123565. interface XRSession {
  123566. addEventListener: Function;
  123567. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  123568. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  123569. requestAnimationFrame: Function;
  123570. end(): Promise<void>;
  123571. renderState: XRRenderState;
  123572. inputSources: Array<XRInputSource>;
  123573. }
  123574. interface XRReferenceSpace extends XRSpace {
  123575. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  123576. onreset: any;
  123577. }
  123578. interface XRFrame {
  123579. session: XRSession;
  123580. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  123581. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  123582. }
  123583. interface XRViewerPose extends XRPose {
  123584. views: Array<XRView>;
  123585. }
  123586. interface XRPose {
  123587. transform: XRRigidTransform;
  123588. emulatedPosition: boolean;
  123589. }
  123590. declare var XRWebGLLayer: {
  123591. prototype: XRWebGLLayer;
  123592. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  123593. };
  123594. interface XRWebGLLayer {
  123595. framebuffer: WebGLFramebuffer;
  123596. framebufferWidth: number;
  123597. framebufferHeight: number;
  123598. getViewport: Function;
  123599. }
  123600. interface XRRigidTransform {
  123601. position: DOMPointReadOnly;
  123602. orientation: DOMPointReadOnly;
  123603. matrix: Float32Array;
  123604. inverse: XRRigidTransform;
  123605. }
  123606. interface XRView {
  123607. eye: XREye;
  123608. projectionMatrix: Float32Array;
  123609. transform: XRRigidTransform;
  123610. }
  123611. interface XRInputSourceChangeEvent {
  123612. session: XRSession;
  123613. removed: Array<XRInputSource>;
  123614. added: Array<XRInputSource>;
  123615. }